Skip to content

Commit a175998

Browse files
committed
compiler: intern architecture at compile time
1 parent 58659c7 commit a175998

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

compiler/rustc_session/src/config/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
240240
}
241241

242242
ins_str!(sym::target_abi, &sess.target.abi);
243-
ins_str!(sym::target_arch, sess.target.arch.desc());
243+
ins_sym!(sym::target_arch, sess.target.arch.desc_symbol());
244244
ins_str!(sym::target_endian, sess.target.endian.as_str());
245245
ins_str!(sym::target_env, &sess.target.env);
246246

@@ -448,7 +448,7 @@ impl CheckCfg {
448448

449449
for target in Target::builtins().chain(iter::once(current_target.clone())) {
450450
values_target_abi.insert(Symbol::intern(&target.options.abi));
451-
values_target_arch.insert(Symbol::intern(target.arch.desc()));
451+
values_target_arch.insert(target.arch.desc_symbol());
452452
values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));
453453
values_target_env.insert(Symbol::intern(&target.options.env));
454454
values_target_family.extend(

compiler/rustc_span/src/symbol.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ symbols! {
400400
_t,
401401
_task_context,
402402
a32,
403+
aarch64,
403404
aarch64_target_feature,
404405
aarch64_unstable_target_feature,
405406
aarch64_ver_target_feature,
@@ -449,6 +450,7 @@ symbols! {
449450
altivec,
450451
alu32,
451452
always,
453+
amdgpu,
452454
analysis,
453455
and,
454456
and_then,
@@ -466,6 +468,7 @@ symbols! {
466468
args,
467469
arith_offset,
468470
arm,
471+
arm64ec,
469472
arm_target_feature,
470473
array,
471474
as_dash_needed: "as-needed",
@@ -554,6 +557,7 @@ symbols! {
554557
autodiff_reverse,
555558
automatically_derived,
556559
available_externally,
560+
avr,
557561
avx,
558562
avx10_target_feature,
559563
avx512_target_feature,
@@ -586,6 +590,7 @@ symbols! {
586590
box_patterns,
587591
box_syntax,
588592
boxed_slice,
593+
bpf,
589594
bpf_target_feature,
590595
braced_empty_structs,
591596
branch,
@@ -790,6 +795,7 @@ symbols! {
790795
crate_type,
791796
crate_visibility_modifier,
792797
crt_dash_static: "crt-static",
798+
csky,
793799
csky_target_feature,
794800
cstr_type,
795801
cstring_as_c_str,
@@ -1156,6 +1162,7 @@ symbols! {
11561162
hashset_drain_ty,
11571163
hashset_iter,
11581164
hashset_iter_ty,
1165+
hexagon,
11591166
hexagon_target_feature,
11601167
hidden,
11611168
hide,
@@ -1342,11 +1349,14 @@ symbols! {
13421349
logf32,
13431350
logf64,
13441351
logf128,
1352+
loongarch32,
1353+
loongarch64,
13451354
loongarch_target_feature,
13461355
loop_break_value,
13471356
loop_match,
13481357
lr,
13491358
lt,
1359+
m68k,
13501360
m68k_target_feature,
13511361
macro_at_most_once_rep,
13521362
macro_attr,
@@ -1422,6 +1432,10 @@ symbols! {
14221432
minnumf32,
14231433
minnumf64,
14241434
minnumf128,
1435+
mips,
1436+
mips32r6,
1437+
mips64,
1438+
mips64r6,
14251439
mips_target_feature,
14261440
mir_assume,
14271441
mir_basic_block,
@@ -1470,6 +1484,7 @@ symbols! {
14701484
move_ref_pattern,
14711485
move_size_limit,
14721486
movrs_target_feature,
1487+
msp430,
14731488
mul,
14741489
mul_assign,
14751490
mul_with_overflow,
@@ -1557,6 +1572,7 @@ symbols! {
15571572
notable_trait,
15581573
note,
15591574
null,
1575+
nvptx64,
15601576
nvptx_target_feature,
15611577
object_safe_for_dispatch,
15621578
of,
@@ -1681,6 +1697,9 @@ symbols! {
16811697
post_cleanup: "post-cleanup",
16821698
post_dash_lto: "post-lto",
16831699
postfix_match,
1700+
powerpc,
1701+
powerpc64,
1702+
powerpc64le,
16841703
powerpc_target_feature,
16851704
powf16,
16861705
powf32,
@@ -1828,6 +1847,8 @@ symbols! {
18281847
resume,
18291848
return_position_impl_trait_in_trait,
18301849
return_type_notation,
1850+
riscv32,
1851+
riscv64,
18311852
riscv_target_feature,
18321853
rlib,
18331854
ropi,
@@ -1974,6 +1995,7 @@ symbols! {
19741995
rvalue_static_promotion,
19751996
rwpi,
19761997
s,
1998+
s390x,
19771999
s390x_target_feature,
19782000
safety,
19792001
sanitize,
@@ -2102,9 +2124,12 @@ symbols! {
21022124
slice_patterns,
21032125
slicing_syntax,
21042126
soft,
2127+
sparc,
2128+
sparc64,
21052129
sparc_target_feature,
21062130
specialization,
21072131
speed,
2132+
spirv,
21082133
spotlight,
21092134
sqrtf16,
21102135
sqrtf32,
@@ -2419,6 +2444,8 @@ symbols! {
24192444
vtable_size,
24202445
warn,
24212446
wasip2,
2447+
wasm32,
2448+
wasm64,
24222449
wasm_abi,
24232450
wasm_import_module,
24242451
wasm_target_feature,
@@ -2445,12 +2472,15 @@ symbols! {
24452472
write_str,
24462473
write_via_move,
24472474
writeln_macro,
2475+
x86,
2476+
x86_64,
24482477
x86_amx_intrinsics,
24492478
x87_reg,
24502479
x87_target_feature,
24512480
xer,
24522481
xmm_reg,
24532482
xop_target_feature,
2483+
xtensa,
24542484
yeet_desugar_details,
24552485
yeet_expr,
24562486
yes,

compiler/rustc_target/src/spec/mod.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,44 @@ crate::target_spec_enum! {
18781878
parse_error_type = "architecture";
18791879
}
18801880

1881+
impl Architecture {
1882+
pub const fn desc_symbol(&self) -> Symbol {
1883+
match self {
1884+
Self::AArch64 => sym::aarch64,
1885+
Self::AmdGpu => sym::amdgpu,
1886+
Self::Arm => sym::arm,
1887+
Self::Arm64EC => sym::arm64ec,
1888+
Self::Avr => sym::avr,
1889+
Self::Bpf => sym::bpf,
1890+
Self::CSKY => sym::csky,
1891+
Self::Hexagon => sym::hexagon,
1892+
Self::LoongArch32 => sym::loongarch32,
1893+
Self::LoongArch64 => sym::loongarch64,
1894+
Self::M68k => sym::m68k,
1895+
Self::Mips => sym::mips,
1896+
Self::Mips32r6 => sym::mips32r6,
1897+
Self::Mips64 => sym::mips64,
1898+
Self::Mips64r6 => sym::mips64r6,
1899+
Self::Msp430 => sym::msp430,
1900+
Self::Nvptx64 => sym::nvptx64,
1901+
Self::PowerPC => sym::powerpc,
1902+
Self::PowerPC64 => sym::powerpc64,
1903+
Self::PowerPC64LE => sym::powerpc64le,
1904+
Self::RiscV32 => sym::riscv32,
1905+
Self::RiscV64 => sym::riscv64,
1906+
Self::S390x => sym::s390x,
1907+
Self::Sparc => sym::sparc,
1908+
Self::Sparc64 => sym::sparc64,
1909+
Self::SpirV => sym::spirv,
1910+
Self::Wasm32 => sym::wasm32,
1911+
Self::Wasm64 => sym::wasm64,
1912+
Self::X86 => sym::x86,
1913+
Self::X86_64 => sym::x86_64,
1914+
Self::Xtensa => sym::xtensa,
1915+
}
1916+
}
1917+
}
1918+
18811919
/// Everything `rustc` knows about how to compile for a specific target.
18821920
///
18831921
/// Every field here must be specified, and has no default value.

0 commit comments

Comments
 (0)