1use rustc_data_structures::fx::{FxHashMap, FxHashSet};
43use rustc_macros::StableHash;
44use rustc_span::{Symbol, sym};
45
46use crate::spec::{Arch, FloatAbi, LlvmAbi, RustcAbi, Target};
47
48pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
52
53#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Stability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Stability::Stable =>
::core::fmt::Formatter::write_str(f, "Stable"),
Stability::CfgStableToggleUnstable(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"CfgStableToggleUnstable", &__self_0),
Stability::Unstable(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Unstable", &__self_0),
Stability::InternalOnly { reason: __self_0, hard_error: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"InternalOnly", "reason", __self_0, "hard_error",
&__self_1),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Stability { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Stability { }
#[automatically_derived]
impl ::core::clone::Clone for Stability {
#[inline]
fn clone(&self) -> Stability {
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<&'static str>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Stability {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Stability::Stable => {}
Stability::CfgStableToggleUnstable(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Stability::Unstable(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
Stability::InternalOnly {
reason: ref __binding_0, hard_error: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
55pub enum Stability {
56 Stable,
59 CfgStableToggleUnstable(
62 Symbol,
65 ),
66 Unstable(
69 Symbol,
72 ),
73 InternalOnly {
85 reason: &'static str,
86 hard_error: bool,
89 },
90}
91use Stability::*;
92
93impl Stability {
94 pub fn in_cfg(&self) -> bool {
98 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::Stable | Stability::CfgStableToggleUnstable { .. } |
Stability::Unstable { .. } => true,
_ => false,
}matches!(
99 self,
100 Stability::Stable
101 | Stability::CfgStableToggleUnstable { .. }
102 | Stability::Unstable { .. }
103 )
104 }
105
106 pub fn requires_nightly(&self, in_cfg: bool) -> Option<Symbol> {
118 match *self {
119 Stability::Unstable(nightly_feature) => Some(nightly_feature),
120 Stability::CfgStableToggleUnstable(nightly_feature) => {
121 if in_cfg {
122 None
123 } else {
124 Some(nightly_feature)
125 }
126 }
127 Stability::Stable { .. } => None,
128 Stability::InternalOnly { .. } => {
129 {
::core::panicking::panic_fmt(format_args!("internal-only features should not reach this far"));
}panic!("internal-only features should not reach this far")
130 }
131 }
132 }
133
134 pub fn is_cfg_stable_toggle_unstable(&self) -> bool {
137 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::CfgStableToggleUnstable { .. } => true,
_ => false,
}matches!(self, Stability::CfgStableToggleUnstable { .. })
138 }
139
140 pub fn toggle_allowed(&self) -> Result<(), &'static str> {
144 match self {
145 Stability::Unstable(_)
146 | Stability::CfgStableToggleUnstable(_)
147 | Stability::Stable { .. } => Ok(()),
148 Stability::InternalOnly { reason, hard_error: _ } => Err(reason),
149 }
150 }
151}
152
153type ImpliedFeatures = &'static [&'static str];
159
160static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
161 ("aclass", Unstable(sym::arm_target_feature), &[]),
163 ("acquire-release", Unstable(sym::arm_target_feature), &[]),
164 ("aes", Unstable(sym::arm_target_feature), &["neon"]),
165 (
166 "atomics-32",
167 Stability::InternalOnly {
169 reason: "unsound because it changes the ABI of atomic operations",
170 hard_error: false,
171 },
172 &[],
173 ),
174 ("crc", Unstable(sym::arm_target_feature), &[]),
175 ("d32", Unstable(sym::arm_target_feature), &[]),
176 ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
177 ("dsp", Unstable(sym::arm_target_feature), &[]),
178 ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
179 ("fp16", Unstable(sym::arm_target_feature), &["neon"]),
180 ("fp64", Unstable(sym::arm_target_feature), &[]),
181 ("fpregs", Unstable(sym::arm_target_feature), &[]),
182 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
183 ("mclass", Unstable(sym::arm_target_feature), &[]),
184 ("mve", Unstable(sym::arm_target_feature), &["v8.1m.main", "dsp", "fpregs"]),
185 ("mve.fp", Unstable(sym::arm_target_feature), &["mve"]),
186 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
187 ("rclass", Unstable(sym::arm_target_feature), &[]),
188 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
189 ("soft-float", Unstable(sym::arm_target_feature), &[]),
194 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
198 ("thumb2", Unstable(sym::arm_target_feature), &[]),
199 ("trustzone", Unstable(sym::arm_target_feature), &[]),
200 ("v5te", Unstable(sym::arm_target_feature), &[]),
201 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
202 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
203 ("v6m", Unstable(sym::arm_target_feature), &["v6"]),
204 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "v8m", "thumb2"]),
205 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
206 ("v8", Unstable(sym::arm_target_feature), &["v7", "acquire-release"]),
207 ("v8.1m.main", Unstable(sym::arm_target_feature), &["v8m.main"]),
208 ("v8m", Unstable(sym::arm_target_feature), &["v6m"]),
209 ("v8m.main", Unstable(sym::arm_target_feature), &["v7"]),
210 ("vfp2", Unstable(sym::arm_target_feature), &["vfp2sp", "fp64"]),
211 ("vfp2sp", Unstable(sym::arm_target_feature), &["fpregs"]),
212 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
213 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
214 ("virtualization", Unstable(sym::arm_target_feature), &[]),
215 ];
217
218static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
219 ("aes", Stable, &["neon"]),
222 ("bf16", Stable, &[]),
224 ("bti", Stable, &[]),
226 ("crc", Stable, &[]),
228 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
230 ("dit", Stable, &[]),
232 ("dotprod", Stable, &["neon"]),
234 ("dpb", Stable, &[]),
236 ("dpb2", Stable, &["dpb"]),
238 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
240 ("f32mm", Stable, &["sve"]),
242 ("f64mm", Stable, &["sve"]),
244 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
246 ("fcma", Stable, &["neon"]),
248 ("fhm", Stable, &["fp16"]),
250 ("flagm", Stable, &[]),
252 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
254 (
256 "fp-armv8",
257 Stability::InternalOnly { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
259 &[],
260 ),
261 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
263 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
265 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
267 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
269 ("fp16", Stable, &["neon"]),
272 ("frintts", Stable, &[]),
274 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
276 ("i8mm", Stable, &[]),
278 ("jsconv", Stable, &["neon"]),
281 ("lor", Stable, &[]),
283 ("lse", Stable, &[]),
285 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
287 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
289 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
291 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
293 ("mte", Stable, &[]),
295 ("neon", Stable, &[]),
297 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
301 ("paca", Stable, &[]),
303 ("pacg", Stable, &[]),
305 ("pan", Stable, &[]),
307 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
309 ("pmuv3", Stable, &[]),
311 ("rand", Stable, &[]),
313 ("ras", Stable, &[]),
315 ("rcpc", Stable, &[]),
317 ("rcpc2", Stable, &["rcpc"]),
319 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
321 ("rdm", Stable, &["neon"]),
323 (
324 "reserve-x18",
325 InternalOnly { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
327 &[],
328 ),
329 ("sb", Stable, &[]),
331 ("sha2", Stable, &["neon"]),
333 ("sha3", Stable, &["sha2"]),
335 ("sm4", Stable, &["neon"]),
337 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
339 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
341 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
343 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
345 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
347 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
349 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
351 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
353 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
355 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
357 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
359 ("spe", Stable, &[]),
361 ("ssbs", Stable, &[]),
363 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
365 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
367 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
369 ("sve", Stable, &["neon", "fp16"]),
377 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
379 ("sve2", Stable, &["sve"]),
381 ("sve2-aes", Stable, &["sve2", "aes"]),
383 ("sve2-bitperm", Stable, &["sve2"]),
385 ("sve2-sha3", Stable, &["sve2", "sha3"]),
387 ("sve2-sm4", Stable, &["sve2", "sm4"]),
389 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
391 ("tme", Stable, &[]),
393 (
394 "v8.1a",
395 Unstable(sym::aarch64_ver_target_feature),
396 &["crc", "lse", "rdm", "pan", "lor", "vh"],
397 ),
398 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
399 (
400 "v8.3a",
401 Unstable(sym::aarch64_ver_target_feature),
402 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
403 ),
404 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
405 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
406 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
407 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
408 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
409 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
410 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
411 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
412 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
413 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
414 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
415 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a"]),
416 ("vh", Stable, &[]),
418 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
420 ];
422
423const AARCH64_TIED_FEATURES: &[&[&str]] = &[
424 &["paca", "pacg"], ];
426
427static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
428 ("adx", Stable, &[]),
430 ("aes", Stable, &["sse2"]),
431 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
432 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
433 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
434 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
435 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
436 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
437 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
438 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
439 ("apxf", Unstable(sym::apx_target_feature), &[]),
440 ("avx", Stable, &["sse4.2"]),
441 ("avx2", Stable, &["avx"]),
442 (
443 "avx10.1",
444 Unstable(sym::avx10_target_feature),
445 &[
446 "avx512bf16",
447 "avx512bitalg",
448 "avx512bw",
449 "avx512cd",
450 "avx512dq",
451 "avx512f",
452 "avx512fp16",
453 "avx512ifma",
454 "avx512vbmi",
455 "avx512vbmi2",
456 "avx512vl",
457 "avx512vnni",
458 "avx512vpopcntdq",
459 ],
460 ),
461 (
462 "avx10.2",
463 Unstable(sym::avx10_target_feature),
464 &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
465 ),
466 ("avx512bf16", Stable, &["avx512bw"]),
467 ("avx512bitalg", Stable, &["avx512bw"]),
468 ("avx512bw", Stable, &["avx512f"]),
469 ("avx512cd", Stable, &["avx512f"]),
470 ("avx512dq", Stable, &["avx512f"]),
471 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
472 ("avx512fp16", Stable, &["avx512bw"]),
473 ("avx512ifma", Stable, &["avx512f"]),
474 ("avx512vbmi", Stable, &["avx512bw"]),
475 ("avx512vbmi2", Stable, &["avx512bw"]),
476 ("avx512vl", Stable, &["avx512f"]),
477 ("avx512vnni", Stable, &["avx512f"]),
478 ("avx512vp2intersect", Stable, &["avx512f"]),
479 ("avx512vpopcntdq", Stable, &["avx512f"]),
480 ("avxifma", Stable, &["avx2"]),
481 ("avxneconvert", Stable, &["avx2"]),
482 ("avxvnni", Stable, &["avx2"]),
483 ("avxvnniint8", Stable, &["avx2"]),
484 ("avxvnniint16", Stable, &["avx2"]),
485 ("bmi1", Stable, &[]),
486 ("bmi2", Stable, &[]),
487 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
488 ("cmpxchg16b", Stable, &[]),
489 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
490 ("f16c", Stable, &["avx"]),
491 ("fma", Stable, &["avx"]),
492 ("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
493 ("fxsr", Stable, &[]),
494 ("gfni", Stable, &["sse2"]),
495 ("kl", Stable, &["sse2"]),
496 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
497 ("lzcnt", Stable, &[]),
498 ("movbe", Stable, &[]),
499 ("movrs", Unstable(sym::movrs_target_feature), &[]),
500 ("pclmulqdq", Stable, &["sse2"]),
501 ("popcnt", Stable, &[]),
502 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
503 ("rdrand", Stable, &[]),
504 ("rdseed", Stable, &[]),
505 (
506 "retpoline-external-thunk",
507 Stability::InternalOnly {
509 reason: "use `-Zretpoline-external-thunk` compiler flag instead",
510 hard_error: false,
511 },
512 &[],
513 ),
514 (
515 "retpoline-indirect-branches",
516 Stability::InternalOnly {
518 reason: "use `-Zretpoline` compiler flag instead",
519 hard_error: false,
520 },
521 &[],
522 ),
523 (
524 "retpoline-indirect-calls",
525 Stability::InternalOnly {
527 reason: "use `-Zretpoline` compiler flag instead",
528 hard_error: false,
529 },
530 &[],
531 ),
532 ("rtm", Unstable(sym::rtm_target_feature), &[]),
533 ("sha", Stable, &["sse2"]),
534 ("sha512", Stable, &["avx2"]),
535 ("sm3", Stable, &["avx"]),
536 ("sm4", Stable, &["avx2"]),
537 (
538 "soft-float",
539 Stability::InternalOnly { reason: "use a soft-float target instead", hard_error: false },
541 &[],
542 ),
543 ("sse", Stable, &[]),
544 ("sse2", Stable, &["sse"]),
545 ("sse3", Stable, &["sse2"]),
546 ("sse4.1", Stable, &["ssse3"]),
547 ("sse4.2", Stable, &["sse4.1"]),
548 ("sse4a", Stable, &["sse3"]),
549 ("ssse3", Stable, &["sse3"]),
550 ("tbm", Stable, &[]),
551 ("vaes", Stable, &["avx2", "aes"]),
552 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
553 ("widekl", Stable, &["kl"]),
554 ("x87", Unstable(sym::x87_target_feature), &[]),
555 ("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
556 ("xsave", Stable, &[]),
557 ("xsavec", Stable, &["xsave"]),
558 ("xsaveopt", Stable, &["xsave"]),
559 ("xsaves", Stable, &["xsave"]),
560 ];
562
563const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
564 ("audio", Unstable(sym::hexagon_target_feature), &[]),
566 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
567 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
568 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
569 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
570 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
571 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
572 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
573 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
574 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
575 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
576 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
577 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
578 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
579 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
580 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
581 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
582 ("v60", Unstable(sym::hexagon_target_feature), &[]),
583 ("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
584 ("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
585 ("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
586 ("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
587 ("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
588 ("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
589 ("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
590 ("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
591 ("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
592 ("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
593 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
594 ];
596
597static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
598 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
602 (
603 "hard-float",
604 InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false },
606 &[],
607 ),
608 ("msync", Unstable(sym::powerpc_target_feature), &[]),
609 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
610 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
611 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
612 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
613 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
614 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
615 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
616 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
617 (
618 "spe",
619 InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false },
621 &[],
622 ),
623 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
624 ];
626
627const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
628 ("fp64", Unstable(sym::mips_target_feature), &[]),
630 ("msa", Unstable(sym::mips_target_feature), &[]),
633 ("virt", Unstable(sym::mips_target_feature), &[]),
634 ];
636
637const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
638 ("sm_70", Unstable(sym::nvptx_target_feature), &[]),
640 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
641 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
642 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
643 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
644 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
645 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
646 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
647 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
648 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
651 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
652 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
653 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
654 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
655 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
656 ("ptx70", Unstable(sym::nvptx_target_feature), &[]),
659 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
660 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
661 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
662 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
663 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
664 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
665 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
666 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
667 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
668 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
669 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
670 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
671 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
672 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
673 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
674 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
675 ];
677
678static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
679 ("a", Stable, &["zaamo", "zalrsc"]),
681 ("b", Stable, &["zba", "zbb", "zbs"]),
682 ("c", Stable, &["zca"]),
683 ("d", Unstable(sym::riscv_target_feature), &["f"]),
684 ("e", Unstable(sym::riscv_target_feature), &[]),
685 ("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
686 (
687 "forced-atomics",
688 Stability::InternalOnly {
690 reason: "unsound because it changes the ABI of atomic operations",
691 hard_error: false,
692 },
693 &[],
694 ),
695 ("m", Stable, &[]),
696 ("relax", Unstable(sym::riscv_target_feature), &[]),
697 (
698 "rva23u64",
699 Unstable(sym::riscv_target_feature),
700 &[
701 "m",
702 "a",
703 "f",
704 "d",
705 "c",
706 "b",
707 "v",
708 "zicsr",
709 "zicntr",
710 "zihpm",
711 "ziccif",
712 "ziccrse",
713 "ziccamoa",
714 "zicclsm",
715 "zic64b",
716 "za64rs",
717 "zihintpause",
718 "zba",
719 "zbb",
720 "zbs",
721 "zicbom",
722 "zicbop",
723 "zicboz",
724 "zfhmin",
725 "zkt",
726 "zvfhmin",
727 "zvbb",
728 "zvkt",
729 "zihintntl",
730 "zicond",
731 "zimop",
732 "zcmop",
733 "zcb",
734 "zfa",
735 "zawrs",
736 "supm",
737 ],
738 ),
739 ("supm", Unstable(sym::riscv_target_feature), &[]),
740 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
741 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
742 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
743 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
745 ("zaamo", Stable, &[]),
746 ("zabha", Stable, &["zaamo"]),
747 ("zacas", Stable, &["zaamo"]),
748 ("zalrsc", Stable, &[]),
749 ("zama16b", Stable, &[]),
750 ("zawrs", Stable, &[]),
751 ("zba", Stable, &[]),
752 ("zbb", Stable, &[]),
753 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
755 ("zbkc", Stable, &[]),
756 ("zbkx", Stable, &[]),
757 ("zbs", Stable, &[]),
758 ("zca", Stable, &[]),
759 ("zcb", Stable, &["zca"]),
760 ("zcmop", Stable, &["zca"]),
761 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
762 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
763 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
765 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
766 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
767 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
768 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
769 ("zic64b", Stable, &[]),
770 ("zicbom", Stable, &[]),
771 ("zicbop", Stable, &[]),
772 ("zicboz", Stable, &[]),
773 ("ziccamoa", Stable, &[]),
774 ("ziccif", Stable, &[]),
775 ("zicclsm", Stable, &[]),
776 ("ziccrse", Stable, &[]),
777 ("zicntr", Stable, &["zicsr"]),
778 ("zicond", Stable, &[]),
779 ("zicsr", Stable, &[]),
780 ("zifencei", Stable, &[]),
781 ("zihintntl", Stable, &[]),
782 ("zihintpause", Stable, &[]),
783 ("zihpm", Stable, &["zicsr"]),
784 ("zimop", Stable, &[]),
785 ("zk", Stable, &["zkn", "zkr", "zkt"]),
786 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
787 ("zknd", Stable, &["zkne_or_zknd"]),
788 ("zkne", Stable, &["zkne_or_zknd"]),
789 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
791 ("zkr", Stable, &[]),
792 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
793 ("zksed", Stable, &[]),
794 ("zksh", Stable, &[]),
795 ("zkt", Stable, &[]),
796 ("ztso", Stable, &[]),
797 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
799 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
800 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
801 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
802 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
803 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
804 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
805 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
806 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
808 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
809 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
810 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
811 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
812 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
813 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
814 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
815 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
817 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
818 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
819 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
820 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
821 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
822 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
823 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
824 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
825 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
826 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
827 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
828 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
829 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
830 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
831 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
832 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
833 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
834 ];
836
837static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
838 ("atomics", Unstable(sym::wasm_target_feature), &[]),
840 ("bulk-memory", Stable, &[]),
841 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
842 ("extended-const", Stable, &[]),
843 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
844 ("multivalue", Stable, &[]),
845 ("mutable-globals", Stable, &[]),
846 ("nontrapping-fptoint", Stable, &[]),
847 ("reference-types", Stable, &[]),
848 ("relaxed-simd", Stable, &["simd128"]),
849 ("sign-ext", Stable, &[]),
850 ("simd128", Stable, &[]),
851 ("tail-call", Stable, &[]),
852 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
853 ];
855
856const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
857 ("alu32", Unstable(sym::bpf_target_feature), &[]),
858 ("allows-misaligned-mem-access", Unstable(sym::bpf_target_feature), &[]),
859];
860
861static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
862 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
864 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
865 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
866 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
867 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
868 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
869 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
870 ("cache", Unstable(sym::csky_target_feature), &[]),
871 ("doloop", Unstable(sym::csky_target_feature), &[]),
872 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
873 ("dspe60", Unstable(sym::csky_target_feature), &[]),
874 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
875 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
876 ("edsp", Unstable(sym::csky_target_feature), &[]),
877 ("elrw", Unstable(sym::csky_target_feature), &[]),
878 ("float1e2", Unstable(sym::csky_target_feature), &[]),
879 ("float1e3", Unstable(sym::csky_target_feature), &[]),
880 ("float3e4", Unstable(sym::csky_target_feature), &[]),
881 ("float7e60", Unstable(sym::csky_target_feature), &[]),
882 ("floate1", Unstable(sym::csky_target_feature), &[]),
883 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
884 ("high-registers", Unstable(sym::csky_target_feature), &[]),
885 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
886 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
887 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
888 ("nvic", Unstable(sym::csky_target_feature), &[]),
889 ("trust", Unstable(sym::csky_target_feature), &[]),
890 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
891 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
892 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
893 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
897 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
898 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
899 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
900 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
901 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
902 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
903 ("hard-float", Unstable(sym::csky_target_feature), &[]),
904 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
905 ];
907
908static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
909 ("32s", Unstable(sym::loongarch_target_feature), &[]),
911 ("d", Stable, &["f"]),
912 ("div32", Stable, &[]),
913 ("f", Stable, &[]),
914 ("frecipe", Stable, &[]),
915 ("lam-bh", Stable, &[]),
916 ("lamcas", Stable, &[]),
917 ("lasx", Stable, &["lsx"]),
918 ("lbt", Stable, &[]),
919 ("ld-seq-sa", Stable, &[]),
920 ("lsx", Stable, &["d"]),
921 ("lvz", Stable, &[]),
922 ("relax", Unstable(sym::loongarch_target_feature), &[]),
923 ("scq", Stable, &[]),
924 ("ual", Unstable(sym::loongarch_target_feature), &[]),
925 ];
927
928#[rustfmt::skip]
929const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
930 ("backchain", Unstable(sym::s390x_target_feature), &[]),
933 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
934 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
935 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
936 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
937 ("high-word", Unstable(sym::s390x_target_feature), &[]),
938 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
940 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
941 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
942 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
943 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
944 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
945 ("miscellaneous-extensions-2", Stable, &[]),
946 ("miscellaneous-extensions-3", Stable, &[]),
947 ("miscellaneous-extensions-4", Stable, &[]),
948 ("nnp-assist", Stable, &["vector"]),
949 ("soft-float", InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
951 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
952 ("vector", Stable, &[]),
953 ("vector-enhancements-1", Stable, &["vector"]),
954 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
955 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
956 ("vector-packed-decimal", Stable, &["vector"]),
957 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
958 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
959 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
960 ];
962
963const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
964 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
966 (
967 "soft-float",
968 InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false },
969 &[],
970 ),
971 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
972 ("v9", Unstable(sym::sparc_target_feature), &[]),
975 ];
977
978static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
979 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
981 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
982 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
983 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
984 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
985 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
986 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
988 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
989 ];
991
992static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
993 ("addsubiw", Unstable(sym::avr_target_feature), &[]),
995 ("break", Unstable(sym::avr_target_feature), &[]),
996 ("eijmpcall", Unstable(sym::avr_target_feature), &[]),
997 ("elpm", Unstable(sym::avr_target_feature), &[]),
998 ("elpmx", Unstable(sym::avr_target_feature), &[]),
999 ("ijmpcall", Unstable(sym::avr_target_feature), &[]),
1000 ("jmpcall", Unstable(sym::avr_target_feature), &[]),
1001 ("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
1002 ("lpm", Unstable(sym::avr_target_feature), &[]),
1003 ("lpmx", Unstable(sym::avr_target_feature), &[]),
1004 ("movw", Unstable(sym::avr_target_feature), &[]),
1005 ("mul", Unstable(sym::avr_target_feature), &[]),
1006 ("rmw", Unstable(sym::avr_target_feature), &[]),
1007 ("spm", Unstable(sym::avr_target_feature), &[]),
1008 ("spmx", Unstable(sym::avr_target_feature), &[]),
1009 (
1010 "sram",
1011 InternalOnly { reason: "devices that have no SRAM are unsupported", hard_error: false },
1013 &[],
1014 ),
1015 ("tinyencoding", Unstable(sym::avr_target_feature), &[]),
1016 ];
1018
1019const XTENSA_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
1020 ("bool", Unstable(sym::xtensa_target_feature), &[]),
1021 ("fp", Unstable(sym::xtensa_target_feature), &["bool", "coprocessor"]),
1022 ("coprocessor", Unstable(sym::xtensa_target_feature), &[]),
1023 ("highpriinterrupts", Unstable(sym::xtensa_target_feature), &["interrupt"]),
1024 ("interrupt", Unstable(sym::xtensa_target_feature), &["exception"]),
1025 (
1026 "windowed",
1027 InternalOnly {
1029 reason: "windowed changes the Xtensa calling convention",
1030 hard_error: false,
1031 },
1032 &["exception"],
1033 ),
1034 ("loop", Unstable(sym::xtensa_target_feature), &[]),
1035 ("sext", Unstable(sym::xtensa_target_feature), &[]),
1036 ("nsa", Unstable(sym::xtensa_target_feature), &[]),
1037 ("mul32", Unstable(sym::xtensa_target_feature), &[]),
1038 ("mul32high", Unstable(sym::xtensa_target_feature), &["mul32"]),
1039 ("div32", Unstable(sym::xtensa_target_feature), &[]),
1040 ("mac16", Unstable(sym::xtensa_target_feature), &[]),
1041 ("s32c1i", Unstable(sym::xtensa_target_feature), &[]),
1042 ("threadptr", Unstable(sym::xtensa_target_feature), &[]),
1043 ("extendedl32r", Unstable(sym::xtensa_target_feature), &[]),
1044 ("debug", Unstable(sym::xtensa_target_feature), &["exception"]),
1045 ("exception", Unstable(sym::xtensa_target_feature), &[]),
1046 ("rvector", Unstable(sym::xtensa_target_feature), &["exception"]),
1047 ("prid", Unstable(sym::xtensa_target_feature), &[]),
1048 ("regprotect", Unstable(sym::xtensa_target_feature), &[]),
1049 ("miscsr", Unstable(sym::xtensa_target_feature), &[]),
1050];
1051
1052pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
1057 std::iter::empty()
1058 .chain(ARM_FEATURES)
1059 .chain(AARCH64_FEATURES)
1060 .chain(X86_FEATURES)
1061 .chain(HEXAGON_FEATURES)
1062 .chain(POWERPC_FEATURES)
1063 .chain(MIPS_FEATURES)
1064 .chain(NVPTX_FEATURES)
1065 .chain(RISCV_FEATURES)
1066 .chain(WASM_FEATURES)
1067 .chain(BPF_FEATURES)
1068 .chain(XTENSA_FEATURES)
1069 .chain(CSKY_FEATURES)
1070 .chain(LOONGARCH_FEATURES)
1071 .chain(IBMZ_FEATURES)
1072 .chain(SPARC_FEATURES)
1073 .chain(M68K_FEATURES)
1074 .chain(AVR_FEATURES)
1075 .cloned()
1076 .map(|(f, s, _)| (f, s))
1077}
1078
1079pub fn feature_to_arch_names(feature: &str) -> Vec<&'static str> {
1083 let mut arches = Vec::new();
1084 macro_rules! check_arch_feats {
1085 ($arch_name:expr, $feats:expr) => {
1086 if $feats.iter().any(|(f, _, _)| *f == feature) {
1087 arches.push($arch_name);
1088 }
1089 };
1090 }
1091 if ARM_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("arm"); };check_arch_feats!("arm", ARM_FEATURES);
1092 if AARCH64_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("aarch64");
};check_arch_feats!("aarch64", AARCH64_FEATURES);
1093 if X86_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("x86"); };check_arch_feats!("x86", X86_FEATURES);
1094 if HEXAGON_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("hexagon");
};check_arch_feats!("hexagon", HEXAGON_FEATURES);
1095 if MIPS_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("mips");
};check_arch_feats!("mips", MIPS_FEATURES);
1096 if NVPTX_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("nvptx64");
};check_arch_feats!("nvptx64", NVPTX_FEATURES);
1097 if POWERPC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("powerpc");
};check_arch_feats!("powerpc", POWERPC_FEATURES);
1098 if RISCV_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("riscv");
};check_arch_feats!("riscv", RISCV_FEATURES);
1099 if WASM_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("wasm");
};check_arch_feats!("wasm", WASM_FEATURES);
1100 if BPF_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("bpf"); };check_arch_feats!("bpf", BPF_FEATURES);
1101 if CSKY_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("csky");
};check_arch_feats!("csky", CSKY_FEATURES);
1102 if LOONGARCH_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("loongarch");
};check_arch_feats!("loongarch", LOONGARCH_FEATURES);
1103 if IBMZ_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("s390x");
};check_arch_feats!("s390x", IBMZ_FEATURES);
1104 if SPARC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("sparc");
};check_arch_feats!("sparc", SPARC_FEATURES);
1105 if M68K_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("m68k");
};check_arch_feats!("m68k", M68K_FEATURES);
1106 if AVR_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("avr"); };check_arch_feats!("avr", AVR_FEATURES);
1107 arches.sort();
1108 arches.dedup();
1109 arches
1110}
1111
1112const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1117 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1119 &[(128, "neon")];
1120
1121const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1122 &[(128, "neon"), (128, "mve")];
1123
1124const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1125 &[(1024, "")];
1126const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1127 &[(128, "altivec")];
1128const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1129 &[(128, "simd128")];
1130const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1131 &[(128, "vector")];
1132const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1133 (32, "zvl32b"),
1134 (64, "zvl64b"),
1135 (128, "zvl128b"),
1136 (256, "zvl256b"),
1137 (512, "zvl512b"),
1138 (1024, "zvl1024b"),
1139 (2048, "zvl2048b"),
1140 (4096, "zvl4096b"),
1141 (8192, "zvl8192b"),
1142 (16384, "zvl16384b"),
1143 (32768, "zvl32768b"),
1144 (65536, "zvl65536b"),
1145];
1146const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1148 &[];
1149
1150const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1151 (512, "hvx-length64b"), (1024, "hvx-length128b"), (2048, "hvx-length128b"), ];
1155const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1156 &[(128, "msa")];
1157const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1158 &[(128, "vdspv1")];
1159const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1160 &[(128, "lsx"), (256, "lasx")];
1161
1162#[derive(#[automatically_derived]
impl ::core::marker::Copy for FeatureConstraints { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for FeatureConstraints { }
#[automatically_derived]
impl ::core::clone::Clone for FeatureConstraints {
#[inline]
fn clone(&self) -> FeatureConstraints {
let _: ::core::clone::AssertParamIsClone<&'static [&'static str]>;
let _: ::core::clone::AssertParamIsClone<&'static [&'static str]>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FeatureConstraints {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"FeatureConstraints", "required", &self.required, "incompatible",
&&self.incompatible)
}
}Debug)]
1163pub struct FeatureConstraints {
1164 pub required: &'static [&'static str],
1166 pub incompatible: &'static [&'static str],
1168}
1169
1170impl Target {
1171 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
1172 match &self.arch {
1173 Arch::Arm => ARM_FEATURES,
1174 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
1175 Arch::X86 | Arch::X86_64 => X86_FEATURES,
1176 Arch::Hexagon => HEXAGON_FEATURES,
1177 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
1178 Arch::Nvptx64 => NVPTX_FEATURES,
1179 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
1180 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
1181 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
1182 Arch::Bpf => BPF_FEATURES,
1183 Arch::CSky => CSKY_FEATURES,
1184 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
1185 Arch::S390x => IBMZ_FEATURES,
1186 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
1187 Arch::M68k => M68K_FEATURES,
1188 Arch::Avr => AVR_FEATURES,
1189 Arch::Xtensa => XTENSA_FEATURES,
1190 Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Other(_) => &[],
1191 }
1192 }
1193
1194 pub fn rust_target_features_map(
1196 &self,
1197 ) -> FxHashMap<&'static str, (Stability, ImpliedFeatures)> {
1198 self.rust_target_features()
1199 .iter()
1200 .map(|&(f, s, i)| (f, (s, i)))
1201 .collect::<FxHashMap<_, _>>()
1202 }
1203
1204 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1205 match &self.arch {
1206 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1207 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1208 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1209 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1210 Arch::LoongArch32 | Arch::LoongArch64 => {
1211 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1212 }
1213 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1214 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1215 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1216 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1217 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1218 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1219 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1220 }
1221 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1222 Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1224 Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1227 }
1228 }
1229
1230 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1231 match &self.arch {
1232 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1233 _ => None,
1235 }
1236 }
1237
1238 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1239 match &self.arch {
1240 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1241 _ => &[],
1242 }
1243 }
1244
1245 #[track_caller]
1247 pub fn implied_target_features<'a>(
1248 &self,
1249 base_feature: &'a str,
1250 target_features_map: &FxHashMap<&'static str, (Stability, ImpliedFeatures)>,
1251 ) -> FxHashSet<&'a str> {
1252 let mut features = FxHashSet::default();
1255 let mut new_features = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[base_feature]))vec![base_feature];
1256 while let Some(new_feature) = new_features.pop() {
1257 if features.insert(new_feature) {
1258 let (_, implied_features) = target_features_map
1259 .get(&new_feature)
1260 .unwrap_or_else(|| {
::core::panicking::panic_fmt(format_args!("encountered non-Rust target feature {0}",
new_feature));
}panic!("encountered non-Rust target feature {new_feature}"));
1261 new_features.extend(implied_features.iter().copied());
1262 }
1263 }
1264 features
1265 }
1266
1267 pub fn abi_required_features(&self) -> FeatureConstraints {
1278 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1279 match &self.arch {
1284 Arch::X86 => {
1285 match self.rustc_abi {
1288 None => {
1289 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1292 }
1293 Some(RustcAbi::X86Sse2) => {
1294 FeatureConstraints {
1296 required: &["x87", "sse2"],
1297 incompatible: &["soft-float"],
1298 }
1299 }
1300 Some(RustcAbi::Softfloat) => {
1301 FeatureConstraints { required: &["soft-float"], incompatible: &["sse"] }
1308 }
1309 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1310 }
1311 }
1312 Arch::X86_64 => {
1313 match self.rustc_abi {
1316 None => {
1317 FeatureConstraints {
1319 required: &["x87", "sse2"],
1320 incompatible: &["soft-float"],
1321 }
1322 }
1323 Some(RustcAbi::Softfloat) => {
1324 FeatureConstraints { required: &["soft-float"], incompatible: &["sse"] }
1331 }
1332 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1333 }
1334 }
1335 Arch::Arm => {
1336 match self.llvm_floatabi.unwrap() {
1339 FloatAbi::Soft => {
1340 NOTHING
1345 }
1346 FloatAbi::Hard => {
1347 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1349 }
1350 }
1351 }
1352 Arch::AArch64 | Arch::Arm64EC => {
1353 match self.rustc_abi {
1356 Some(RustcAbi::Softfloat) => {
1357 FeatureConstraints { required: &[], incompatible: &["neon", "fp-armv8"] }
1363 }
1364 None => {
1365 FeatureConstraints { required: &["neon"], incompatible: &[] }
1368 }
1369 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1370 }
1371 }
1372 Arch::RiscV32 | Arch::RiscV64 => {
1373 match &self.llvm_abiname {
1376 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1377 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1379 }
1380 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1381 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1383 }
1384 LlvmAbi::Ilp32 | LlvmAbi::Lp64 => {
1385 FeatureConstraints { required: &[], incompatible: &["e"] }
1387 }
1388 LlvmAbi::Ilp32e => {
1389 FeatureConstraints { required: &[], incompatible: &["d"] }
1398 }
1399 LlvmAbi::Lp64e => {
1400 NOTHING
1402 }
1403 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1404 }
1405 }
1406 Arch::LoongArch32 | Arch::LoongArch64 => {
1407 match &self.llvm_abiname {
1410 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1411 FeatureConstraints { required: &["d"], incompatible: &[] }
1413 }
1414 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1415 FeatureConstraints { required: &["f"], incompatible: &[] }
1417 }
1418 LlvmAbi::Ilp32s | LlvmAbi::Lp64s => {
1419 NOTHING
1424 }
1425 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1426 }
1427 }
1428 Arch::S390x => {
1429 match self.rustc_abi {
1437 None => {
1438 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1440 }
1441 Some(RustcAbi::Softfloat) => {
1442 FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] }
1445 }
1446 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1447 }
1448 }
1449 Arch::PowerPC => {
1450 match self.rustc_abi {
1453 None => {
1454 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1456 }
1457 Some(RustcAbi::PowerPcSpe) => {
1458 FeatureConstraints { required: &["hard-float", "spe"], incompatible: &[] }
1463 }
1464 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1465 }
1466 }
1467 Arch::PowerPC64 => {
1468 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1472 }
1473 Arch::Sparc => {
1474 match self.rustc_abi {
1478 None => FeatureConstraints {
1479 required: &[],
1480 incompatible: &["soft-float", "v8plus"],
1481 },
1482 Some(RustcAbi::SparcV8Plus) => {
1483 FeatureConstraints { required: &["v8plus"], incompatible: &["soft-float"] }
1484 }
1485 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1486 }
1487 }
1488 Arch::Sparc64 => {
1489 FeatureConstraints { required: &[], incompatible: &["soft-float", "v8plus"] }
1492 }
1493 Arch::Avr => {
1494 FeatureConstraints { required: &["sram"], incompatible: &[] }
1499 }
1500 Arch::Wasm32 | Arch::Wasm64 => {
1501 NOTHING
1504 }
1505 Arch::Xtensa => {
1506 FeatureConstraints { required: &["windowed", "exception"], incompatible: &[] }
1515 }
1516 _ => NOTHING,
1517 }
1518 }
1519}