1use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6use rustc_span::{Symbol, sym};
7
8use crate::spec::{Abi, Arch, FloatAbi, 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::Unstable(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Unstable", &__self_0),
Stability::Forbidden { reason: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Forbidden", "reason", &__self_0),
}
}
}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>;
*self
}
}Clone)]
16pub enum Stability {
17 Stable,
20 Unstable(
23 Symbol,
26 ),
27 Forbidden { reason: &'static str },
32}
33use Stability::*;
34
35impl<CTX> HashStable<CTX> for Stability {
36 #[inline]
37 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
38 std::mem::discriminant(self).hash_stable(hcx, hasher);
39 match self {
40 Stability::Stable => {}
41 Stability::Unstable(nightly_feature) => {
42 nightly_feature.hash_stable(hcx, hasher);
43 }
44 Stability::Forbidden { reason } => {
45 reason.hash_stable(hcx, hasher);
46 }
47 }
48 }
49}
50
51impl Stability {
52 pub fn in_cfg(&self) -> bool {
56 #[allow(non_exhaustive_omitted_patterns)] match self {
Stability::Stable | Stability::Unstable { .. } => true,
_ => false,
}matches!(self, Stability::Stable | Stability::Unstable { .. })
57 }
58
59 pub fn requires_nightly(&self) -> Option<Symbol> {
68 match *self {
69 Stability::Unstable(nightly_feature) => Some(nightly_feature),
70 Stability::Stable { .. } => None,
71 Stability::Forbidden { .. } => {
::core::panicking::panic_fmt(format_args!("forbidden features should not reach this far"));
}panic!("forbidden features should not reach this far"),
72 }
73 }
74
75 pub fn toggle_allowed(&self) -> Result<(), &'static str> {
79 match self {
80 Stability::Unstable(_) | Stability::Stable { .. } => Ok(()),
81 Stability::Forbidden { reason } => Err(reason),
82 }
83 }
84}
85
86type ImpliedFeatures = &'static [&'static str];
131
132static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
133 ("aclass", Unstable(sym::arm_target_feature), &[]),
135 ("aes", Unstable(sym::arm_target_feature), &["neon"]),
136 (
137 "atomics-32",
138 Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
139 &[],
140 ),
141 ("crc", Unstable(sym::arm_target_feature), &[]),
142 ("d32", Unstable(sym::arm_target_feature), &[]),
143 ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
144 ("dsp", Unstable(sym::arm_target_feature), &[]),
145 ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
146 ("fp16", Unstable(sym::arm_target_feature), &["neon"]),
147 ("fpregs", Unstable(sym::arm_target_feature), &[]),
148 ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
149 ("mclass", Unstable(sym::arm_target_feature), &[]),
150 ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
151 ("rclass", Unstable(sym::arm_target_feature), &[]),
152 ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
153 ("soft-float", Unstable(sym::arm_target_feature), &[]),
158 ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
162 ("thumb2", Unstable(sym::arm_target_feature), &[]),
163 ("trustzone", Unstable(sym::arm_target_feature), &[]),
164 ("v5te", Unstable(sym::arm_target_feature), &[]),
165 ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
166 ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
167 ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "thumb2"]),
168 ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
169 ("v8", Unstable(sym::arm_target_feature), &["v7"]),
170 ("vfp2", Unstable(sym::arm_target_feature), &[]),
171 ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
172 ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
173 ("virtualization", Unstable(sym::arm_target_feature), &[]),
174 ];
176
177static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
178 ("aes", Stable, &["neon"]),
181 ("bf16", Stable, &[]),
183 ("bti", Stable, &[]),
185 ("crc", Stable, &[]),
187 ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
189 ("dit", Stable, &[]),
191 ("dotprod", Stable, &["neon"]),
193 ("dpb", Stable, &[]),
195 ("dpb2", Stable, &["dpb"]),
197 ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
199 ("f32mm", Stable, &["sve"]),
201 ("f64mm", Stable, &["sve"]),
203 ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
205 ("fcma", Stable, &["neon"]),
207 ("fhm", Stable, &["fp16"]),
209 ("flagm", Stable, &[]),
211 ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
213 ("fp-armv8", Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`" }, &[]),
215 ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
217 ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
219 ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
221 ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
223 ("fp16", Stable, &["neon"]),
226 ("frintts", Stable, &[]),
228 ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
230 ("i8mm", Stable, &[]),
232 ("jsconv", Stable, &["neon"]),
235 ("lor", Stable, &[]),
237 ("lse", Stable, &[]),
239 ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
241 ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
243 ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
245 ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
247 ("mte", Stable, &[]),
249 ("neon", Stable, &[]),
251 ("outline-atomics", Unstable(sym::aarch64_unstable_target_feature), &[]),
255 ("paca", Stable, &[]),
257 ("pacg", Stable, &[]),
259 ("pan", Stable, &[]),
261 ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
263 ("pmuv3", Stable, &[]),
265 ("rand", Stable, &[]),
267 ("ras", Stable, &[]),
269 ("rcpc", Stable, &[]),
271 ("rcpc2", Stable, &["rcpc"]),
273 ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
275 ("rdm", Stable, &["neon"]),
277 ("reserve-x18", Forbidden { reason: "use `-Zfixed-x18` compiler flag instead" }, &[]),
278 ("sb", Stable, &[]),
280 ("sha2", Stable, &["neon"]),
282 ("sha3", Stable, &["sha2"]),
284 ("sm4", Stable, &["neon"]),
286 ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
288 ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
290 ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
292 ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
294 ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
296 ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
298 ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
300 ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
302 ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
304 ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
306 ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
308 ("spe", Stable, &[]),
310 ("ssbs", Stable, &[]),
312 ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
314 ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
316 ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
318 ("sve", Stable, &["neon"]),
326 ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
328 ("sve2", Stable, &["sve"]),
330 ("sve2-aes", Stable, &["sve2", "aes"]),
332 ("sve2-bitperm", Stable, &["sve2"]),
334 ("sve2-sha3", Stable, &["sve2", "sha3"]),
336 ("sve2-sm4", Stable, &["sve2", "sm4"]),
338 ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
340 ("tme", Stable, &[]),
342 (
343 "v8.1a",
344 Unstable(sym::aarch64_ver_target_feature),
345 &["crc", "lse", "rdm", "pan", "lor", "vh"],
346 ),
347 ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
348 (
349 "v8.3a",
350 Unstable(sym::aarch64_ver_target_feature),
351 &["v8.2a", "rcpc", "paca", "pacg", "jsconv"],
352 ),
353 ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
354 ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
355 ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
356 ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
357 ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
358 ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
359 ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
360 ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
361 ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
362 ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
363 ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
364 ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
365 ("vh", Stable, &[]),
367 ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
369 ];
371
372const AARCH64_TIED_FEATURES: &[&[&str]] = &[
373 &["paca", "pacg"], ];
375
376static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
377 ("adx", Stable, &[]),
379 ("aes", Stable, &["sse2"]),
380 ("amx-avx512", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
381 ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
382 ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
383 ("amx-fp8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
384 ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
385 ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
386 ("amx-movrs", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
387 ("amx-tf32", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
388 ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
389 ("apxf", Unstable(sym::apx_target_feature), &[]),
390 ("avx", Stable, &["sse4.2"]),
391 ("avx2", Stable, &["avx"]),
392 (
393 "avx10.1",
394 Unstable(sym::avx10_target_feature),
395 &[
396 "avx512bf16",
397 "avx512bitalg",
398 "avx512bw",
399 "avx512cd",
400 "avx512dq",
401 "avx512f",
402 "avx512fp16",
403 "avx512ifma",
404 "avx512vbmi",
405 "avx512vbmi2",
406 "avx512vl",
407 "avx512vnni",
408 "avx512vpopcntdq",
409 ],
410 ),
411 ("avx10.2", Unstable(sym::avx10_target_feature), &["avx10.1"]),
412 ("avx512bf16", Stable, &["avx512bw"]),
413 ("avx512bitalg", Stable, &["avx512bw"]),
414 ("avx512bw", Stable, &["avx512f"]),
415 ("avx512cd", Stable, &["avx512f"]),
416 ("avx512dq", Stable, &["avx512f"]),
417 ("avx512f", Stable, &["avx2", "fma", "f16c"]),
418 ("avx512fp16", Stable, &["avx512bw"]),
419 ("avx512ifma", Stable, &["avx512f"]),
420 ("avx512vbmi", Stable, &["avx512bw"]),
421 ("avx512vbmi2", Stable, &["avx512bw"]),
422 ("avx512vl", Stable, &["avx512f"]),
423 ("avx512vnni", Stable, &["avx512f"]),
424 ("avx512vp2intersect", Stable, &["avx512f"]),
425 ("avx512vpopcntdq", Stable, &["avx512f"]),
426 ("avxifma", Stable, &["avx2"]),
427 ("avxneconvert", Stable, &["avx2"]),
428 ("avxvnni", Stable, &["avx2"]),
429 ("avxvnniint8", Stable, &["avx2"]),
430 ("avxvnniint16", Stable, &["avx2"]),
431 ("bmi1", Stable, &[]),
432 ("bmi2", Stable, &[]),
433 ("cmpxchg16b", Stable, &[]),
434 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
435 ("f16c", Stable, &["avx"]),
436 ("fma", Stable, &["avx"]),
437 ("fxsr", Stable, &[]),
438 ("gfni", Stable, &["sse2"]),
439 ("kl", Stable, &["sse2"]),
440 ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
441 ("lzcnt", Stable, &[]),
442 ("movbe", Stable, &[]),
443 ("movrs", Unstable(sym::movrs_target_feature), &[]),
444 ("pclmulqdq", Stable, &["sse2"]),
445 ("popcnt", Stable, &[]),
446 ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
447 ("rdrand", Stable, &[]),
448 ("rdseed", Stable, &[]),
449 (
450 "retpoline-external-thunk",
451 Stability::Forbidden { reason: "use `-Zretpoline-external-thunk` compiler flag instead" },
452 &[],
453 ),
454 (
455 "retpoline-indirect-branches",
456 Stability::Forbidden { reason: "use `-Zretpoline` compiler flag instead" },
457 &[],
458 ),
459 (
460 "retpoline-indirect-calls",
461 Stability::Forbidden { reason: "use `-Zretpoline` compiler flag instead" },
462 &[],
463 ),
464 ("rtm", Unstable(sym::rtm_target_feature), &[]),
465 ("sha", Stable, &["sse2"]),
466 ("sha512", Stable, &["avx2"]),
467 ("sm3", Stable, &["avx"]),
468 ("sm4", Stable, &["avx2"]),
469 ("soft-float", Stability::Forbidden { reason: "use a soft-float target instead" }, &[]),
470 ("sse", Stable, &[]),
471 ("sse2", Stable, &["sse"]),
472 ("sse3", Stable, &["sse2"]),
473 ("sse4.1", Stable, &["ssse3"]),
474 ("sse4.2", Stable, &["sse4.1"]),
475 ("sse4a", Stable, &["sse3"]),
476 ("ssse3", Stable, &["sse3"]),
477 ("tbm", Stable, &[]),
478 ("vaes", Stable, &["avx2", "aes"]),
479 ("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
480 ("widekl", Stable, &["kl"]),
481 ("x87", Unstable(sym::x87_target_feature), &[]),
482 ("xop", Unstable(sym::xop_target_feature), &["avx", "sse4a"]),
483 ("xsave", Stable, &[]),
484 ("xsavec", Stable, &["xsave"]),
485 ("xsaveopt", Stable, &["xsave"]),
486 ("xsaves", Stable, &["xsave"]),
487 ];
489
490const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
491 ("hvx", Unstable(sym::hexagon_target_feature), &[]),
493 ("hvx-ieee-fp", Unstable(sym::hexagon_target_feature), &["hvx"]),
494 ("hvx-length64b", Unstable(sym::hexagon_target_feature), &["hvx"]),
495 ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
496 ("hvx-qfloat", Unstable(sym::hexagon_target_feature), &["hvx"]),
497 ("hvxv60", Unstable(sym::hexagon_target_feature), &["hvx"]),
498 ("hvxv62", Unstable(sym::hexagon_target_feature), &["hvxv60"]),
499 ("hvxv65", Unstable(sym::hexagon_target_feature), &["hvxv62"]),
500 ("hvxv66", Unstable(sym::hexagon_target_feature), &["hvxv65", "zreg"]),
501 ("hvxv67", Unstable(sym::hexagon_target_feature), &["hvxv66"]),
502 ("hvxv68", Unstable(sym::hexagon_target_feature), &["hvxv67"]),
503 ("hvxv69", Unstable(sym::hexagon_target_feature), &["hvxv68"]),
504 ("hvxv71", Unstable(sym::hexagon_target_feature), &["hvxv69"]),
505 ("hvxv73", Unstable(sym::hexagon_target_feature), &["hvxv71"]),
506 ("hvxv75", Unstable(sym::hexagon_target_feature), &["hvxv73"]),
507 ("hvxv79", Unstable(sym::hexagon_target_feature), &["hvxv75"]),
508 ("zreg", Unstable(sym::hexagon_target_feature), &[]),
509 ];
511
512static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
513 ("altivec", Unstable(sym::powerpc_target_feature), &[]),
515 ("msync", Unstable(sym::powerpc_target_feature), &[]),
516 ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
517 ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
518 ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
519 ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
520 ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
521 ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
522 ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
523 ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
524 ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
525 ];
527
528const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
529 ("fp64", Unstable(sym::mips_target_feature), &[]),
531 ("msa", Unstable(sym::mips_target_feature), &[]),
532 ("virt", Unstable(sym::mips_target_feature), &[]),
533 ];
535
536const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
537 ("sm_20", Unstable(sym::nvptx_target_feature), &[]),
539 ("sm_21", Unstable(sym::nvptx_target_feature), &["sm_20"]),
540 ("sm_30", Unstable(sym::nvptx_target_feature), &["sm_21"]),
541 ("sm_32", Unstable(sym::nvptx_target_feature), &["sm_30"]),
542 ("sm_35", Unstable(sym::nvptx_target_feature), &["sm_32"]),
543 ("sm_37", Unstable(sym::nvptx_target_feature), &["sm_35"]),
544 ("sm_50", Unstable(sym::nvptx_target_feature), &["sm_37"]),
545 ("sm_52", Unstable(sym::nvptx_target_feature), &["sm_50"]),
546 ("sm_53", Unstable(sym::nvptx_target_feature), &["sm_52"]),
547 ("sm_60", Unstable(sym::nvptx_target_feature), &["sm_53"]),
548 ("sm_61", Unstable(sym::nvptx_target_feature), &["sm_60"]),
549 ("sm_62", Unstable(sym::nvptx_target_feature), &["sm_61"]),
550 ("sm_70", Unstable(sym::nvptx_target_feature), &["sm_62"]),
551 ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
552 ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
553 ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
554 ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
555 ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
556 ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
557 ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
558 ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
559 ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
562 ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
563 ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
564 ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
565 ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
566 ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
567 ("ptx32", Unstable(sym::nvptx_target_feature), &[]),
570 ("ptx40", Unstable(sym::nvptx_target_feature), &["ptx32"]),
571 ("ptx41", Unstable(sym::nvptx_target_feature), &["ptx40"]),
572 ("ptx42", Unstable(sym::nvptx_target_feature), &["ptx41"]),
573 ("ptx43", Unstable(sym::nvptx_target_feature), &["ptx42"]),
574 ("ptx50", Unstable(sym::nvptx_target_feature), &["ptx43"]),
575 ("ptx60", Unstable(sym::nvptx_target_feature), &["ptx50"]),
576 ("ptx61", Unstable(sym::nvptx_target_feature), &["ptx60"]),
577 ("ptx62", Unstable(sym::nvptx_target_feature), &["ptx61"]),
578 ("ptx63", Unstable(sym::nvptx_target_feature), &["ptx62"]),
579 ("ptx64", Unstable(sym::nvptx_target_feature), &["ptx63"]),
580 ("ptx65", Unstable(sym::nvptx_target_feature), &["ptx64"]),
581 ("ptx70", Unstable(sym::nvptx_target_feature), &["ptx65"]),
582 ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
583 ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
584 ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
585 ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
586 ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
587 ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
588 ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
589 ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
590 ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
591 ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
592 ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
593 ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
594 ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
595 ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
596 ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
597 ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
598 ];
600
601static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
602 ("a", Stable, &["zaamo", "zalrsc"]),
604 ("b", Stable, &["zba", "zbb", "zbs"]),
605 ("c", Stable, &["zca"]),
606 ("d", Unstable(sym::riscv_target_feature), &["f"]),
607 ("e", Unstable(sym::riscv_target_feature), &[]),
608 ("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
609 (
610 "forced-atomics",
611 Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
612 &[],
613 ),
614 ("m", Stable, &[]),
615 ("relax", Unstable(sym::riscv_target_feature), &[]),
616 (
617 "rva23u64",
618 Unstable(sym::riscv_target_feature),
619 &[
620 "m",
621 "a",
622 "f",
623 "d",
624 "c",
625 "b",
626 "v",
627 "zicsr",
628 "zicntr",
629 "zihpm",
630 "ziccif",
631 "ziccrse",
632 "ziccamoa",
633 "zicclsm",
634 "zic64b",
635 "za64rs",
636 "zihintpause",
637 "zba",
638 "zbb",
639 "zbs",
640 "zicbom",
641 "zicbop",
642 "zicboz",
643 "zfhmin",
644 "zkt",
645 "zvfhmin",
646 "zvbb",
647 "zvkt",
648 "zihintntl",
649 "zicond",
650 "zimop",
651 "zcmop",
652 "zcb",
653 "zfa",
654 "zawrs",
655 "supm",
656 ],
657 ),
658 ("supm", Unstable(sym::riscv_target_feature), &[]),
659 ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
660 ("unaligned-vector-mem", Unstable(sym::riscv_target_feature), &[]),
661 ("v", Unstable(sym::riscv_target_feature), &["zvl128b", "zve64d"]),
662 ("za64rs", Stable, &["za128rs"]), ("za128rs", Stable, &[]),
664 ("zaamo", Stable, &[]),
665 ("zabha", Stable, &["zaamo"]),
666 ("zacas", Stable, &["zaamo"]),
667 ("zalrsc", Stable, &[]),
668 ("zama16b", Stable, &[]),
669 ("zawrs", Stable, &[]),
670 ("zba", Stable, &[]),
671 ("zbb", Stable, &[]),
672 ("zbc", Stable, &["zbkc"]), ("zbkb", Stable, &[]),
674 ("zbkc", Stable, &[]),
675 ("zbkx", Stable, &[]),
676 ("zbs", Stable, &[]),
677 ("zca", Stable, &[]),
678 ("zcb", Stable, &["zca"]),
679 ("zcmop", Stable, &["zca"]),
680 ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
681 ("zfa", Unstable(sym::riscv_target_feature), &["f"]),
682 ("zfbfmin", Unstable(sym::riscv_target_feature), &["f"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
684 ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
685 ("zfinx", Unstable(sym::riscv_target_feature), &["zicsr"]),
686 ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
687 ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
688 ("zic64b", Stable, &[]),
689 ("zicbom", Stable, &[]),
690 ("zicbop", Stable, &[]),
691 ("zicboz", Stable, &[]),
692 ("ziccamoa", Stable, &[]),
693 ("ziccif", Stable, &[]),
694 ("zicclsm", Stable, &[]),
695 ("ziccrse", Stable, &[]),
696 ("zicntr", Stable, &["zicsr"]),
697 ("zicond", Stable, &[]),
698 ("zicsr", Stable, &[]),
699 ("zifencei", Stable, &[]),
700 ("zihintntl", Stable, &[]),
701 ("zihintpause", Stable, &[]),
702 ("zihpm", Stable, &["zicsr"]),
703 ("zimop", Stable, &[]),
704 ("zk", Stable, &["zkn", "zkr", "zkt"]),
705 ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
706 ("zknd", Stable, &["zkne_or_zknd"]),
707 ("zkne", Stable, &["zkne_or_zknd"]),
708 ("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), ("zknh", Stable, &[]),
710 ("zkr", Stable, &[]),
711 ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
712 ("zksed", Stable, &[]),
713 ("zksh", Stable, &[]),
714 ("zkt", Stable, &[]),
715 ("ztso", Stable, &[]),
716 ("zvbb", Unstable(sym::riscv_target_feature), &["zvkb"]), ("zvbc", Unstable(sym::riscv_target_feature), &["zve64x"]),
718 ("zve32f", Unstable(sym::riscv_target_feature), &["zve32x", "f"]),
719 ("zve32x", Unstable(sym::riscv_target_feature), &["zvl32b", "zicsr"]),
720 ("zve64d", Unstable(sym::riscv_target_feature), &["zve64f", "d"]),
721 ("zve64f", Unstable(sym::riscv_target_feature), &["zve32f", "zve64x"]),
722 ("zve64x", Unstable(sym::riscv_target_feature), &["zve32x", "zvl64b"]),
723 ("zvfbfmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
724 ("zvfbfwma", Unstable(sym::riscv_target_feature), &["zfbfmin", "zvfbfmin"]),
725 ("zvfh", Unstable(sym::riscv_target_feature), &["zvfhmin", "zve32f", "zfhmin"]), ("zvfhmin", Unstable(sym::riscv_target_feature), &["zve32f"]),
727 ("zvkb", Unstable(sym::riscv_target_feature), &["zve32x"]),
728 ("zvkg", Unstable(sym::riscv_target_feature), &["zve32x"]),
729 ("zvkn", Unstable(sym::riscv_target_feature), &["zvkned", "zvknhb", "zvkb", "zvkt"]),
730 ("zvknc", Unstable(sym::riscv_target_feature), &["zvkn", "zvbc"]),
731 ("zvkned", Unstable(sym::riscv_target_feature), &["zve32x"]),
732 ("zvkng", Unstable(sym::riscv_target_feature), &["zvkn", "zvkg"]),
733 ("zvknha", Unstable(sym::riscv_target_feature), &["zve32x"]),
734 ("zvknhb", Unstable(sym::riscv_target_feature), &["zvknha", "zve64x"]), ("zvks", Unstable(sym::riscv_target_feature), &["zvksed", "zvksh", "zvkb", "zvkt"]),
736 ("zvksc", Unstable(sym::riscv_target_feature), &["zvks", "zvbc"]),
737 ("zvksed", Unstable(sym::riscv_target_feature), &["zve32x"]),
738 ("zvksg", Unstable(sym::riscv_target_feature), &["zvks", "zvkg"]),
739 ("zvksh", Unstable(sym::riscv_target_feature), &["zve32x"]),
740 ("zvkt", Unstable(sym::riscv_target_feature), &[]),
741 ("zvl32b", Unstable(sym::riscv_target_feature), &[]),
742 ("zvl64b", Unstable(sym::riscv_target_feature), &["zvl32b"]),
743 ("zvl128b", Unstable(sym::riscv_target_feature), &["zvl64b"]),
744 ("zvl256b", Unstable(sym::riscv_target_feature), &["zvl128b"]),
745 ("zvl512b", Unstable(sym::riscv_target_feature), &["zvl256b"]),
746 ("zvl1024b", Unstable(sym::riscv_target_feature), &["zvl512b"]),
747 ("zvl2048b", Unstable(sym::riscv_target_feature), &["zvl1024b"]),
748 ("zvl4096b", Unstable(sym::riscv_target_feature), &["zvl2048b"]),
749 ("zvl8192b", Unstable(sym::riscv_target_feature), &["zvl4096b"]),
750 ("zvl16384b", Unstable(sym::riscv_target_feature), &["zvl8192b"]),
751 ("zvl32768b", Unstable(sym::riscv_target_feature), &["zvl16384b"]),
752 ("zvl65536b", Unstable(sym::riscv_target_feature), &["zvl32768b"]),
753 ];
755
756static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
757 ("atomics", Unstable(sym::wasm_target_feature), &[]),
759 ("bulk-memory", Stable, &[]),
760 ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
761 ("extended-const", Stable, &[]),
762 ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]),
763 ("multivalue", Stable, &[]),
764 ("mutable-globals", Stable, &[]),
765 ("nontrapping-fptoint", Stable, &[]),
766 ("reference-types", Stable, &[]),
767 ("relaxed-simd", Stable, &["simd128"]),
768 ("sign-ext", Stable, &[]),
769 ("simd128", Stable, &[]),
770 ("tail-call", Stable, &[]),
771 ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
772 ];
774
775const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] =
776 &[("alu32", Unstable(sym::bpf_target_feature), &[])];
777
778static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
779 ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
781 ("3e3r1", Unstable(sym::csky_target_feature), &[]),
782 ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
783 ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
784 ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
785 ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
786 ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
787 ("cache", Unstable(sym::csky_target_feature), &[]),
788 ("doloop", Unstable(sym::csky_target_feature), &[]),
789 ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
790 ("dspe60", Unstable(sym::csky_target_feature), &[]),
791 ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
792 ("e2", Unstable(sym::csky_target_feature), &["e2"]),
793 ("edsp", Unstable(sym::csky_target_feature), &[]),
794 ("elrw", Unstable(sym::csky_target_feature), &[]),
795 ("float1e2", Unstable(sym::csky_target_feature), &[]),
796 ("float1e3", Unstable(sym::csky_target_feature), &[]),
797 ("float3e4", Unstable(sym::csky_target_feature), &[]),
798 ("float7e60", Unstable(sym::csky_target_feature), &[]),
799 ("floate1", Unstable(sym::csky_target_feature), &[]),
800 ("hard-tp", Unstable(sym::csky_target_feature), &[]),
801 ("high-registers", Unstable(sym::csky_target_feature), &[]),
802 ("hwdiv", Unstable(sym::csky_target_feature), &[]),
803 ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
804 ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
805 ("nvic", Unstable(sym::csky_target_feature), &[]),
806 ("trust", Unstable(sym::csky_target_feature), &[]),
807 ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
808 ("vdspv1", Unstable(sym::csky_target_feature), &[]),
809 ("vdspv2", Unstable(sym::csky_target_feature), &[]),
810 ("fdivdu", Unstable(sym::csky_target_feature), &[]),
814 ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
815 ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
816 ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
817 ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
818 ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
819 ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
820 ("hard-float", Unstable(sym::csky_target_feature), &[]),
821 ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
822 ];
824
825static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
826 ("32s", Unstable(sym::loongarch_target_feature), &[]),
828 ("d", Stable, &["f"]),
829 ("div32", Unstable(sym::loongarch_target_feature), &[]),
830 ("f", Stable, &[]),
831 ("frecipe", Stable, &[]),
832 ("lam-bh", Unstable(sym::loongarch_target_feature), &[]),
833 ("lamcas", Unstable(sym::loongarch_target_feature), &[]),
834 ("lasx", Stable, &["lsx"]),
835 ("lbt", Stable, &[]),
836 ("ld-seq-sa", Unstable(sym::loongarch_target_feature), &[]),
837 ("lsx", Stable, &["d"]),
838 ("lvz", Stable, &[]),
839 ("relax", Unstable(sym::loongarch_target_feature), &[]),
840 ("scq", Unstable(sym::loongarch_target_feature), &[]),
841 ("ual", Unstable(sym::loongarch_target_feature), &[]),
842 ];
844
845#[rustfmt::skip]
846const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
847 ("backchain", Unstable(sym::s390x_target_feature), &[]),
850 ("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
851 ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
852 ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
853 ("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
854 ("high-word", Unstable(sym::s390x_target_feature), &[]),
855 ("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
857 ("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
858 ("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
859 ("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
860 ("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
861 ("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
862 ("miscellaneous-extensions-2", Stable, &[]),
863 ("miscellaneous-extensions-3", Stable, &[]),
864 ("miscellaneous-extensions-4", Stable, &[]),
865 ("nnp-assist", Stable, &["vector"]),
866 ("soft-float", Forbidden { reason: "currently unsupported ABI-configuration feature" }, &[]),
867 ("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
868 ("vector", Stable, &[]),
869 ("vector-enhancements-1", Stable, &["vector"]),
870 ("vector-enhancements-2", Stable, &["vector-enhancements-1"]),
871 ("vector-enhancements-3", Stable, &["vector-enhancements-2"]),
872 ("vector-packed-decimal", Stable, &["vector"]),
873 ("vector-packed-decimal-enhancement", Stable, &["vector-packed-decimal"]),
874 ("vector-packed-decimal-enhancement-2", Stable, &["vector-packed-decimal-enhancement"]),
875 ("vector-packed-decimal-enhancement-3", Stable, &["vector-packed-decimal-enhancement-2"]),
876 ];
878
879const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
880 ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
882 ("v8plus", Unstable(sym::sparc_target_feature), &[]),
883 ("v9", Unstable(sym::sparc_target_feature), &[]),
884 ];
886
887static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
888 ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
890 ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
891 ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
892 ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
893 ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
894 ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
895 ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
897 ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
898 ];
900
901pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
906 std::iter::empty()
907 .chain(ARM_FEATURES.iter())
908 .chain(AARCH64_FEATURES.iter())
909 .chain(X86_FEATURES.iter())
910 .chain(HEXAGON_FEATURES.iter())
911 .chain(POWERPC_FEATURES.iter())
912 .chain(MIPS_FEATURES.iter())
913 .chain(NVPTX_FEATURES.iter())
914 .chain(RISCV_FEATURES.iter())
915 .chain(WASM_FEATURES.iter())
916 .chain(BPF_FEATURES.iter())
917 .chain(CSKY_FEATURES)
918 .chain(LOONGARCH_FEATURES)
919 .chain(IBMZ_FEATURES)
920 .chain(SPARC_FEATURES)
921 .chain(M68K_FEATURES)
922 .cloned()
923 .map(|(f, s, _)| (f, s))
924}
925
926const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
930 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
932 &[(128, "neon")];
933
934const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
936 &[(128, "neon")];
937
938const AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
939 &[(1024, "")];
940const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
941 &[(128, "altivec")];
942const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
943 &[(128, "simd128")];
944const S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
945 &[(128, "vector")];
946const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
947 (32, "zvl32b"),
948 (64, "zvl64b"),
949 (128, "zvl128b"),
950 (256, "zvl256b"),
951 (512, "zvl512b"),
952 (1024, "zvl1024b"),
953 (2048, "zvl2048b"),
954 (4096, "zvl4096b"),
955 (8192, "zvl8192b"),
956 (16384, "zvl16384b"),
957 (32768, "zvl32768b"),
958 (65536, "zvl65536b"),
959];
960const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
962 &[];
963
964const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
965 &[(512, "hvx-length64b"), (1024, "hvx-length128b")];
966const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
967 &[(128, "msa")];
968const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
969 &[(128, "vdspv1")];
970const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
971 &[(128, "lsx"), (256, "lasx")];
972
973#[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)]
974pub struct FeatureConstraints {
975 pub required: &'static [&'static str],
977 pub incompatible: &'static [&'static str],
979}
980
981impl Target {
982 pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
983 match &self.arch {
984 Arch::Arm => ARM_FEATURES,
985 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES,
986 Arch::X86 | Arch::X86_64 => X86_FEATURES,
987 Arch::Hexagon => HEXAGON_FEATURES,
988 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES,
989 Arch::Nvptx64 => NVPTX_FEATURES,
990 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES,
991 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES,
992 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES,
993 Arch::Bpf => BPF_FEATURES,
994 Arch::CSky => CSKY_FEATURES,
995 Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES,
996 Arch::S390x => IBMZ_FEATURES,
997 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
998 Arch::M68k => M68K_FEATURES,
999 Arch::AmdGpu
1000 | Arch::Avr
1001 | Arch::Msp430
1002 | Arch::SpirV
1003 | Arch::Xtensa
1004 | Arch::Other(_) => &[],
1005 }
1006 }
1007
1008 pub fn features_for_correct_fixed_length_vector_abi(&self) -> &'static [(u64, &'static str)] {
1009 match &self.arch {
1010 Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1011 Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1012 Arch::Arm => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1013 Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1014 Arch::LoongArch32 | Arch::LoongArch64 => {
1015 LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1016 }
1017 Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1018 Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1019 Arch::S390x => S390X_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1020 Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1021 Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1022 Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => {
1023 MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
1024 }
1025 Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1026 Arch::Nvptx64 | Arch::Bpf | Arch::M68k => &[], Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
1028 Arch::Avr | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
1031 }
1032 }
1033
1034 pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
1035 match &self.arch {
1036 Arch::AArch64 | Arch::Arm64EC => Some("sve"),
1037 _ => None,
1039 }
1040 }
1041
1042 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
1043 match &self.arch {
1044 Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES,
1045 _ => &[],
1046 }
1047 }
1048
1049 pub fn implied_target_features<'a>(&self, base_feature: &'a str) -> FxHashSet<&'a str> {
1051 let implied_features =
1052 self.rust_target_features().iter().map(|(f, _, i)| (f, i)).collect::<FxHashMap<_, _>>();
1053
1054 let mut features = FxHashSet::default();
1057 let mut new_features = <[_]>::into_vec(::alloc::boxed::box_new([base_feature]))vec![base_feature];
1058 while let Some(new_feature) = new_features.pop() {
1059 if features.insert(new_feature) {
1060 if let Some(implied_features) = implied_features.get(&new_feature) {
1061 new_features.extend(implied_features.iter().copied())
1062 }
1063 }
1064 }
1065 features
1066 }
1067
1068 pub fn abi_required_features(&self) -> FeatureConstraints {
1079 const NOTHING: FeatureConstraints = FeatureConstraints { required: &[], incompatible: &[] };
1080 match &self.arch {
1085 Arch::X86 => {
1086 match self.rustc_abi {
1089 None => {
1090 FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
1093 }
1094 Some(RustcAbi::X86Sse2) => {
1095 FeatureConstraints {
1097 required: &["x87", "sse2"],
1098 incompatible: &["soft-float"],
1099 }
1100 }
1101 Some(RustcAbi::X86Softfloat) => {
1102 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1107 }
1108 }
1109 }
1110 Arch::X86_64 => {
1111 match self.rustc_abi {
1114 None => {
1115 FeatureConstraints {
1117 required: &["x87", "sse2"],
1118 incompatible: &["soft-float"],
1119 }
1120 }
1121 Some(RustcAbi::X86Softfloat) => {
1122 FeatureConstraints { required: &["soft-float"], incompatible: &[] }
1127 }
1128 Some(r) => {
::core::panicking::panic_fmt(format_args!("invalid Rust ABI for x86_64: {0:?}",
r));
}panic!("invalid Rust ABI for x86_64: {r:?}"),
1129 }
1130 }
1131 Arch::Arm => {
1132 match self.llvm_floatabi.unwrap() {
1135 FloatAbi::Soft => {
1136 NOTHING
1141 }
1142 FloatAbi::Hard => {
1143 FeatureConstraints { required: &["fpregs"], incompatible: &["soft-float"] }
1145 }
1146 }
1147 }
1148 Arch::AArch64 | Arch::Arm64EC => {
1149 if self.abi == Abi::SoftFloat {
1152 FeatureConstraints { required: &[], incompatible: &["neon"] }
1158 } else {
1159 FeatureConstraints { required: &["neon"], incompatible: &[] }
1162 }
1163 }
1164 Arch::RiscV32 | Arch::RiscV64 => {
1165 match &*self.llvm_abiname {
1168 "ilp32d" | "lp64d" => {
1169 FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
1171 }
1172 "ilp32f" | "lp64f" => {
1173 FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
1175 }
1176 "ilp32" | "lp64" => {
1177 FeatureConstraints { required: &[], incompatible: &["e"] }
1179 }
1180 "ilp32e" => {
1181 FeatureConstraints { required: &[], incompatible: &["d"] }
1190 }
1191 "lp64e" => {
1192 NOTHING
1194 }
1195 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1196 }
1197 }
1198 Arch::LoongArch32 | Arch::LoongArch64 => {
1199 match &*self.llvm_abiname {
1202 "ilp32d" | "lp64d" => {
1203 FeatureConstraints { required: &["d"], incompatible: &[] }
1205 }
1206 "ilp32f" | "lp64f" => {
1207 FeatureConstraints { required: &["f"], incompatible: &[] }
1209 }
1210 "ilp32s" | "lp64s" => {
1211 NOTHING
1216 }
1217 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1218 }
1219 }
1220 Arch::S390x => {
1221 FeatureConstraints { required: &[], incompatible: &["soft-float"] }
1226 }
1227 _ => NOTHING,
1228 }
1229 }
1230}