Skip to content

Commit 46f0fb9

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 1b7d722 commit 46f0fb9

8 files changed

Lines changed: 508 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
@@ -738,6 +738,11 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str {
738738
| X86InlineAsmRegClass::mmx_reg
739739
| X86InlineAsmRegClass::tmm_reg,
740740
) => unreachable!("clobber-only"),
741+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::reg) => "r",
742+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::freg) => "f",
743+
InlineAsmRegClass::Xtensa(
744+
XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg,
745+
) => unreachable!("clobber-only"),
741746
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
742747
bug!("GCC backend does not support SPIR-V")
743748
}
@@ -849,6 +854,11 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
849854
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
850855
bug!("GCC backend does not support SPIR-V")
851856
}
857+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::reg) => cx.type_i32(),
858+
InlineAsmRegClass::Xtensa(XtensaInlineAsmRegClass::freg) => cx.type_f32(),
859+
InlineAsmRegClass::Xtensa(
860+
XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg,
861+
) => unreachable!("clobber-only"),
852862
InlineAsmRegClass::Err => unreachable!(),
853863
}
854864
}
@@ -1040,6 +1050,7 @@ fn modifier_to_gcc(
10401050
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
10411051
bug!("LLVM backend does not support SPIR-V")
10421052
}
1053+
InlineAsmRegClass::Xtensa(_) => None,
10431054
InlineAsmRegClass::Err => unreachable!(),
10441055
}
10451056
}

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
277277
}
278278
InlineAsmArch::SpirV => {}
279279
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
280+
InlineAsmArch::Xtensa => {}
280281
InlineAsmArch::Bpf => {}
281282
InlineAsmArch::Msp430 => {
282283
constraints.push("~{sr}".to_string());
@@ -683,6 +684,11 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
683684
| X86InlineAsmRegClass::kreg0
684685
| X86InlineAsmRegClass::tmm_reg,
685686
) => unreachable!("clobber-only"),
687+
Xtensa(XtensaInlineAsmRegClass::freg) => "f",
688+
Xtensa(XtensaInlineAsmRegClass::reg) => "r",
689+
Xtensa(XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg) => {
690+
unreachable!("clobber-only")
691+
}
686692
Wasm(WasmInlineAsmRegClass::local) => "r",
687693
Bpf(BpfInlineAsmRegClass::reg) => "r",
688694
Bpf(BpfInlineAsmRegClass::wreg) => "w",
@@ -788,6 +794,7 @@ fn modifier_to_llvm(
788794
| X86InlineAsmRegClass::kreg0
789795
| X86InlineAsmRegClass::tmm_reg,
790796
) => unreachable!("clobber-only"),
797+
Xtensa(_) => None,
791798
Wasm(WasmInlineAsmRegClass::local) => None,
792799
Bpf(_) => None,
793800
Avr(AvrInlineAsmRegClass::reg_pair)
@@ -864,6 +871,11 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
864871
| X86InlineAsmRegClass::kreg0
865872
| X86InlineAsmRegClass::tmm_reg,
866873
) => unreachable!("clobber-only"),
874+
Xtensa(XtensaInlineAsmRegClass::reg) => cx.type_i32(),
875+
Xtensa(XtensaInlineAsmRegClass::freg) => cx.type_f32(),
876+
Xtensa(XtensaInlineAsmRegClass::sreg | XtensaInlineAsmRegClass::breg) => {
877+
unreachable!("clobber-only")
878+
}
867879
Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
868880
Bpf(BpfInlineAsmRegClass::reg) => cx.type_i64(),
869881
Bpf(BpfInlineAsmRegClass::wreg) => cx.type_i32(),

compiler/rustc_span/src/symbol.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ symbols! {
465465
async_iterator,
466466
async_iterator_poll_next,
467467
async_trait_bounds,
468+
atomctl,
469+
atomic,
468470
atomic_and,
469471
atomic_cxchg,
470472
atomic_cxchgweak,
@@ -537,6 +539,7 @@ symbols! {
537539
braced_empty_structs,
538540
branch,
539541
breakpoint,
542+
breg,
540543
bridge,
541544
bswap,
542545
built,
@@ -697,6 +700,8 @@ symbols! {
697700
contracts_internals,
698701
contracts_requires,
699702
convert,
703+
convert_identity,
704+
coprocessor,
700705
copy,
701706
copy_closures,
702707
copy_nonoverlapping,
@@ -868,6 +873,7 @@ symbols! {
868873
ermsb_target_feature,
869874
exact_div,
870875
except,
876+
exception,
871877
exception_handling: "exception-handling",
872878
exclusive_range_pattern,
873879
exhaustive_integer_patterns,
@@ -894,6 +900,7 @@ symbols! {
894900
expr_fragment_specifier_2024,
895901
extended_key_value_attributes,
896902
extended_varargs_abi_support,
903+
extendedl32r,
897904
extern_absolute_paths,
898905
extern_crate_item_prelude,
899906
extern_crate_self,
@@ -978,6 +985,9 @@ symbols! {
978985
format_argument,
979986
format_arguments,
980987
format_macro,
988+
format_placeholder,
989+
format_unsafe_arg,
990+
fp,
981991
framework,
982992
freeze,
983993
freeze_impls,
@@ -1035,6 +1045,8 @@ symbols! {
10351045
hexagon_target_feature,
10361046
hidden,
10371047
hide,
1048+
highpriinterrupts,
1049+
hint,
10381050
homogeneous_aggregate,
10391051
html_favicon_url,
10401052
html_logo_url,
@@ -1090,6 +1102,7 @@ symbols! {
10901102
internal,
10911103
internal_eq_trait_method_impls,
10921104
internal_features,
1105+
interrupt,
10931106
into_async_iter_into_iter,
10941107
into_future,
10951108
into_iter,
@@ -1182,6 +1195,7 @@ symbols! {
11821195
lt,
11831196
m68k,
11841197
m68k_target_feature,
1198+
mac16,
11851199
macro_at_most_once_rep,
11861200
macro_attr,
11871201
macro_attributes_in_derive_output,
@@ -1229,6 +1243,7 @@ symbols! {
12291243
mem_variant_count,
12301244
mem_zeroed,
12311245
member_constraints,
1246+
memctl,
12321247
memory,
12331248
memtag,
12341249
message,
@@ -1290,6 +1305,8 @@ symbols! {
12901305
mir_unwind_unreachable,
12911306
mir_variant,
12921307
miri,
1308+
misc,
1309+
miscsr,
12931310
mmx_reg,
12941311
modifiers,
12951312
module,
@@ -1531,6 +1548,10 @@ symbols! {
15311548
prelude_import,
15321549
preserves_flags,
15331550
prfchw_target_feature,
1551+
prid,
1552+
primitive,
1553+
print_macro,
1554+
println_macro,
15341555
proc_dash_macro: "proc-macro",
15351556
proc_macro,
15361557
proc_macro_attribute,
@@ -1786,7 +1807,9 @@ symbols! {
17861807
rustdoc_missing_doc_code_examples,
17871808
rustfmt,
17881809
rvalue_static_promotion,
1810+
rvector,
17891811
rwpi,
1812+
s32c1i,
17901813
s390x,
17911814
s390x_target_feature,
17921815
s390x_target_feature_vector,
@@ -2007,9 +2030,13 @@ symbols! {
20072030
test_unstable_lint,
20082031
thread,
20092032
thread_local,
2033+
thread_local_macro,
2034+
threadptr,
20102035
three_way_compare,
20112036
thumb2,
20122037
thumb_mode: "thumb-mode",
2038+
time,
2039+
timerint,
20132040
tmm_reg,
20142041
to_string,
20152042
to_vec,
@@ -2222,6 +2249,7 @@ symbols! {
22222249
while_let,
22232250
whole_dash_archive: "whole-archive",
22242251
width,
2252+
windowed,
22252253
windows,
22262254
windows_subsystem,
22272255
with_negative_coherence,
@@ -2246,9 +2274,11 @@ symbols! {
22462274
x87_reg,
22472275
x87_target_feature,
22482276
xer,
2277+
xloop,
22492278
xmm_reg,
22502279
xop_target_feature,
22512280
xtensa,
2281+
xtensa_target_feature,
22522282
yeet_desugar_details,
22532283
yeet_expr,
22542284
yes,

0 commit comments

Comments
 (0)