clean up target feature system; most of the toggleability is now handled by the ABI target feature check

This commit is contained in:
Ralf Jung 2024-12-26 18:59:19 +01:00
parent 2bf27e09be
commit cfae43d638
4 changed files with 349 additions and 438 deletions

View file

@ -728,7 +728,7 @@ pub(crate) fn global_llvm_features(
sess.dcx().emit_warn(unknown_feature); sess.dcx().emit_warn(unknown_feature);
} }
Some((_, stability, _)) => { Some((_, stability, _)) => {
if let Err(reason) = stability.toggle_allowed(&sess.target, enable) { if let Err(reason) = stability.toggle_allowed() {
sess.dcx().emit_warn(ForbiddenCTargetFeature { sess.dcx().emit_warn(ForbiddenCTargetFeature {
feature, feature,
enabled: if enable { "enabled" } else { "disabled" }, enabled: if enable { "enabled" } else { "disabled" },

View file

@ -19,7 +19,7 @@ use crate::errors;
pub(crate) fn from_target_feature_attr( pub(crate) fn from_target_feature_attr(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
attr: &hir::Attribute, attr: &hir::Attribute,
rust_target_features: &UnordMap<String, target_features::StabilityComputed>, rust_target_features: &UnordMap<String, target_features::Stability>,
target_features: &mut Vec<TargetFeature>, target_features: &mut Vec<TargetFeature>,
) { ) {
let Some(list) = attr.meta_item_list() else { return }; let Some(list) = attr.meta_item_list() else { return };
@ -64,7 +64,7 @@ pub(crate) fn from_target_feature_attr(
// Only allow target features whose feature gates have been enabled // Only allow target features whose feature gates have been enabled
// and which are permitted to be toggled. // and which are permitted to be toggled.
if let Err(reason) = stability.toggle_allowed(/*enable*/ true) { if let Err(reason) = stability.toggle_allowed() {
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr { tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
span: item.span(), span: item.span(),
feature, feature,
@ -141,19 +141,18 @@ pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { *providers = Providers {
rust_target_features: |tcx, cnum| { rust_target_features: |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
let target = &tcx.sess.target;
if tcx.sess.opts.actually_rustdoc { if tcx.sess.opts.actually_rustdoc {
// rustdoc needs to be able to document functions that use all the features, so // rustdoc needs to be able to document functions that use all the features, so
// whitelist them all // whitelist them all
rustc_target::target_features::all_rust_features() rustc_target::target_features::all_rust_features()
.map(|(a, b)| (a.to_string(), b.compute_toggleability(target))) .map(|(a, b)| (a.to_string(), b))
.collect() .collect()
} else { } else {
tcx.sess tcx.sess
.target .target
.rust_target_features() .rust_target_features()
.iter() .iter()
.map(|(a, b, _)| (a.to_string(), b.compute_toggleability(target))) .map(|(a, b, _)| (a.to_string(), *b))
.collect() .collect()
} }
}, },

View file

@ -2355,7 +2355,7 @@ rustc_queries! {
} }
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features! /// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::StabilityComputed> { query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
arena_cache arena_cache
eval_always eval_always
desc { "looking up Rust target features" } desc { "looking up Rust target features" }

View file

@ -17,60 +17,34 @@ pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
pub const RUSTC_SPECIAL_FEATURES: &[&str] = &["backchain"]; pub const RUSTC_SPECIAL_FEATURES: &[&str] = &["backchain"];
/// Stability information for target features. /// Stability information for target features.
/// `Toggleability` is the type storing whether (un)stable features can be toggled: #[derive(Debug, Copy, Clone)]
/// this is initially a function since it can depend on `Target`, but for stable hashing pub enum Stability {
/// it needs to be something hashable to we have to make the type generic.
#[derive(Debug, Clone)]
pub enum Stability<Toggleability> {
/// This target feature is stable, it can be used in `#[target_feature]` and /// This target feature is stable, it can be used in `#[target_feature]` and
/// `#[cfg(target_feature)]`. /// `#[cfg(target_feature)]`.
Stable { Stable,
/// When enabling/disabling the feature via `-Ctarget-feature` or `#[target_feature]`,
/// determine if that is allowed.
allow_toggle: Toggleability,
},
/// This target feature is unstable. It is only present in `#[cfg(target_feature)]` on /// This target feature is unstable. It is only present in `#[cfg(target_feature)]` on
/// nightly and using it in `#[target_feature]` requires enabling the given nightly feature. /// nightly and using it in `#[target_feature]` requires enabling the given nightly feature.
Unstable { Unstable(
/// This must be a *language* feature, or else rustc will ICE when reporting a missing /// This must be a *language* feature, or else rustc will ICE when reporting a missing
/// feature gate! /// feature gate!
nightly_feature: Symbol, Symbol,
/// See `Stable::allow_toggle` comment above. ),
allow_toggle: Toggleability,
},
/// This feature can not be set via `-Ctarget-feature` or `#[target_feature]`, it can only be /// This feature can not be set via `-Ctarget-feature` or `#[target_feature]`, it can only be
/// set in the target spec. It is never set in `cfg(target_feature)`. Used in /// set in the target spec. It is never set in `cfg(target_feature)`. Used in
/// particular for features that change the floating-point ABI. /// particular for features are actually ABI configuration flags (not all targets are as nice as
/// RISC-V and have an explicit way to set the ABI separate from target features).
Forbidden { reason: &'static str }, Forbidden { reason: &'static str },
} }
use Stability::*;
/// Returns `Ok` if the toggle is allowed, `Err` with an explanation of not. impl<CTX> HashStable<CTX> for Stability {
/// The `bool` indicates whether the feature is being enabled (`true`) or disabled.
pub type AllowToggleUncomputed = fn(&Target, bool) -> Result<(), &'static str>;
/// The computed result of whether a feature can be enabled/disabled on the current target.
#[derive(Debug, Clone)]
pub struct AllowToggleComputed {
enable: Result<(), &'static str>,
disable: Result<(), &'static str>,
}
/// `Stability` where `allow_toggle` has not been computed yet.
pub type StabilityUncomputed = Stability<AllowToggleUncomputed>;
/// `Stability` where `allow_toggle` has already been computed.
pub type StabilityComputed = Stability<AllowToggleComputed>;
impl<CTX, Toggleability: HashStable<CTX>> HashStable<CTX> for Stability<Toggleability> {
#[inline] #[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
std::mem::discriminant(self).hash_stable(hcx, hasher); std::mem::discriminant(self).hash_stable(hcx, hasher);
match self { match self {
Stability::Stable { allow_toggle } => { Stability::Stable => {}
allow_toggle.hash_stable(hcx, hasher); Stability::Unstable(nightly_feature) => {
}
Stability::Unstable { nightly_feature, allow_toggle } => {
nightly_feature.hash_stable(hcx, hasher); nightly_feature.hash_stable(hcx, hasher);
allow_toggle.hash_stable(hcx, hasher);
} }
Stability::Forbidden { reason } => { Stability::Forbidden { reason } => {
reason.hash_stable(hcx, hasher); reason.hash_stable(hcx, hasher);
@ -79,16 +53,7 @@ impl<CTX, Toggleability: HashStable<CTX>> HashStable<CTX> for Stability<Toggleab
} }
} }
impl<CTX> HashStable<CTX> for AllowToggleComputed { impl Stability {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
let AllowToggleComputed { enable, disable } = self;
enable.hash_stable(hcx, hasher);
disable.hash_stable(hcx, hasher);
}
}
impl<Toggleability> Stability<Toggleability> {
/// Returns whether the feature can be used in `cfg(target_feature)` ever. /// Returns whether the feature can be used in `cfg(target_feature)` ever.
/// (It might still be nightly-only even if this returns `true`, so make sure to also check /// (It might still be nightly-only even if this returns `true`, so make sure to also check
/// `requires_nightly`.) /// `requires_nightly`.)
@ -106,57 +71,21 @@ impl<Toggleability> Stability<Toggleability> {
/// - for `cfg(target_feature)`, check `in_cfg` /// - for `cfg(target_feature)`, check `in_cfg`
pub fn requires_nightly(&self) -> Option<Symbol> { pub fn requires_nightly(&self) -> Option<Symbol> {
match *self { match *self {
Stability::Unstable { nightly_feature, .. } => Some(nightly_feature), Stability::Unstable(nightly_feature) => Some(nightly_feature),
Stability::Stable { .. } => None, Stability::Stable { .. } => None,
Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"), Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"),
} }
} }
}
impl StabilityUncomputed {
pub fn compute_toggleability(&self, target: &Target) -> StabilityComputed {
use Stability::*;
let compute = |f: AllowToggleUncomputed| AllowToggleComputed {
enable: f(target, true),
disable: f(target, false),
};
match *self {
Stable { allow_toggle } => Stable { allow_toggle: compute(allow_toggle) },
Unstable { nightly_feature, allow_toggle } => {
Unstable { nightly_feature, allow_toggle: compute(allow_toggle) }
}
Forbidden { reason } => Forbidden { reason },
}
}
pub fn toggle_allowed(&self, target: &Target, enable: bool) -> Result<(), &'static str> {
use Stability::*;
match *self {
Stable { allow_toggle } => allow_toggle(target, enable),
Unstable { allow_toggle, .. } => allow_toggle(target, enable),
Forbidden { reason } => Err(reason),
}
}
}
impl StabilityComputed {
/// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`. /// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`.
/// (It might still be nightly-only even if this returns `true`, so make sure to also check /// (It might still be nightly-only even if this returns `true`, so make sure to also check
/// `requires_nightly`.) /// `requires_nightly`.)
pub fn toggle_allowed(&self, enable: bool) -> Result<(), &'static str> { pub fn toggle_allowed(&self) -> Result<(), &'static str> {
let allow_toggle = match self { match self {
Stability::Stable { allow_toggle } => allow_toggle, Stability::Forbidden { reason } => Err(reason),
Stability::Unstable { allow_toggle, .. } => allow_toggle, _ => Ok(()),
Stability::Forbidden { reason } => return Err(reason), }
};
if enable { allow_toggle.enable } else { allow_toggle.disable }
} }
}
// Constructors for the list below, defaulting to "always allow toggle".
const STABLE: StabilityUncomputed = Stability::Stable { allow_toggle: |_target, _enable| Ok(()) };
const fn unstable(nightly_feature: Symbol) -> StabilityUncomputed {
Stability::Unstable { nightly_feature, allow_toggle: |_target, _enable| Ok(()) }
} }
// Here we list target features that rustc "understands": they can be used in `#[target_feature]` // Here we list target features that rustc "understands": they can be used in `#[target_feature]`
@ -204,182 +133,182 @@ const fn unstable(nightly_feature: Symbol) -> StabilityUncomputed {
// Both of these are also applied transitively. // Both of these are also applied transitively.
type ImpliedFeatures = &'static [&'static str]; type ImpliedFeatures = &'static [&'static str];
const ARM_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("aclass", unstable(sym::arm_target_feature), &[]), ("aclass", Unstable(sym::arm_target_feature), &[]),
("aes", unstable(sym::arm_target_feature), &["neon"]), ("aes", Unstable(sym::arm_target_feature), &["neon"]),
("crc", unstable(sym::arm_target_feature), &[]), ("crc", Unstable(sym::arm_target_feature), &[]),
("d32", unstable(sym::arm_target_feature), &[]), ("d32", Unstable(sym::arm_target_feature), &[]),
("dotprod", unstable(sym::arm_target_feature), &["neon"]), ("dotprod", Unstable(sym::arm_target_feature), &["neon"]),
("dsp", unstable(sym::arm_target_feature), &[]), ("dsp", Unstable(sym::arm_target_feature), &[]),
("fp-armv8", unstable(sym::arm_target_feature), &["vfp4"]), ("fp-armv8", Unstable(sym::arm_target_feature), &["vfp4"]),
("fpregs", unstable(sym::arm_target_feature), &[]), ("fpregs", Unstable(sym::arm_target_feature), &[]),
("i8mm", unstable(sym::arm_target_feature), &["neon"]), ("i8mm", Unstable(sym::arm_target_feature), &["neon"]),
("mclass", unstable(sym::arm_target_feature), &[]), ("mclass", Unstable(sym::arm_target_feature), &[]),
("neon", unstable(sym::arm_target_feature), &["vfp3"]), ("neon", Unstable(sym::arm_target_feature), &["vfp3"]),
("rclass", unstable(sym::arm_target_feature), &[]), ("rclass", Unstable(sym::arm_target_feature), &[]),
("sha2", unstable(sym::arm_target_feature), &["neon"]), ("sha2", Unstable(sym::arm_target_feature), &["neon"]),
("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]), ("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]),
// This is needed for inline assembly, but shouldn't be stabilized as-is // This is needed for inline assembly, but shouldn't be stabilized as-is
// since it should be enabled per-function using #[instruction_set], not // since it should be enabled per-function using #[instruction_set], not
// #[target_feature]. // #[target_feature].
("thumb-mode", unstable(sym::arm_target_feature), &[]), ("thumb-mode", Unstable(sym::arm_target_feature), &[]),
("thumb2", unstable(sym::arm_target_feature), &[]), ("thumb2", Unstable(sym::arm_target_feature), &[]),
("trustzone", unstable(sym::arm_target_feature), &[]), ("trustzone", Unstable(sym::arm_target_feature), &[]),
("v5te", unstable(sym::arm_target_feature), &[]), ("v5te", Unstable(sym::arm_target_feature), &[]),
("v6", unstable(sym::arm_target_feature), &["v5te"]), ("v6", Unstable(sym::arm_target_feature), &["v5te"]),
("v6k", unstable(sym::arm_target_feature), &["v6"]), ("v6k", Unstable(sym::arm_target_feature), &["v6"]),
("v6t2", unstable(sym::arm_target_feature), &["v6k", "thumb2"]), ("v6t2", Unstable(sym::arm_target_feature), &["v6k", "thumb2"]),
("v7", unstable(sym::arm_target_feature), &["v6t2"]), ("v7", Unstable(sym::arm_target_feature), &["v6t2"]),
("v8", unstable(sym::arm_target_feature), &["v7"]), ("v8", Unstable(sym::arm_target_feature), &["v7"]),
("vfp2", unstable(sym::arm_target_feature), &[]), ("vfp2", Unstable(sym::arm_target_feature), &[]),
("vfp3", unstable(sym::arm_target_feature), &["vfp2", "d32"]), ("vfp3", Unstable(sym::arm_target_feature), &["vfp2", "d32"]),
("vfp4", unstable(sym::arm_target_feature), &["vfp3"]), ("vfp4", Unstable(sym::arm_target_feature), &["vfp3"]),
("virtualization", unstable(sym::arm_target_feature), &[]), ("virtualization", Unstable(sym::arm_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const AARCH64_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
// FEAT_AES & FEAT_PMULL // FEAT_AES & FEAT_PMULL
("aes", STABLE, &["neon"]), ("aes", Stable, &["neon"]),
// FEAT_BF16 // FEAT_BF16
("bf16", STABLE, &[]), ("bf16", Stable, &[]),
// FEAT_BTI // FEAT_BTI
("bti", STABLE, &[]), ("bti", Stable, &[]),
// FEAT_CRC // FEAT_CRC
("crc", STABLE, &[]), ("crc", Stable, &[]),
// FEAT_CSSC // FEAT_CSSC
("cssc", unstable(sym::aarch64_unstable_target_feature), &[]), ("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_DIT // FEAT_DIT
("dit", STABLE, &[]), ("dit", Stable, &[]),
// FEAT_DotProd // FEAT_DotProd
("dotprod", STABLE, &["neon"]), ("dotprod", Stable, &["neon"]),
// FEAT_DPB // FEAT_DPB
("dpb", STABLE, &[]), ("dpb", Stable, &[]),
// FEAT_DPB2 // FEAT_DPB2
("dpb2", STABLE, &["dpb"]), ("dpb2", Stable, &["dpb"]),
// FEAT_ECV // FEAT_ECV
("ecv", unstable(sym::aarch64_unstable_target_feature), &[]), ("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_F32MM // FEAT_F32MM
("f32mm", STABLE, &["sve"]), ("f32mm", Stable, &["sve"]),
// FEAT_F64MM // FEAT_F64MM
("f64mm", STABLE, &["sve"]), ("f64mm", Stable, &["sve"]),
// FEAT_FAMINMAX // FEAT_FAMINMAX
("faminmax", unstable(sym::aarch64_unstable_target_feature), &[]), ("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FCMA // FEAT_FCMA
("fcma", STABLE, &["neon"]), ("fcma", Stable, &["neon"]),
// FEAT_FHM // FEAT_FHM
("fhm", STABLE, &["fp16"]), ("fhm", Stable, &["fp16"]),
// FEAT_FLAGM // FEAT_FLAGM
("flagm", STABLE, &[]), ("flagm", Stable, &[]),
// FEAT_FLAGM2 // FEAT_FLAGM2
("flagm2", unstable(sym::aarch64_unstable_target_feature), &[]), ("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
("fp-armv8", Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`" }, &[]), ("fp-armv8", Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`" }, &[]),
// FEAT_FP16 // FEAT_FP16
// Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608 // Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608
("fp16", STABLE, &["neon"]), ("fp16", Stable, &["neon"]),
// FEAT_FP8 // FEAT_FP8
("fp8", unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]), ("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
// FEAT_FP8DOT2 // FEAT_FP8DOT2
("fp8dot2", unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]), ("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
// FEAT_FP8DOT4 // FEAT_FP8DOT4
("fp8dot4", unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]), ("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
// FEAT_FP8FMA // FEAT_FP8FMA
("fp8fma", unstable(sym::aarch64_unstable_target_feature), &["fp8"]), ("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
// FEAT_FRINTTS // FEAT_FRINTTS
("frintts", STABLE, &[]), ("frintts", Stable, &[]),
// FEAT_HBC // FEAT_HBC
("hbc", unstable(sym::aarch64_unstable_target_feature), &[]), ("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_I8MM // FEAT_I8MM
("i8mm", STABLE, &[]), ("i8mm", Stable, &[]),
// FEAT_JSCVT // FEAT_JSCVT
// Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608 // Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608
("jsconv", STABLE, &["neon"]), ("jsconv", Stable, &["neon"]),
// FEAT_LOR // FEAT_LOR
("lor", STABLE, &[]), ("lor", Stable, &[]),
// FEAT_LSE // FEAT_LSE
("lse", STABLE, &[]), ("lse", Stable, &[]),
// FEAT_LSE128 // FEAT_LSE128
("lse128", unstable(sym::aarch64_unstable_target_feature), &["lse"]), ("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
// FEAT_LSE2 // FEAT_LSE2
("lse2", unstable(sym::aarch64_unstable_target_feature), &[]), ("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_LUT // FEAT_LUT
("lut", unstable(sym::aarch64_unstable_target_feature), &[]), ("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MOPS // FEAT_MOPS
("mops", unstable(sym::aarch64_unstable_target_feature), &[]), ("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MTE & FEAT_MTE2 // FEAT_MTE & FEAT_MTE2
("mte", STABLE, &[]), ("mte", Stable, &[]),
// FEAT_AdvSimd & FEAT_FP // FEAT_AdvSimd & FEAT_FP
("neon", STABLE, &[]), ("neon", Stable, &[]),
// FEAT_PAUTH (address authentication) // FEAT_PAUTH (address authentication)
("paca", STABLE, &[]), ("paca", Stable, &[]),
// FEAT_PAUTH (generic authentication) // FEAT_PAUTH (generic authentication)
("pacg", STABLE, &[]), ("pacg", Stable, &[]),
// FEAT_PAN // FEAT_PAN
("pan", STABLE, &[]), ("pan", Stable, &[]),
// FEAT_PAuth_LR // FEAT_PAuth_LR
("pauth-lr", unstable(sym::aarch64_unstable_target_feature), &[]), ("pauth-lr", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_PMUv3 // FEAT_PMUv3
("pmuv3", STABLE, &[]), ("pmuv3", Stable, &[]),
// FEAT_RNG // FEAT_RNG
("rand", STABLE, &[]), ("rand", Stable, &[]),
// FEAT_RAS & FEAT_RASv1p1 // FEAT_RAS & FEAT_RASv1p1
("ras", STABLE, &[]), ("ras", Stable, &[]),
// FEAT_LRCPC // FEAT_LRCPC
("rcpc", STABLE, &[]), ("rcpc", Stable, &[]),
// FEAT_LRCPC2 // FEAT_LRCPC2
("rcpc2", STABLE, &["rcpc"]), ("rcpc2", Stable, &["rcpc"]),
// FEAT_LRCPC3 // FEAT_LRCPC3
("rcpc3", unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]), ("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
// FEAT_RDM // FEAT_RDM
("rdm", STABLE, &["neon"]), ("rdm", Stable, &["neon"]),
// This is needed for inline assembly, but shouldn't be stabilized as-is // This is needed for inline assembly, but shouldn't be stabilized as-is
// since it should be enabled globally using -Zfixed-x18, not // since it should be enabled globally using -Zfixed-x18, not
// #[target_feature]. // #[target_feature].
// Note that cfg(target_feature = "reserve-x18") is currently not set for // Note that cfg(target_feature = "reserve-x18") is currently not set for
// targets that reserve x18 by default. // targets that reserve x18 by default.
("reserve-x18", unstable(sym::aarch64_unstable_target_feature), &[]), ("reserve-x18", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_SB // FEAT_SB
("sb", STABLE, &[]), ("sb", Stable, &[]),
// FEAT_SHA1 & FEAT_SHA256 // FEAT_SHA1 & FEAT_SHA256
("sha2", STABLE, &["neon"]), ("sha2", Stable, &["neon"]),
// FEAT_SHA512 & FEAT_SHA3 // FEAT_SHA512 & FEAT_SHA3
("sha3", STABLE, &["sha2"]), ("sha3", Stable, &["sha2"]),
// FEAT_SM3 & FEAT_SM4 // FEAT_SM3 & FEAT_SM4
("sm4", STABLE, &["neon"]), ("sm4", Stable, &["neon"]),
// FEAT_SME // FEAT_SME
("sme", unstable(sym::aarch64_unstable_target_feature), &["bf16"]), ("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
// FEAT_SME_B16B16 // FEAT_SME_B16B16
("sme-b16b16", unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]), ("sme-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16", "sme2", "sve-b16b16"]),
// FEAT_SME_F16F16 // FEAT_SME_F16F16
("sme-f16f16", unstable(sym::aarch64_unstable_target_feature), &["sme2"]), ("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
// FEAT_SME_F64F64 // FEAT_SME_F64F64
("sme-f64f64", unstable(sym::aarch64_unstable_target_feature), &["sme"]), ("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME_F8F16 // FEAT_SME_F8F16
("sme-f8f16", unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]), ("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
// FEAT_SME_F8F32 // FEAT_SME_F8F32
("sme-f8f32", unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]), ("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
// FEAT_SME_FA64 // FEAT_SME_FA64
("sme-fa64", unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]), ("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
// FEAT_SME_I16I64 // FEAT_SME_I16I64
("sme-i16i64", unstable(sym::aarch64_unstable_target_feature), &["sme"]), ("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME_LUTv2 // FEAT_SME_LUTv2
("sme-lutv2", unstable(sym::aarch64_unstable_target_feature), &[]), ("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_SME2 // FEAT_SME2
("sme2", unstable(sym::aarch64_unstable_target_feature), &["sme"]), ("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME2p1 // FEAT_SME2p1
("sme2p1", unstable(sym::aarch64_unstable_target_feature), &["sme2"]), ("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
// FEAT_SPE // FEAT_SPE
("spe", STABLE, &[]), ("spe", Stable, &[]),
// FEAT_SSBS & FEAT_SSBS2 // FEAT_SSBS & FEAT_SSBS2
("ssbs", STABLE, &[]), ("ssbs", Stable, &[]),
// FEAT_SSVE_FP8FDOT2 // FEAT_SSVE_FP8FDOT2
("ssve-fp8dot2", unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]), ("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
// FEAT_SSVE_FP8FDOT4 // FEAT_SSVE_FP8FDOT4
("ssve-fp8dot4", unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]), ("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
// FEAT_SSVE_FP8FMA // FEAT_SSVE_FP8FMA
("ssve-fp8fma", unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]), ("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
// FEAT_SVE // FEAT_SVE
// It was decided that SVE requires Neon: https://github.com/rust-lang/rust/pull/91608 // It was decided that SVE requires Neon: https://github.com/rust-lang/rust/pull/91608
// //
@ -387,46 +316,46 @@ const AARCH64_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
// exist together: https://developer.arm.com/documentation/102340/0100/New-features-in-SVE2 // exist together: https://developer.arm.com/documentation/102340/0100/New-features-in-SVE2
// //
// "For backwards compatibility, Neon and VFP are required in the latest architectures." // "For backwards compatibility, Neon and VFP are required in the latest architectures."
("sve", STABLE, &["neon"]), ("sve", Stable, &["neon"]),
// FEAT_SVE_B16B16 (SVE or SME Z-targeting instructions) // FEAT_SVE_B16B16 (SVE or SME Z-targeting instructions)
("sve-b16b16", unstable(sym::aarch64_unstable_target_feature), &["bf16"]), ("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
// FEAT_SVE2 // FEAT_SVE2
("sve2", STABLE, &["sve"]), ("sve2", Stable, &["sve"]),
// FEAT_SVE_AES & FEAT_SVE_PMULL128 // FEAT_SVE_AES & FEAT_SVE_PMULL128
("sve2-aes", STABLE, &["sve2", "aes"]), ("sve2-aes", Stable, &["sve2", "aes"]),
// FEAT_SVE2_BitPerm // FEAT_SVE2_BitPerm
("sve2-bitperm", STABLE, &["sve2"]), ("sve2-bitperm", Stable, &["sve2"]),
// FEAT_SVE2_SHA3 // FEAT_SVE2_SHA3
("sve2-sha3", STABLE, &["sve2", "sha3"]), ("sve2-sha3", Stable, &["sve2", "sha3"]),
// FEAT_SVE2_SM4 // FEAT_SVE2_SM4
("sve2-sm4", STABLE, &["sve2", "sm4"]), ("sve2-sm4", Stable, &["sve2", "sm4"]),
// FEAT_SVE2p1 // FEAT_SVE2p1
("sve2p1", unstable(sym::aarch64_unstable_target_feature), &["sve2"]), ("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
// FEAT_TME // FEAT_TME
("tme", STABLE, &[]), ("tme", Stable, &[]),
("v8.1a", unstable(sym::aarch64_ver_target_feature), &[ ("v8.1a", Unstable(sym::aarch64_ver_target_feature), &[
"crc", "lse", "rdm", "pan", "lor", "vh", "crc", "lse", "rdm", "pan", "lor", "vh",
]), ]),
("v8.2a", unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]), ("v8.2a", Unstable(sym::aarch64_ver_target_feature), &["v8.1a", "ras", "dpb"]),
("v8.3a", unstable(sym::aarch64_ver_target_feature), &[ ("v8.3a", Unstable(sym::aarch64_ver_target_feature), &[
"v8.2a", "rcpc", "paca", "pacg", "jsconv", "v8.2a", "rcpc", "paca", "pacg", "jsconv",
]), ]),
("v8.4a", unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]), ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
("v8.5a", unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]), ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
("v8.6a", unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]), ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
("v8.7a", unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]), ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
("v8.8a", unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]), ("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
("v8.9a", unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]), ("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
("v9.1a", unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]), ("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
("v9.2a", unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]), ("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
("v9.3a", unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]), ("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
("v9.4a", unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]), ("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
("v9.5a", unstable(sym::aarch64_ver_target_feature), &["v9.4a"]), ("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
("v9a", unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]), ("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
// FEAT_VHE // FEAT_VHE
("vh", STABLE, &[]), ("vh", Stable, &[]),
// FEAT_WFxT // FEAT_WFxT
("wfxt", unstable(sym::aarch64_unstable_target_feature), &[]), ("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
@ -434,275 +363,260 @@ const AARCH64_TIED_FEATURES: &[&[&str]] = &[
&["paca", "pacg"], // Together these represent `pauth` in LLVM &["paca", "pacg"], // Together these represent `pauth` in LLVM
]; ];
const X86_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("adx", STABLE, &[]), ("adx", Stable, &[]),
("aes", STABLE, &["sse2"]), ("aes", Stable, &["sse2"]),
("amx-bf16", unstable(sym::x86_amx_intrinsics), &["amx-tile"]), ("amx-bf16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
("amx-complex", unstable(sym::x86_amx_intrinsics), &["amx-tile"]), ("amx-complex", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
("amx-fp16", unstable(sym::x86_amx_intrinsics), &["amx-tile"]), ("amx-fp16", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
("amx-int8", unstable(sym::x86_amx_intrinsics), &["amx-tile"]), ("amx-int8", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
("amx-tile", unstable(sym::x86_amx_intrinsics), &[]), ("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
("avx", STABLE, &["sse4.2"]), ("avx", Stable, &["sse4.2"]),
("avx2", STABLE, &["avx"]), ("avx2", Stable, &["avx"]),
("avx512bf16", unstable(sym::avx512_target_feature), &["avx512bw"]), ("avx512bf16", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512bitalg", unstable(sym::avx512_target_feature), &["avx512bw"]), ("avx512bitalg", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512bw", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512bw", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512cd", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512cd", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512dq", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512dq", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512f", unstable(sym::avx512_target_feature), &["avx2", "fma", "f16c"]), ("avx512f", Unstable(sym::avx512_target_feature), &["avx2", "fma", "f16c"]),
("avx512fp16", unstable(sym::avx512_target_feature), &["avx512bw", "avx512vl", "avx512dq"]), ("avx512fp16", Unstable(sym::avx512_target_feature), &["avx512bw", "avx512vl", "avx512dq"]),
("avx512ifma", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512ifma", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vbmi", unstable(sym::avx512_target_feature), &["avx512bw"]), ("avx512vbmi", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512vbmi2", unstable(sym::avx512_target_feature), &["avx512bw"]), ("avx512vbmi2", Unstable(sym::avx512_target_feature), &["avx512bw"]),
("avx512vl", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512vl", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vnni", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512vnni", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vp2intersect", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512vp2intersect", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avx512vpopcntdq", unstable(sym::avx512_target_feature), &["avx512f"]), ("avx512vpopcntdq", Unstable(sym::avx512_target_feature), &["avx512f"]),
("avxifma", unstable(sym::avx512_target_feature), &["avx2"]), ("avxifma", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxneconvert", unstable(sym::avx512_target_feature), &["avx2"]), ("avxneconvert", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnni", unstable(sym::avx512_target_feature), &["avx2"]), ("avxvnni", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnniint16", unstable(sym::avx512_target_feature), &["avx2"]), ("avxvnniint16", Unstable(sym::avx512_target_feature), &["avx2"]),
("avxvnniint8", unstable(sym::avx512_target_feature), &["avx2"]), ("avxvnniint8", Unstable(sym::avx512_target_feature), &["avx2"]),
("bmi1", STABLE, &[]), ("bmi1", Stable, &[]),
("bmi2", STABLE, &[]), ("bmi2", Stable, &[]),
("cmpxchg16b", STABLE, &[]), ("cmpxchg16b", Stable, &[]),
("ermsb", unstable(sym::ermsb_target_feature), &[]), ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
("f16c", STABLE, &["avx"]), ("f16c", Stable, &["avx"]),
("fma", STABLE, &["avx"]), ("fma", Stable, &["avx"]),
("fxsr", STABLE, &[]), ("fxsr", Stable, &[]),
("gfni", unstable(sym::avx512_target_feature), &["sse2"]), ("gfni", Unstable(sym::avx512_target_feature), &["sse2"]),
("lahfsahf", unstable(sym::lahfsahf_target_feature), &[]), ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
("lzcnt", STABLE, &[]), ("lzcnt", Stable, &[]),
("movbe", STABLE, &[]), ("movbe", Stable, &[]),
("pclmulqdq", STABLE, &["sse2"]), ("pclmulqdq", Stable, &["sse2"]),
("popcnt", STABLE, &[]), ("popcnt", Stable, &[]),
("prfchw", unstable(sym::prfchw_target_feature), &[]), ("prfchw", Unstable(sym::prfchw_target_feature), &[]),
("rdrand", STABLE, &[]), ("rdrand", Stable, &[]),
("rdseed", STABLE, &[]), ("rdseed", Stable, &[]),
("rtm", unstable(sym::rtm_target_feature), &[]), ("rtm", Unstable(sym::rtm_target_feature), &[]),
("sha", STABLE, &["sse2"]), ("sha", Stable, &["sse2"]),
("sha512", unstable(sym::sha512_sm_x86), &["avx2"]), ("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]),
("sm3", unstable(sym::sha512_sm_x86), &["avx"]), ("sm3", Unstable(sym::sha512_sm_x86), &["avx"]),
("sm4", unstable(sym::sha512_sm_x86), &["avx2"]), ("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]),
("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]), ("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]),
("sse", STABLE, &[]), ("sse", Stable, &[]),
("sse2", STABLE, &["sse"]), ("sse2", Stable, &["sse"]),
("sse3", STABLE, &["sse2"]), ("sse3", Stable, &["sse2"]),
("sse4.1", STABLE, &["ssse3"]), ("sse4.1", Stable, &["ssse3"]),
("sse4.2", STABLE, &["sse4.1"]), ("sse4.2", Stable, &["sse4.1"]),
("sse4a", unstable(sym::sse4a_target_feature), &["sse3"]), ("sse4a", Unstable(sym::sse4a_target_feature), &["sse3"]),
("ssse3", STABLE, &["sse3"]), ("ssse3", Stable, &["sse3"]),
("tbm", unstable(sym::tbm_target_feature), &[]), ("tbm", Unstable(sym::tbm_target_feature), &[]),
("vaes", unstable(sym::avx512_target_feature), &["avx2", "aes"]), ("vaes", Unstable(sym::avx512_target_feature), &["avx2", "aes"]),
("vpclmulqdq", unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]), ("vpclmulqdq", Unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]),
("x87", unstable(sym::x87_target_feature), &[]), ("x87", Unstable(sym::x87_target_feature), &[]),
("xop", unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]), ("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
("xsave", STABLE, &[]), ("xsave", Stable, &[]),
("xsavec", STABLE, &["xsave"]), ("xsavec", Stable, &["xsave"]),
("xsaveopt", STABLE, &["xsave"]), ("xsaveopt", Stable, &["xsave"]),
("xsaves", STABLE, &["xsave"]), ("xsaves", Stable, &["xsave"]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const HEXAGON_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const HEXAGON_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("hvx", unstable(sym::hexagon_target_feature), &[]), ("hvx", Unstable(sym::hexagon_target_feature), &[]),
("hvx-length128b", unstable(sym::hexagon_target_feature), &["hvx"]), ("hvx-length128b", Unstable(sym::hexagon_target_feature), &["hvx"]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const POWERPC_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("altivec", unstable(sym::powerpc_target_feature), &[]), ("altivec", Unstable(sym::powerpc_target_feature), &[]),
("partword-atomics", unstable(sym::powerpc_target_feature), &[]), ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("power10-vector", unstable(sym::powerpc_target_feature), &["power9-vector"]), ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
("power8-altivec", unstable(sym::powerpc_target_feature), &["altivec"]), ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
("power8-crypto", unstable(sym::powerpc_target_feature), &["power8-altivec"]), ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
("power8-vector", unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]), ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
("power9-altivec", unstable(sym::powerpc_target_feature), &["power8-altivec"]), ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
("power9-vector", unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]), ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
("quadword-atomics", unstable(sym::powerpc_target_feature), &[]), ("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("vsx", unstable(sym::powerpc_target_feature), &["altivec"]), ("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const MIPS_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("fp64", unstable(sym::mips_target_feature), &[]), ("fp64", Unstable(sym::mips_target_feature), &[]),
("msa", unstable(sym::mips_target_feature), &[]), ("msa", Unstable(sym::mips_target_feature), &[]),
("virt", unstable(sym::mips_target_feature), &[]), ("virt", Unstable(sym::mips_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const RISCV_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("a", STABLE, &["zaamo", "zalrsc"]), ("a", Stable, &["zaamo", "zalrsc"]),
("c", STABLE, &[]), ("c", Stable, &[]),
("d", unstable(sym::riscv_target_feature), &["f"]), ("d", Unstable(sym::riscv_target_feature), &["f"]),
("e", unstable(sym::riscv_target_feature), &[]), ("e", Unstable(sym::riscv_target_feature), &[]),
( ("f", Unstable(sym::riscv_target_feature), &[]),
"f",
Stability::Unstable {
nightly_feature: sym::riscv_target_feature,
allow_toggle: |target, enable| {
match &*target.llvm_abiname {
"ilp32f" | "ilp32d" | "lp64f" | "lp64d" if !enable => {
// The ABI requires the `f` feature, so it cannot be disabled.
Err("feature is required by ABI")
}
_ => Ok(()),
}
},
},
&[],
),
( (
"forced-atomics", "forced-atomics",
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" }, Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
&[], &[],
), ),
("m", STABLE, &[]), ("m", Stable, &[]),
("relax", unstable(sym::riscv_target_feature), &[]), ("relax", Unstable(sym::riscv_target_feature), &[]),
("unaligned-scalar-mem", unstable(sym::riscv_target_feature), &[]), ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
("v", unstable(sym::riscv_target_feature), &[]), ("v", Unstable(sym::riscv_target_feature), &[]),
("zaamo", unstable(sym::riscv_target_feature), &[]), ("zaamo", Unstable(sym::riscv_target_feature), &[]),
("zabha", unstable(sym::riscv_target_feature), &["zaamo"]), ("zabha", Unstable(sym::riscv_target_feature), &["zaamo"]),
("zalrsc", unstable(sym::riscv_target_feature), &[]), ("zalrsc", Unstable(sym::riscv_target_feature), &[]),
("zba", STABLE, &[]), ("zba", Stable, &[]),
("zbb", STABLE, &[]), ("zbb", Stable, &[]),
("zbc", STABLE, &[]), ("zbc", Stable, &[]),
("zbkb", STABLE, &[]), ("zbkb", Stable, &[]),
("zbkc", STABLE, &[]), ("zbkc", Stable, &[]),
("zbkx", STABLE, &[]), ("zbkx", Stable, &[]),
("zbs", STABLE, &[]), ("zbs", Stable, &[]),
("zdinx", unstable(sym::riscv_target_feature), &["zfinx"]), ("zdinx", Unstable(sym::riscv_target_feature), &["zfinx"]),
("zfh", unstable(sym::riscv_target_feature), &["zfhmin"]), ("zfh", Unstable(sym::riscv_target_feature), &["zfhmin"]),
("zfhmin", unstable(sym::riscv_target_feature), &["f"]), ("zfhmin", Unstable(sym::riscv_target_feature), &["f"]),
("zfinx", unstable(sym::riscv_target_feature), &[]), ("zfinx", Unstable(sym::riscv_target_feature), &[]),
("zhinx", unstable(sym::riscv_target_feature), &["zhinxmin"]), ("zhinx", Unstable(sym::riscv_target_feature), &["zhinxmin"]),
("zhinxmin", unstable(sym::riscv_target_feature), &["zfinx"]), ("zhinxmin", Unstable(sym::riscv_target_feature), &["zfinx"]),
("zk", STABLE, &["zkn", "zkr", "zkt"]), ("zk", Stable, &["zkn", "zkr", "zkt"]),
("zkn", STABLE, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]), ("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
("zknd", STABLE, &[]), ("zknd", Stable, &[]),
("zkne", STABLE, &[]), ("zkne", Stable, &[]),
("zknh", STABLE, &[]), ("zknh", Stable, &[]),
("zkr", STABLE, &[]), ("zkr", Stable, &[]),
("zks", STABLE, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]), ("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),
("zksed", STABLE, &[]), ("zksed", Stable, &[]),
("zksh", STABLE, &[]), ("zksh", Stable, &[]),
("zkt", STABLE, &[]), ("zkt", Stable, &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const WASM_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("atomics", unstable(sym::wasm_target_feature), &[]), ("atomics", Unstable(sym::wasm_target_feature), &[]),
("bulk-memory", STABLE, &[]), ("bulk-memory", Stable, &[]),
("exception-handling", unstable(sym::wasm_target_feature), &[]), ("exception-handling", Unstable(sym::wasm_target_feature), &[]),
("extended-const", STABLE, &[]), ("extended-const", Stable, &[]),
("multivalue", STABLE, &[]), ("multivalue", Stable, &[]),
("mutable-globals", STABLE, &[]), ("mutable-globals", Stable, &[]),
("nontrapping-fptoint", STABLE, &[]), ("nontrapping-fptoint", Stable, &[]),
("reference-types", STABLE, &[]), ("reference-types", Stable, &[]),
("relaxed-simd", STABLE, &["simd128"]), ("relaxed-simd", Stable, &["simd128"]),
("sign-ext", STABLE, &[]), ("sign-ext", Stable, &[]),
("simd128", STABLE, &[]), ("simd128", Stable, &[]),
("tail-call", STABLE, &[]), ("tail-call", Stable, &[]),
("wide-arithmetic", unstable(sym::wasm_target_feature), &[]), ("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const BPF_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = const BPF_FEATURES: &[(&str, Stability, ImpliedFeatures)] =
&[("alu32", unstable(sym::bpf_target_feature), &[])]; &[("alu32", Unstable(sym::bpf_target_feature), &[])];
const CSKY_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("10e60", unstable(sym::csky_target_feature), &["7e10"]), ("10e60", Unstable(sym::csky_target_feature), &["7e10"]),
("2e3", unstable(sym::csky_target_feature), &["e2"]), ("2e3", Unstable(sym::csky_target_feature), &["e2"]),
("3e3r1", unstable(sym::csky_target_feature), &[]), ("3e3r1", Unstable(sym::csky_target_feature), &[]),
("3e3r2", unstable(sym::csky_target_feature), &["3e3r1", "doloop"]), ("3e3r2", Unstable(sym::csky_target_feature), &["3e3r1", "doloop"]),
("3e3r3", unstable(sym::csky_target_feature), &["doloop"]), ("3e3r3", Unstable(sym::csky_target_feature), &["doloop"]),
("3e7", unstable(sym::csky_target_feature), &["2e3"]), ("3e7", Unstable(sym::csky_target_feature), &["2e3"]),
("7e10", unstable(sym::csky_target_feature), &["3e7"]), ("7e10", Unstable(sym::csky_target_feature), &["3e7"]),
("cache", unstable(sym::csky_target_feature), &[]), ("cache", Unstable(sym::csky_target_feature), &[]),
("doloop", unstable(sym::csky_target_feature), &[]), ("doloop", Unstable(sym::csky_target_feature), &[]),
("dsp1e2", unstable(sym::csky_target_feature), &[]), ("dsp1e2", Unstable(sym::csky_target_feature), &[]),
("dspe60", unstable(sym::csky_target_feature), &[]), ("dspe60", Unstable(sym::csky_target_feature), &[]),
("e1", unstable(sym::csky_target_feature), &["elrw"]), ("e1", Unstable(sym::csky_target_feature), &["elrw"]),
("e2", unstable(sym::csky_target_feature), &["e2"]), ("e2", Unstable(sym::csky_target_feature), &["e2"]),
("edsp", unstable(sym::csky_target_feature), &[]), ("edsp", Unstable(sym::csky_target_feature), &[]),
("elrw", unstable(sym::csky_target_feature), &[]), ("elrw", Unstable(sym::csky_target_feature), &[]),
("float1e2", unstable(sym::csky_target_feature), &[]), ("float1e2", Unstable(sym::csky_target_feature), &[]),
("float1e3", unstable(sym::csky_target_feature), &[]), ("float1e3", Unstable(sym::csky_target_feature), &[]),
("float3e4", unstable(sym::csky_target_feature), &[]), ("float3e4", Unstable(sym::csky_target_feature), &[]),
("float7e60", unstable(sym::csky_target_feature), &[]), ("float7e60", Unstable(sym::csky_target_feature), &[]),
("floate1", unstable(sym::csky_target_feature), &[]), ("floate1", Unstable(sym::csky_target_feature), &[]),
("hard-tp", unstable(sym::csky_target_feature), &[]), ("hard-tp", Unstable(sym::csky_target_feature), &[]),
("high-registers", unstable(sym::csky_target_feature), &[]), ("high-registers", Unstable(sym::csky_target_feature), &[]),
("hwdiv", unstable(sym::csky_target_feature), &[]), ("hwdiv", Unstable(sym::csky_target_feature), &[]),
("mp", unstable(sym::csky_target_feature), &["2e3"]), ("mp", Unstable(sym::csky_target_feature), &["2e3"]),
("mp1e2", unstable(sym::csky_target_feature), &["3e7"]), ("mp1e2", Unstable(sym::csky_target_feature), &["3e7"]),
("nvic", unstable(sym::csky_target_feature), &[]), ("nvic", Unstable(sym::csky_target_feature), &[]),
("trust", unstable(sym::csky_target_feature), &[]), ("trust", Unstable(sym::csky_target_feature), &[]),
("vdsp2e60f", unstable(sym::csky_target_feature), &[]), ("vdsp2e60f", Unstable(sym::csky_target_feature), &[]),
("vdspv1", unstable(sym::csky_target_feature), &[]), ("vdspv1", Unstable(sym::csky_target_feature), &[]),
("vdspv2", unstable(sym::csky_target_feature), &[]), ("vdspv2", Unstable(sym::csky_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
//fpu //fpu
// tidy-alphabetical-start // tidy-alphabetical-start
("fdivdu", unstable(sym::csky_target_feature), &[]), ("fdivdu", Unstable(sym::csky_target_feature), &[]),
("fpuv2_df", unstable(sym::csky_target_feature), &[]), ("fpuv2_df", Unstable(sym::csky_target_feature), &[]),
("fpuv2_sf", unstable(sym::csky_target_feature), &[]), ("fpuv2_sf", Unstable(sym::csky_target_feature), &[]),
("fpuv3_df", unstable(sym::csky_target_feature), &[]), ("fpuv3_df", Unstable(sym::csky_target_feature), &[]),
("fpuv3_hf", unstable(sym::csky_target_feature), &[]), ("fpuv3_hf", Unstable(sym::csky_target_feature), &[]),
("fpuv3_hi", unstable(sym::csky_target_feature), &[]), ("fpuv3_hi", Unstable(sym::csky_target_feature), &[]),
("fpuv3_sf", unstable(sym::csky_target_feature), &[]), ("fpuv3_sf", Unstable(sym::csky_target_feature), &[]),
("hard-float", unstable(sym::csky_target_feature), &[]), ("hard-float", Unstable(sym::csky_target_feature), &[]),
("hard-float-abi", unstable(sym::csky_target_feature), &[]), ("hard-float-abi", Unstable(sym::csky_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const LOONGARCH_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("d", unstable(sym::loongarch_target_feature), &["f"]), ("d", Unstable(sym::loongarch_target_feature), &["f"]),
("f", unstable(sym::loongarch_target_feature), &[]), ("f", Unstable(sym::loongarch_target_feature), &[]),
("frecipe", unstable(sym::loongarch_target_feature), &[]), ("frecipe", Unstable(sym::loongarch_target_feature), &[]),
("lasx", unstable(sym::loongarch_target_feature), &["lsx"]), ("lasx", Unstable(sym::loongarch_target_feature), &["lsx"]),
("lbt", unstable(sym::loongarch_target_feature), &[]), ("lbt", Unstable(sym::loongarch_target_feature), &[]),
("lsx", unstable(sym::loongarch_target_feature), &["d"]), ("lsx", Unstable(sym::loongarch_target_feature), &["d"]),
("lvz", unstable(sym::loongarch_target_feature), &[]), ("lvz", Unstable(sym::loongarch_target_feature), &[]),
("relax", unstable(sym::loongarch_target_feature), &[]), ("relax", Unstable(sym::loongarch_target_feature), &[]),
("ual", unstable(sym::loongarch_target_feature), &[]), ("ual", Unstable(sym::loongarch_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const IBMZ_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("backchain", unstable(sym::s390x_target_feature), &[]), ("backchain", Unstable(sym::s390x_target_feature), &[]),
("vector", unstable(sym::s390x_target_feature), &[]), ("vector", Unstable(sym::s390x_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const SPARC_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("leoncasa", unstable(sym::sparc_target_feature), &[]), ("leoncasa", Unstable(sym::sparc_target_feature), &[]),
("v8plus", unstable(sym::sparc_target_feature), &[]), ("v8plus", Unstable(sym::sparc_target_feature), &[]),
("v9", unstable(sym::sparc_target_feature), &[]), ("v9", Unstable(sym::sparc_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
const M68K_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[ const M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start // tidy-alphabetical-start
("isa-68000", unstable(sym::m68k_target_feature), &[]), ("isa-68000", Unstable(sym::m68k_target_feature), &[]),
("isa-68010", unstable(sym::m68k_target_feature), &["isa-68000"]), ("isa-68010", Unstable(sym::m68k_target_feature), &["isa-68000"]),
("isa-68020", unstable(sym::m68k_target_feature), &["isa-68010"]), ("isa-68020", Unstable(sym::m68k_target_feature), &["isa-68010"]),
("isa-68030", unstable(sym::m68k_target_feature), &["isa-68020"]), ("isa-68030", Unstable(sym::m68k_target_feature), &["isa-68020"]),
("isa-68040", unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]), ("isa-68040", Unstable(sym::m68k_target_feature), &["isa-68030", "isa-68882"]),
("isa-68060", unstable(sym::m68k_target_feature), &["isa-68040"]), ("isa-68060", Unstable(sym::m68k_target_feature), &["isa-68040"]),
// FPU // FPU
("isa-68881", unstable(sym::m68k_target_feature), &[]), ("isa-68881", Unstable(sym::m68k_target_feature), &[]),
("isa-68882", unstable(sym::m68k_target_feature), &["isa-68881"]), ("isa-68882", Unstable(sym::m68k_target_feature), &["isa-68881"]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];
@ -710,7 +624,7 @@ const M68K_FEATURES: &[(&str, StabilityUncomputed, ImpliedFeatures)] = &[
/// primitives may be documented. /// primitives may be documented.
/// ///
/// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator! /// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator!
pub fn all_rust_features() -> impl Iterator<Item = (&'static str, StabilityUncomputed)> { pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
std::iter::empty() std::iter::empty()
.chain(ARM_FEATURES.iter()) .chain(ARM_FEATURES.iter())
.chain(AARCH64_FEATURES.iter()) .chain(AARCH64_FEATURES.iter())
@ -756,9 +670,7 @@ const LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)]
&[(128, "lsx"), (256, "lasx")]; &[(128, "lsx"), (256, "lasx")];
impl Target { impl Target {
pub fn rust_target_features( pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
&self,
) -> &'static [(&'static str, StabilityUncomputed, ImpliedFeatures)] {
match &*self.arch { match &*self.arch {
"arm" => ARM_FEATURES, "arm" => ARM_FEATURES,
"aarch64" | "arm64ec" => AARCH64_FEATURES, "aarch64" | "arm64ec" => AARCH64_FEATURES,