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 ("aes", Unstable(sym::arm_target_feature), &["neon"]),
157 (
158 "atomics-32",
159 Stability::Forbidden {
160 reason: "unsound because it changes the ABI of atomic operations",
161 hard_error: false,
162 },
163 &[],
164 ),
165 ("crc", Unstable(sym::arm_target_feature), &[]),
166 ("d32", Unstable(sym::arm_target_feature), &[]),
167 ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
168 ("dsp", Unstable(sym::arm_target_feature), &[]),
169 ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
170 ("fp16", Unstable(sym::arm_target_feature), &["neon"]),
171 ("fpregs", Unstable(sym::arm_target_feature), &[]),
172 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
173 ("mclass", Unstable(sym::arm_target_feature), &[]),
174 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
175 ("rclass", Unstable(sym::arm_target_feature), &[]),
176 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
177 ("soft-float", Unstable(sym::arm_target_feature), &[]),
182 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
186 ("thumb2", Unstable(sym::arm_target_feature), &[]),
187 ("trustzone", Unstable(sym::arm_target_feature), &[]),
188 ("v5te", Unstable(sym::arm_target_feature), &[]),
189 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
190 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
191 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "thumb2"]),
192 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
193 ("v8", Unstable(sym::arm_target_feature), &["v7"]),
194 ("vfp2", Unstable(sym::arm_target_feature), &[]),
195 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
196 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
197 ("virtualization", Unstable(sym::arm_target_feature), &[]),
198 ];
200
201static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
202 ("aes", Stable, &["neon"]),
205 ("bf16", Stable, &[]),
207 ("bti", Stable, &[]),
209 ("crc", Stable, &[]),
211 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
213 ("dit", Stable, &[]),
215 ("dotprod", Stable, &["neon"]),
217 ("dpb", Stable, &[]),
219 ("dpb2", Stable, &["dpb"]),
221 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
223 ("f32mm", Stable, &["sve"]),
225 ("f64mm", Stable, &["sve"]),
227 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
229 ("fcma", Stable, &["neon"]),
231 ("fhm", Stable, &["fp16"]),
233 ("flagm", Stable, &[]),
235 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
237 (
239 "fp-armv8",
240 Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
241 &[],
242 ),
243 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
245 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
247 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
249 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
251 ("fp16", Stable, &["neon"]),
254 ("frintts", Stable, &[]),
256 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
258 ("i8mm", Stable, &[]),
260 ("jsconv", Stable, &["neon"]),
263 ("lor", Stable, &[]),
265 ("lse", Stable, &[]),
267 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
269 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
271 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
273 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
275 ("mte", Stable, &[]),
277 ("neon", Stable, &[]),
279 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
283 ("paca", Stable, &[]),
285 ("pacg", Stable, &[]),
287 ("pan", Stable, &[]),
289 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
291 ("pmuv3", Stable, &[]),
293 ("rand", Stable, &[]),
295 ("ras", Stable, &[]),
297 ("rcpc", Stable, &[]),
299 ("rcpc2", Stable, &["rcpc"]),
301 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
303 ("rdm", Stable, &["neon"]),
305 (
306 "reserve-x18",
307 Forbidden { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
308 &[],
309 ),
310 ("sb", Stable, &[]),
312 ("sha2", Stable, &["neon"]),
314 ("sha3", Stable, &["sha2"]),
316 ("sm4", Stable, &["neon"]),
318 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
320 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
322 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
324 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
326 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
328 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
330 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
332 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
334 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
336 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
338 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
340 ("spe", Stable, &[]),
342 ("ssbs", Stable, &[]),
344 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
346 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
348 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
350 ("sve", Stable, &["neon"]),
358 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
360 ("sve2", Stable, &["sve"]),
362 ("sve2-aes", Stable, &["sve2", "aes"]),
364 ("sve2-bitperm", Stable, &["sve2"]),
366 ("sve2-sha3", Stable, &["sve2", "sha3"]),
368 ("sve2-sm4", Stable, &["sve2", "sm4"]),
370 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
372 ("tme", Stable, &[]),
374 (
375 "v8.1a",
376 Unstable(sym::aarch64_ver_target_feature),
377 &["crc", "lse", "rdm", "pan", "lor", "vh"],
378 ),
379 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
380 (
381 "v8.3a",
382 Unstable(sym::aarch64_ver_target_feature),
383 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
384 ),
385 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
386 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
387 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
388 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
389 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
390 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
391 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
392 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
393 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
394 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
395 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
396 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
397 ("vh", Stable, &[]),
399 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
401 ];
403
404const AARCH64_TIED_FEATURES: &[&[&str]] = &[
405 &["paca", "pacg"], ];
407
408static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
409 ("adx", Stable, &[]),
411 ("aes", Stable, &["sse2"]),
412 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
413 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
414 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
415 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
416 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
417 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
418 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
419 ("amx-tf32", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
420 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
421 ("apxf", Unstable(sym::apx_target_feature), &[]),
422 ("avx", Stable, &["sse4.2"]),
423 ("avx2", Stable, &["avx"]),
424 (
425 "avx10.1",
426 Unstable(sym::avx10_target_feature),
427 &[
428 "avx512bf16",
429 "avx512bitalg",
430 "avx512bw",
431 "avx512cd",
432 "avx512dq",
433 "avx512f",
434 "avx512fp16",
435 "avx512ifma",
436 "avx512vbmi",
437 "avx512vbmi2",
438 "avx512vl",
439 "avx512vnni",
440 "avx512vpopcntdq",
441 ],
442 ),
443 (
444 "avx10.2",
445 Unstable(sym::avx10_target_feature),
446 &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
447 ),
448 ("avx512bf16", Stable, &["avx512bw"]),
449 ("avx512bitalg", Stable, &["avx512bw"]),
450 ("avx512bw", Stable, &["avx512f"]),
451 ("avx512cd", Stable, &["avx512f"]),
452 ("avx512dq", Stable, &["avx512f"]),
453 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
454 ("avx512fp16", Stable, &["avx512bw"]),
455 ("avx512ifma", Stable, &["avx512f"]),
456 ("avx512vbmi", Stable, &["avx512bw"]),
457 ("avx512vbmi2", Stable, &["avx512bw"]),
458 ("avx512vl", Stable, &["avx512f"]),
459 ("avx512vnni", Stable, &["avx512f"]),
460 ("avx512vp2intersect", Stable, &["avx512f"]),
461 ("avx512vpopcntdq", Stable, &["avx512f"]),
462 ("avxifma", Stable, &["avx2"]),
463 ("avxneconvert", Stable, &["avx2"]),
464 ("avxvnni", Stable, &["avx2"]),
465 ("avxvnniint8", Stable, &["avx2"]),
466 ("avxvnniint16", Stable, &["avx2"]),
467 ("bmi1", Stable, &[]),
468 ("bmi2", Stable, &[]),
469 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
470 ("cmpxchg16b", Stable, &[]),
471 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
472 ("f16c", Stable, &["avx"]),
473 ("fma", Stable, &["avx"]),
474 ("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
475 ("fxsr", Stable, &[]),
476 ("gfni", Stable, &["sse2"]),
477 ("kl", Stable, &["sse2"]),
478 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
479 ("lzcnt", Stable, &[]),
480 ("movbe", Stable, &[]),
481 ("movrs", Unstable(sym::movrs_target_feature), &[]),
482 ("pclmulqdq", Stable, &["sse2"]),
483 ("popcnt", Stable, &[]),
484 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
485 ("rdrand", Stable, &[]),
486 ("rdseed", Stable, &[]),
487 (
488 "retpoline-external-thunk",
489 Stability::Forbidden {
490 reason: "use `-Zretpoline-external-thunk` compiler flag instead",
491 hard_error: false,
492 },
493 &[],
494 ),
495 (
496 "retpoline-indirect-branches",
497 Stability::Forbidden {
498 reason: "use `-Zretpoline` compiler flag instead",
499 hard_error: false,
500 },
501 &[],
502 ),
503 (
504 "retpoline-indirect-calls",
505 Stability::Forbidden {
506 reason: "use `-Zretpoline` compiler flag instead",
507 hard_error: false,
508 },
509 &[],
510 ),
511 ("rtm", Unstable(sym::rtm_target_feature), &[]),
512 ("sha", Stable, &["sse2"]),
513 ("sha512", Stable, &["avx2"]),
514 ("sm3", Stable, &["avx"]),
515 ("sm4", Stable, &["avx2"]),
516 (
517 "soft-float",
518 Stability::Forbidden { reason: "use a soft-float target instead", hard_error: false },
519 &[],
520 ),
521 ("sse", Stable, &[]),
522 ("sse2", Stable, &["sse"]),
523 ("sse3", Stable, &["sse2"]),
524 ("sse4.1", Stable, &["ssse3"]),
525 ("sse4.2", Stable, &["sse4.1"]),
526 ("sse4a", Stable, &["sse3"]),
527 ("ssse3", Stable, &["sse3"]),
528 ("tbm", Stable, &[]),
529 ("vaes", Stable, &["avx2", "aes"]),
530 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
531 ("widekl", Stable, &["kl"]),
532 ("x87", Unstable(sym::x87_target_feature), &[]),
533 ("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
534 ("xsave", Stable, &[]),
535 ("xsavec", Stable, &["xsave"]),
536 ("xsaveopt", Stable, &["xsave"]),
537 ("xsaves", Stable, &["xsave"]),
538 ];
540
541const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
542 ("audio", Unstable(sym::hexagon_target_feature), &[]),
544 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
545 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
546 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
547 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
548 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
549 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
550 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
551 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
552 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
553 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
554 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
555 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
556 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
557 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
558 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
559 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
560 ("v60", Unstable(sym::hexagon_target_feature), &[]),
561 ("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
562 ("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
563 ("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
564 ("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
565 ("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
566 ("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
567 ("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
568 ("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
569 ("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
570 ("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
571 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
572 ];
574
575static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
576 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
580 (
581 "hard-float",
582 Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false },
583 &[],
584 ),
585 ("msync", Unstable(sym::powerpc_target_feature), &[]),
586 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
587 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
588 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
589 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
590 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
591 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
592 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
593 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
594 ("spe", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
595 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
596 ];
598
599const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
600 ("fp64", Unstable(sym::mips_target_feature), &[]),
602 ("msa", Unstable(sym::mips_target_feature), &[]),
603 ("virt", Unstable(sym::mips_target_feature), &[]),
604 ];
606
607const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
608 ("sm_70", Unstable(sym::nvptx_target_feature), &[]),
610 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
611 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
612 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
613 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
614 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
615 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
616 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
617 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
618 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
621 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
622 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
623 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
624 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
625 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
626 ("ptx70", Unstable(sym::nvptx_target_feature), &[]),
629 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
630 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
631 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
632 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
633 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
634 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
635 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
636 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
637 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
638 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
639 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
640 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
641 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
642 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
643 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
644 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
645 ];
647
648static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
649 ("a", Stable, &["zaamo", "zalrsc"]),
651 ("b", Stable, &["zba", "zbb", "zbs"]),
652 ("c", Stable, &["zca"]),
653 ("d", CfgStableToggleUnstable(sym::riscv_target_feature), &["f"]),
654 ("e", CfgStableToggleUnstable(sym::riscv_target_feature), &[]),
655 ("f", CfgStableToggleUnstable(sym::riscv_target_feature), &["zicsr"]),
656 (
657 "forced-atomics",
658 Stability::Forbidden {
659 reason: "unsound because it changes the ABI of atomic operations",
660 hard_error: false,
661 },
662 &[],
663 ),
664 ("m", Stable, &[]),
665 ("relax", Unstable(sym::riscv_target_feature), &[]),
666 (
667 "rva23u64",
668 Unstable(sym::riscv_target_feature),
669 &[
670 "m",
671 "a",
672 "f",
673 "d",
674 "c",
675 "b",
676 "v",
677 "zicsr",
678 "zicntr",
679 "zihpm",
680 "ziccif",
681 "ziccrse",
682 "ziccamoa",
683 "zicclsm",
684 "zic64b",
685 "za64rs",
686 "zihintpause",
687 "zba",
688 "zbb",
689 "zbs",
690 "zicbom",
691 "zicbop",
692 "zicboz",
693 "zfhmin",
694 "zkt",
695 "zvfhmin",
696 "zvbb",
697 "zvkt",
698 "zihintntl",
699 "zicond",
700 "zimop",
701 "zcmop",
702 "zcb",
703 "zfa",
704 "zawrs",
705 "supm",
706 ],
707 ),
708 ("supm", Unstable(sym::riscv_target_feature), &[]),
709 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
710 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
711 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
712 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
714 ("zaamo", Stable, &[]),
715 ("zabha", Stable, &["zaamo"]),
716 ("zacas", Stable, &["zaamo"]),
717 ("zalrsc", Stable, &[]),
718 ("zama16b", Stable, &[]),
719 ("zawrs", Stable, &[]),
720 ("zba", Stable, &[]),
721 ("zbb", Stable, &[]),
722 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
724 ("zbkc", Stable, &[]),
725 ("zbkx", Stable, &[]),
726 ("zbs", Stable, &[]),
727 ("zca", Stable, &[]),
728 ("zcb", Stable, &["zca"]),
729 ("zcmop", Stable, &["zca"]),
730 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
731 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
732 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
734 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
735 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
736 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
737 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
738 ("zic64b", Stable, &[]),
739 ("zicbom", Stable, &[]),
740 ("zicbop", Stable, &[]),
741 ("zicboz", Stable, &[]),
742 ("ziccamoa", Stable, &[]),
743 ("ziccif", Stable, &[]),
744 ("zicclsm", Stable, &[]),
745 ("ziccrse", Stable, &[]),
746 ("zicntr", Stable, &["zicsr"]),
747 ("zicond", Stable, &[]),
748 ("zicsr", Stable, &[]),
749 ("zifencei", Stable, &[]),
750 ("zihintntl", Stable, &[]),
751 ("zihintpause", Stable, &[]),
752 ("zihpm", Stable, &["zicsr"]),
753 ("zimop", Stable, &[]),
754 ("zk", Stable, &["zkn", "zkr", "zkt"]),
755 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
756 ("zknd", Stable, &["zkne_or_zknd"]),
757 ("zkne", Stable, &["zkne_or_zknd"]),
758 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
760 ("zkr", Stable, &[]),
761 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
762 ("zksed", Stable, &[]),
763 ("zksh", Stable, &[]),
764 ("zkt", Stable, &[]),
765 ("ztso", Stable, &[]),
766 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
768 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
769 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
770 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
771 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
772 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
773 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
774 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
775 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
777 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
778 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
779 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
780 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
781 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
782 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
783 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
784 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
786 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
787 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
788 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
789 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
790 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
791 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
792 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
793 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
794 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
795 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
796 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
797 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
798 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
799 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
800 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
801 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
802 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
803 ];
805
806static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
807 ("atomics", Unstable(sym::wasm_target_feature), &[]),
809 ("bulk-memory", Stable, &[]),
810 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
811 ("extended-const", Stable, &[]),
812 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
813 ("multivalue", Stable, &[]),
814 ("mutable-globals", Stable, &[]),
815 ("nontrapping-fptoint", Stable, &[]),
816 ("reference-types", Stable, &[]),
817 ("relaxed-simd", Stable, &["simd128"]),
818 ("sign-ext", Stable, &[]),
819 ("simd128", Stable, &[]),
820 ("tail-call", Stable, &[]),
821 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
822 ];
824
825const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
826 ("alu32", Unstable(sym::bpf_target_feature), &[]),
827 ("allows-misaligned-mem-access", Unstable(sym::bpf_target_feature), &[]),
828];
829
830static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
831 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
833 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
834 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
835 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
836 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
837 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
838 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
839 ("cache", Unstable(sym::csky_target_feature), &[]),
840 ("doloop", Unstable(sym::csky_target_feature), &[]),
841 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
842 ("dspe60", Unstable(sym::csky_target_feature), &[]),
843 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
844 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
845 ("edsp", Unstable(sym::csky_target_feature), &[]),
846 ("elrw", Unstable(sym::csky_target_feature), &[]),
847 ("float1e2", Unstable(sym::csky_target_feature), &[]),
848 ("float1e3", Unstable(sym::csky_target_feature), &[]),
849 ("float3e4", Unstable(sym::csky_target_feature), &[]),
850 ("float7e60", Unstable(sym::csky_target_feature), &[]),
851 ("floate1", Unstable(sym::csky_target_feature), &[]),
852 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
853 ("high-registers", Unstable(sym::csky_target_feature), &[]),
854 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
855 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
856 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
857 ("nvic", Unstable(sym::csky_target_feature), &[]),
858 ("trust", Unstable(sym::csky_target_feature), &[]),
859 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
860 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
861 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
862 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
866 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
867 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
868 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
869 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
870 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
871 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
872 ("hard-float", Unstable(sym::csky_target_feature), &[]),
873 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
874 ];
876
877static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
878 ("32s", Unstable(sym::loongarch_target_feature), &[]),
880 ("d", Stable, &["f"]),
881 ("div32", Stable, &[]),
882 ("f", Stable, &[]),
883 ("frecipe", Stable, &[]),
884 ("lam-bh", Stable, &[]),
885 ("lamcas", Stable, &[]),
886 ("lasx", Stable, &["lsx"]),
887 ("lbt", Stable, &[]),
888 ("ld-seq-sa", Stable, &[]),
889 ("lsx", Stable, &["d"]),
890 ("lvz", Stable, &[]),
891 ("relax", Unstable(sym::loongarch_target_feature), &[]),
892 ("scq", Stable, &[]),
893 ("ual", Unstable(sym::loongarch_target_feature), &[]),
894 ];
896
897#[rustfmt::skip]
898const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
899 ("backchain", Unstable(sym::s390x_target_feature), &[]),
902 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
903 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
904 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
905 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
906 ("high-word", Unstable(sym::s390x_target_feature), &[]),
907 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
909 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
910 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
911 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
912 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
913 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
914 ("miscellaneous-extensions-2", Stable, &[]),
915 ("miscellaneous-extensions-3", Stable, &[]),
916 ("miscellaneous-extensions-4", Stable, &[]),
917 ("nnp-assist", Stable, &["vector"]),
918 ("soft-float", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
919 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
920 ("vector", Stable, &[]),
921 ("vector-enhancements-1", Stable, &["vector"]),
922 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
923 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
924 ("vector-packed-decimal", Stable, &["vector"]),
925 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
926 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
927 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
928 ];
930
931const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
932 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
934 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
935 ("v9", Unstable(sym::sparc_target_feature), &[]),
936 ];
938
939static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
940 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
942 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
943 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
944 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
945 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
946 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
947 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
949 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
950 ];
952
953static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
954 ("addsubiw", Unstable(sym::avr_target_feature), &[]),
956 ("break", Unstable(sym::avr_target_feature), &[]),
957 ("eijmpcall", Unstable(sym::avr_target_feature), &[]),
958 ("elpm", Unstable(sym::avr_target_feature), &[]),
959 ("elpmx", Unstable(sym::avr_target_feature), &[]),
960 ("ijmpcall", Unstable(sym::avr_target_feature), &[]),
961 ("jmpcall", Unstable(sym::avr_target_feature), &[]),
962 ("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
963 ("lpm", Unstable(sym::avr_target_feature), &[]),
964 ("lpmx", Unstable(sym::avr_target_feature), &[]),
965 ("movw", Unstable(sym::avr_target_feature), &[]),
966 ("mul", Unstable(sym::avr_target_feature), &[]),
967 ("rmw", Unstable(sym::avr_target_feature), &[]),
968 ("spm", Unstable(sym::avr_target_feature), &[]),
969 ("spmx", Unstable(sym::avr_target_feature), &[]),
970 (
971 "sram",
972 Forbidden { reason: "devices that have no SRAM are unsupported", hard_error: false },
973 &[],
974 ),
975 ("tinyencoding", Unstable(sym::avr_target_feature), &[]),
976 ];
978
979const XTENSA_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
980 ("bool", Unstable(sym::xtensa_target_feature), &[]),
981 ("fp", Unstable(sym::xtensa_target_feature), &["bool", "coprocessor"]),
982 ("coprocessor", Unstable(sym::xtensa_target_feature), &[]),
983 ("highpriinterrupts", Unstable(sym::xtensa_target_feature), &["interrupt"]),
984 ("interrupt", Unstable(sym::xtensa_target_feature), &["exception"]),
985 (
986 "windowed",
987 Forbidden { reason: "windowed changes the Xtensa calling convention", hard_error: false },
988 &["exception"],
989 ),
990 ("loop", Unstable(sym::xtensa_target_feature), &[]),
991 ("sext", Unstable(sym::xtensa_target_feature), &[]),
992 ("nsa", Unstable(sym::xtensa_target_feature), &[]),
993 ("mul32", Unstable(sym::xtensa_target_feature), &[]),
994 ("mul32high", Unstable(sym::xtensa_target_feature), &["mul32"]),
995 ("div32", Unstable(sym::xtensa_target_feature), &[]),
996 ("mac16", Unstable(sym::xtensa_target_feature), &[]),
997 ("s32c1i", Unstable(sym::xtensa_target_feature), &[]),
998 ("threadptr", Unstable(sym::xtensa_target_feature), &[]),
999 ("extendedl32r", Unstable(sym::xtensa_target_feature), &[]),
1000 ("debug", Unstable(sym::xtensa_target_feature), &["exception"]),
1001 ("exception", Unstable(sym::xtensa_target_feature), &[]),
1002 ("rvector", Unstable(sym::xtensa_target_feature), &["exception"]),
1003 ("prid", Unstable(sym::xtensa_target_feature), &[]),
1004 ("regprotect", Unstable(sym::xtensa_target_feature), &[]),
1005 ("miscsr", Unstable(sym::xtensa_target_feature), &[]),
1006];
1007
1008pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
1013 std::iter::empty()
1014 .chain(ARM_FEATURES.iter())
1015 .chain(AARCH64_FEATURES.iter())
1016 .chain(X86_FEATURES.iter())
1017 .chain(HEXAGON_FEATURES.iter())
1018 .chain(POWERPC_FEATURES.iter())
1019 .chain(MIPS_FEATURES.iter())
1020 .chain(NVPTX_FEATURES.iter())
1021 .chain(RISCV_FEATURES.iter())
1022 .chain(WASM_FEATURES.iter())
1023 .chain(BPF_FEATURES.iter())
1024 .chain(XTENSA_FEATURES.iter())
1025 .chain(CSKY_FEATURES)
1026 .chain(LOONGARCH_FEATURES)
1027 .chain(IBMZ_FEATURES)
1028 .chain(SPARC_FEATURES)
1029 .chain(M68K_FEATURES)
1030 .chain(AVR_FEATURES)
1031 .cloned()
1032 .map(|(f, s, _)| (f, s))
1033}
1034
1035pub fn feature_to_arch_names(feature: &str) -> Vec<&'static str> {
1039 let mut arches = Vec::new();
1040 macro_rules! check_arch_feats {
1041 ($arch_name:expr, $feats:expr) => {
1042 if $feats.iter().any(|(f, _, _)| *f == feature) {
1043 arches.push($arch_name);
1044 }
1045 };
1046 }
1047 if ARM_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("arm"); };check_arch_feats!("arm", ARM_FEATURES);
1048 if AARCH64_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("aarch64");
};check_arch_feats!("aarch64", AARCH64_FEATURES);
1049 if X86_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("x86"); };check_arch_feats!("x86", X86_FEATURES);
1050 if HEXAGON_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("hexagon");
};check_arch_feats!("hexagon", HEXAGON_FEATURES);
1051 if MIPS_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("mips");
};check_arch_feats!("mips", MIPS_FEATURES);
1052 if NVPTX_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("nvptx64");
};check_arch_feats!("nvptx64", NVPTX_FEATURES);
1053 if POWERPC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("powerpc");
};check_arch_feats!("powerpc", POWERPC_FEATURES);
1054 if RISCV_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("riscv");
};check_arch_feats!("riscv", RISCV_FEATURES);
1055 if WASM_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("wasm");
};check_arch_feats!("wasm", WASM_FEATURES);
1056 if BPF_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("bpf"); };check_arch_feats!("bpf", BPF_FEATURES);
1057 if CSKY_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("csky");
};check_arch_feats!("csky", CSKY_FEATURES);
1058 if LOONGARCH_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("loongarch");
};check_arch_feats!("loongarch", LOONGARCH_FEATURES);
1059 if IBMZ_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("s390x");
};check_arch_feats!("s390x", IBMZ_FEATURES);
1060 if SPARC_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("sparc");
};check_arch_feats!("sparc", SPARC_FEATURES);
1061 if M68K_FEATURES.iter().any(|(f, _, _)| *f == feature) {
arches.push("m68k");
};check_arch_feats!("m68k", M68K_FEATURES);
1062 if AVR_FEATURES.iter().any(|(f, _, _)| *f == feature) { arches.push("avr"); };check_arch_feats!("avr", AVR_FEATURES);
1063 arches.sort();
1064 arches.dedup();
1065 arches
1066}
1067
1068const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1072 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1074 &[(128, "neon")];
1075
1076const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1078 &[(128, "neon")];
1079
1080const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1081 &[(1024, "")];
1082const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1083 &[(128, "altivec")];
1084const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1085 &[(128, "simd128")];
1086const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1087 &[(128, "vector")];
1088const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1089 (32, "zvl32b"),
1090 (64, "zvl64b"),
1091 (128, "zvl128b"),
1092 (256, "zvl256b"),
1093 (512, "zvl512b"),
1094 (1024, "zvl1024b"),
1095 (2048, "zvl2048b"),
1096 (4096, "zvl4096b"),
1097 (8192, "zvl8192b"),
1098 (16384, "zvl16384b"),
1099 (32768, "zvl32768b"),
1100 (65536, "zvl65536b"),
1101];
1102const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1104 &[];
1105
1106const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1107 (512, "hvx-length64b"), (1024, "hvx-length128b"), (2048, "hvx-length128b"), ];
1111const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1112 &[(128, "msa")];
1113const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1114 &[(128, "vdspv1")];
1115const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1116 &[(128, "lsx"), (256, "lasx")];
1117
1118#[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)]
1119pub struct FeatureConstraints {
1120 pub required: &'static [&'static str],
1122 pub incompatible: &'static [&'static str],
1124}
1125
1126impl Target {
1127 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
1128 match &self.arch {
1129 Arch::Arm => ARM_FEATURES,
1130 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
1131 Arch::X86 | Arch::X86_64 => X86_FEATURES,
1132 Arch::Hexagon => HEXAGON_FEATURES,
1133 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
1134 Arch::Nvptx64 => NVPTX_FEATURES,
1135 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
1136 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
1137 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
1138 Arch::Bpf => BPF_FEATURES,
1139 Arch::CSky => CSKY_FEATURES,
1140 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
1141 Arch::S390x => IBMZ_FEATURES,
1142 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
1143 Arch::M68k => M68K_FEATURES,
1144 Arch::Avr => AVR_FEATURES,
1145 Arch::Xtensa => XTENSA_FEATURES,
1146 Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Other(_) => &[],
1147 }
1148 }
1149
1150 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1151 match &self.arch {
1152 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1153 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1154 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1155 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1156 Arch::LoongArch32 | Arch::LoongArch64 => {
1157 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1158 }
1159 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1160 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1161 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1162 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1163 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1164 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1165 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1166 }
1167 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1168 Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1170 Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1173 }
1174 }
1175
1176 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1177 match &self.arch {
1178 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1179 _ => None,
1181 }
1182 }
1183
1184 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1185 match &self.arch {
1186 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1187 _ => &[],
1188 }
1189 }
1190
1191 pub fn implied_target_features<'a>(&self, base_feature: &'a str) -> FxHashSet<&'a str> {
1193 let implied_features =
1194 self.rust_target_features().iter().map(|(f, _, i)| (f, i)).collect::<FxHashMap<_, _>>();
1195
1196 let mut features = FxHashSet::default();
1199 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];
1200 while let Some(new_feature) = new_features.pop() {
1201 if features.insert(new_feature) {
1202 if let Some(implied_features) = implied_features.get(&new_feature) {
1203 new_features.extend(implied_features.iter().copied())
1204 }
1205 }
1206 }
1207 features
1208 }
1209
1210 pub fn abi_required_features(&self) -> FeatureConstraints {
1221 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1222 match &self.arch {
1227 Arch::X86 => {
1228 match self.rustc_abi {
1231 None => {
1232 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1235 }
1236 Some(RustcAbi::X86Sse2) => {
1237 FeatureConstraints {
1239 required: &["x87", "sse2"],
1240 incompatible: &["soft-float"],
1241 }
1242 }
1243 Some(RustcAbi::Softfloat) => {
1244 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1249 }
1250 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1251 }
1252 }
1253 Arch::X86_64 => {
1254 match self.rustc_abi {
1257 None => {
1258 FeatureConstraints {
1260 required: &["x87", "sse2"],
1261 incompatible: &["soft-float"],
1262 }
1263 }
1264 Some(RustcAbi::Softfloat) => {
1265 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1270 }
1271 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1272 }
1273 }
1274 Arch::Arm => {
1275 match self.llvm_floatabi.unwrap() {
1278 FloatAbi::Soft => {
1279 NOTHING
1284 }
1285 FloatAbi::Hard => {
1286 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1288 }
1289 }
1290 }
1291 Arch::AArch64 | Arch::Arm64EC => {
1292 match self.rustc_abi {
1295 Some(RustcAbi::Softfloat) => {
1296 FeatureConstraints { required: &[], incompatible: &["neon"] }
1302 }
1303 None => {
1304 FeatureConstraints { required: &["neon"], incompatible: &[] }
1307 }
1308 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1309 }
1310 }
1311 Arch::RiscV32 | Arch::RiscV64 => {
1312 match &self.llvm_abiname {
1315 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1316 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1318 }
1319 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1320 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1322 }
1323 LlvmAbi::Ilp32 | LlvmAbi::Lp64 => {
1324 FeatureConstraints { required: &[], incompatible: &["e"] }
1326 }
1327 LlvmAbi::Ilp32e => {
1328 FeatureConstraints { required: &[], incompatible: &["d"] }
1337 }
1338 LlvmAbi::Lp64e => {
1339 NOTHING
1341 }
1342 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1343 }
1344 }
1345 Arch::LoongArch32 | Arch::LoongArch64 => {
1346 match &self.llvm_abiname {
1349 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1350 FeatureConstraints { required: &["d"], incompatible: &[] }
1352 }
1353 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1354 FeatureConstraints { required: &["f"], incompatible: &[] }
1356 }
1357 LlvmAbi::Ilp32s | LlvmAbi::Lp64s => {
1358 NOTHING
1363 }
1364 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1365 }
1366 }
1367 Arch::S390x => {
1368 match self.rustc_abi {
1376 None => {
1377 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1379 }
1380 Some(RustcAbi::Softfloat) => {
1381 FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] }
1384 }
1385 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1386 }
1387 }
1388 Arch::PowerPC => {
1389 match self.rustc_abi {
1392 None => {
1393 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1395 }
1396 Some(RustcAbi::PowerPcSpe) => {
1397 FeatureConstraints { required: &["hard-float", "spe"], incompatible: &[] }
1402 }
1403 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1404 }
1405 }
1406 Arch::PowerPC64 => {
1407 FeatureConstraints { required: &["hard-float"], incompatible: &["spe"] }
1411 }
1412 Arch::Avr => {
1413 FeatureConstraints { required: &["sram"], incompatible: &[] }
1418 }
1419 Arch::Wasm32 | Arch::Wasm64 => {
1420 NOTHING
1423 }
1424 _ => NOTHING,
1425 }
1426 }
1427}