Skip to content

Commit 9411f39

Browse files
committed
Update aarch64 linux feature detection
This commit doesn't add support for features not available in LLVM 12
1 parent cfb137b commit 9411f39

File tree

4 files changed

+332
-63
lines changed

4 files changed

+332
-63
lines changed

crates/std_detect/src/detect/arch/aarch64.rs

+123-13
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,145 @@ features! {
44
@TARGET: aarch64;
55
@MACRO_NAME: is_aarch64_feature_detected;
66
@MACRO_ATTRS:
7-
/// Checks if `aarch64` feature is enabled.
7+
/// This macro tests, at runtime, whether an `aarch64` feature is enabled on aarch64 platforms.
8+
/// Currently most features are only supported on linux-based platforms.
9+
///
10+
/// This macro takes one argument which is a string literal of the feature being tested for.
11+
/// The feature names are mostly taken from their FEAT_* definitiions in the [ARM Architecture
12+
/// Reference Manual][docs].
13+
///
14+
/// ## Supported arguments
15+
///
16+
/// * `"asimd"` or "neon" - FEAT_AdvSIMD
17+
/// * `"pmull"` - FEAT_PMULL
18+
/// * `"fp"` - FEAT_FP
19+
/// * `"fp16"` - FEAT_FP16
20+
/// * `"sve"` - FEAT_SVE
21+
/// * `"crc"` - FEAT_CRC
22+
/// * `"crypto"` - Cryptographic Extension (AES + PMULL + SHA1 + SHA2-256)
23+
/// * `"lse"` - FEAT_LSE
24+
/// * `"lse2"` - FEAT_LSE2
25+
/// * `"rdm"` - FEAT_RDM
26+
/// * `"rcpc"` - FEAT_LRCPC
27+
/// * `"rcpc2"` - FEAT_LRCPC2
28+
/// * `"dotprod"` - FEAT_DotProd
29+
/// * `"tme"` - FEAT_TME
30+
/// * `"fhm"` - FEAT_FHM
31+
/// * `"dit"` - FEAT_DIT
32+
/// * `"flagm"` - FEAT_FLAGM
33+
/// * `"ssbs"` - FEAT_SSBS
34+
/// * `"sb"` - FEAT_SB
35+
/// * `"pauth"` - FEAT_PAuth
36+
/// * `"dpb"` - FEAT_DPB
37+
/// * `"dpb2"` - FEAT_DPB2
38+
/// * `"sve2"` - FEAT_SVE2
39+
/// * `"sve2-aes"` - FEAT_SVE2_AES
40+
/// * `"sve2-sm4"` - FEAT_SVE2_SM4
41+
/// * `"sve2-sha3"` - FEAT_SVE2_SHA3
42+
/// * `"sve2-bitperm"` - FEAT_SVE2_BitPerm
43+
/// * `"fptoint"` - FEAT_FRINTTS
44+
/// * `"i8mm"` - FEAT_I8MM
45+
/// * `"f32mm"` - FEAT_F32MM
46+
/// * `"f64mm"` - FEAT_F64MM
47+
/// * `"bf16"` - FEAT_BF16
48+
/// * `"rand"` - FEAT_RNG
49+
/// * `"bti"` - FEAT_BTI
50+
/// * `"mte"` - FEAT_MTE
51+
/// * `"jsconv"` - FEAT_JSCVT
52+
/// * `"fcma"` - FEAT_FCMA
53+
/// * `"sha2"` - FEAT_SHA1 & FEAT_SHA256
54+
/// * `"sha3"` - FEAT_SHA512 & FEAT_SHA3
55+
/// * `"sm4"` - FEAT_SM3 & FEAT_SM4
56+
///
57+
/// [docs]: https://developer.arm.com/documentation/ddi0487/latest
858
#[unstable(feature = "stdsimd", issue = "27731")]
959
@BIND_FEATURE_NAME: "asimd"; "neon";
1060
@NO_RUNTIME_DETECTION: "ras";
1161
@NO_RUNTIME_DETECTION: "v8.1a";
1262
@NO_RUNTIME_DETECTION: "v8.2a";
1363
@NO_RUNTIME_DETECTION: "v8.3a";
64+
@NO_RUNTIME_DETECTION: "v8.4a";
65+
@NO_RUNTIME_DETECTION: "v8.5a";
66+
@NO_RUNTIME_DETECTION: "v8.6a";
67+
@NO_RUNTIME_DETECTION: "v8.7a";
1468
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] asimd: "neon";
15-
/// ARM Advanced SIMD (ASIMD)
69+
/// FEAT_AdvSIMD (Advanced SIMD/NEON)
1670
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
17-
/// Polynomial Multiply
71+
/// FEAT_PMULL (Polynomial Multiply)
1872
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp: "fp";
19-
/// Floating point support
73+
/// FEAT_FP (Floating point support)
2074
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp16: "fp16";
21-
/// Half-float support.
75+
/// FEAT_FP16 (Half-float support)
2276
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve: "sve";
23-
/// Scalable Vector Extension (SVE)
77+
/// FEAT_SVE (Scalable Vector Extension)
2478
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
25-
/// CRC32 (Cyclic Redundancy Check)
79+
/// FEAT_CRC32 (Cyclic Redundancy Check)
2680
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crypto: "crypto";
27-
/// Crypto: AES + PMULL + SHA1 + SHA2
81+
/// Cryptographic Extension (AES + PMULL + SHA1 + SHA2-256)
2882
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] lse: "lse";
29-
/// Atomics (Large System Extension)
83+
/// FEAT_LSE (Large System Extension - atomics)
84+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] lse2: "lse2";
85+
/// FEAT_LSE2 (unaligned and register-pair atomics)
3086
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rdm: "rdm";
31-
/// Rounding Double Multiply (ASIMDRDM)
87+
/// FEAT_RDM (Rounding Doubling Multiply - ASIMDRDM)
3288
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rcpc: "rcpc";
33-
/// Release consistent Processor consistent (RcPc)
89+
/// FEAT_LRCPC (Release consistent Processor consistent)
90+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rcpc2: "rcpc2";
91+
/// FEAT_LRCPC2 (RCPC with immediate offsets)
3492
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dotprod: "dotprod";
35-
/// Vector Dot-Product (ASIMDDP)
93+
/// FEAT_DotProd (Vector Dot-Product - ASIMDDP)
3694
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] tme: "tme";
37-
/// Transactional Memory Extensions (TME)
95+
/// FEAT_TME (Transactional Memory Extensions)
96+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fhm: "fhm";
97+
/// FEAT_FHM (fp16 multiplication instructions)
98+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dit: "dit";
99+
/// FEAT_DIT (Data Independent Timing instructions)
100+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] flagm: "flagm";
101+
/// FEAT_FLAGM (flag manipulation instructions)
102+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] ssbs: "ssbs";
103+
/// FEAT_SSBS (speculative store bypass safe)
104+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sb: "sb";
105+
/// FEAT_SB (speculation barrier)
106+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pauth: "pauth";
107+
/// FEAT_PAuth (pointer authentication)
108+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dpb: "dpb";
109+
/// FEAT_DPB (aka dcpop - data cache clean to point of persistance)
110+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dpb2: "dpb2";
111+
/// FEAT_DPB2 (aka dcpodp - data cache clean to point of deep persistance)
112+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve2: "sve2";
113+
/// FEAT_SVE2 (Scalable Vector Extension 2)
114+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve2_aes: "sve2-aes";
115+
/// FEAT_SVE_AES (SVE2 AES crypto)
116+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve2_sm4: "sve2-sm4";
117+
/// FEAT_SVE_SM4 (SVE2 SM4 crypto)
118+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve2_sha3: "sve2-sha3";
119+
/// FEAT_SVE_SHA3 (SVE2 SHA3 crypto)
120+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve2_bitperm: "sve2-bitperm";
121+
/// FEAT_SVE_BitPerm (SVE2 bit permutation instructions)
122+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fptoint: "fptoint";
123+
/// FEAT_FRINTTS (float to integer rounding instructions)
124+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] i8mm: "i8mm";
125+
/// FEAT_I8MM (integer matrix multiplication, plus ASIMD support)
126+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f32mm: "f32mm";
127+
/// FEAT_F32MM (single-precision matrix multiplication)
128+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f64mm: "f64mm";
129+
/// FEAT_F64MM (double-precision matrix multiplication)
130+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] bf16: "bf16";
131+
/// FEAT_BF16 (BFloat16 type, plus MM instructions, plus ASIMD support)
132+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rand: "rand";
133+
/// FEAT_RNG (Random Number Generator)
134+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] bti: "bti";
135+
/// FEAT_BTI (Branch Target Identification)
136+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] mte: "mte";
137+
/// FEAT_MTE (Memory Tagging Extension)
138+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] jsconv: "jsconv";
139+
/// FEAT_JSCVT (JavaScript float conversion instructions)
140+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fcma: "fcma";
141+
/// FEAT_FCMA (float complex number operations)
142+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sha2: "sha2";
143+
/// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
144+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sha3: "sha3";
145+
/// FEAT_SHA512 & FEAT_SHA3 (SHA2-512 & SHA3 instructions)
146+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sm4: "sm4";
147+
/// FEAT_SM3 & FEAT_SM4 (SM3 & SM4 instructions)
38148
}

crates/std_detect/src/detect/bit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
#[allow(dead_code)]
55
#[inline]
66
pub(crate) fn test(x: usize, bit: u32) -> bool {
7-
debug_assert!(bit < 32, "bit index out-of-bounds");
7+
debug_assert!(bit < usize::BITS, "bit index out-of-bounds");
88
x & (1 << bit) != 0
99
}

0 commit comments

Comments
 (0)