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"];
51
52#[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::Forbidden { reason: __self_0, hard_error: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Forbidden", "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::Forbidden {
reason: ref __binding_0, hard_error: ref __binding_1 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
54pub enum Stability {
55 Stable,
58 CfgStableToggleUnstable(
61 Symbol,
64 ),
65 Unstable(
68 Symbol,
71 ),
72 Forbidden {
80 reason: &'static str,
81 hard_error: bool,
84 },
85}
86use Stability::*;
87
88impl Stability {
89 pub fn in_cfg(&self) -> bool {
93 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::Stable | Stability::CfgStableToggleUnstable { .. } |
Stability::Unstable { .. } => true,
_ => false,
}matches!(
94 self,
95 Stability::Stable
96 | Stability::CfgStableToggleUnstable { .. }
97 | Stability::Unstable { .. }
98 )
99 }
100
101 pub fn requires_nightly(&self, in_cfg: bool) -> Option<Symbol> {
113 match *self {
114 Stability::Unstable(nightly_feature) => Some(nightly_feature),
115 Stability::CfgStableToggleUnstable(nightly_feature) => {
116 if in_cfg {
117 None
118 } else {
119 Some(nightly_feature)
120 }
121 }
122 Stability::Stable { .. } => None,
123 Stability::Forbidden { .. } => {
::core::panicking::panic_fmt(format_args!("forbidden features should not reach this far"));
}panic!("forbidden features should not reach this far"),
124 }
125 }
126
127 pub fn is_cfg_stable_toggle_unstable(&self) -> bool {
130 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::CfgStableToggleUnstable { .. } => true,
_ => false,
}matches!(self, Stability::CfgStableToggleUnstable { .. })
131 }
132
133 pub fn toggle_allowed(&self) -> Result<(), &'static str> {
137 match self {
138 Stability::Unstable(_)
139 | Stability::CfgStableToggleUnstable(_)
140 | Stability::Stable { .. } => Ok(()),
141 Stability::Forbidden { reason, hard_error: _ } => Err(reason),
142 }
143 }
144}
145
146type ImpliedFeatures = &'static [&'static str];
152
153static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
154 ("aclass", Unstable(sym::arm_target_feature), &[]),
156 ("acquire-release", Unstable(sym::arm_target_feature), &[]),
157 ("aes", Unstable(sym::arm_target_feature), &["neon"]),
158 (
159 "atomics-32",
160 Stability::Forbidden {
161 reason: "unsound because it changes the ABI of atomic operations",
162 hard_error: false,
163 },
164 &[],
165 ),
166 ("crc", Unstable(sym::arm_target_feature), &[]),
167 ("d32", Unstable(sym::arm_target_feature), &[]),
168 ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
169 ("dsp", Unstable(sym::arm_target_feature), &[]),
170 ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
171 ("fp16", Unstable(sym::arm_target_feature), &["neon"]),
172 ("fpregs", Unstable(sym::arm_target_feature), &[]),
173 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
174 ("mclass", Unstable(sym::arm_target_feature), &[]),
175 ("mve", Unstable(sym::arm_target_feature), &["v8.1m.main", "dsp", "fpregs"]),
176 ("mve.fp", Unstable(sym::arm_target_feature), &["mve"]),
177 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
178 ("rclass", Unstable(sym::arm_target_feature), &[]),
179 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
180 ("soft-float", Unstable(sym::arm_target_feature), &[]),
185 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
189 ("thumb2", Unstable(sym::arm_target_feature), &[]),
190 ("trustzone", Unstable(sym::arm_target_feature), &[]),
191 ("v5te", Unstable(sym::arm_target_feature), &[]),
192 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
193 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
194 ("v6m", Unstable(sym::arm_target_feature), &["v6"]),
195 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "v8m", "thumb2"]),
196 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
197 ("v8", Unstable(sym::arm_target_feature), &["v7", "acquire-release"]),
198 ("v8.1m.main", Unstable(sym::arm_target_feature), &["v8m.main"]),
199 ("v8m", Unstable(sym::arm_target_feature), &["v6m"]),
200 ("v8m.main", Unstable(sym::arm_target_feature), &["v7"]),
201 ("vfp2", Unstable(sym::arm_target_feature), &[]),
202 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
203 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
204 ("virtualization", Unstable(sym::arm_target_feature), &[]),
205 ];
207
208static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
209 ("aes", Stable, &["neon"]),
212 ("bf16", Stable, &[]),
214 ("bti", Stable, &[]),
216 ("crc", Stable, &[]),
218 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
220 ("dit", Stable, &[]),
222 ("dotprod", Stable, &["neon"]),
224 ("dpb", Stable, &[]),
226 ("dpb2", Stable, &["dpb"]),
228 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
230 ("f32mm", Stable, &["sve"]),
232 ("f64mm", Stable, &["sve"]),
234 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
236 ("fcma", Stable, &["neon"]),
238 ("fhm", Stable, &["fp16"]),
240 ("flagm", Stable, &[]),
242 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
244 (
246 "fp-armv8",
247 Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
248 &[],
249 ),
250 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
252 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
254 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
256 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
258 ("fp16", Stable, &["neon"]),
261 ("frintts", Stable, &[]),
263 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
265 ("i8mm", Stable, &[]),
267 ("jsconv", Stable, &["neon"]),
270 ("lor", Stable, &[]),
272 ("lse", Stable, &[]),
274 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
276 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
278 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
280 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
282 ("mte", Stable, &[]),
284 ("neon", Stable, &[]),
286 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
290 ("paca", Stable, &[]),
292 ("pacg", Stable, &[]),
294 ("pan", Stable, &[]),
296 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
298 ("pmuv3", Stable, &[]),
300 ("rand", Stable, &[]),
302 ("ras", Stable, &[]),
304 ("rcpc", Stable, &[]),
306 ("rcpc2", Stable, &["rcpc"]),
308 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
310 ("rdm", Stable, &["neon"]),
312 (
313 "reserve-x18",
314 Forbidden { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
315 &[],
316 ),
317 ("sb", Stable, &[]),
319 ("sha2", Stable, &["neon"]),
321 ("sha3", Stable, &["sha2"]),
323 ("sm4", Stable, &["neon"]),
325 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
327 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
329 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
331 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
333 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
335 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
337 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
339 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
341 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
343 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
345 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
347 ("spe", Stable, &[]),
349 ("ssbs", Stable, &[]),
351 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
353 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
355 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
357 ("sve", Stable, &["neon", "fp16"]),
365 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
367 ("sve2", Stable, &["sve"]),
369 ("sve2-aes", Stable, &["sve2", "aes"]),
371 ("sve2-bitperm", Stable, &["sve2"]),
373 ("sve2-sha3", Stable, &["sve2", "sha3"]),
375 ("sve2-sm4", Stable, &["sve2", "sm4"]),
377 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
379 ("tme", Stable, &[]),
381 (
382 "v8.1a",
383 Unstable(sym::aarch64_ver_target_feature),
384 &["crc", "lse", "rdm", "pan", "lor", "vh"],
385 ),
386 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
387 (
388 "v8.3a",
389 Unstable(sym::aarch64_ver_target_feature),
390 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
391 ),
392 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
393 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
394 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
395 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
396 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
397 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
398 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
399 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
400 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
401 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
402 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
403 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a"]),
404 ("vh", Stable, &[]),
406 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
408 ];
410
411const AARCH64_TIED_FEATURES: &[&[&str]] = &[
412 &["paca", "pacg"], ];
414
415static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
416 ("adx", Stable, &[]),
418 ("aes", Stable, &["sse2"]),
419 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
420 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
421 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
422 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
423 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
424 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
425 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
426 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
427 ("apxf", Unstable(sym::apx_target_feature), &[]),
428 ("avx", Stable, &["sse4.2"]),
429 ("avx2", Stable, &["avx"]),
430 (
431 "avx10.1",
432 Unstable(sym::avx10_target_feature),
433 &[
434 "avx512bf16",
435 "avx512bitalg",
436 "avx512bw",
437 "avx512cd",
438 "avx512dq",
439 "avx512f",
440 "avx512fp16",
441 "avx512ifma",
442 "avx512vbmi",
443 "avx512vbmi2",
444 "avx512vl",
445 "avx512vnni",
446 "avx512vpopcntdq",
447 ],
448 ),
449 (
450 "avx10.2",
451 Unstable(sym::avx10_target_feature),
452 &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
453 ),
454 ("avx512bf16", Stable, &["avx512bw"]),
455 ("avx512bitalg", Stable, &["avx512bw"]),
456 ("avx512bw", Stable, &["avx512f"]),
457 ("avx512cd", Stable, &["avx512f"]),
458 ("avx512dq", Stable, &["avx512f"]),
459 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
460 ("avx512fp16", Stable, &["avx512bw"]),
461 ("avx512ifma", Stable, &["avx512f"]),
462 ("avx512vbmi", Stable, &["avx512bw"]),
463 ("avx512vbmi2", Stable, &["avx512bw"]),
464 ("avx512vl", Stable, &["avx512f"]),
465 ("avx512vnni", Stable, &["avx512f"]),
466 ("avx512vp2intersect", Stable, &["avx512f"]),
467 ("avx512vpopcntdq", Stable, &["avx512f"]),
468 ("avxifma", Stable, &["avx2"]),
469 ("avxneconvert", Stable, &["avx2"]),
470 ("avxvnni", Stable, &["avx2"]),
471 ("avxvnniint8", Stable, &["avx2"]),
472 ("avxvnniint16", Stable, &["avx2"]),
473 ("bmi1", Stable, &[]),
474 ("bmi2", Stable, &[]),
475 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
476 ("cmpxchg16b", Stable, &[]),
477 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
478 ("f16c", Stable, &["avx"]),
479 ("fma", Stable, &["avx"]),
480 ("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
481 ("fxsr", Stable, &[]),
482 ("gfni", Stable, &["sse2"]),
483 ("kl", Stable, &["sse2"]),
484 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
485 ("lzcnt", Stable, &[]),
486 ("movbe", Stable, &[]),
487 ("movrs", Unstable(sym::movrs_target_feature), &[]),
488 ("pclmulqdq", Stable, &["sse2"]),
489 ("popcnt", Stable, &[]),
490 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
491 ("rdrand", Stable, &[]),
492 ("rdseed", Stable, &[]),
493 (
494 "retpoline-external-thunk",
495 Stability::Forbidden {
496 reason: "use `-Zretpoline-external-thunk` compiler flag instead",
497 hard_error: false,
498 },
499 &[],
500 ),
501 (
502 "retpoline-indirect-branches",
503 Stability::Forbidden {
504 reason: "use `-Zretpoline` compiler flag instead",
505 hard_error: false,
506 },
507 &[],
508 ),
509 (
510 "retpoline-indirect-calls",
511 Stability::Forbidden {
512 reason: "use `-Zretpoline` compiler flag instead",
513 hard_error: false,
514 },
515 &[],
516 ),
517 ("rtm", Unstable(sym::rtm_target_feature), &[]),
518 ("sha", Stable, &["sse2"]),
519 ("sha512", Stable, &["avx2"]),
520 ("sm3", Stable, &["avx"]),
521 ("sm4", Stable, &["avx2"]),
522 (
523 "soft-float",
524 Stability::Forbidden { reason: "use a soft-float target instead", hard_error: false },
525 &[],
526 ),
527 ("sse", Stable, &[]),
528 ("sse2", Stable, &["sse"]),
529 ("sse3", Stable, &["sse2"]),
530 ("sse4.1", Stable, &["ssse3"]),
531 ("sse4.2", Stable, &["sse4.1"]),
532 ("sse4a", Stable, &["sse3"]),
533 ("ssse3", Stable, &["sse3"]),
534 ("tbm", Stable, &[]),
535 ("vaes", Stable, &["avx2", "aes"]),
536 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
537 ("widekl", Stable, &["kl"]),
538 ("x87", Unstable(sym::x87_target_feature), &[]),
539 ("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
540 ("xsave", Stable, &[]),
541 ("xsavec", Stable, &["xsave"]),
542 ("xsaveopt", Stable, &["xsave"]),
543 ("xsaves", Stable, &["xsave"]),
544 ];
546
547const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
548 ("audio", Unstable(sym::hexagon_target_feature), &[]),
550 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
551 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
552 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
553 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
554 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
555 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
556 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
557 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
558 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
559 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
560 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
561 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
562 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
563 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
564 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
565 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
566 ("v60", Unstable(sym::hexagon_target_feature), &[]),
567 ("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
568 ("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
569 ("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
570 ("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
571 ("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
572 ("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
573 ("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
574 ("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
575 ("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
576 ("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
577 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
578 ];
580
581static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
582 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
586 (
587 "hard-float",
588 Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false },
589 &[],
590 ),
591 ("msync", Unstable(sym::powerpc_target_feature), &[]),
592 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
593 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
594 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
595 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
596 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
597 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
598 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
599 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
600 ("spe", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
601 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
602 ];
604
605const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
606 ("fp64", Unstable(sym::mips_target_feature), &[]),
608 ("msa", Unstable(sym::mips_target_feature), &[]),
609 ("virt", Unstable(sym::mips_target_feature), &[]),
610 ];
612
613const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
614 ("sm_70", Unstable(sym::nvptx_target_feature), &[]),
616 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
617 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
618 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
619 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
620 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
621 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
622 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
623 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
624 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
627 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
628 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
629 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
630 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
631 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
632 ("ptx70", Unstable(sym::nvptx_target_feature), &[]),
635 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
636 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
637 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
638 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
639 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
640 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
641 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
642 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
643 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
644 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
645 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
646 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
647 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
648 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
649 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
650 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
651 ];
653
654static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
655 ("a", Stable, &["zaamo", "zalrsc"]),
657 ("b", Stable, &["zba", "zbb", "zbs"]),
658 ("c", Stable, &["zca"]),
659 ("d", CfgStableToggleUnstable(sym::riscv_target_feature), &["f"]),
660 ("e", CfgStableToggleUnstable(sym::riscv_target_feature), &[]),
661 ("f", CfgStableToggleUnstable(sym::riscv_target_feature), &["zicsr"]),
662 (
663 "forced-atomics",
664 Stability::Forbidden {
665 reason: "unsound because it changes the ABI of atomic operations",
666 hard_error: false,
667 },
668 &[],
669 ),
670 ("m", Stable, &[]),
671 ("relax", Unstable(sym::riscv_target_feature), &[]),
672 (
673 "rva23u64",
674 Unstable(sym::riscv_target_feature),
675 &[
676 "m",
677 "a",
678 "f",
679 "d",
680 "c",
681 "b",
682 "v",
683 "zicsr",
684 "zicntr",
685 "zihpm",
686 "ziccif",
687 "ziccrse",
688 "ziccamoa",
689 "zicclsm",
690 "zic64b",
691 "za64rs",
692 "zihintpause",
693 "zba",
694 "zbb",
695 "zbs",
696 "zicbom",
697 "zicbop",
698 "zicboz",
699 "zfhmin",
700 "zkt",
701 "zvfhmin",
702 "zvbb",
703 "zvkt",
704 "zihintntl",
705 "zicond",
706 "zimop",
707 "zcmop",
708 "zcb",
709 "zfa",
710 "zawrs",
711 "supm",
712 ],
713 ),
714 ("supm", Unstable(sym::riscv_target_feature), &[]),
715 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
716 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
717 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
718 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
720 ("zaamo", Stable, &[]),
721 ("zabha", Stable, &["zaamo"]),
722 ("zacas", Stable, &["zaamo"]),
723 ("zalrsc", Stable, &[]),
724 ("zama16b", Stable, &[]),
725 ("zawrs", Stable, &[]),
726 ("zba", Stable, &[]),
727 ("zbb", Stable, &[]),
728 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
730 ("zbkc", Stable, &[]),
731 ("zbkx", Stable, &[]),
732 ("zbs", Stable, &[]),
733 ("zca", Stable, &[]),
734 ("zcb", Stable, &["zca"]),
735 ("zcmop", Stable, &["zca"]),
736 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
737 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
738 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
740 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
741 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
742 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
743 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
744 ("zic64b", Stable, &[]),
745 ("zicbom", Stable, &[]),
746 ("zicbop", Stable, &[]),
747 ("zicboz", Stable, &[]),
748 ("ziccamoa", Stable, &[]),
749 ("ziccif", Stable, &[]),
750 ("zicclsm", Stable, &[]),
751 ("ziccrse", Stable, &[]),
752 ("zicntr", Stable, &["zicsr"]),
753 ("zicond", Stable, &[]),
754 ("zicsr", Stable, &[]),
755 ("zifencei", Stable, &[]),
756 ("zihintntl", Stable, &[]),
757 ("zihintpause", Stable, &[]),
758 ("zihpm", Stable, &["zicsr"]),
759 ("zimop", Stable, &[]),
760 ("zk", Stable, &["zkn", "zkr", "zkt"]),
761 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
762 ("zknd", Stable, &["zkne_or_zknd"]),
763 ("zkne", Stable, &["zkne_or_zknd"]),
764 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
766 ("zkr", Stable, &[]),
767 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
768 ("zksed", Stable, &[]),
769 ("zksh", Stable, &[]),
770 ("zkt", Stable, &[]),
771 ("ztso", Stable, &[]),
772 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
774 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
775 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
776 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
777 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
778 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
779 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
780 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
781 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
783 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
784 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
785 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
786 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
787 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
788 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
789 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
790 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
792 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
793 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
794 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
795 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
796 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
797 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
798 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
799 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
800 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
801 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
802 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
803 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
804 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
805 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
806 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
807 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
808 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
809 ];
811
812static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
813 ("atomics", Unstable(sym::wasm_target_feature), &[]),
815 ("bulk-memory", Stable, &[]),
816 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
817 ("extended-const", Stable, &[]),
818 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
819 ("multivalue", Stable, &[]),
820 ("mutable-globals", Stable, &[]),
821 ("nontrapping-fptoint", Stable, &[]),
822 ("reference-types", Stable, &[]),
823 ("relaxed-simd", Stable, &["simd128"]),
824 ("sign-ext", Stable, &[]),
825 ("simd128", Stable, &[]),
826 ("tail-call", Stable, &[]),
827 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
828 ];
830
831const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
832 ("alu32", Unstable(sym::bpf_target_feature), &[]),
833 ("allows-misaligned-mem-access", Unstable(sym::bpf_target_feature), &[]),
834];
835
836static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
837 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
839 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
840 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
841 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
842 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
843 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
844 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
845 ("cache", Unstable(sym::csky_target_feature), &[]),
846 ("doloop", Unstable(sym::csky_target_feature), &[]),
847 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
848 ("dspe60", Unstable(sym::csky_target_feature), &[]),
849 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
850 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
851 ("edsp", Unstable(sym::csky_target_feature), &[]),
852 ("elrw", Unstable(sym::csky_target_feature), &[]),
853 ("float1e2", Unstable(sym::csky_target_feature), &[]),
854 ("float1e3", Unstable(sym::csky_target_feature), &[]),
855 ("float3e4", Unstable(sym::csky_target_feature), &[]),
856 ("float7e60", Unstable(sym::csky_target_feature), &[]),
857 ("floate1", Unstable(sym::csky_target_feature), &[]),
858 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
859 ("high-registers", Unstable(sym::csky_target_feature), &[]),
860 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
861 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
862 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
863 ("nvic", Unstable(sym::csky_target_feature), &[]),
864 ("trust", Unstable(sym::csky_target_feature), &[]),
865 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
866 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
867 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
868 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
872 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
873 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
874 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
875 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
876 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
877 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
878 ("hard-float", Unstable(sym::csky_target_feature), &[]),
879 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
880 ];
882
883static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
884 ("32s", Unstable(sym::loongarch_target_feature), &[]),
886 ("d", Stable, &["f"]),
887 ("div32", Stable, &[]),
888 ("f", Stable, &[]),
889 ("frecipe", Stable, &[]),
890 ("lam-bh", Stable, &[]),
891 ("lamcas", Stable, &[]),
892 ("lasx", Stable, &["lsx"]),
893 ("lbt", Stable, &[]),
894 ("ld-seq-sa", Stable, &[]),
895 ("lsx", Stable, &["d"]),
896 ("lvz", Stable, &[]),
897 ("relax", Unstable(sym::loongarch_target_feature), &[]),
898 ("scq", Stable, &[]),
899 ("ual", Unstable(sym::loongarch_target_feature), &[]),
900 ];
902
903#[rustfmt::skip]
904const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
905 ("backchain", Unstable(sym::s390x_target_feature), &[]),
908 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
909 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
910 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
911 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
912 ("high-word", Unstable(sym::s390x_target_feature), &[]),
913 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
915 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
916 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
917 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
918 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
919 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
920 ("miscellaneous-extensions-2", Stable, &[]),
921 ("miscellaneous-extensions-3", Stable, &[]),
922 ("miscellaneous-extensions-4", Stable, &[]),
923 ("nnp-assist", Stable, &["vector"]),
924 ("soft-float", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
925 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
926 ("vector", Stable, &[]),
927 ("vector-enhancements-1", Stable, &["vector"]),
928 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
929 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
930 ("vector-packed-decimal", Stable, &["vector"]),
931 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
932 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
933 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
934 ];
936
937const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
938 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
940 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
941 ("v9", Unstable(sym::sparc_target_feature), &[]),
942 ];
944
945static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
946 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
948 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
949 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
950 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
951 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
952 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
953 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
955 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
956 ];
958
959static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
960 ("addsubiw", Unstable(sym::avr_target_feature), &[]),
962 ("break", Unstable(sym::avr_target_feature), &[]),
963 ("eijmpcall", Unstable(sym::avr_target_feature), &[]),
964 ("elpm", Unstable(sym::avr_target_feature), &[]),
965 ("elpmx", Unstable(sym::avr_target_feature), &[]),
966 ("ijmpcall", Unstable(sym::avr_target_feature), &[]),
967 ("jmpcall", Unstable(sym::avr_target_feature), &[]),
968 ("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
969 ("lpm", Unstable(sym::avr_target_feature), &[]),
970 ("lpmx", Unstable(sym::avr_target_feature), &[]),
971 ("movw", Unstable(sym::avr_target_feature), &[]),
972 ("mul", Unstable(sym::avr_target_feature), &[]),
973 ("rmw", Unstable(sym::avr_target_feature), &[]),
974 ("spm", Unstable(sym::avr_target_feature), &[]),
975 ("spmx", Unstable(sym::avr_target_feature), &[]),
976 (
977 "sram",
978 Forbidden { reason: "devices that have no SRAM are unsupported", hard_error: false },
979 &[],
980 ),
981 ("tinyencoding", Unstable(sym::avr_target_feature), &[]),
982 ];
984
985const XTENSA_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
986 ("bool", Unstable(sym::xtensa_target_feature), &[]),
987 ("fp", Unstable(sym::xtensa_target_feature), &["bool", "coprocessor"]),
988 ("coprocessor", Unstable(sym::xtensa_target_feature), &[]),
989 ("highpriinterrupts", Unstable(sym::xtensa_target_feature), &["interrupt"]),
990 ("interrupt", Unstable(sym::xtensa_target_feature), &["exception"]),
991 (
992 "windowed",
993 Forbidden { reason: "windowed changes the Xtensa calling convention", hard_error: false },
994 &["exception"],
995 ),
996 ("loop", Unstable(sym::xtensa_target_feature), &[]),
997 ("sext", Unstable(sym::xtensa_target_feature), &[]),
998 ("nsa", Unstable(sym::xtensa_target_feature), &[]),
999 ("mul32", Unstable(sym::xtensa_target_feature), &[]),
1000 ("mul32high", Unstable(sym::xtensa_target_feature), &["mul32"]),
1001 ("div32", Unstable(sym::xtensa_target_feature), &[]),
1002 ("mac16", Unstable(sym::xtensa_target_feature), &[]),
1003 ("s32c1i", Unstable(sym::xtensa_target_feature), &[]),
1004 ("threadptr", Unstable(sym::xtensa_target_feature), &[]),
1005 ("extendedl32r", Unstable(sym::xtensa_target_feature), &[]),
1006 ("debug", Unstable(sym::xtensa_target_feature), &["exception"]),
1007 ("exception", Unstable(sym::xtensa_target_feature), &[]),
1008 ("rvector", Unstable(sym::xtensa_target_feature), &["exception"]),
1009 ("prid", Unstable(sym::xtensa_target_feature), &[]),
1010 ("regprotect", Unstable(sym::xtensa_target_feature), &[]),
1011 ("miscsr", Unstable(sym::xtensa_target_feature), &[]),
1012];
1013
1014pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
1019 std::iter::empty()
1020 .chain(ARM_FEATURES.iter())
1021 .chain(AARCH64_FEATURES.iter())
1022 .chain(X86_FEATURES.iter())
1023 .chain(HEXAGON_FEATURES.iter())
1024 .chain(POWERPC_FEATURES.iter())
1025 .chain(MIPS_FEATURES.iter())
1026 .chain(NVPTX_FEATURES.iter())
1027 .chain(RISCV_FEATURES.iter())
1028 .chain(WASM_FEATURES.iter())
1029 .chain(BPF_FEATURES.iter())
1030 .chain(XTENSA_FEATURES.iter())
1031 .chain(CSKY_FEATURES)
1032 .chain(LOONGARCH_FEATURES)
1033 .chain(IBMZ_FEATURES)
1034 .chain(SPARC_FEATURES)
1035 .chain(M68K_FEATURES)
1036 .chain(AVR_FEATURES)
1037 .cloned()
1038 .map(|(f, s, _)| (f, s))
1039}
1040
1041pub fn feature_to_arch_names(feature: &str) -> Vec<&'static str> {
1045 let mut arches = Vec::new();
1046 macro_rules! check_arch_feats {
1047 ($arch_name:expr, $feats:expr) => {
1048 if $feats.iter().any(|(f, _, _)| *f == feature) {
1049 arches.push($arch_name);
1050 }
1051 };
1052 }
1053 if ARM_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("arm"); };check_arch_feats!("arm", ARM_FEATURES);
1054 if AARCH64_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("aarch64");
};check_arch_feats!("aarch64", AARCH64_FEATURES);
1055 if X86_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("x86"); };check_arch_feats!("x86", X86_FEATURES);
1056 if HEXAGON_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("hexagon");
};check_arch_feats!("hexagon", HEXAGON_FEATURES);
1057 if MIPS_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("mips");
};check_arch_feats!("mips", MIPS_FEATURES);
1058 if NVPTX_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("nvptx64");
};check_arch_feats!("nvptx64", NVPTX_FEATURES);
1059 if POWERPC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("powerpc");
};check_arch_feats!("powerpc", POWERPC_FEATURES);
1060 if RISCV_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("riscv");
};check_arch_feats!("riscv", RISCV_FEATURES);
1061 if WASM_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("wasm");
};check_arch_feats!("wasm", WASM_FEATURES);
1062 if BPF_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("bpf"); };check_arch_feats!("bpf", BPF_FEATURES);
1063 if CSKY_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("csky");
};check_arch_feats!("csky", CSKY_FEATURES);
1064 if LOONGARCH_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("loongarch");
};check_arch_feats!("loongarch", LOONGARCH_FEATURES);
1065 if IBMZ_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("s390x");
};check_arch_feats!("s390x", IBMZ_FEATURES);
1066 if SPARC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("sparc");
};check_arch_feats!("sparc", SPARC_FEATURES);
1067 if M68K_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("m68k");
};check_arch_feats!("m68k", M68K_FEATURES);
1068 if AVR_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("avr"); };check_arch_feats!("avr", AVR_FEATURES);
1069 arches.sort();
1070 arches.dedup();
1071 arches
1072}
1073
1074const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1078 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1080 &[(128, "neon")];
1081
1082const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1083 &[(128, "neon"), (128, "mve")];
1084
1085const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1086 &[(1024, "")];
1087const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1088 &[(128, "altivec")];
1089const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1090 &[(128, "simd128")];
1091const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1092 &[(128, "vector")];
1093const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1094 (32, "zvl32b"),
1095 (64, "zvl64b"),
1096 (128, "zvl128b"),
1097 (256, "zvl256b"),
1098 (512, "zvl512b"),
1099 (1024, "zvl1024b"),
1100 (2048, "zvl2048b"),
1101 (4096, "zvl4096b"),
1102 (8192, "zvl8192b"),
1103 (16384, "zvl16384b"),
1104 (32768, "zvl32768b"),
1105 (65536, "zvl65536b"),
1106];
1107const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1109 &[];
1110
1111const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1112 (512, "hvx-length64b"), (1024, "hvx-length128b"), (2048, "hvx-length128b"), ];
1116const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1117 &[(128, "msa")];
1118const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1119 &[(128, "vdspv1")];
1120const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1121 &[(128, "lsx"), (256, "lasx")];
1122
1123#[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)]
1124pub struct FeatureConstraints {
1125 pub required: &'static [&'static str],
1127 pub incompatible: &'static [&'static str],
1129}
1130
1131impl Target {
1132 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
1133 match &self.arch {
1134 Arch::Arm => ARM_FEATURES,
1135 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
1136 Arch::X86 | Arch::X86_64 => X86_FEATURES,
1137 Arch::Hexagon => HEXAGON_FEATURES,
1138 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
1139 Arch::Nvptx64 => NVPTX_FEATURES,
1140 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
1141 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
1142 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
1143 Arch::Bpf => BPF_FEATURES,
1144 Arch::CSky => CSKY_FEATURES,
1145 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
1146 Arch::S390x => IBMZ_FEATURES,
1147 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
1148 Arch::M68k => M68K_FEATURES,
1149 Arch::Avr => AVR_FEATURES,
1150 Arch::Xtensa => XTENSA_FEATURES,
1151 Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Other(_) => &[],
1152 }
1153 }
1154
1155 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1156 match &self.arch {
1157 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1158 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1159 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1160 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1161 Arch::LoongArch32 | Arch::LoongArch64 => {
1162 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1163 }
1164 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1165 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1166 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1167 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1168 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1169 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1170 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1171 }
1172 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1173 Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1175 Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1178 }
1179 }
1180
1181 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1182 match &self.arch {
1183 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1184 _ => None,
1186 }
1187 }
1188
1189 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1190 match &self.arch {
1191 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1192 _ => &[],
1193 }
1194 }
1195
1196 pub fn implied_target_features<'a>(&self, base_feature: &'a str) -> FxHashSet<&'a str> {
1198 let implied_features =
1199 self.rust_target_features().iter().map(|(f, _, i)| (f, i)).collect::<FxHashMap<_, _>>();
1200
1201 let mut features = FxHashSet::default();
1204 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];
1205 while let Some(new_feature) = new_features.pop() {
1206 if features.insert(new_feature) {
1207 if let Some(implied_features) = implied_features.get(&new_feature) {
1208 new_features.extend(implied_features.iter().copied())
1209 }
1210 }
1211 }
1212 features
1213 }
1214
1215 pub fn abi_required_features(&self) -> FeatureConstraints {
1226 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1227 match &self.arch {
1232 Arch::X86 => {
1233 match self.rustc_abi {
1236 None => {
1237 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1240 }
1241 Some(RustcAbi::X86Sse2) => {
1242 FeatureConstraints {
1244 required: &["x87", "sse2"],
1245 incompatible: &["soft-float"],
1246 }
1247 }
1248 Some(RustcAbi::Softfloat) => {
1249 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1254 }
1255 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1256 }
1257 }
1258 Arch::X86_64 => {
1259 match self.rustc_abi {
1262 None => {
1263 FeatureConstraints {
1265 required: &["x87", "sse2"],
1266 incompatible: &["soft-float"],
1267 }
1268 }
1269 Some(RustcAbi::Softfloat) => {
1270 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1275 }
1276 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1277 }
1278 }
1279 Arch::Arm => {
1280 match self.llvm_floatabi.unwrap() {
1283 FloatAbi::Soft => {
1284 NOTHING
1289 }
1290 FloatAbi::Hard => {
1291 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1293 }
1294 }
1295 }
1296 Arch::AArch64 | Arch::Arm64EC => {
1297 match self.rustc_abi {
1300 Some(RustcAbi::Softfloat) => {
1301 FeatureConstraints { required: &[], incompatible: &["neon"] }
1307 }
1308 None => {
1309 FeatureConstraints { required: &["neon"], incompatible: &[] }
1312 }
1313 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1314 }
1315 }
1316 Arch::RiscV32 | Arch::RiscV64 => {
1317 match &self.llvm_abiname {
1320 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1321 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1323 }
1324 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1325 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1327 }
1328 LlvmAbi::Ilp32 | LlvmAbi::Lp64 => {
1329 FeatureConstraints { required: &[], incompatible: &["e"] }
1331 }
1332 LlvmAbi::Ilp32e => {
1333 FeatureConstraints { required: &[], incompatible: &["d"] }
1342 }
1343 LlvmAbi::Lp64e => {
1344 NOTHING
1346 }
1347 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1348 }
1349 }
1350 Arch::LoongArch32 | Arch::LoongArch64 => {
1351 match &self.llvm_abiname {
1354 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1355 FeatureConstraints { required: &["d"], incompatible: &[] }
1357 }
1358 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1359 FeatureConstraints { required: &["f"], incompatible: &[] }
1361 }
1362 LlvmAbi::Ilp32s | LlvmAbi::Lp64s => {
1363 NOTHING
1368 }
1369 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1370 }
1371 }
1372 Arch::S390x => {
1373 match self.rustc_abi {
1381 None => {
1382 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1384 }
1385 Some(RustcAbi::Softfloat) => {
1386 FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] }
1389 }
1390 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1391 }
1392 }
1393 Arch::PowerPC => {
1394 match self.rustc_abi {
1397 None => {
1398 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1400 }
1401 Some(RustcAbi::PowerPcSpe) => {
1402 FeatureConstraints { required: &["hard-float", "spe"], incompatible: &[] }
1407 }
1408 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1409 }
1410 }
1411 Arch::PowerPC64 => {
1412 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1416 }
1417 Arch::Avr => {
1418 FeatureConstraints { required: &["sram"], incompatible: &[] }
1423 }
1424 Arch::Wasm32 | Arch::Wasm64 => {
1425 NOTHING
1428 }
1429 _ => NOTHING,
1430 }
1431 }
1432}