Skip to content

Commit 4161cef

Browse files
Rollup merge of rust-lang#133422 - taiki-e:riscv-e-clobber-abi, r=Amanieu
Fix clobber_abi in RV32E and RV64E inline assembly Currently clobber_abi in RV32E and RV64E inline assembly is implemented using InlineAsmClobberAbi::RiscV, but broken since x16-x31 cannot be used in RV32E and RV64E. ``` error: cannot use register `x16`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x17`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x28`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x29`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x30`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ error: cannot use register `x31`: register can't be used with the `e` target feature --> <source>:42:14 | 42 | asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ^^^^^^^^^^^^^^^^ ``` r? `@Amanieu` `@rustbot` label O-riscv +A-inline-assembly
2 parents e73d321 + b9e2bdd commit 4161cef

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/inline_asm.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,14 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
476476
let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
477477

478478
// Allocate stack slots for saving clobbered registers
479-
let abi_clobber = InlineAsmClobberAbi::parse(self.arch, &self.tcx.sess.target, sym::C)
480-
.unwrap()
481-
.clobbered_regs();
479+
let abi_clobber = InlineAsmClobberAbi::parse(
480+
self.arch,
481+
&self.tcx.sess.target,
482+
&self.tcx.sess.unstable_target_features,
483+
sym::C,
484+
)
485+
.unwrap()
486+
.clobbered_regs();
482487
for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
483488
let mut need_save = true;
484489
// If the register overlaps with a register clobbered by function call, then

0 commit comments

Comments
 (0)