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]
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 ("fpregs", Unstable(sym::arm_target_feature), &[]),
181 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
182 ("mclass", Unstable(sym::arm_target_feature), &[]),
183 ("mve", Unstable(sym::arm_target_feature), &["v8.1m.main", "dsp", "fpregs"]),
184 ("mve.fp", Unstable(sym::arm_target_feature), &["mve"]),
185 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
186 ("rclass", Unstable(sym::arm_target_feature), &[]),
187 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
188 ("soft-float", Unstable(sym::arm_target_feature), &[]),
193 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
197 ("thumb2", Unstable(sym::arm_target_feature), &[]),
198 ("trustzone", Unstable(sym::arm_target_feature), &[]),
199 ("v5te", Unstable(sym::arm_target_feature), &[]),
200 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
201 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
202 ("v6m", Unstable(sym::arm_target_feature), &["v6"]),
203 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "v8m", "thumb2"]),
204 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
205 ("v8", Unstable(sym::arm_target_feature), &["v7", "acquire-release"]),
206 ("v8.1m.main", Unstable(sym::arm_target_feature), &["v8m.main"]),
207 ("v8m", Unstable(sym::arm_target_feature), &["v6m"]),
208 ("v8m.main", Unstable(sym::arm_target_feature), &["v7"]),
209 ("vfp2", Unstable(sym::arm_target_feature), &[]),
210 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
211 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
212 ("virtualization", Unstable(sym::arm_target_feature), &[]),
213 ];
215
216static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
217 ("aes", Stable, &["neon"]),
220 ("bf16", Stable, &[]),
222 ("bti", Stable, &[]),
224 ("crc", Stable, &[]),
226 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
228 ("dit", Stable, &[]),
230 ("dotprod", Stable, &["neon"]),
232 ("dpb", Stable, &[]),
234 ("dpb2", Stable, &["dpb"]),
236 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
238 ("f32mm", Stable, &["sve"]),
240 ("f64mm", Stable, &["sve"]),
242 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
244 ("fcma", Stable, &["neon"]),
246 ("fhm", Stable, &["fp16"]),
248 ("flagm", Stable, &[]),
250 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
252 (
254 "fp-armv8",
255 Stability::InternalOnly { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
257 &[],
258 ),
259 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
261 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
263 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
265 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
267 ("fp16", Stable, &["neon"]),
270 ("frintts", Stable, &[]),
272 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
274 ("i8mm", Stable, &[]),
276 ("jsconv", Stable, &["neon"]),
279 ("lor", Stable, &[]),
281 ("lse", Stable, &[]),
283 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
285 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
287 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
289 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
291 ("mte", Stable, &[]),
293 ("neon", Stable, &[]),
295 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
299 ("paca", Stable, &[]),
301 ("pacg", Stable, &[]),
303 ("pan", Stable, &[]),
305 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
307 ("pmuv3", Stable, &[]),
309 ("rand", Stable, &[]),
311 ("ras", Stable, &[]),
313 ("rcpc", Stable, &[]),
315 ("rcpc2", Stable, &["rcpc"]),
317 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
319 ("rdm", Stable, &["neon"]),
321 (
322 "reserve-x18",
323 InternalOnly { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
325 &[],
326 ),
327 ("sb", Stable, &[]),
329 ("sha2", Stable, &["neon"]),
331 ("sha3", Stable, &["sha2"]),
333 ("sm4", Stable, &["neon"]),
335 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
337 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
339 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
341 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
343 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
345 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
347 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
349 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
351 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
353 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
355 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
357 ("spe", Stable, &[]),
359 ("ssbs", Stable, &[]),
361 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
363 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
365 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
367 ("sve", Stable, &["neon", "fp16"]),
375 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
377 ("sve2", Stable, &["sve"]),
379 ("sve2-aes", Stable, &["sve2", "aes"]),
381 ("sve2-bitperm", Stable, &["sve2"]),
383 ("sve2-sha3", Stable, &["sve2", "sha3"]),
385 ("sve2-sm4", Stable, &["sve2", "sm4"]),
387 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
389 ("tme", Stable, &[]),
391 (
392 "v8.1a",
393 Unstable(sym::aarch64_ver_target_feature),
394 &["crc", "lse", "rdm", "pan", "lor", "vh"],
395 ),
396 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
397 (
398 "v8.3a",
399 Unstable(sym::aarch64_ver_target_feature),
400 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
401 ),
402 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
403 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
404 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
405 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
406 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
407 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
408 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
409 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
410 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
411 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
412 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
413 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a"]),
414 ("vh", Stable, &[]),
416 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
418 ];
420
421const AARCH64_TIED_FEATURES: &[&[&str]] = &[
422 &["paca", "pacg"], ];
424
425static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
426 ("adx", Stable, &[]),
428 ("aes", Stable, &["sse2"]),
429 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
430 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
431 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
432 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
433 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
434 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
435 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
436 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
437 ("apxf", Unstable(sym::apx_target_feature), &[]),
438 ("avx", Stable, &["sse4.2"]),
439 ("avx2", Stable, &["avx"]),
440 (
441 "avx10.1",
442 Unstable(sym::avx10_target_feature),
443 &[
444 "avx512bf16",
445 "avx512bitalg",
446 "avx512bw",
447 "avx512cd",
448 "avx512dq",
449 "avx512f",
450 "avx512fp16",
451 "avx512ifma",
452 "avx512vbmi",
453 "avx512vbmi2",
454 "avx512vl",
455 "avx512vnni",
456 "avx512vpopcntdq",
457 ],
458 ),
459 (
460 "avx10.2",
461 Unstable(sym::avx10_target_feature),
462 &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
463 ),
464 ("avx512bf16", Stable, &["avx512bw"]),
465 ("avx512bitalg", Stable, &["avx512bw"]),
466 ("avx512bw", Stable, &["avx512f"]),
467 ("avx512cd", Stable, &["avx512f"]),
468 ("avx512dq", Stable, &["avx512f"]),
469 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
470 ("avx512fp16", Stable, &["avx512bw"]),
471 ("avx512ifma", Stable, &["avx512f"]),
472 ("avx512vbmi", Stable, &["avx512bw"]),
473 ("avx512vbmi2", Stable, &["avx512bw"]),
474 ("avx512vl", Stable, &["avx512f"]),
475 ("avx512vnni", Stable, &["avx512f"]),
476 ("avx512vp2intersect", Stable, &["avx512f"]),
477 ("avx512vpopcntdq", Stable, &["avx512f"]),
478 ("avxifma", Stable, &["avx2"]),
479 ("avxneconvert", Stable, &["avx2"]),
480 ("avxvnni", Stable, &["avx2"]),
481 ("avxvnniint8", Stable, &["avx2"]),
482 ("avxvnniint16", Stable, &["avx2"]),
483 ("bmi1", Stable, &[]),
484 ("bmi2", Stable, &[]),
485 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
486 ("cmpxchg16b", Stable, &[]),
487 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
488 ("f16c", Stable, &["avx"]),
489 ("fma", Stable, &["avx"]),
490 ("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
491 ("fxsr", Stable, &[]),
492 ("gfni", Stable, &["sse2"]),
493 ("kl", Stable, &["sse2"]),
494 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
495 ("lzcnt", Stable, &[]),
496 ("movbe", Stable, &[]),
497 ("movrs", Unstable(sym::movrs_target_feature), &[]),
498 ("pclmulqdq", Stable, &["sse2"]),
499 ("popcnt", Stable, &[]),
500 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
501 ("rdrand", Stable, &[]),
502 ("rdseed", Stable, &[]),
503 (
504 "retpoline-external-thunk",
505 Stability::InternalOnly {
507 reason: "use `-Zretpoline-external-thunk` compiler flag instead",
508 hard_error: false,
509 },
510 &[],
511 ),
512 (
513 "retpoline-indirect-branches",
514 Stability::InternalOnly {
516 reason: "use `-Zretpoline` compiler flag instead",
517 hard_error: false,
518 },
519 &[],
520 ),
521 (
522 "retpoline-indirect-calls",
523 Stability::InternalOnly {
525 reason: "use `-Zretpoline` compiler flag instead",
526 hard_error: false,
527 },
528 &[],
529 ),
530 ("rtm", Unstable(sym::rtm_target_feature), &[]),
531 ("sha", Stable, &["sse2"]),
532 ("sha512", Stable, &["avx2"]),
533 ("sm3", Stable, &["avx"]),
534 ("sm4", Stable, &["avx2"]),
535 (
536 "soft-float",
537 Stability::InternalOnly { reason: "use a soft-float target instead", hard_error: false },
539 &[],
540 ),
541 ("sse", Stable, &[]),
542 ("sse2", Stable, &["sse"]),
543 ("sse3", Stable, &["sse2"]),
544 ("sse4.1", Stable, &["ssse3"]),
545 ("sse4.2", Stable, &["sse4.1"]),
546 ("sse4a", Stable, &["sse3"]),
547 ("ssse3", Stable, &["sse3"]),
548 ("tbm", Stable, &[]),
549 ("vaes", Stable, &["avx2", "aes"]),
550 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
551 ("widekl", Stable, &["kl"]),
552 ("x87", Unstable(sym::x87_target_feature), &[]),
553 ("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
554 ("xsave", Stable, &[]),
555 ("xsavec", Stable, &["xsave"]),
556 ("xsaveopt", Stable, &["xsave"]),
557 ("xsaves", Stable, &["xsave"]),
558 ];
560
561const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
562 ("audio", Unstable(sym::hexagon_target_feature), &[]),
564 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
565 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
566 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
567 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
568 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
569 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
570 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
571 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
572 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
573 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
574 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
575 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
576 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
577 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
578 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
579 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
580 ("v60", Unstable(sym::hexagon_target_feature), &[]),
581 ("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
582 ("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
583 ("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
584 ("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
585 ("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
586 ("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
587 ("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
588 ("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
589 ("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
590 ("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
591 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
592 ];
594
595static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
596 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
600 (
601 "hard-float",
602 InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false },
604 &[],
605 ),
606 ("msync", Unstable(sym::powerpc_target_feature), &[]),
607 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
608 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
609 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
610 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
611 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
612 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
613 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
614 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
615 (
616 "spe",
617 InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false },
619 &[],
620 ),
621 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
622 ];
624
625const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
626 ("fp64", Unstable(sym::mips_target_feature), &[]),
628 ("msa", Unstable(sym::mips_target_feature), &[]),
629 ("virt", Unstable(sym::mips_target_feature), &[]),
630 ];
632
633const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
634 ("sm_70", Unstable(sym::nvptx_target_feature), &[]),
636 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
637 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
638 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
639 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
640 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
641 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
642 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
643 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
644 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
647 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
648 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
649 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
650 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
651 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
652 ("ptx70", Unstable(sym::nvptx_target_feature), &[]),
655 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
656 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
657 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
658 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
659 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
660 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
661 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
662 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
663 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
664 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
665 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
666 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
667 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
668 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
669 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
670 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
671 ];
673
674static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
675 ("a", Stable, &["zaamo", "zalrsc"]),
677 ("b", Stable, &["zba", "zbb", "zbs"]),
678 ("c", Stable, &["zca"]),
679 ("d", Unstable(sym::riscv_target_feature), &["f"]),
680 ("e", Unstable(sym::riscv_target_feature), &[]),
681 ("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
682 (
683 "forced-atomics",
684 Stability::InternalOnly {
686 reason: "unsound because it changes the ABI of atomic operations",
687 hard_error: false,
688 },
689 &[],
690 ),
691 ("m", Stable, &[]),
692 ("relax", Unstable(sym::riscv_target_feature), &[]),
693 (
694 "rva23u64",
695 Unstable(sym::riscv_target_feature),
696 &[
697 "m",
698 "a",
699 "f",
700 "d",
701 "c",
702 "b",
703 "v",
704 "zicsr",
705 "zicntr",
706 "zihpm",
707 "ziccif",
708 "ziccrse",
709 "ziccamoa",
710 "zicclsm",
711 "zic64b",
712 "za64rs",
713 "zihintpause",
714 "zba",
715 "zbb",
716 "zbs",
717 "zicbom",
718 "zicbop",
719 "zicboz",
720 "zfhmin",
721 "zkt",
722 "zvfhmin",
723 "zvbb",
724 "zvkt",
725 "zihintntl",
726 "zicond",
727 "zimop",
728 "zcmop",
729 "zcb",
730 "zfa",
731 "zawrs",
732 "supm",
733 ],
734 ),
735 ("supm", Unstable(sym::riscv_target_feature), &[]),
736 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
737 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
738 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
739 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
741 ("zaamo", Stable, &[]),
742 ("zabha", Stable, &["zaamo"]),
743 ("zacas", Stable, &["zaamo"]),
744 ("zalrsc", Stable, &[]),
745 ("zama16b", Stable, &[]),
746 ("zawrs", Stable, &[]),
747 ("zba", Stable, &[]),
748 ("zbb", Stable, &[]),
749 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
751 ("zbkc", Stable, &[]),
752 ("zbkx", Stable, &[]),
753 ("zbs", Stable, &[]),
754 ("zca", Stable, &[]),
755 ("zcb", Stable, &["zca"]),
756 ("zcmop", Stable, &["zca"]),
757 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
758 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
759 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
761 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
762 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
763 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
764 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
765 ("zic64b", Stable, &[]),
766 ("zicbom", Stable, &[]),
767 ("zicbop", Stable, &[]),
768 ("zicboz", Stable, &[]),
769 ("ziccamoa", Stable, &[]),
770 ("ziccif", Stable, &[]),
771 ("zicclsm", Stable, &[]),
772 ("ziccrse", Stable, &[]),
773 ("zicntr", Stable, &["zicsr"]),
774 ("zicond", Stable, &[]),
775 ("zicsr", Stable, &[]),
776 ("zifencei", Stable, &[]),
777 ("zihintntl", Stable, &[]),
778 ("zihintpause", Stable, &[]),
779 ("zihpm", Stable, &["zicsr"]),
780 ("zimop", Stable, &[]),
781 ("zk", Stable, &["zkn", "zkr", "zkt"]),
782 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
783 ("zknd", Stable, &["zkne_or_zknd"]),
784 ("zkne", Stable, &["zkne_or_zknd"]),
785 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
787 ("zkr", Stable, &[]),
788 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
789 ("zksed", Stable, &[]),
790 ("zksh", Stable, &[]),
791 ("zkt", Stable, &[]),
792 ("ztso", Stable, &[]),
793 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
795 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
796 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
797 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
798 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
799 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
800 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
801 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
802 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
804 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
805 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
806 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
807 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
808 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
809 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
810 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
811 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
813 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
814 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
815 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
816 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
817 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
818 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
819 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
820 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
821 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
822 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
823 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
824 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
825 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
826 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
827 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
828 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
829 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
830 ];
832
833static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
834 ("atomics", Unstable(sym::wasm_target_feature), &[]),
836 ("bulk-memory", Stable, &[]),
837 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
838 ("extended-const", Stable, &[]),
839 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
840 ("multivalue", Stable, &[]),
841 ("mutable-globals", Stable, &[]),
842 ("nontrapping-fptoint", Stable, &[]),
843 ("reference-types", Stable, &[]),
844 ("relaxed-simd", Stable, &["simd128"]),
845 ("sign-ext", Stable, &[]),
846 ("simd128", Stable, &[]),
847 ("tail-call", Stable, &[]),
848 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
849 ];
851
852const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
853 ("alu32", Unstable(sym::bpf_target_feature), &[]),
854 ("allows-misaligned-mem-access", Unstable(sym::bpf_target_feature), &[]),
855];
856
857static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
858 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
860 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
861 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
862 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
863 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
864 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
865 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
866 ("cache", Unstable(sym::csky_target_feature), &[]),
867 ("doloop", Unstable(sym::csky_target_feature), &[]),
868 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
869 ("dspe60", Unstable(sym::csky_target_feature), &[]),
870 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
871 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
872 ("edsp", Unstable(sym::csky_target_feature), &[]),
873 ("elrw", Unstable(sym::csky_target_feature), &[]),
874 ("float1e2", Unstable(sym::csky_target_feature), &[]),
875 ("float1e3", Unstable(sym::csky_target_feature), &[]),
876 ("float3e4", Unstable(sym::csky_target_feature), &[]),
877 ("float7e60", Unstable(sym::csky_target_feature), &[]),
878 ("floate1", Unstable(sym::csky_target_feature), &[]),
879 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
880 ("high-registers", Unstable(sym::csky_target_feature), &[]),
881 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
882 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
883 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
884 ("nvic", Unstable(sym::csky_target_feature), &[]),
885 ("trust", Unstable(sym::csky_target_feature), &[]),
886 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
887 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
888 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
889 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
893 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
894 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
895 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
896 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
897 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
898 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
899 ("hard-float", Unstable(sym::csky_target_feature), &[]),
900 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
901 ];
903
904static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
905 ("32s", Unstable(sym::loongarch_target_feature), &[]),
907 ("d", Stable, &["f"]),
908 ("div32", Stable, &[]),
909 ("f", Stable, &[]),
910 ("frecipe", Stable, &[]),
911 ("lam-bh", Stable, &[]),
912 ("lamcas", Stable, &[]),
913 ("lasx", Stable, &["lsx"]),
914 ("lbt", Stable, &[]),
915 ("ld-seq-sa", Stable, &[]),
916 ("lsx", Stable, &["d"]),
917 ("lvz", Stable, &[]),
918 ("relax", Unstable(sym::loongarch_target_feature), &[]),
919 ("scq", Stable, &[]),
920 ("ual", Unstable(sym::loongarch_target_feature), &[]),
921 ];
923
924#[rustfmt::skip]
925const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
926 ("backchain", Unstable(sym::s390x_target_feature), &[]),
929 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
930 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
931 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
932 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
933 ("high-word", Unstable(sym::s390x_target_feature), &[]),
934 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
936 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
937 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
938 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
939 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
940 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
941 ("miscellaneous-extensions-2", Stable, &[]),
942 ("miscellaneous-extensions-3", Stable, &[]),
943 ("miscellaneous-extensions-4", Stable, &[]),
944 ("nnp-assist", Stable, &["vector"]),
945 ("soft-float", InternalOnly { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
947 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
948 ("vector", Stable, &[]),
949 ("vector-enhancements-1", Stable, &["vector"]),
950 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
951 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
952 ("vector-packed-decimal", Stable, &["vector"]),
953 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
954 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
955 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
956 ];
958
959const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
960 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
962 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
963 ("v9", Unstable(sym::sparc_target_feature), &[]),
964 ];
966
967static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
968 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
970 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
971 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
972 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
973 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
974 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
975 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
977 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
978 ];
980
981static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
982 ("addsubiw", Unstable(sym::avr_target_feature), &[]),
984 ("break", Unstable(sym::avr_target_feature), &[]),
985 ("eijmpcall", Unstable(sym::avr_target_feature), &[]),
986 ("elpm", Unstable(sym::avr_target_feature), &[]),
987 ("elpmx", Unstable(sym::avr_target_feature), &[]),
988 ("ijmpcall", Unstable(sym::avr_target_feature), &[]),
989 ("jmpcall", Unstable(sym::avr_target_feature), &[]),
990 ("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
991 ("lpm", Unstable(sym::avr_target_feature), &[]),
992 ("lpmx", Unstable(sym::avr_target_feature), &[]),
993 ("movw", Unstable(sym::avr_target_feature), &[]),
994 ("mul", Unstable(sym::avr_target_feature), &[]),
995 ("rmw", Unstable(sym::avr_target_feature), &[]),
996 ("spm", Unstable(sym::avr_target_feature), &[]),
997 ("spmx", Unstable(sym::avr_target_feature), &[]),
998 (
999 "sram",
1000 InternalOnly { reason: "devices that have no SRAM are unsupported", hard_error: false },
1002 &[],
1003 ),
1004 ("tinyencoding", Unstable(sym::avr_target_feature), &[]),
1005 ];
1007
1008const XTENSA_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
1009 ("bool", Unstable(sym::xtensa_target_feature), &[]),
1010 ("fp", Unstable(sym::xtensa_target_feature), &["bool", "coprocessor"]),
1011 ("coprocessor", Unstable(sym::xtensa_target_feature), &[]),
1012 ("highpriinterrupts", Unstable(sym::xtensa_target_feature), &["interrupt"]),
1013 ("interrupt", Unstable(sym::xtensa_target_feature), &["exception"]),
1014 (
1015 "windowed",
1016 InternalOnly {
1018 reason: "windowed changes the Xtensa calling convention",
1019 hard_error: false,
1020 },
1021 &["exception"],
1022 ),
1023 ("loop", Unstable(sym::xtensa_target_feature), &[]),
1024 ("sext", Unstable(sym::xtensa_target_feature), &[]),
1025 ("nsa", Unstable(sym::xtensa_target_feature), &[]),
1026 ("mul32", Unstable(sym::xtensa_target_feature), &[]),
1027 ("mul32high", Unstable(sym::xtensa_target_feature), &["mul32"]),
1028 ("div32", Unstable(sym::xtensa_target_feature), &[]),
1029 ("mac16", Unstable(sym::xtensa_target_feature), &[]),
1030 ("s32c1i", Unstable(sym::xtensa_target_feature), &[]),
1031 ("threadptr", Unstable(sym::xtensa_target_feature), &[]),
1032 ("extendedl32r", Unstable(sym::xtensa_target_feature), &[]),
1033 ("debug", Unstable(sym::xtensa_target_feature), &["exception"]),
1034 ("exception", Unstable(sym::xtensa_target_feature), &[]),
1035 ("rvector", Unstable(sym::xtensa_target_feature), &["exception"]),
1036 ("prid", Unstable(sym::xtensa_target_feature), &[]),
1037 ("regprotect", Unstable(sym::xtensa_target_feature), &[]),
1038 ("miscsr", Unstable(sym::xtensa_target_feature), &[]),
1039];
1040
1041pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
1046 std::iter::empty()
1047 .chain(ARM_FEATURES)
1048 .chain(AARCH64_FEATURES)
1049 .chain(X86_FEATURES)
1050 .chain(HEXAGON_FEATURES)
1051 .chain(POWERPC_FEATURES)
1052 .chain(MIPS_FEATURES)
1053 .chain(NVPTX_FEATURES)
1054 .chain(RISCV_FEATURES)
1055 .chain(WASM_FEATURES)
1056 .chain(BPF_FEATURES)
1057 .chain(XTENSA_FEATURES)
1058 .chain(CSKY_FEATURES)
1059 .chain(LOONGARCH_FEATURES)
1060 .chain(IBMZ_FEATURES)
1061 .chain(SPARC_FEATURES)
1062 .chain(M68K_FEATURES)
1063 .chain(AVR_FEATURES)
1064 .cloned()
1065 .map(|(f, s, _)| (f, s))
1066}
1067
1068pub fn feature_to_arch_names(feature: &str) -> Vec<&'static str> {
1072 let mut arches = Vec::new();
1073 macro_rules! check_arch_feats {
1074 ($arch_name:expr, $feats:expr) => {
1075 if $feats.iter().any(|(f, _, _)| *f == feature) {
1076 arches.push($arch_name);
1077 }
1078 };
1079 }
1080 if ARM_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("arm"); };check_arch_feats!("arm", ARM_FEATURES);
1081 if AARCH64_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("aarch64");
};check_arch_feats!("aarch64", AARCH64_FEATURES);
1082 if X86_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("x86"); };check_arch_feats!("x86", X86_FEATURES);
1083 if HEXAGON_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("hexagon");
};check_arch_feats!("hexagon", HEXAGON_FEATURES);
1084 if MIPS_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("mips");
};check_arch_feats!("mips", MIPS_FEATURES);
1085 if NVPTX_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("nvptx64");
};check_arch_feats!("nvptx64", NVPTX_FEATURES);
1086 if POWERPC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("powerpc");
};check_arch_feats!("powerpc", POWERPC_FEATURES);
1087 if RISCV_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("riscv");
};check_arch_feats!("riscv", RISCV_FEATURES);
1088 if WASM_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("wasm");
};check_arch_feats!("wasm", WASM_FEATURES);
1089 if BPF_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("bpf"); };check_arch_feats!("bpf", BPF_FEATURES);
1090 if CSKY_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("csky");
};check_arch_feats!("csky", CSKY_FEATURES);
1091 if LOONGARCH_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("loongarch");
};check_arch_feats!("loongarch", LOONGARCH_FEATURES);
1092 if IBMZ_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("s390x");
};check_arch_feats!("s390x", IBMZ_FEATURES);
1093 if SPARC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("sparc");
};check_arch_feats!("sparc", SPARC_FEATURES);
1094 if M68K_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("m68k");
};check_arch_feats!("m68k", M68K_FEATURES);
1095 if AVR_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("avr"); };check_arch_feats!("avr", AVR_FEATURES);
1096 arches.sort();
1097 arches.dedup();
1098 arches
1099}
1100
1101const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1105 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1107 &[(128, "neon")];
1108
1109const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1110 &[(128, "neon"), (128, "mve")];
1111
1112const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1113 &[(1024, "")];
1114const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1115 &[(128, "altivec")];
1116const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1117 &[(128, "simd128")];
1118const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1119 &[(128, "vector")];
1120const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1121 (32, "zvl32b"),
1122 (64, "zvl64b"),
1123 (128, "zvl128b"),
1124 (256, "zvl256b"),
1125 (512, "zvl512b"),
1126 (1024, "zvl1024b"),
1127 (2048, "zvl2048b"),
1128 (4096, "zvl4096b"),
1129 (8192, "zvl8192b"),
1130 (16384, "zvl16384b"),
1131 (32768, "zvl32768b"),
1132 (65536, "zvl65536b"),
1133];
1134const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1136 &[];
1137
1138const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1139 (512, "hvx-length64b"), (1024, "hvx-length128b"), (2048, "hvx-length128b"), ];
1143const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1144 &[(128, "msa")];
1145const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1146 &[(128, "vdspv1")];
1147const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1148 &[(128, "lsx"), (256, "lasx")];
1149
1150#[derive(#[automatically_derived]
impl ::core::marker::Copy for FeatureConstraints { }Copy, #[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)]
1151pub struct FeatureConstraints {
1152 pub required: &'static [&'static str],
1154 pub incompatible: &'static [&'static str],
1156}
1157
1158impl Target {
1159 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
1160 match &self.arch {
1161 Arch::Arm => ARM_FEATURES,
1162 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
1163 Arch::X86 | Arch::X86_64 => X86_FEATURES,
1164 Arch::Hexagon => HEXAGON_FEATURES,
1165 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
1166 Arch::Nvptx64 => NVPTX_FEATURES,
1167 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
1168 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
1169 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
1170 Arch::Bpf => BPF_FEATURES,
1171 Arch::CSky => CSKY_FEATURES,
1172 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
1173 Arch::S390x => IBMZ_FEATURES,
1174 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
1175 Arch::M68k => M68K_FEATURES,
1176 Arch::Avr => AVR_FEATURES,
1177 Arch::Xtensa => XTENSA_FEATURES,
1178 Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Other(_) => &[],
1179 }
1180 }
1181
1182 pub fn rust_target_features_map(
1184 &self,
1185 ) -> FxHashMap<&'static str, (Stability, ImpliedFeatures)> {
1186 self.rust_target_features()
1187 .iter()
1188 .map(|&(f, s, i)| (f, (s, i)))
1189 .collect::<FxHashMap<_, _>>()
1190 }
1191
1192 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1193 match &self.arch {
1194 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1195 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1196 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1197 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1198 Arch::LoongArch32 | Arch::LoongArch64 => {
1199 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1200 }
1201 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1202 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1203 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1204 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1205 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1206 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1207 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1208 }
1209 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1210 Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1212 Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1215 }
1216 }
1217
1218 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1219 match &self.arch {
1220 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1221 _ => None,
1223 }
1224 }
1225
1226 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1227 match &self.arch {
1228 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1229 _ => &[],
1230 }
1231 }
1232
1233 #[track_caller]
1235 pub fn implied_target_features<'a>(
1236 &self,
1237 base_feature: &'a str,
1238 target_features_map: &FxHashMap<&'static str, (Stability, ImpliedFeatures)>,
1239 ) -> FxHashSet<&'a str> {
1240 let mut features = FxHashSet::default();
1243 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];
1244 while let Some(new_feature) = new_features.pop() {
1245 if features.insert(new_feature) {
1246 let (_, implied_features) = target_features_map
1247 .get(&new_feature)
1248 .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}"));
1249 new_features.extend(implied_features.iter().copied());
1250 }
1251 }
1252 features
1253 }
1254
1255 pub fn abi_required_features(&self) -> FeatureConstraints {
1266 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1267 match &self.arch {
1272 Arch::X86 => {
1273 match self.rustc_abi {
1276 None => {
1277 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1280 }
1281 Some(RustcAbi::X86Sse2) => {
1282 FeatureConstraints {
1284 required: &["x87", "sse2"],
1285 incompatible: &["soft-float"],
1286 }
1287 }
1288 Some(RustcAbi::Softfloat) => {
1289 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1294 }
1295 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1296 }
1297 }
1298 Arch::X86_64 => {
1299 match self.rustc_abi {
1302 None => {
1303 FeatureConstraints {
1305 required: &["x87", "sse2"],
1306 incompatible: &["soft-float"],
1307 }
1308 }
1309 Some(RustcAbi::Softfloat) => {
1310 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1315 }
1316 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1317 }
1318 }
1319 Arch::Arm => {
1320 match self.llvm_floatabi.unwrap() {
1323 FloatAbi::Soft => {
1324 NOTHING
1329 }
1330 FloatAbi::Hard => {
1331 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1333 }
1334 }
1335 }
1336 Arch::AArch64 | Arch::Arm64EC => {
1337 match self.rustc_abi {
1340 Some(RustcAbi::Softfloat) => {
1341 FeatureConstraints { required: &[], incompatible: &["neon", "fp-armv8"] }
1347 }
1348 None => {
1349 FeatureConstraints { required: &["neon"], incompatible: &[] }
1352 }
1353 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1354 }
1355 }
1356 Arch::RiscV32 | Arch::RiscV64 => {
1357 match &self.llvm_abiname {
1360 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1361 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1363 }
1364 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1365 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1367 }
1368 LlvmAbi::Ilp32 | LlvmAbi::Lp64 => {
1369 FeatureConstraints { required: &[], incompatible: &["e"] }
1371 }
1372 LlvmAbi::Ilp32e => {
1373 FeatureConstraints { required: &[], incompatible: &["d"] }
1382 }
1383 LlvmAbi::Lp64e => {
1384 NOTHING
1386 }
1387 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1388 }
1389 }
1390 Arch::LoongArch32 | Arch::LoongArch64 => {
1391 match &self.llvm_abiname {
1394 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1395 FeatureConstraints { required: &["d"], incompatible: &[] }
1397 }
1398 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1399 FeatureConstraints { required: &["f"], incompatible: &[] }
1401 }
1402 LlvmAbi::Ilp32s | LlvmAbi::Lp64s => {
1403 NOTHING
1408 }
1409 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1410 }
1411 }
1412 Arch::S390x => {
1413 match self.rustc_abi {
1421 None => {
1422 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1424 }
1425 Some(RustcAbi::Softfloat) => {
1426 FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] }
1429 }
1430 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1431 }
1432 }
1433 Arch::PowerPC => {
1434 match self.rustc_abi {
1437 None => {
1438 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1440 }
1441 Some(RustcAbi::PowerPcSpe) => {
1442 FeatureConstraints { required: &["hard-float", "spe"], incompatible: &[] }
1447 }
1448 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1449 }
1450 }
1451 Arch::PowerPC64 => {
1452 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1456 }
1457 Arch::Avr => {
1458 FeatureConstraints { required: &["sram"], incompatible: &[] }
1463 }
1464 Arch::Wasm32 | Arch::Wasm64 => {
1465 NOTHING
1468 }
1469 _ => NOTHING,
1470 }
1471 }
1472}