summaryrefslogtreecommitdiffstats
path: root/library/stdarch/crates/std_detect/src/detect/arch
diff options
context:
space:
mode:
Diffstat (limited to 'library/stdarch/crates/std_detect/src/detect/arch')
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs152
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/arm.rs28
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/mips.rs12
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/mips64.rs12
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/mod.rs56
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs16
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs16
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/riscv.rs206
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/x86.rs197
9 files changed, 695 insertions, 0 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs b/library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs
new file mode 100644
index 000000000..f32f961ae
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs
@@ -0,0 +1,152 @@
+//! Aarch64 run-time features.
+
+features! {
+ @TARGET: aarch64;
+ @CFG: target_arch = "aarch64";
+ @MACRO_NAME: is_aarch64_feature_detected;
+ @MACRO_ATTRS:
+ /// This macro tests, at runtime, whether an `aarch64` feature is enabled on aarch64 platforms.
+ /// Currently most features are only supported on linux-based platforms.
+ ///
+ /// This macro takes one argument which is a string literal of the feature being tested for.
+ /// The feature names are mostly taken from their FEAT_* definitions in the [ARM Architecture
+ /// Reference Manual][docs].
+ ///
+ /// ## Supported arguments
+ ///
+ /// * `"asimd"` or "neon" - FEAT_AdvSIMD
+ /// * `"pmull"` - FEAT_PMULL
+ /// * `"fp"` - FEAT_FP
+ /// * `"fp16"` - FEAT_FP16
+ /// * `"sve"` - FEAT_SVE
+ /// * `"crc"` - FEAT_CRC
+ /// * `"lse"` - FEAT_LSE
+ /// * `"lse2"` - FEAT_LSE2
+ /// * `"rdm"` - FEAT_RDM
+ /// * `"rcpc"` - FEAT_LRCPC
+ /// * `"rcpc2"` - FEAT_LRCPC2
+ /// * `"dotprod"` - FEAT_DotProd
+ /// * `"tme"` - FEAT_TME
+ /// * `"fhm"` - FEAT_FHM
+ /// * `"dit"` - FEAT_DIT
+ /// * `"flagm"` - FEAT_FLAGM
+ /// * `"ssbs"` - FEAT_SSBS
+ /// * `"sb"` - FEAT_SB
+ /// * `"paca"` - FEAT_PAuth (address authentication)
+ /// * `"pacg"` - FEAT_Pauth (generic authentication)
+ /// * `"dpb"` - FEAT_DPB
+ /// * `"dpb2"` - FEAT_DPB2
+ /// * `"sve2"` - FEAT_SVE2
+ /// * `"sve2-aes"` - FEAT_SVE2_AES
+ /// * `"sve2-sm4"` - FEAT_SVE2_SM4
+ /// * `"sve2-sha3"` - FEAT_SVE2_SHA3
+ /// * `"sve2-bitperm"` - FEAT_SVE2_BitPerm
+ /// * `"frintts"` - FEAT_FRINTTS
+ /// * `"i8mm"` - FEAT_I8MM
+ /// * `"f32mm"` - FEAT_F32MM
+ /// * `"f64mm"` - FEAT_F64MM
+ /// * `"bf16"` - FEAT_BF16
+ /// * `"rand"` - FEAT_RNG
+ /// * `"bti"` - FEAT_BTI
+ /// * `"mte"` - FEAT_MTE
+ /// * `"jsconv"` - FEAT_JSCVT
+ /// * `"fcma"` - FEAT_FCMA
+ /// * `"aes"` - FEAT_AES
+ /// * `"sha2"` - FEAT_SHA1 & FEAT_SHA256
+ /// * `"sha3"` - FEAT_SHA512 & FEAT_SHA3
+ /// * `"sm4"` - FEAT_SM3 & FEAT_SM4
+ ///
+ /// [docs]: https://developer.arm.com/documentation/ddi0487/latest
+ #[stable(feature = "simd_aarch64", since = "1.60.0")]
+ @BIND_FEATURE_NAME: "asimd"; "neon";
+ @NO_RUNTIME_DETECTION: "ras";
+ @NO_RUNTIME_DETECTION: "v8.1a";
+ @NO_RUNTIME_DETECTION: "v8.2a";
+ @NO_RUNTIME_DETECTION: "v8.3a";
+ @NO_RUNTIME_DETECTION: "v8.4a";
+ @NO_RUNTIME_DETECTION: "v8.5a";
+ @NO_RUNTIME_DETECTION: "v8.6a";
+ @NO_RUNTIME_DETECTION: "v8.7a";
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] asimd: "neon";
+ /// FEAT_AdvSIMD (Advanced SIMD/NEON)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pmull: "pmull";
+ /// FEAT_PMULL (Polynomial Multiply)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp: "fp";
+ /// FEAT_FP (Floating point support)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp16: "fp16";
+ /// FEAT_FP16 (Half-float support)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve: "sve";
+ /// FEAT_SVE (Scalable Vector Extension)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] crc: "crc";
+ /// FEAT_CRC32 (Cyclic Redundancy Check)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] lse: "lse";
+ /// FEAT_LSE (Large System Extension - atomics)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] lse2: "lse2";
+ /// FEAT_LSE2 (unaligned and register-pair atomics)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rdm: "rdm";
+ /// FEAT_RDM (Rounding Doubling Multiply - ASIMDRDM)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rcpc: "rcpc";
+ /// FEAT_LRCPC (Release consistent Processor consistent)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rcpc2: "rcpc2";
+ /// FEAT_LRCPC2 (RCPC with immediate offsets)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dotprod: "dotprod";
+ /// FEAT_DotProd (Vector Dot-Product - ASIMDDP)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] tme: "tme";
+ /// FEAT_TME (Transactional Memory Extensions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fhm: "fhm";
+ /// FEAT_FHM (fp16 multiplication instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dit: "dit";
+ /// FEAT_DIT (Data Independent Timing instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] flagm: "flagm";
+ /// FEAT_FLAGM (flag manipulation instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] ssbs: "ssbs";
+ /// FEAT_SSBS (speculative store bypass safe)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sb: "sb";
+ /// FEAT_SB (speculation barrier)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] paca: "paca";
+ /// FEAT_PAuth (address authentication)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pacg: "pacg";
+ /// FEAT_PAuth (generic authentication)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb: "dpb";
+ /// FEAT_DPB (aka dcpop - data cache clean to point of persistence)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb2: "dpb2";
+ /// FEAT_DPB2 (aka dcpodp - data cache clean to point of deep persistence)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2: "sve2";
+ /// FEAT_SVE2 (Scalable Vector Extension 2)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_aes: "sve2-aes";
+ /// FEAT_SVE_AES (SVE2 AES crypto)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_sm4: "sve2-sm4";
+ /// FEAT_SVE_SM4 (SVE2 SM4 crypto)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_sha3: "sve2-sha3";
+ /// FEAT_SVE_SHA3 (SVE2 SHA3 crypto)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_bitperm: "sve2-bitperm";
+ /// FEAT_SVE_BitPerm (SVE2 bit permutation instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] frintts: "frintts";
+ /// FEAT_FRINTTS (float to integer rounding instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] i8mm: "i8mm";
+ /// FEAT_I8MM (integer matrix multiplication, plus ASIMD support)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] f32mm: "f32mm";
+ /// FEAT_F32MM (single-precision matrix multiplication)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] f64mm: "f64mm";
+ /// FEAT_F64MM (double-precision matrix multiplication)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] bf16: "bf16";
+ /// FEAT_BF16 (BFloat16 type, plus MM instructions, plus ASIMD support)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rand: "rand";
+ /// FEAT_RNG (Random Number Generator)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] bti: "bti";
+ /// FEAT_BTI (Branch Target Identification)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] mte: "mte";
+ /// FEAT_MTE (Memory Tagging Extension)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] jsconv: "jsconv";
+ /// FEAT_JSCVT (JavaScript float conversion instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fcma: "fcma";
+ /// FEAT_FCMA (float complex number operations)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] aes: "aes";
+ /// FEAT_AES (AES instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha2: "sha2";
+ /// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha3: "sha3";
+ /// FEAT_SHA512 & FEAT_SHA3 (SHA2-512 & SHA3 instructions)
+ @FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sm4: "sm4";
+ /// FEAT_SM3 & FEAT_SM4 (SM3 & SM4 instructions)
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/arm.rs b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
new file mode 100644
index 000000000..897dc314c
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
@@ -0,0 +1,28 @@
+//! Run-time feature detection on ARM Aarch32.
+
+features! {
+ @TARGET: arm;
+ @CFG: target_arch = "arm";
+ @MACRO_NAME: is_arm_feature_detected;
+ @MACRO_ATTRS:
+ /// Checks if `arm` feature is enabled.
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @NO_RUNTIME_DETECTION: "v7";
+ @NO_RUNTIME_DETECTION: "vfp2";
+ @NO_RUNTIME_DETECTION: "vfp3";
+ @NO_RUNTIME_DETECTION: "vfp4";
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] neon: "neon";
+ /// ARM Advanced SIMD (NEON) - Aarch32
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
+ /// Polynomial Multiply
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
+ /// CRC32 (Cyclic Redundancy Check)
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crypto: "crypto";
+ /// Crypto: AES + PMULL + SHA1 + SHA256. Prefer using the individual features where possible.
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] aes: "aes";
+ /// FEAT_AES (AES instructions)
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sha2: "sha2";
+ /// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] i8mm: "i8mm";
+ /// FEAT_I8MM
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/mips.rs b/library/stdarch/crates/std_detect/src/detect/arch/mips.rs
new file mode 100644
index 000000000..ae27d0093
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/mips.rs
@@ -0,0 +1,12 @@
+//! Run-time feature detection on MIPS.
+
+features! {
+ @TARGET: mips;
+ @CFG: target_arch = "mips";
+ @MACRO_NAME: is_mips_feature_detected;
+ @MACRO_ATTRS:
+ /// Checks if `mips` feature is enabled.
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] msa: "msa";
+ /// MIPS SIMD Architecture (MSA)
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/mips64.rs b/library/stdarch/crates/std_detect/src/detect/arch/mips64.rs
new file mode 100644
index 000000000..7182ec2da
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/mips64.rs
@@ -0,0 +1,12 @@
+//! Run-time feature detection on MIPS64.
+
+features! {
+ @TARGET: mips64;
+ @CFG: target_arch = "mips64";
+ @MACRO_NAME: is_mips64_feature_detected;
+ @MACRO_ATTRS:
+ /// Checks if `mips64` feature is enabled.
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] msa: "msa";
+ /// MIPS SIMD Architecture (MSA)
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/mod.rs b/library/stdarch/crates/std_detect/src/detect/arch/mod.rs
new file mode 100644
index 000000000..81a1f23e8
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/mod.rs
@@ -0,0 +1,56 @@
+#![allow(dead_code)]
+
+use cfg_if::cfg_if;
+
+// Export the macros for all supported architectures.
+#[macro_use]
+mod x86;
+#[macro_use]
+mod arm;
+#[macro_use]
+mod aarch64;
+#[macro_use]
+mod riscv;
+#[macro_use]
+mod powerpc;
+#[macro_use]
+mod powerpc64;
+#[macro_use]
+mod mips;
+#[macro_use]
+mod mips64;
+
+cfg_if! {
+ if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
+ pub use x86::*;
+ } else if #[cfg(target_arch = "arm")] {
+ pub use arm::*;
+ } else if #[cfg(target_arch = "aarch64")] {
+ pub use aarch64::*;
+ } else if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] {
+ pub use riscv::*;
+ } else if #[cfg(target_arch = "powerpc")] {
+ pub use powerpc::*;
+ } else if #[cfg(target_arch = "powerpc64")] {
+ pub use powerpc64::*;
+ } else if #[cfg(target_arch = "mips")] {
+ pub use mips::*;
+ } else if #[cfg(target_arch = "mips64")] {
+ pub use mips64::*;
+ } else {
+ // Unimplemented architecture:
+ #[doc(hidden)]
+ pub(crate) enum Feature {
+ Null
+ }
+ #[doc(hidden)]
+ pub mod __is_feature_detected {}
+
+ impl Feature {
+ #[doc(hidden)]
+ pub(crate) fn from_str(_s: &str) -> Result<Feature, ()> { Err(()) }
+ #[doc(hidden)]
+ pub(crate) fn to_str(self) -> &'static str { "" }
+ }
+ }
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs b/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs
new file mode 100644
index 000000000..d135cd95d
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs
@@ -0,0 +1,16 @@
+//! Run-time feature detection on PowerPC.
+
+features! {
+ @TARGET: powerpc;
+ @CFG: target_arch = "powerpc";
+ @MACRO_NAME: is_powerpc_feature_detected;
+ @MACRO_ATTRS:
+ /// Checks if `powerpc` feature is enabled.
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
+ /// Altivec
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
+ /// VSX
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] power8: "power8";
+ /// Power8
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs b/library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs
new file mode 100644
index 000000000..773afd6ce
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs
@@ -0,0 +1,16 @@
+//! Run-time feature detection on PowerPC64.
+
+features! {
+ @TARGET: powerpc64;
+ @CFG: target_arch = "powerpc64";
+ @MACRO_NAME: is_powerpc64_feature_detected;
+ @MACRO_ATTRS:
+ /// Checks if `powerpc` feature is enabled.
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
+ /// Altivec
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
+ /// VSX
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] power8: "power8";
+ /// Power8
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/riscv.rs b/library/stdarch/crates/std_detect/src/detect/arch/riscv.rs
new file mode 100644
index 000000000..5ea36e7c1
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/riscv.rs
@@ -0,0 +1,206 @@
+//! Run-time feature detection on RISC-V.
+
+features! {
+ @TARGET: riscv;
+ @CFG: any(target_arch = "riscv32", target_arch = "riscv64");
+ @MACRO_NAME: is_riscv_feature_detected;
+ @MACRO_ATTRS:
+ /// A macro to test at *runtime* whether instruction sets are available on
+ /// RISC-V platforms.
+ ///
+ /// RISC-V standard defined the base sets and the extension sets.
+ /// The base sets are RV32I, RV64I, RV32E or RV128I. Any RISC-V platform
+ /// must support one base set and/or multiple extension sets.
+ ///
+ /// Any RISC-V standard instruction sets can be in state of either ratified,
+ /// frozen or draft. The version and status of current standard instruction
+ /// sets can be checked out from preface section of the [ISA manual].
+ ///
+ /// Platform may define and support their own custom instruction sets with
+ /// ISA prefix X. These sets are highly platform specific and should be
+ /// detected with their own platform support crates.
+ ///
+ /// # Unprivileged Specification
+ ///
+ /// The supported ratified RISC-V instruction sets are as follows:
+ ///
+ /// * RV32I: `"rv32i"`
+ /// * Zifencei: `"zifencei"`
+ /// * Zihintpause: `"zihintpause"`
+ /// * RV64I: `"rv64i"`
+ /// * M: `"m"`
+ /// * A: `"a"`
+ /// * Zicsr: `"zicsr"`
+ /// * Zicntr: `"zicntr"`
+ /// * Zihpm: `"zihpm"`
+ /// * F: `"f"`
+ /// * D: `"d"`
+ /// * Q: `"q"`
+ /// * C: `"c"`
+ ///
+ /// There's also bases and extensions marked as standard instruction set,
+ /// but they are in frozen or draft state. These instruction sets are also
+ /// reserved by this macro and can be detected in the future platforms.
+ ///
+ /// Frozen RISC-V instruction sets:
+ ///
+ /// * Zfinx: `"zfinx"`
+ /// * Zdinx: `"zdinx"`
+ /// * Zhinx: `"zhinx"`
+ /// * Zhinxmin: `"zhinxmin"`
+ /// * Ztso: `"ztso"`
+ ///
+ /// Draft RISC-V instruction sets:
+ ///
+ /// * RV32E: `"rv32e"`
+ /// * RV128I: `"rv128i"`
+ /// * Zfh: `"zfh"`
+ /// * Zfhmin: `"zfhmin"`
+ /// * B: `"b"`
+ /// * J: `"j"`
+ /// * P: `"p"`
+ /// * V: `"v"`
+ /// * Zam: `"zam"`
+ ///
+ /// Defined by Privileged Specification:
+ ///
+ /// * Supervisor: `"s"`
+ /// * Svnapot: `"svnapot"`
+ /// * Svpbmt: `"svpbmt"`
+ /// * Svinval: `"svinval"`
+ /// * Hypervisor: `"h"`
+ ///
+ /// # RISC-V Bit-Manipulation ISA-extensions
+ ///
+ /// This document defined the following extensions:
+ ///
+ /// * Zba: `"zba"`
+ /// * Zbb: `"zbb"`
+ /// * Zbc: `"zbc"`
+ /// * Zbs: `"zbs"`
+ ///
+ /// # RISC-V Cryptography Extensions
+ ///
+ /// These extensions are defined in Volume I, Scalar & Entropy Source
+ /// Instructions:
+ ///
+ /// * Zbkb: `"zbkb"`
+ /// * Zbkc: `"zbkc"`
+ /// * Zbkx: `"zbkx"`
+ /// * Zknd: `"zknd"`
+ /// * Zkne: `"zkne"`
+ /// * Zknh: `"zknh"`
+ /// * Zksed: `"zksed"`
+ /// * Zksh: `"zksh"`
+ /// * Zkr: `"zkr"`
+ /// * Zkn: `"zkn"`
+ /// * Zks: `"zks"`
+ /// * Zk: `"zk"`
+ /// * Zkt: `"zkt"`
+ ///
+ /// [ISA manual]: https://github.com/riscv/riscv-isa-manual/
+ #[unstable(feature = "stdsimd", issue = "27731")]
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rv32i: "rv32i";
+ /// RV32I Base Integer Instruction Set
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zifencei: "zifencei";
+ /// "Zifencei" Instruction-Fetch Fence
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zihintpause: "zihintpause";
+ /// "Zihintpause" Pause Hint
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rv64i: "rv64i";
+ /// RV64I Base Integer Instruction Set
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] m: "m";
+ /// "M" Standard Extension for Integer Multiplication and Division
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] a: "a";
+ /// "A" Standard Extension for Atomic Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zicsr: "zicsr";
+ /// "Zicsr", Control and Status Register (CSR) Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zicntr: "zicntr";
+ /// "Zicntr", Standard Extension for Base Counters and Timers
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zihpm: "zihpm";
+ /// "Zihpm", Standard Extension for Hardware Performance Counters
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f: "f";
+ /// "F" Standard Extension for Single-Precision Floating-Point
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] d: "d";
+ /// "D" Standard Extension for Double-Precision Floating-Point
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] q: "q";
+ /// "Q" Standard Extension for Quad-Precision Floating-Point
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] c: "c";
+ /// "C" Standard Extension for Compressed Instructions
+
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zfinx: "zfinx";
+ /// "Zfinx" Standard Extension for Single-Precision Floating-Point in Integer Registers
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zdinx: "zdinx";
+ /// "Zdinx" Standard Extension for Double-Precision Floating-Point in Integer Registers
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zhinx: "zhinx";
+ /// "Zhinx" Standard Extension for Half-Precision Floating-Point in Integer Registers
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zhinxmin: "zhinxmin";
+ /// "Zhinxmin" Standard Extension for Minimal Half-Precision Floating-Point in Integer Registers
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] ztso: "ztso";
+ /// "Ztso" Standard Extension for Total Store Ordering
+
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rv32e: "rv32e";
+ /// RV32E Base Integer Instruction Set
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rv128i: "rv128i";
+ /// RV128I Base Integer Instruction Set
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zfh: "zfh";
+ /// "Zfh" Standard Extension for 16-Bit Half-Precision Floating-Point
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zfhmin: "zfhmin";
+ /// "Zfhmin" Standard Extension for Minimal Half-Precision Floating-Point Support
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] b: "b";
+ /// "B" Standard Extension for Bit Manipulation
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] j: "j";
+ /// "J" Standard Extension for Dynamically Translated Languages
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] p: "p";
+ /// "P" Standard Extension for Packed-SIMD Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] v: "v";
+ /// "V" Standard Extension for Vector Operations
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zam: "zam";
+ /// "Zam" Standard Extension for Misaligned Atomics
+
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] s: "s";
+ /// Supervisor-Level ISA
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] svnapot: "svnapot";
+ /// "Svnapot" Standard Extension for NAPOT Translation Contiguity
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] svpbmt: "svpbmt";
+ /// "Svpbmt" Standard Extension for Page-Based Memory Types
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] svinval: "svinval";
+ /// "Svinval" Standard Extension for Fine-Grained Address-Translation Cache Invalidation
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] h: "h";
+ /// Hypervisor Extension
+
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zba: "zba";
+ /// "Zba" Standard Extension for Address Generation Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbb: "zbb";
+ /// "Zbb" Standard Extension for Basic Bit-Manipulation
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbc: "zbc";
+ /// "Zbc" Standard Extension for Carry-less Multiplication
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbs: "zbs";
+ /// "Zbs" Standard Extension for Single-Bit instructions
+
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbkb: "zbkb";
+ /// "Zbkb" Standard Extension for Bitmanip instructions for Cryptography
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbkc: "zbkc";
+ /// "Zbkc" Standard Extension for Carry-less multiply instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zbkx: "zbkx";
+ /// "Zbkx" Standard Extension for Crossbar permutation instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zknd: "zknd";
+ /// "Zknd" Standard Extension for NIST Suite: AES Decryption
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zkne: "zkne";
+ /// "Zkne" Standard Extension for NIST Suite: AES Encryption
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zknh: "zknh";
+ /// "Zknh" Standard Extension for NIST Suite: Hash Function Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zksed: "zksed";
+ /// "Zksed" Standard Extension for ShangMi Suite: SM4 Block Cipher Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zksh: "zksh";
+ /// "Zksh" Standard Extension for ShangMi Suite: SM3 Hash Function Instructions
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zkr: "zkr";
+ /// "Zkr" Standard Extension for Entropy Source Extension
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zkn: "zkn";
+ /// "Zkn" Standard Extension for NIST Algorithm Suite
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zks: "zks";
+ /// "Zks" Standard Extension for ShangMi Algorithm Suite
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zk: "zk";
+ /// "Zk" Standard Extension for Standard scalar cryptography extension
+ @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] zkt: "zkt";
+ /// "Zkt" Standard Extension for Data Independent Execution Latency
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/x86.rs b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs
new file mode 100644
index 000000000..893e1a887
--- /dev/null
+++ b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs
@@ -0,0 +1,197 @@
+//! This module implements minimal run-time feature detection for x86.
+//!
+//! The features are detected using the `detect_features` function below.
+//! This function uses the CPUID instruction to read the feature flags from the
+//! CPU and encodes them in a `usize` where each bit position represents
+//! whether a feature is available (bit is set) or unavailable (bit is cleared).
+//!
+//! The enum `Feature` is used to map bit positions to feature names, and the
+//! the `__crate::detect::check_for!` macro is used to map string literals (e.g.,
+//! "avx") to these bit positions (e.g., `Feature::avx`).
+//!
+//! The run-time feature detection is performed by the
+//! `__crate::detect::check_for(Feature) -> bool` function. On its first call,
+//! this functions queries the CPU for the available features and stores them
+//! in a global `AtomicUsize` variable. The query is performed by just checking
+//! whether the feature bit in this global variable is set or cleared.
+
+features! {
+ @TARGET: x86;
+ @CFG: any(target_arch = "x86", target_arch = "x86_64");
+ @MACRO_NAME: is_x86_feature_detected;
+ @MACRO_ATTRS:
+ /// A macro to test at *runtime* whether a CPU feature is available on
+ /// x86/x86-64 platforms.
+ ///
+ /// This macro is provided in the standard library and will detect at runtime
+ /// whether the specified CPU feature is detected. This does **not** resolve at
+ /// compile time unless the specified feature is already enabled for the entire
+ /// crate. Runtime detection currently relies mostly on the `cpuid` instruction.
+ ///
+ /// This macro only takes one argument which is a string literal of the feature
+ /// being tested for. The feature names supported are the lowercase versions of
+ /// the ones defined by Intel in [their documentation][docs].
+ ///
+ /// ## Supported arguments
+ ///
+ /// This macro supports the same names that `#[target_feature]` supports. Unlike
+ /// `#[target_feature]`, however, this macro does not support names separated
+ /// with a comma. Instead testing for multiple features must be done through
+ /// separate macro invocations for now.
+ ///
+ /// Supported arguments are:
+ ///
+ /// * `"aes"`
+ /// * `"pclmulqdq"`
+ /// * `"rdrand"`
+ /// * `"rdseed"`
+ /// * `"tsc"`
+ /// * `"mmx"`
+ /// * `"sse"`
+ /// * `"sse2"`
+ /// * `"sse3"`
+ /// * `"ssse3"`
+ /// * `"sse4.1"`
+ /// * `"sse4.2"`
+ /// * `"sse4a"`
+ /// * `"sha"`
+ /// * `"avx"`
+ /// * `"avx2"`
+ /// * `"avx512f"`
+ /// * `"avx512cd"`
+ /// * `"avx512er"`
+ /// * `"avx512pf"`
+ /// * `"avx512bw"`
+ /// * `"avx512dq"`
+ /// * `"avx512vl"`
+ /// * `"avx512ifma"`
+ /// * `"avx512vbmi"`
+ /// * `"avx512vpopcntdq"`
+ /// * `"avx512vbmi2"`
+ /// * `"avx512gfni"`
+ /// * `"avx512vaes"`
+ /// * `"avx512vpclmulqdq"`
+ /// * `"avx512vnni"`
+ /// * `"avx512bitalg"`
+ /// * `"avx512bf16"`
+ /// * `"avx512vp2intersect"`
+ /// * `"f16c"`
+ /// * `"fma"`
+ /// * `"bmi1"`
+ /// * `"bmi2"`
+ /// * `"abm"`
+ /// * `"lzcnt"`
+ /// * `"tbm"`
+ /// * `"popcnt"`
+ /// * `"fxsr"`
+ /// * `"xsave"`
+ /// * `"xsaveopt"`
+ /// * `"xsaves"`
+ /// * `"xsavec"`
+ /// * `"cmpxchg16b"`
+ /// * `"adx"`
+ /// * `"rtm"`
+ ///
+ /// [docs]: https://software.intel.com/sites/landingpage/IntrinsicsGuide
+ #[stable(feature = "simd_x86", since = "1.27.0")]
+ @BIND_FEATURE_NAME: "abm"; "lzcnt"; // abm is a synonym for lzcnt
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] aes: "aes";
+ /// AES (Advanced Encryption Standard New Instructions AES-NI)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] pclmulqdq: "pclmulqdq";
+ /// CLMUL (Carry-less Multiplication)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdrand: "rdrand";
+ /// RDRAND
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdseed: "rdseed";
+ /// RDSEED
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tsc: "tsc";
+ /// TSC (Time Stamp Counter)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] mmx: "mmx";
+ /// MMX (MultiMedia eXtensions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse: "sse";
+ /// SSE (Streaming SIMD Extensions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse2: "sse2";
+ /// SSE2 (Streaming SIMD Extensions 2)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse3: "sse3";
+ /// SSE3 (Streaming SIMD Extensions 3)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ssse3: "ssse3";
+ /// SSSE3 (Supplemental Streaming SIMD Extensions 3)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_1: "sse4.1";
+ /// SSE4.1 (Streaming SIMD Extensions 4.1)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_2: "sse4.2";
+ /// SSE4.2 (Streaming SIMD Extensions 4.2)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4a: "sse4a";
+ /// SSE4a (Streaming SIMD Extensions 4a)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sha: "sha";
+ /// SHA
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx: "avx";
+ /// AVX (Advanced Vector Extensions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2";
+ /// AVX2 (Advanced Vector Extensions 2)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512f: "avx512f" ;
+ /// AVX-512 F (Foundation)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512cd: "avx512cd" ;
+ /// AVX-512 CD (Conflict Detection Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512er: "avx512er";
+ /// AVX-512 ER (Expo nential and Reciprocal Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512pf: "avx512pf";
+ /// AVX-512 PF (Prefetch Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bw: "avx512bw";
+ /// AVX-512 BW (Byte and Word Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512dq: "avx512dq";
+ /// AVX-512 DQ (Doubleword and Quadword)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vl: "avx512vl";
+ /// AVX-512 VL (Vector Length Extensions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512ifma: "avx512ifma";
+ /// AVX-512 IFMA (Integer Fused Multiply Add)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi: "avx512vbmi";
+ /// AVX-512 VBMI (Vector Byte Manipulation Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vpopcntdq: "avx512vpopcntdq";
+ /// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and
+ /// Quadword)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi2: "avx512vbmi2";
+ /// AVX-512 VBMI2 (Additional byte, word, dword and qword capabilities)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512gfni: "avx512gfni";
+ /// AVX-512 GFNI (Galois Field New Instruction)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vaes: "avx512vaes";
+ /// AVX-512 VAES (Vector AES instruction)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vpclmulqdq: "avx512vpclmulqdq";
+ /// AVX-512 VPCLMULQDQ (Vector PCLMULQDQ instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vnni: "avx512vnni";
+ /// AVX-512 VNNI (Vector Neural Network Instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bitalg: "avx512bitalg";
+ /// AVX-512 BITALG (Support for VPOPCNT\[B,W\] and VPSHUFBITQMB)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bf16: "avx512bf16";
+ /// AVX-512 BF16 (BFLOAT16 instructions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vp2intersect: "avx512vp2intersect";
+ /// AVX-512 P2INTERSECT
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] f16c: "f16c";
+ /// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fma: "fma";
+ /// FMA (Fused Multiply Add)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi1: "bmi1" ;
+ /// BMI1 (Bit Manipulation Instructions 1)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi2: "bmi2" ;
+ /// BMI2 (Bit Manipulation Instructions 2)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] lzcnt: "lzcnt";
+ /// ABM (Advanced Bit Manipulation) / LZCNT (Leading Zero Count)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tbm: "tbm";
+ /// TBM (Trailing Bit Manipulation)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] popcnt: "popcnt";
+ /// POPCNT (Population Count)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fxsr: "fxsr";
+ /// FXSR (Floating-point context fast save and restore)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsave: "xsave";
+ /// XSAVE (Save Processor Extended States)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaveopt: "xsaveopt";
+ /// XSAVEOPT (Save Processor Extended States Optimized)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaves: "xsaves";
+ /// XSAVES (Save Processor Extended States Supervisor)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsavec: "xsavec";
+ /// XSAVEC (Save Processor Extended States Compacted)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] cmpxchg16b: "cmpxchg16b";
+ /// CMPXCH16B (16-byte compare-and-swap instruction)
+ @FEATURE: #[stable(feature = "simd_x86_adx", since = "1.33.0")] adx: "adx";
+ /// ADX, Intel ADX (Multi-Precision Add-Carry Instruction Extensions)
+ @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rtm: "rtm";
+ /// RTM, Intel (Restricted Transactional Memory)
+}