1use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5use rustc_macros::StableHash;
6use rustc_span::{Symbol, sym};
7
8use crate::spec::{Arch, FloatAbi, LlvmAbi, RustcAbi, Target};
9
10pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
13
14#[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)]
16pub enum Stability {
17 Stable,
20 CfgStableToggleUnstable(
23 Symbol,
26 ),
27 Unstable(
30 Symbol,
33 ),
34 Forbidden {
39 reason: &'static str,
40 hard_error: bool,
43 },
44}
45use Stability::*;
46
47impl Stability {
48 pub fn in_cfg(&self) -> bool {
52 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::Stable | Stability::CfgStableToggleUnstable { .. } |
Stability::Unstable { .. } => true,
_ => false,
}matches!(
53 self,
54 Stability::Stable
55 | Stability::CfgStableToggleUnstable { .. }
56 | Stability::Unstable { .. }
57 )
58 }
59
60 pub fn requires_nightly(&self, in_cfg: bool) -> Option<Symbol> {
72 match *self {
73 Stability::Unstable(nightly_feature) => Some(nightly_feature),
74 Stability::CfgStableToggleUnstable(nightly_feature) => {
75 if in_cfg {
76 None
77 } else {
78 Some(nightly_feature)
79 }
80 }
81 Stability::Stable { .. } => None,
82 Stability::Forbidden { .. } => {
::core::panicking::panic_fmt(format_args!("forbidden features should not reach this far"));
}panic!("forbidden features should not reach this far"),
83 }
84 }
85
86 pub fn is_cfg_stable_toggle_unstable(&self) -> bool {
89 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::CfgStableToggleUnstable { .. } => true,
_ => false,
}matches!(self, Stability::CfgStableToggleUnstable { .. })
90 }
91
92 pub fn toggle_allowed(&self) -> Result<(), &'static str> {
96 match self {
97 Stability::Unstable(_)
98 | Stability::CfgStableToggleUnstable(_)
99 | Stability::Stable { .. } => Ok(()),
100 Stability::Forbidden { reason, hard_error: _ } => Err(reason),
101 }
102 }
103}
104
105type ImpliedFeatures = &'static [&'static str];
150
151static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
152 ("aclass", Unstable(sym::arm_target_feature), &[]),
154 ("aes", Unstable(sym::arm_target_feature), &["neon"]),
155 (
156 "atomics-32",
157 Stability::Forbidden {
158 reason: "unsound because it changes the ABI of atomic operations",
159 hard_error: false,
160 },
161 &[],
162 ),
163 ("crc", Unstable(sym::arm_target_feature), &[]),
164 ("d32", Unstable(sym::arm_target_feature), &[]),
165 ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
166 ("dsp", Unstable(sym::arm_target_feature), &[]),
167 ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
168 ("fp16", Unstable(sym::arm_target_feature), &["neon"]),
169 ("fpregs", Unstable(sym::arm_target_feature), &[]),
170 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
171 ("mclass", Unstable(sym::arm_target_feature), &[]),
172 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
173 ("rclass", Unstable(sym::arm_target_feature), &[]),
174 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
175 ("soft-float", Unstable(sym::arm_target_feature), &[]),
180 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
184 ("thumb2", Unstable(sym::arm_target_feature), &[]),
185 ("trustzone", Unstable(sym::arm_target_feature), &[]),
186 ("v5te", Unstable(sym::arm_target_feature), &[]),
187 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
188 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
189 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "thumb2"]),
190 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
191 ("v8", Unstable(sym::arm_target_feature), &["v7"]),
192 ("vfp2", Unstable(sym::arm_target_feature), &[]),
193 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
194 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
195 ("virtualization", Unstable(sym::arm_target_feature), &[]),
196 ];
198
199static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
200 ("aes", Stable, &["neon"]),
203 ("bf16", Stable, &[]),
205 ("bti", Stable, &[]),
207 ("crc", Stable, &[]),
209 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
211 ("dit", Stable, &[]),
213 ("dotprod", Stable, &["neon"]),
215 ("dpb", Stable, &[]),
217 ("dpb2", Stable, &["dpb"]),
219 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
221 ("f32mm", Stable, &["sve"]),
223 ("f64mm", Stable, &["sve"]),
225 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
227 ("fcma", Stable, &["neon"]),
229 ("fhm", Stable, &["fp16"]),
231 ("flagm", Stable, &[]),
233 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
235 (
237 "fp-armv8",
238 Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
239 &[],
240 ),
241 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
243 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
245 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
247 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
249 ("fp16", Stable, &["neon"]),
252 ("frintts", Stable, &[]),
254 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
256 ("i8mm", Stable, &[]),
258 ("jsconv", Stable, &["neon"]),
261 ("lor", Stable, &[]),
263 ("lse", Stable, &[]),
265 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
267 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
269 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
271 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
273 ("mte", Stable, &[]),
275 ("neon", Stable, &[]),
277 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
281 ("paca", Stable, &[]),
283 ("pacg", Stable, &[]),
285 ("pan", Stable, &[]),
287 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
289 ("pmuv3", Stable, &[]),
291 ("rand", Stable, &[]),
293 ("ras", Stable, &[]),
295 ("rcpc", Stable, &[]),
297 ("rcpc2", Stable, &["rcpc"]),
299 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
301 ("rdm", Stable, &["neon"]),
303 (
304 "reserve-x18",
305 Forbidden { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
306 &[],
307 ),
308 ("sb", Stable, &[]),
310 ("sha2", Stable, &["neon"]),
312 ("sha3", Stable, &["sha2"]),
314 ("sm4", Stable, &["neon"]),
316 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
318 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
320 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
322 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
324 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
326 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
328 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
330 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
332 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
334 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
336 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
338 ("spe", Stable, &[]),
340 ("ssbs", Stable, &[]),
342 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
344 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
346 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
348 ("sve", Stable, &["neon"]),
356 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
358 ("sve2", Stable, &["sve"]),
360 ("sve2-aes", Stable, &["sve2", "aes"]),
362 ("sve2-bitperm", Stable, &["sve2"]),
364 ("sve2-sha3", Stable, &["sve2", "sha3"]),
366 ("sve2-sm4", Stable, &["sve2", "sm4"]),
368 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
370 ("tme", Stable, &[]),
372 (
373 "v8.1a",
374 Unstable(sym::aarch64_ver_target_feature),
375 &["crc", "lse", "rdm", "pan", "lor", "vh"],
376 ),
377 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
378 (
379 "v8.3a",
380 Unstable(sym::aarch64_ver_target_feature),
381 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
382 ),
383 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
384 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
385 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
386 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
387 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
388 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
389 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
390 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
391 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
392 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
393 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
394 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
395 ("vh", Stable, &[]),
397 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
399 ];
401
402const AARCH64_TIED_FEATURES: &[&[&str]] = &[
403 &["paca", "pacg"], ];
405
406static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
407 ("adx", Stable, &[]),
409 ("aes", Stable, &["sse2"]),
410 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
411 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
412 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
413 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
414 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
415 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
416 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
417 ("amx-tf32", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
418 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
419 ("apxf", Unstable(sym::apx_target_feature), &[]),
420 ("avx", Stable, &["sse4.2"]),
421 ("avx2", Stable, &["avx"]),
422 (
423 "avx10.1",
424 Unstable(sym::avx10_target_feature),
425 &[
426 "avx512bf16",
427 "avx512bitalg",
428 "avx512bw",
429 "avx512cd",
430 "avx512dq",
431 "avx512f",
432 "avx512fp16",
433 "avx512ifma",
434 "avx512vbmi",
435 "avx512vbmi2",
436 "avx512vl",
437 "avx512vnni",
438 "avx512vpopcntdq",
439 ],
440 ),
441 (
442 "avx10.2",
443 Unstable(sym::avx10_target_feature),
444 &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
445 ),
446 ("avx512bf16", Stable, &["avx512bw"]),
447 ("avx512bitalg", Stable, &["avx512bw"]),
448 ("avx512bw", Stable, &["avx512f"]),
449 ("avx512cd", Stable, &["avx512f"]),
450 ("avx512dq", Stable, &["avx512f"]),
451 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
452 ("avx512fp16", Stable, &["avx512bw"]),
453 ("avx512ifma", Stable, &["avx512f"]),
454 ("avx512vbmi", Stable, &["avx512bw"]),
455 ("avx512vbmi2", Stable, &["avx512bw"]),
456 ("avx512vl", Stable, &["avx512f"]),
457 ("avx512vnni", Stable, &["avx512f"]),
458 ("avx512vp2intersect", Stable, &["avx512f"]),
459 ("avx512vpopcntdq", Stable, &["avx512f"]),
460 ("avxifma", Stable, &["avx2"]),
461 ("avxneconvert", Stable, &["avx2"]),
462 ("avxvnni", Stable, &["avx2"]),
463 ("avxvnniint8", Stable, &["avx2"]),
464 ("avxvnniint16", Stable, &["avx2"]),
465 ("bmi1", Stable, &[]),
466 ("bmi2", Stable, &[]),
467 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
468 ("cmpxchg16b", Stable, &[]),
469 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
470 ("f16c", Stable, &["avx"]),
471 ("fma", Stable, &["avx"]),
472 ("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
473 ("fxsr", Stable, &[]),
474 ("gfni", Stable, &["sse2"]),
475 ("kl", Stable, &["sse2"]),
476 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
477 ("lzcnt", Stable, &[]),
478 ("movbe", Stable, &[]),
479 ("movrs", Unstable(sym::movrs_target_feature), &[]),
480 ("pclmulqdq", Stable, &["sse2"]),
481 ("popcnt", Stable, &[]),
482 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
483 ("rdrand", Stable, &[]),
484 ("rdseed", Stable, &[]),
485 (
486 "retpoline-external-thunk",
487 Stability::Forbidden {
488 reason: "use `-Zretpoline-external-thunk` compiler flag instead",
489 hard_error: false,
490 },
491 &[],
492 ),
493 (
494 "retpoline-indirect-branches",
495 Stability::Forbidden {
496 reason: "use `-Zretpoline` compiler flag instead",
497 hard_error: false,
498 },
499 &[],
500 ),
501 (
502 "retpoline-indirect-calls",
503 Stability::Forbidden {
504 reason: "use `-Zretpoline` compiler flag instead",
505 hard_error: false,
506 },
507 &[],
508 ),
509 ("rtm", Unstable(sym::rtm_target_feature), &[]),
510 ("sha", Stable, &["sse2"]),
511 ("sha512", Stable, &["avx2"]),
512 ("sm3", Stable, &["avx"]),
513 ("sm4", Stable, &["avx2"]),
514 (
515 "soft-float",
516 Stability::Forbidden { reason: "use a soft-float target instead", hard_error: false },
517 &[],
518 ),
519 ("sse", Stable, &[]),
520 ("sse2", Stable, &["sse"]),
521 ("sse3", Stable, &["sse2"]),
522 ("sse4.1", Stable, &["ssse3"]),
523 ("sse4.2", Stable, &["sse4.1"]),
524 ("sse4a", Stable, &["sse3"]),
525 ("ssse3", Stable, &["sse3"]),
526 ("tbm", Stable, &[]),
527 ("vaes", Stable, &["avx2", "aes"]),
528 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
529 ("widekl", Stable, &["kl"]),
530 ("x87", Unstable(sym::x87_target_feature), &[]),
531 ("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
532 ("xsave", Stable, &[]),
533 ("xsavec", Stable, &["xsave"]),
534 ("xsaveopt", Stable, &["xsave"]),
535 ("xsaves", Stable, &["xsave"]),
536 ];
538
539const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
540 ("audio", Unstable(sym::hexagon_target_feature), &[]),
542 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
543 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
544 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
545 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
546 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
547 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
548 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
549 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
550 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
551 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
552 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
553 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
554 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
555 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
556 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
557 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
558 ("v60", Unstable(sym::hexagon_target_feature), &[]),
559 ("v62", Unstable(sym::hexagon_target_feature), &["v60"]),
560 ("v65", Unstable(sym::hexagon_target_feature), &["v62"]),
561 ("v66", Unstable(sym::hexagon_target_feature), &["v65"]),
562 ("v67", Unstable(sym::hexagon_target_feature), &["v66"]),
563 ("v68", Unstable(sym::hexagon_target_feature), &["v67"]),
564 ("v69", Unstable(sym::hexagon_target_feature), &["v68"]),
565 ("v71", Unstable(sym::hexagon_target_feature), &["v69"]),
566 ("v73", Unstable(sym::hexagon_target_feature), &["v71"]),
567 ("v75", Unstable(sym::hexagon_target_feature), &["v73"]),
568 ("v79", Unstable(sym::hexagon_target_feature), &["v75"]),
569 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
570 ];
572
573static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
574 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
576 ("msync", Unstable(sym::powerpc_target_feature), &[]),
577 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
578 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
579 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
580 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
581 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
582 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
583 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
584 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
585 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
586 ];
588
589const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
590 ("fp64", Unstable(sym::mips_target_feature), &[]),
592 ("msa", Unstable(sym::mips_target_feature), &[]),
593 ("virt", Unstable(sym::mips_target_feature), &[]),
594 ];
596
597const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
598 ("sm_70", Unstable(sym::nvptx_target_feature), &[]),
600 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
601 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
602 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
603 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
604 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
605 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
606 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
607 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
608 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
611 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
612 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
613 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
614 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
615 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
616 ("ptx70", Unstable(sym::nvptx_target_feature), &[]),
619 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
620 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
621 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
622 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
623 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
624 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
625 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
626 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
627 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
628 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
629 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
630 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
631 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
632 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
633 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
634 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
635 ];
637
638static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
639 ("a", Stable, &["zaamo", "zalrsc"]),
641 ("b", Stable, &["zba", "zbb", "zbs"]),
642 ("c", Stable, &["zca"]),
643 ("d", Unstable(sym::riscv_target_feature), &["f"]),
644 ("e", Unstable(sym::riscv_target_feature), &[]),
645 ("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
646 (
647 "forced-atomics",
648 Stability::Forbidden {
649 reason: "unsound because it changes the ABI of atomic operations",
650 hard_error: false,
651 },
652 &[],
653 ),
654 ("m", Stable, &[]),
655 ("relax", Unstable(sym::riscv_target_feature), &[]),
656 (
657 "rva23u64",
658 Unstable(sym::riscv_target_feature),
659 &[
660 "m",
661 "a",
662 "f",
663 "d",
664 "c",
665 "b",
666 "v",
667 "zicsr",
668 "zicntr",
669 "zihpm",
670 "ziccif",
671 "ziccrse",
672 "ziccamoa",
673 "zicclsm",
674 "zic64b",
675 "za64rs",
676 "zihintpause",
677 "zba",
678 "zbb",
679 "zbs",
680 "zicbom",
681 "zicbop",
682 "zicboz",
683 "zfhmin",
684 "zkt",
685 "zvfhmin",
686 "zvbb",
687 "zvkt",
688 "zihintntl",
689 "zicond",
690 "zimop",
691 "zcmop",
692 "zcb",
693 "zfa",
694 "zawrs",
695 "supm",
696 ],
697 ),
698 ("supm", Unstable(sym::riscv_target_feature), &[]),
699 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
700 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
701 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
702 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
704 ("zaamo", Stable, &[]),
705 ("zabha", Stable, &["zaamo"]),
706 ("zacas", Stable, &["zaamo"]),
707 ("zalrsc", Stable, &[]),
708 ("zama16b", Stable, &[]),
709 ("zawrs", Stable, &[]),
710 ("zba", Stable, &[]),
711 ("zbb", Stable, &[]),
712 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
714 ("zbkc", Stable, &[]),
715 ("zbkx", Stable, &[]),
716 ("zbs", Stable, &[]),
717 ("zca", Stable, &[]),
718 ("zcb", Stable, &["zca"]),
719 ("zcmop", Stable, &["zca"]),
720 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
721 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
722 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
724 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
725 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
726 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
727 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
728 ("zic64b", Stable, &[]),
729 ("zicbom", Stable, &[]),
730 ("zicbop", Stable, &[]),
731 ("zicboz", Stable, &[]),
732 ("ziccamoa", Stable, &[]),
733 ("ziccif", Stable, &[]),
734 ("zicclsm", Stable, &[]),
735 ("ziccrse", Stable, &[]),
736 ("zicntr", Stable, &["zicsr"]),
737 ("zicond", Stable, &[]),
738 ("zicsr", Stable, &[]),
739 ("zifencei", Stable, &[]),
740 ("zihintntl", Stable, &[]),
741 ("zihintpause", Stable, &[]),
742 ("zihpm", Stable, &["zicsr"]),
743 ("zimop", Stable, &[]),
744 ("zk", Stable, &["zkn", "zkr", "zkt"]),
745 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
746 ("zknd", Stable, &["zkne_or_zknd"]),
747 ("zkne", Stable, &["zkne_or_zknd"]),
748 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
750 ("zkr", Stable, &[]),
751 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
752 ("zksed", Stable, &[]),
753 ("zksh", Stable, &[]),
754 ("zkt", Stable, &[]),
755 ("ztso", Stable, &[]),
756 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
758 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
759 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
760 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
761 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
762 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
763 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
764 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
765 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
767 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
768 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
769 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
770 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
771 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
772 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
773 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
774 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
776 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
777 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
778 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
779 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
780 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
781 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
782 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
783 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
784 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
785 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
786 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
787 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
788 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
789 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
790 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
791 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
792 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
793 ];
795
796static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
797 ("atomics", Unstable(sym::wasm_target_feature), &[]),
799 ("bulk-memory", Stable, &[]),
800 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
801 ("extended-const", Stable, &[]),
802 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
803 ("multivalue", Stable, &[]),
804 ("mutable-globals", Stable, &[]),
805 ("nontrapping-fptoint", Stable, &[]),
806 ("reference-types", Stable, &[]),
807 ("relaxed-simd", Stable, &["simd128"]),
808 ("sign-ext", Stable, &[]),
809 ("simd128", Stable, &[]),
810 ("tail-call", Stable, &[]),
811 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
812 ];
814
815const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
816 ("alu32", Unstable(sym::bpf_target_feature), &[]),
817 ("allows-misaligned-mem-access", Unstable(sym::bpf_target_feature), &[]),
818];
819
820static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
821 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
823 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
824 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
825 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
826 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
827 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
828 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
829 ("cache", Unstable(sym::csky_target_feature), &[]),
830 ("doloop", Unstable(sym::csky_target_feature), &[]),
831 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
832 ("dspe60", Unstable(sym::csky_target_feature), &[]),
833 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
834 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
835 ("edsp", Unstable(sym::csky_target_feature), &[]),
836 ("elrw", Unstable(sym::csky_target_feature), &[]),
837 ("float1e2", Unstable(sym::csky_target_feature), &[]),
838 ("float1e3", Unstable(sym::csky_target_feature), &[]),
839 ("float3e4", Unstable(sym::csky_target_feature), &[]),
840 ("float7e60", Unstable(sym::csky_target_feature), &[]),
841 ("floate1", Unstable(sym::csky_target_feature), &[]),
842 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
843 ("high-registers", Unstable(sym::csky_target_feature), &[]),
844 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
845 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
846 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
847 ("nvic", Unstable(sym::csky_target_feature), &[]),
848 ("trust", Unstable(sym::csky_target_feature), &[]),
849 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
850 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
851 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
852 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
856 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
857 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
858 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
859 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
860 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
861 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
862 ("hard-float", Unstable(sym::csky_target_feature), &[]),
863 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
864 ];
866
867static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
868 ("32s", Unstable(sym::loongarch_target_feature), &[]),
870 ("d", Stable, &["f"]),
871 ("div32", Stable, &[]),
872 ("f", Stable, &[]),
873 ("frecipe", Stable, &[]),
874 ("lam-bh", Stable, &[]),
875 ("lamcas", Stable, &[]),
876 ("lasx", Stable, &["lsx"]),
877 ("lbt", Stable, &[]),
878 ("ld-seq-sa", Stable, &[]),
879 ("lsx", Stable, &["d"]),
880 ("lvz", Stable, &[]),
881 ("relax", Unstable(sym::loongarch_target_feature), &[]),
882 ("scq", Stable, &[]),
883 ("ual", Unstable(sym::loongarch_target_feature), &[]),
884 ];
886
887#[rustfmt::skip]
888const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
889 ("backchain", Unstable(sym::s390x_target_feature), &[]),
892 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
893 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
894 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
895 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
896 ("high-word", Unstable(sym::s390x_target_feature), &[]),
897 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
899 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
900 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
901 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
902 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
903 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
904 ("miscellaneous-extensions-2", Stable, &[]),
905 ("miscellaneous-extensions-3", Stable, &[]),
906 ("miscellaneous-extensions-4", Stable, &[]),
907 ("nnp-assist", Stable, &["vector"]),
908 ("soft-float", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
909 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
910 ("vector", Stable, &[]),
911 ("vector-enhancements-1", Stable, &["vector"]),
912 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
913 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
914 ("vector-packed-decimal", Stable, &["vector"]),
915 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
916 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
917 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
918 ];
920
921const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
922 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
924 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
925 ("v9", Unstable(sym::sparc_target_feature), &[]),
926 ];
928
929static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
930 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
932 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
933 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
934 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
935 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
936 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
937 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
939 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
940 ];
942
943static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
944 ("addsubiw", Unstable(sym::avr_target_feature), &[]),
946 ("break", Unstable(sym::avr_target_feature), &[]),
947 ("eijmpcall", Unstable(sym::avr_target_feature), &[]),
948 ("elpm", Unstable(sym::avr_target_feature), &[]),
949 ("elpmx", Unstable(sym::avr_target_feature), &[]),
950 ("ijmpcall", Unstable(sym::avr_target_feature), &[]),
951 ("jmpcall", Unstable(sym::avr_target_feature), &[]),
952 ("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
953 ("lpm", Unstable(sym::avr_target_feature), &[]),
954 ("lpmx", Unstable(sym::avr_target_feature), &[]),
955 ("movw", Unstable(sym::avr_target_feature), &[]),
956 ("mul", Unstable(sym::avr_target_feature), &[]),
957 ("rmw", Unstable(sym::avr_target_feature), &[]),
958 ("spm", Unstable(sym::avr_target_feature), &[]),
959 ("spmx", Unstable(sym::avr_target_feature), &[]),
960 (
961 "sram",
962 Forbidden { reason: "devices that have no SRAM are unsupported", hard_error: false },
963 &[],
964 ),
965 ("tinyencoding", Unstable(sym::avr_target_feature), &[]),
966 ];
968
969pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
974 std::iter::empty()
975 .chain(ARM_FEATURES.iter())
976 .chain(AARCH64_FEATURES.iter())
977 .chain(X86_FEATURES.iter())
978 .chain(HEXAGON_FEATURES.iter())
979 .chain(POWERPC_FEATURES.iter())
980 .chain(MIPS_FEATURES.iter())
981 .chain(NVPTX_FEATURES.iter())
982 .chain(RISCV_FEATURES.iter())
983 .chain(WASM_FEATURES.iter())
984 .chain(BPF_FEATURES.iter())
985 .chain(CSKY_FEATURES)
986 .chain(LOONGARCH_FEATURES)
987 .chain(IBMZ_FEATURES)
988 .chain(SPARC_FEATURES)
989 .chain(M68K_FEATURES)
990 .chain(AVR_FEATURES)
991 .cloned()
992 .map(|(f, s, _)| (f, s))
993}
994
995const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
999 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1001 &[(128, "neon")];
1002
1003const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1005 &[(128, "neon")];
1006
1007const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1008 &[(1024, "")];
1009const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1010 &[(128, "altivec")];
1011const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1012 &[(128, "simd128")];
1013const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1014 &[(128, "vector")];
1015const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1016 (32, "zvl32b"),
1017 (64, "zvl64b"),
1018 (128, "zvl128b"),
1019 (256, "zvl256b"),
1020 (512, "zvl512b"),
1021 (1024, "zvl1024b"),
1022 (2048, "zvl2048b"),
1023 (4096, "zvl4096b"),
1024 (8192, "zvl8192b"),
1025 (16384, "zvl16384b"),
1026 (32768, "zvl32768b"),
1027 (65536, "zvl65536b"),
1028];
1029const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1031 &[];
1032
1033const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
1034 (512, "hvx-length64b"), (1024, "hvx-length128b"), (2048, "hvx-length128b"), ];
1038const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1039 &[(128, "msa")];
1040const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1041 &[(128, "vdspv1")];
1042const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
1043 &[(128, "lsx"), (256, "lasx")];
1044
1045#[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)]
1046pub struct FeatureConstraints {
1047 pub required: &'static [&'static str],
1049 pub incompatible: &'static [&'static str],
1051}
1052
1053impl Target {
1054 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
1055 match &self.arch {
1056 Arch::Arm => ARM_FEATURES,
1057 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
1058 Arch::X86 | Arch::X86_64 => X86_FEATURES,
1059 Arch::Hexagon => HEXAGON_FEATURES,
1060 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
1061 Arch::Nvptx64 => NVPTX_FEATURES,
1062 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
1063 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
1064 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
1065 Arch::Bpf => BPF_FEATURES,
1066 Arch::CSky => CSKY_FEATURES,
1067 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
1068 Arch::S390x => IBMZ_FEATURES,
1069 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
1070 Arch::M68k => M68K_FEATURES,
1071 Arch::Avr => AVR_FEATURES,
1072 Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1073 }
1074 }
1075
1076 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1077 match &self.arch {
1078 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1079 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1080 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1081 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1082 Arch::LoongArch32 | Arch::LoongArch64 => {
1083 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1084 }
1085 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1086 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1087 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1088 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1089 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1090 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1091 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1092 }
1093 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1094 Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1096 Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1099 }
1100 }
1101
1102 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1103 match &self.arch {
1104 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1105 _ => None,
1107 }
1108 }
1109
1110 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1111 match &self.arch {
1112 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1113 _ => &[],
1114 }
1115 }
1116
1117 pub fn implied_target_features<'a>(&self, base_feature: &'a str) -> FxHashSet<&'a str> {
1119 let implied_features =
1120 self.rust_target_features().iter().map(|(f, _, i)| (f, i)).collect::<FxHashMap<_, _>>();
1121
1122 let mut features = FxHashSet::default();
1125 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];
1126 while let Some(new_feature) = new_features.pop() {
1127 if features.insert(new_feature) {
1128 if let Some(implied_features) = implied_features.get(&new_feature) {
1129 new_features.extend(implied_features.iter().copied())
1130 }
1131 }
1132 }
1133 features
1134 }
1135
1136 pub fn abi_required_features(&self) -> FeatureConstraints {
1147 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1148 match &self.arch {
1153 Arch::X86 => {
1154 match self.rustc_abi {
1157 None => {
1158 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1161 }
1162 Some(RustcAbi::X86Sse2) => {
1163 FeatureConstraints {
1165 required: &["x87", "sse2"],
1166 incompatible: &["soft-float"],
1167 }
1168 }
1169 Some(RustcAbi::Softfloat) => {
1170 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1175 }
1176 }
1177 }
1178 Arch::X86_64 => {
1179 match self.rustc_abi {
1182 None => {
1183 FeatureConstraints {
1185 required: &["x87", "sse2"],
1186 incompatible: &["soft-float"],
1187 }
1188 }
1189 Some(RustcAbi::Softfloat) => {
1190 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1195 }
1196 Some(r) => {
::core::panicking::panic_fmt(format_args!("invalid Rust ABI for x86_64: {0:?}",
r));
}panic!("invalid Rust ABI for x86_64: {r:?}"),
1197 }
1198 }
1199 Arch::Arm => {
1200 match self.llvm_floatabi.unwrap() {
1203 FloatAbi::Soft => {
1204 NOTHING
1209 }
1210 FloatAbi::Hard => {
1211 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1213 }
1214 }
1215 }
1216 Arch::AArch64 | Arch::Arm64EC => {
1217 match self.rustc_abi {
1220 Some(RustcAbi::Softfloat) => {
1221 FeatureConstraints { required: &[], incompatible: &["neon"] }
1227 }
1228 None => {
1229 FeatureConstraints { required: &["neon"], incompatible: &[] }
1232 }
1233 Some(r) => {
::core::panicking::panic_fmt(format_args!("invalid Rust ABI for aarch64: {0:?}",
r));
}panic!("invalid Rust ABI for aarch64: {r:?}"),
1234 }
1235 }
1236 Arch::RiscV32 | Arch::RiscV64 => {
1237 match &self.llvm_abiname {
1240 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1241 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1243 }
1244 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1245 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1247 }
1248 LlvmAbi::Ilp32 | LlvmAbi::Lp64 => {
1249 FeatureConstraints { required: &[], incompatible: &["e"] }
1251 }
1252 LlvmAbi::Ilp32e => {
1253 FeatureConstraints { required: &[], incompatible: &["d"] }
1262 }
1263 LlvmAbi::Lp64e => {
1264 NOTHING
1266 }
1267 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1268 }
1269 }
1270 Arch::LoongArch32 | Arch::LoongArch64 => {
1271 match &self.llvm_abiname {
1274 LlvmAbi::Ilp32d | LlvmAbi::Lp64d => {
1275 FeatureConstraints { required: &["d"], incompatible: &[] }
1277 }
1278 LlvmAbi::Ilp32f | LlvmAbi::Lp64f => {
1279 FeatureConstraints { required: &["f"], incompatible: &[] }
1281 }
1282 LlvmAbi::Ilp32s | LlvmAbi::Lp64s => {
1283 NOTHING
1288 }
1289 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1290 }
1291 }
1292 Arch::S390x => {
1293 match self.rustc_abi {
1301 None => {
1302 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1304 }
1305 Some(RustcAbi::Softfloat) => {
1306 FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] }
1309 }
1310 Some(r) => {
1311 {
::core::panicking::panic_fmt(format_args!("invalid Rust ABI for s390x: {0:?}",
r));
};panic!("invalid Rust ABI for s390x: {r:?}");
1312 }
1313 }
1314 }
1315 Arch::Avr => {
1316 FeatureConstraints { required: &["sram"], incompatible: &[] }
1321 }
1322 Arch::Wasm32 | Arch::Wasm64 => {
1323 NOTHING
1326 }
1327 _ => NOTHING,
1328 }
1329 }
1330}