Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8714345
Include vendored sources in the rust-src component
bjorn3 May 5, 2026
57a1291
Fix paths in generated .cargo/config.toml for vendoring
bjorn3 May 11, 2026
fc6d00e
Add inline asm support for amdgpu
Flakebi Feb 20, 2026
21d3e57
Split amdgpu inline asm reg classes by size
Flakebi Feb 23, 2026
d959ff1
Add vector types to amdgpu inline asm
Flakebi Feb 23, 2026
dc350d8
Store register size as int instead of listing all
Flakebi Apr 16, 2026
581b55a
Compute amdgpu supported_types dynamically
Flakebi May 11, 2026
4011f0d
Forgot to run tidy
Flakebi May 13, 2026
d7f16d7
Support defaults for static EIIs
AsakuraMizu May 14, 2026
88eb204
Fix compilation for espidf target by conditionally disabling process …
FelixLttks May 16, 2026
2677965
Change division to multiplication in floating-point midpoint
oscargus May 16, 2026
43436c9
Fix typo in `format_into` docs: signed -> unsigned
joshtriplett May 17, 2026
ffc067c
Rollup merge of #156196 - bjorn3:vendor_stdlib, r=Mark-Simulacrum
JonathanBrouwer May 17, 2026
129ae43
Rollup merge of #149793 - Flakebi:inline-asm, r=Amanieu
JonathanBrouwer May 17, 2026
27adf3d
Rollup merge of #156583 - AsakuraMizu:eii-static-default, r=JonathanB…
JonathanBrouwer May 17, 2026
75cc4d5
Rollup merge of #156638 - FelixLttks:fix-espidf-sigkill, r=SimonSapin
JonathanBrouwer May 17, 2026
c29a2ed
Rollup merge of #156647 - oscargus:fasterfloatmidpoint, r=SimonSapin
JonathanBrouwer May 17, 2026
9e9bc5e
Rollup merge of #156668 - joshtriplett:format-into-typo, r=SimonSapin
JonathanBrouwer May 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 48 additions & 35 deletions compiler/rustc_builtin_macros/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use thin_vec::{ThinVec, thin_vec};
use crate::errors::{
EiiExternTargetExpectedList, EiiExternTargetExpectedMacro, EiiExternTargetExpectedUnsafe,
EiiMacroExpectedMaxOneArgument, EiiOnlyOnce, EiiSharedMacroInStatementPosition,
EiiSharedMacroTarget, EiiStaticArgumentRequired, EiiStaticDefault,
EiiStaticMultipleImplementations, EiiStaticMutable,
EiiSharedMacroTarget, EiiStaticArgumentRequired, EiiStaticMultipleImplementations,
EiiStaticMutable,
};

/// ```rust
Expand Down Expand Up @@ -86,14 +86,6 @@ fn eii_(
let (item_span, foreign_item_name) = match kind {
ItemKind::Fn(func) => (func.sig.span, func.ident),
ItemKind::Static(stat) => {
// Statics with a default are not supported yet
if let Some(stat_body) = &stat.expr {
ecx.dcx().emit_err(EiiStaticDefault {
span: stat_body.span,
name: path_to_string(&meta_item.path),
});
return vec![];
}
// Statics must have an explicit name for the eii
if meta_item.is_word() {
ecx.dcx().emit_err(EiiStaticArgumentRequired {
Expand Down Expand Up @@ -137,18 +129,16 @@ fn eii_(

let mut module_items = Vec::new();

if let ItemKind::Fn(func) = kind
&& func.body.is_some()
{
module_items.push(generate_default_func_impl(
ecx,
&func,
impl_unsafe,
macro_name,
eii_attr_span,
item_span,
foreign_item_name,
))
if let Some(default_impl) = generate_default_impl(
ecx,
kind,
impl_unsafe,
macro_name,
eii_attr_span,
item_span,
foreign_item_name,
) {
module_items.push(default_impl);
}

module_items.push(generate_foreign_item(
Expand Down Expand Up @@ -220,20 +210,33 @@ fn filter_attrs_for_multiple_eii_attr(
.collect()
}

fn generate_default_func_impl(
fn generate_default_impl(
ecx: &mut ExtCtxt<'_>,
func: &ast::Fn,
item_kind: &ItemKind,
impl_unsafe: bool,
macro_name: Ident,
eii_attr_span: Span,
item_span: Span,
foreign_item_name: Ident,
) -> Box<ast::Item> {
) -> Option<Box<ast::Item>> {
match item_kind {
ItemKind::Fn(func) => {
if func.body.is_none() {
return None;
}
}
ItemKind::Static(stat) => {
if stat.expr.is_none() {
return None;
}
}
_ => unreachable!("Target was checked earlier"),
};

// FIXME: re-add some original attrs
let attrs = ThinVec::new();

let mut default_func = func.clone();
default_func.eii_impls.push(EiiImpl {
let eii_impl = EiiImpl {
node_id: DUMMY_NODE_ID,
inner_span: macro_name.span,
eii_macro_path: ast::Path::from_ident(macro_name),
Expand All @@ -253,7 +256,18 @@ fn generate_default_func_impl(
),
impl_unsafe,
}),
});
};

let mut item_kind = item_kind.clone();
match &mut item_kind {
ItemKind::Fn(func) => {
func.eii_impls.push(eii_impl);
}
ItemKind::Static(stat) => {
stat.eii_impls.push(eii_impl);
}
_ => unreachable!("Target was checked earlier"),
};

let anon_mod = |span: Span, stmts: ThinVec<ast::Stmt>| {
let unit = ecx.ty(item_span, ast::TyKind::Tup(ThinVec::new()));
Expand All @@ -267,15 +281,12 @@ fn generate_default_func_impl(
};

// const _: () = {
// <orig fn>
// <orig item>
// }
anon_mod(
Some(anon_mod(
item_span,
thin_vec![ecx.stmt_item(
item_span,
ecx.item(item_span, attrs, ItemKind::Fn(Box::new(default_func)))
),],
)
thin_vec![ecx.stmt_item(item_span, ecx.item(item_span, attrs, item_kind))],
))
}

/// Generates a foreign item, like
Expand Down Expand Up @@ -362,6 +373,8 @@ fn generate_foreign_static(mut stat: Box<ast::StaticItem>) -> ast::ForeignItemKi
stat.safety = ast::Safety::Safe(stat.ident.span);
}

stat.expr = None;

ast::ForeignItemKind::Static(stat)
}

Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,14 +1134,6 @@ pub(crate) struct EiiStaticMultipleImplementations {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`#[{$name}]` cannot be used on statics with a value")]
pub(crate) struct EiiStaticDefault {
#[primary_span]
pub span: Span,
pub name: String,
}

#[derive(Diagnostic)]
#[diag("`#[{$name}]` requires the name as an explicit argument when used on a static")]
pub(crate) struct EiiStaticArgumentRequired {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str {
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => {
unreachable!("clobber-only")
}
InlineAsmRegClass::Amdgpu(AmdgpuInlineAsmRegClass::Sgpr(_)) => "Sg",
InlineAsmRegClass::Amdgpu(AmdgpuInlineAsmRegClass::Vgpr(_)) => "v",
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg)
| InlineAsmRegClass::Arm(ArmInlineAsmRegClass::dreg_low16)
Expand Down Expand Up @@ -780,6 +782,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => {
unreachable!("clobber-only")
}
InlineAsmRegClass::Amdgpu(_) => cx.type_i32(),
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg)
| InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg_low16) => cx.type_f32(),
Expand Down Expand Up @@ -983,6 +986,7 @@ fn modifier_to_gcc(
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => {
unreachable!("clobber-only")
}
InlineAsmRegClass::Amdgpu(_) => None,
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::reg) => None,
InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg)
| InlineAsmRegClass::Arm(ArmInlineAsmRegClass::sreg_low16) => None,
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
match *op {
InlineAsmOperandRef::Out { reg, late, place } => {
let is_target_supported = |reg_class: InlineAsmRegClass| {
for &(_, feature) in reg_class.supported_types(asm_arch, true) {
for &(_, feature) in reg_class.supported_types(asm_arch, true).as_ref() {
if let Some(feature) = feature {
if self
.tcx
Expand Down Expand Up @@ -229,6 +229,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
InlineAsmArch::AArch64 | InlineAsmArch::Arm64EC | InlineAsmArch::Arm => {
constraints.push("~{cc}".to_string());
}
InlineAsmArch::Amdgpu => {}
InlineAsmArch::X86 | InlineAsmArch::X86_64 => {
constraints.extend_from_slice(&[
"~{dirflag}".to_string(),
Expand Down Expand Up @@ -698,6 +699,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
| Arm(ArmInlineAsmRegClass::dreg_low8)
| Arm(ArmInlineAsmRegClass::qreg_low4) => "x",
Arm(ArmInlineAsmRegClass::dreg) | Arm(ArmInlineAsmRegClass::qreg) => "w",
Amdgpu(AmdgpuInlineAsmRegClass::Sgpr(_)) => "s",
Amdgpu(AmdgpuInlineAsmRegClass::Vgpr(_)) => "v",
Hexagon(HexagonInlineAsmRegClass::reg) => "r",
Hexagon(HexagonInlineAsmRegClass::reg_pair) => "r",
Hexagon(HexagonInlineAsmRegClass::preg) => unreachable!("clobber-only"),
Expand Down Expand Up @@ -803,6 +806,7 @@ fn modifier_to_llvm(
modifier
}
}
Amdgpu(_) => None,
Hexagon(_) => None,
LoongArch(_) => None,
Mips(_) => None,
Expand Down Expand Up @@ -883,6 +887,7 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
Arm(ArmInlineAsmRegClass::qreg)
| Arm(ArmInlineAsmRegClass::qreg_low8)
| Arm(ArmInlineAsmRegClass::qreg_low4) => cx.type_vector(cx.type_i64(), 2),
Amdgpu(_) => cx.type_i32(),
Hexagon(HexagonInlineAsmRegClass::reg) => cx.type_i32(),
Hexagon(HexagonInlineAsmRegClass::reg_pair) => cx.type_i64(),
Hexagon(HexagonInlineAsmRegClass::preg) => unreachable!("clobber-only"),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
if let InlineAsmRegClass::Err = reg_class {
continue;
}
for &(_, feature) in reg_class.supported_types(asm_arch, allow_experimental_reg)
for &(_, feature) in
reg_class.supported_types(asm_arch, allow_experimental_reg).as_ref()
{
match feature {
Some(feature) => {
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,12 @@ symbols! {
self_in_typedefs,
self_struct_ctor,
semiopaque,
sgpr32,
sgpr64,
sgpr96,
sgpr128,
sgpr256,
sgpr512,
sha2,
sha3,
sha512_sm_x86,
Expand Down Expand Up @@ -2239,6 +2245,21 @@ symbols! {
verbatim,
version,
vfp2,
vgpr16,
vgpr32,
vgpr64,
vgpr96,
vgpr128,
vgpr160,
vgpr192,
vgpr224,
vgpr256,
vgpr288,
vgpr320,
vgpr352,
vgpr384,
vgpr512,
vgpr1024,
view_types,
vis,
visible_private_types,
Expand Down
Loading
Loading