Skip to content

Commit 768fc10

Browse files
MabezDevtaiki-eKerryRJ
committed
asm! support for the Xtensa architecture
Co-authored-by: Taiki Endo <te316e89@gmail.com> Co-authored-by: Kerry Jones <kerry@iodrive.co.za>
1 parent dc375db commit 768fc10

12 files changed

Lines changed: 665 additions & 2 deletions

File tree

compiler/rustc_codegen_gcc/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
}

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
278278
}
279279
InlineAsmArch::SpirV => {}
280280
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
281+
InlineAsmArch::Xtensa => {}
281282
InlineAsmArch::Bpf => {}
282283
InlineAsmArch::Msp430 => {
283284
constraints.push("~{sr}".to_string());
@@ -740,6 +741,11 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
740741
| X86InlineAsmRegClass::kreg0
741742
| X86InlineAsmRegClass::tmm_reg,
742743
) => unreachable!("clobber-only"),
744+
Xtensa(XtensaInlineAsmRegClass::freg) => "f",
745+
Xtensa(XtensaInlineAsmRegClass::reg) => "r",
746+
Xtensa(XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg) => {
747+
unreachable!("clobber-only")
748+
}
743749
Wasm(WasmInlineAsmRegClass::local) => "r",
744750
Bpf(BpfInlineAsmRegClass::reg) => "r",
745751
Bpf(BpfInlineAsmRegClass::wreg) => "w",
@@ -845,6 +851,7 @@ fn modifier_to_llvm(
845851
| X86InlineAsmRegClass::kreg0
846852
| X86InlineAsmRegClass::tmm_reg,
847853
) => unreachable!("clobber-only"),
854+
Xtensa(_) => None,
848855
Wasm(WasmInlineAsmRegClass::local) => None,
849856
Bpf(_) => None,
850857
Avr(AvrInlineAsmRegClass::reg_pair)
@@ -939,6 +946,11 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
939946
| X86InlineAsmRegClass::kreg0
940947
| X86InlineAsmRegClass::tmm_reg,
941948
) => unreachable!("clobber-only"),
949+
Xtensa(XtensaInlineAsmRegClass::reg) => cx.type_i32(),
950+
Xtensa(XtensaInlineAsmRegClass::freg) => cx.type_f32(),
951+
Xtensa(XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg) => {
952+
unreachable!("clobber-only")
953+
}
942954
Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
943955
Bpf(BpfInlineAsmRegClass::reg) => cx.type_i64(),
944956
Bpf(BpfInlineAsmRegClass::wreg) => cx.type_i32(),

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ declare_features! (
771771
(unstable, x87_target_feature, "1.85.0", Some(150261)),
772772
/// Allows use of the `xop` target-feature
773773
(unstable, xop_target_feature, "1.81.0", Some(127208)),
774+
/// Allows use of the Xtensa target-features
775+
(unstable, xtensa_target_feature, "CURRENT_RUSTC_VERSION", Some(157063)),
774776
/// Allows `do yeet` expressions
775777
(unstable, yeet_expr, "1.62.0", Some(96373)),
776778
(unstable, yield_expr, "1.87.0", Some(43122)),

compiler/rustc_span/src/symbol.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ symbols! {
466466
async_iterator,
467467
async_iterator_poll_next,
468468
async_trait_bounds,
469+
atomic,
469470
atomic_and,
470471
atomic_cxchg,
471472
atomic_cxchgweak,
@@ -540,6 +541,7 @@ symbols! {
540541
braced_empty_structs,
541542
branch,
542543
breakpoint,
544+
breg,
543545
bridge,
544546
bswap,
545547
built,
@@ -704,6 +706,7 @@ symbols! {
704706
contracts_internals,
705707
contracts_requires,
706708
convert,
709+
coprocessor,
707710
copy,
708711
copy_closures,
709712
copy_nonoverlapping,
@@ -881,6 +884,7 @@ symbols! {
881884
ermsb_target_feature,
882885
exact_div,
883886
except,
887+
exception,
884888
exception_handling: "exception-handling",
885889
exclusive_range_pattern,
886890
exhaustive_integer_patterns,
@@ -907,6 +911,7 @@ symbols! {
907911
expr_fragment_specifier_2024,
908912
extended_key_value_attributes,
909913
extended_varargs_abi_support,
914+
extendedl32r,
910915
extern_absolute_paths,
911916
extern_crate_item_prelude,
912917
extern_crate_self,
@@ -990,6 +995,9 @@ symbols! {
990995
format_argument,
991996
format_arguments,
992997
format_macro,
998+
format_placeholder,
999+
format_unsafe_arg,
1000+
fp,
9931001
framework,
9941002
freeze,
9951003
freeze_impls,
@@ -1050,6 +1058,8 @@ symbols! {
10501058
hexagon_target_feature,
10511059
hidden,
10521060
hide,
1061+
highpriinterrupts,
1062+
hint,
10531063
homogeneous_aggregate,
10541064
html_favicon_url,
10551065
html_logo_url,
@@ -1110,6 +1120,7 @@ symbols! {
11101120
internal,
11111121
internal_eq_trait_method_impls,
11121122
internal_features,
1123+
interrupt,
11131124
into_async_iter_into_iter,
11141125
into_future,
11151126
into_iter,
@@ -1205,6 +1216,7 @@ symbols! {
12051216
lt,
12061217
m68k,
12071218
m68k_target_feature,
1219+
mac16,
12081220
macho: "mach-o",
12091221
macro_at_most_once_rep,
12101222
macro_attr,
@@ -1317,6 +1329,8 @@ symbols! {
13171329
mir_unwind_unreachable,
13181330
mir_variant,
13191331
miri,
1332+
misc,
1333+
miscsr,
13201334
mmx_reg,
13211335
modifiers,
13221336
module,
@@ -1564,6 +1578,8 @@ symbols! {
15641578
prelude_import,
15651579
preserves_flags,
15661580
prfchw_target_feature,
1581+
prid,
1582+
primitive,
15671583
proc_dash_macro: "proc-macro",
15681584
proc_macro,
15691585
proc_macro_attribute,
@@ -1820,7 +1836,9 @@ symbols! {
18201836
rustdoc_missing_doc_code_examples,
18211837
rustfmt,
18221838
rvalue_static_promotion,
1839+
rvector,
18231840
rwpi,
1841+
s32c1i,
18241842
s390x,
18251843
s390x_target_feature,
18261844
s390x_target_feature_vector,
@@ -2050,9 +2068,11 @@ symbols! {
20502068
test_unstable_lint,
20512069
thread,
20522070
thread_local,
2071+
threadptr,
20532072
three_way_compare,
20542073
thumb2,
20552074
thumb_mode: "thumb-mode",
2075+
time,
20562076
tmm_reg,
20572077
to_owned_method,
20582078
to_string,
@@ -2274,6 +2294,7 @@ symbols! {
22742294
while_let,
22752295
whole_dash_archive: "whole-archive",
22762296
width,
2297+
windowed,
22772298
windows,
22782299
windows_subsystem,
22792300
with_negative_coherence,
@@ -2299,9 +2320,11 @@ symbols! {
22992320
x87_target_feature,
23002321
xcoff,
23012322
xer,
2323+
xloop,
23022324
xmm_reg,
23032325
xop_target_feature,
23042326
xtensa,
2327+
xtensa_target_feature,
23052328
yeet_desugar_details,
23062329
yeet_expr,
23072330
yes,

0 commit comments

Comments
 (0)