Skip to content

Rollup of 7 pull requests #133609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
25e13fd
Bootstrap: Don't duplicate cc-rs flags
madsmtm Nov 16, 2024
8729ba3
Remove outdated workaround for -mmacosx-version-min=
madsmtm Nov 16, 2024
f816d33
Always set the deployment target when building std
madsmtm Nov 16, 2024
673b3d3
restrict synthetic types to standard library types
Walnut356 Nov 17, 2024
ff3dab4
Explain why MACOSX_STD_DEPLOYMENT_TARGET exist
madsmtm Nov 25, 2024
8ecac88
force expanded formatting for non-synthetic types
Walnut356 Nov 28, 2024
ba73166
Support `clobber_abi` for AVR inline assembly
jfrimmel Oct 6, 2024
d7e0a3e
Add test case for the clobber options
jfrimmel Oct 6, 2024
2bd3bbb
Move & rename test case to match naming of #132456
jfrimmel Nov 2, 2024
67d2f3f
Reword error message of reserved AVR registers
jfrimmel Nov 28, 2024
76adf05
Rename `-Zparse-only`.
nnethercote Nov 28, 2024
accdfa1
Update `-Zshow-span` help message.
nnethercote Nov 28, 2024
c52d952
add instructions for generating `flake.lock` to `envrc-flake`
WaffleLapkin Nov 28, 2024
33f13f2
ignore `/build` instead of `build/` in gitignore
WaffleLapkin Nov 28, 2024
8e77349
fix a comment with uneven number of backticks in rustc_mir_build
WaffleLapkin Nov 28, 2024
b36dcc1
Improve the diagnostic of fn item in variadic fn
Nov 27, 2024
1e4817c
bless the tests and add a new one
Nov 27, 2024
9461f42
Revert "Rollup merge of #133418 - Zalathar:spans, r=jieyouxu"
Zalathar Nov 29, 2024
960f367
Rollup merge of #131323 - jfrimmel:avr-inline-asm-clobber-abi, r=Amanieu
Zalathar Nov 29, 2024
a8b54d6
Rollup merge of #133092 - madsmtm:bootstrap-deployment-target, r=Mark…
Zalathar Nov 29, 2024
71ffb44
Rollup merge of #133134 - Walnut356:synth_prov, r=Mark-Simulacrum
Zalathar Nov 29, 2024
35b2ec5
Rollup merge of #133538 - dev-ardi:69232-better-diag, r=compiler-errors
Zalathar Nov 29, 2024
fbbf3cd
Rollup merge of #133590 - nnethercote:rename-parse-only, r=estebank
Zalathar Nov 29, 2024
a5007e3
Rollup merge of #133592 - WaffleLapkin:misc-meowing, r=jieyouxu
Zalathar Nov 29, 2024
088868c
Rollup merge of #133608 - Zalathar:spans-revert, r=jieyouxu
Zalathar Nov 29, 2024
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
7 changes: 6 additions & 1 deletion compiler/rustc_target/src/asm/avr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ def_regs! {
#error = ["SP", "SPL", "SPH"] =>
"the stack pointer cannot be used as an operand for inline asm",
#error = ["r0", "r1", "r1r0"] =>
"r0 and r1 are not available due to an issue in LLVM",
"LLVM reserves r0 (scratch register) and r1 (zero register)",
// If this changes within LLVM, the compiler might use the registers
// in the future. This must be reflected in the set of clobbered
// registers, else the clobber ABI implementation is *unsound*, as
// this generates invalid code (register is not marked as clobbered
// but may change the register content).
}
}

Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_target/src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ pub enum InlineAsmClobberAbi {
AArch64,
AArch64NoX18,
Arm64EC,
Avr,
RiscV,
RiscVE,
LoongArch,
Expand Down Expand Up @@ -986,6 +987,10 @@ impl InlineAsmClobberAbi {
}),
_ => Err(&["C", "system", "efiapi"]),
},
InlineAsmArch::Avr => match name {
"C" | "system" => Ok(InlineAsmClobberAbi::Avr),
_ => Err(&["C", "system"]),
},
InlineAsmArch::LoongArch64 => match name {
"C" | "system" => Ok(InlineAsmClobberAbi::LoongArch),
_ => Err(&["C", "system"]),
Expand Down Expand Up @@ -1133,6 +1138,23 @@ impl InlineAsmClobberAbi {
d24, d25, d26, d27, d28, d29, d30, d31,
}
},
InlineAsmClobberAbi::Avr => clobbered_regs! {
Avr AvrInlineAsmReg {
// The list of "Call-Used Registers" according to
// https://gcc.gnu.org/wiki/avr-gcc#Call-Used_Registers

// Clobbered registers available in inline assembly
r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r30, r31,
// As per the AVR-GCC-ABI documentation linked above, the R0
// register is a clobbered register as well. Since we don't
// allow the usage of R0 in inline assembly, nothing has to
// be done here.
// Likewise, the T-flag in the SREG should be clobbered, but
// this is not necessary to be listed here, since the SREG
// is considered clobbered anyways unless `preserve_flags`
// is used.
}
},
InlineAsmClobberAbi::RiscV => clobbered_regs! {
RiscV RiscVInlineAsmReg {
// ra
Expand Down
43 changes: 43 additions & 0 deletions tests/codegen/asm/avr-clobbers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//@ assembly-output: emit-asm
//@ compile-flags: --target avr-unknown-gnu-atmega328
//@ needs-llvm-components: avr

#![crate_type = "rlib"]
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)]
#![no_core]

#[lang = "sized"]
trait Sized {}

#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}

// CHECK-LABEL: @sreg_is_clobbered
// CHECK: void asm sideeffect "", "~{sreg}"()
#[no_mangle]
pub unsafe fn sreg_is_clobbered() {
asm!("", options(nostack, nomem));
}

// CHECK-LABEL: @sreg_is_not_clobbered_if_preserve_flags_is_used
// CHECK: void asm sideeffect "", ""()
#[no_mangle]
pub unsafe fn sreg_is_not_clobbered_if_preserve_flags_is_used() {
asm!("", options(nostack, nomem, preserves_flags));
}

// CHECK-LABEL: @clobber_abi
// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31},~{sreg}"()
#[no_mangle]
pub unsafe fn clobber_abi() {
asm!("", clobber_abi("C"), options(nostack, nomem));
}

// CHECK-LABEL: @clobber_abi_with_preserved_flags
// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31}"()
#[no_mangle]
pub unsafe fn clobber_abi_with_preserved_flags() {
asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags));
}