Skip to content

Commit a20ecda

Browse files
Rollup merge of #147302 - esp-rs:xtensa-asm, r=Amanieu
asm! support for the Xtensa architecture This implements the asm! support for Xtensa. We've been using this code for a few years in [our fork](https://github.com/esp-rs/rust) and it's been working well. I finally found some time to clean it up a bit and start the upstreaming process. This should be one of the final PRs for Xtensa support on the Rust side (minus bug fixes of course). After this, we're mostly just waiting on the LLVM upstreaming which is going well. This PR doesn't cover all possible asm options for Xtensa, but the base ISA plus a few extras that are used in Espressif chips. r? Amanieu
2 parents 774e911 + 5fb3b38 commit a20ecda

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/asm.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,11 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str {
751751
| X86InlineAsmRegClass::mmx_reg
752752
| X86InlineAsmRegClass::tmm_reg,
753753
) => unreachable!("clobber-only"),
754+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::reg) => "r",
755+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::freg) => "f",
756+
InlineAsmRegClass::Xtensa(
757+
XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg,
758+
) => unreachable!("clobber-only"),
754759
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
755760
bug!("GCC backend does not support SPIR-V")
756761
}
@@ -872,6 +877,11 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
872877
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
873878
bug!("GCC backend does not support SPIR-V")
874879
}
880+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::reg) => cx.type_i32(),
881+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::freg) => cx.type_f32(),
882+
InlineAsmRegClass::Xtensa(
883+
XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg,
884+
) => unreachable!("clobber-only"),
875885
InlineAsmRegClass::Err => unreachable!(),
876886
}
877887
}
@@ -1070,6 +1080,7 @@ fn modifier_to_gcc(
10701080
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
10711081
bug!("LLVM backend does not support SPIR-V")
10721082
}
1083+
InlineAsmRegClass::Xtensa(_) => None,
10731084
InlineAsmRegClass::Err => unreachable!(),
10741085
}
10751086
}

0 commit comments

Comments
 (0)