Skip to content

Commit 3f60e64

Browse files
committed
Enforce staged_api on a per-feature basis
1 parent 4185960 commit 3f60e64

File tree

9 files changed

+87
-67
lines changed

9 files changed

+87
-67
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ features! {
1111
@NO_RUNTIME_DETECTION: "v8.1a";
1212
@NO_RUNTIME_DETECTION: "v8.2a";
1313
@NO_RUNTIME_DETECTION: "v8.3a";
14-
@FEATURE: asimd: "neon";
14+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] asimd: "neon";
1515
/// ARM Advanced SIMD (ASIMD)
16-
@FEATURE: pmull: "pmull";
16+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
1717
/// Polynomial Multiply
18-
@FEATURE: fp: "fp";
18+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp: "fp";
1919
/// Floating point support
20-
@FEATURE: fp16: "fp16";
20+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp16: "fp16";
2121
/// Half-float support.
22-
@FEATURE: sve: "sve";
22+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve: "sve";
2323
/// Scalable Vector Extension (SVE)
24-
@FEATURE: crc: "crc";
24+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
2525
/// CRC32 (Cyclic Redundancy Check)
26-
@FEATURE: crypto: "crypto";
26+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crypto: "crypto";
2727
/// Crypto: AES + PMULL + SHA1 + SHA2
28-
@FEATURE: lse: "lse";
28+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] lse: "lse";
2929
/// Atomics (Large System Extension)
30-
@FEATURE: rdm: "rdm";
30+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rdm: "rdm";
3131
/// Rounding Double Multiply (ASIMDRDM)
32-
@FEATURE: rcpc: "rcpc";
32+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rcpc: "rcpc";
3333
/// Release consistent Processor consistent (RcPc)
34-
@FEATURE: dotprod: "dotprod";
34+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dotprod: "dotprod";
3535
/// Vector Dot-Product (ASIMDDP)
3636
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ features! {
1010
@NO_RUNTIME_DETECTION: "vfp2";
1111
@NO_RUNTIME_DETECTION: "vfp3";
1212
@NO_RUNTIME_DETECTION: "vfp4";
13-
@FEATURE: neon: "neon";
13+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] neon: "neon";
1414
/// ARM Advanced SIMD (NEON) - Aarch32
15-
@FEATURE: pmull: "pmull";
15+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
1616
/// Polynomial Multiply
1717
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ features! {
66
@MACRO_ATTRS:
77
/// Checks if `mips` feature is enabled.
88
#[unstable(feature = "stdsimd", issue = "27731")]
9-
@FEATURE: msa: "msa";
9+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] msa: "msa";
1010
/// MIPS SIMD Architecture (MSA)
1111
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ features! {
66
@MACRO_ATTRS:
77
/// Checks if `mips64` feature is enabled.
88
#[unstable(feature = "stdsimd", issue = "27731")]
9-
@FEATURE: msa: "msa";
9+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] msa: "msa";
1010
/// MIPS SIMD Architecture (MSA)
1111
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ features! {
66
@MACRO_ATTRS:
77
/// Checks if `powerpc` feature is enabled.
88
#[unstable(feature = "stdsimd", issue = "27731")]
9-
@FEATURE: altivec: "altivec";
9+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
1010
/// Altivec
11-
@FEATURE: vsx: "vsx";
11+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
1212
/// VSX
13-
@FEATURE: power8: "power8";
13+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] power8: "power8";
1414
/// Power8
1515
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ features! {
66
@MACRO_ATTRS:
77
/// Checks if `powerpc` feature is enabled.
88
#[unstable(feature = "stdsimd", issue = "27731")]
9-
@FEATURE: altivec: "altivec";
9+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
1010
/// Altivec
11-
@FEATURE: vsx: "vsx";
11+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
1212
/// VSX
13-
@FEATURE: power8: "power8";
13+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] power8: "power8";
1414
/// Power8
1515
}

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

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -82,87 +82,87 @@ features! {
8282
/// [docs]: https://software.intel.com/sites/landingpage/IntrinsicsGuide
8383
#[stable(feature = "simd_x86", since = "1.27.0")]
8484
@BIND_FEATURE_NAME: "abm"; "lzcnt"; // abm is a synonym for lzcnt
85-
@FEATURE: aes: "aes";
85+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] aes: "aes";
8686
/// AES (Advanced Encryption Standard New Instructions AES-NI)
87-
@FEATURE: pclmulqdq: "pclmulqdq";
87+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] pclmulqdq: "pclmulqdq";
8888
/// CLMUL (Carry-less Multiplication)
89-
@FEATURE: rdrand: "rdrand";
89+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdrand: "rdrand";
9090
/// RDRAND
91-
@FEATURE: rdseed: "rdseed";
91+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdseed: "rdseed";
9292
/// RDSEED
93-
@FEATURE: tsc: "tsc";
93+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tsc: "tsc";
9494
/// TSC (Time Stamp Counter)
95-
@FEATURE: mmx: "mmx";
95+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] mmx: "mmx";
9696
/// MMX (MultiMedia eXtensions)
97-
@FEATURE: sse: "sse";
97+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse: "sse";
9898
/// SSE (Streaming SIMD Extensions)
99-
@FEATURE: sse2: "sse2";
99+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse2: "sse2";
100100
/// SSE2 (Streaming SIMD Extensions 2)
101-
@FEATURE: sse3: "sse3";
101+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse3: "sse3";
102102
/// SSE3 (Streaming SIMD Extensions 3)
103-
@FEATURE: ssse3: "ssse3";
103+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ssse3: "ssse3";
104104
/// SSSE3 (Supplemental Streaming SIMD Extensions 3)
105-
@FEATURE: sse4_1: "sse4.1";
105+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_1: "sse4.1";
106106
/// SSE4.1 (Streaming SIMD Extensions 4.1)
107-
@FEATURE: sse4_2: "sse4.2";
107+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_2: "sse4.2";
108108
/// SSE4.2 (Streaming SIMD Extensions 4.2)
109-
@FEATURE: sse4a: "sse4a";
109+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sse4a: "sse4a";
110110
/// SSE4a (Streaming SIMD Extensions 4a)
111-
@FEATURE: sha: "sha";
111+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sha: "sha";
112112
/// SHA
113-
@FEATURE: avx: "avx";
113+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx: "avx";
114114
/// AVX (Advanced Vector Extensions)
115-
@FEATURE: avx2: "avx2";
115+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2";
116116
/// AVX2 (Advanced Vector Extensions 2)
117-
@FEATURE: avx512f: "avx512f" ;
117+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512f: "avx512f" ;
118118
/// AVX-512 F (Foundation)
119-
@FEATURE: avx512cd: "avx512cd" ;
119+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512cd: "avx512cd" ;
120120
/// AVX-512 CD (Conflict Detection Instructions)
121-
@FEATURE: avx512er: "avx512er";
121+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512er: "avx512er";
122122
/// AVX-512 ER (Expo nential and Reciprocal Instructions)
123-
@FEATURE: avx512pf: "avx512pf";
123+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512pf: "avx512pf";
124124
/// AVX-512 PF (Prefetch Instructions)
125-
@FEATURE: avx512bw: "avx512bw";
125+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512bw: "avx512bw";
126126
/// AVX-512 BW (Byte and Word Instructions)
127-
@FEATURE: avx512dq: "avx512dq";
127+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512dq: "avx512dq";
128128
/// AVX-512 DQ (Doubleword and Quadword)
129-
@FEATURE: avx512vl: "avx512vl";
129+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vl: "avx512vl";
130130
/// AVX-512 VL (Vector Length Extensions)
131-
@FEATURE: avx512ifma: "avx512ifma";
131+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512ifma: "avx512ifma";
132132
/// AVX-512 IFMA (Integer Fused Multiply Add)
133-
@FEATURE: avx512vbmi: "avx512vbmi";
133+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi: "avx512vbmi";
134134
/// AVX-512 VBMI (Vector Byte Manipulation Instructions)
135-
@FEATURE: avx512vpopcntdq: "avx512vpopcntdq";
135+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpopcntdq: "avx512vpopcntdq";
136136
/// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and
137137
/// Quadword)
138-
@FEATURE: f16c: "f16c";
138+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f16c: "f16c";
139139
/// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats)
140-
@FEATURE: fma: "fma";
140+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fma: "fma";
141141
/// FMA (Fused Multiply Add)
142-
@FEATURE: bmi1: "bmi1" ;
142+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi1: "bmi1" ;
143143
/// BMI1 (Bit Manipulation Instructions 1)
144-
@FEATURE: bmi2: "bmi2" ;
144+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi2: "bmi2" ;
145145
/// BMI2 (Bit Manipulation Instructions 2)
146-
@FEATURE: lzcnt: "lzcnt";
146+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] lzcnt: "lzcnt";
147147
/// ABM (Advanced Bit Manipulation) / LZCNT (Leading Zero Count)
148-
@FEATURE: tbm: "tbm";
148+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] tbm: "tbm";
149149
/// TBM (Trailing Bit Manipulation)
150-
@FEATURE: popcnt: "popcnt";
150+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] popcnt: "popcnt";
151151
/// POPCNT (Population Count)
152-
@FEATURE: fxsr: "fxsr";
152+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fxsr: "fxsr";
153153
/// FXSR (Floating-point context fast save and restor)
154-
@FEATURE: xsave: "xsave";
154+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsave: "xsave";
155155
/// XSAVE (Save Processor Extended States)
156-
@FEATURE: xsaveopt: "xsaveopt";
156+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaveopt: "xsaveopt";
157157
/// XSAVEOPT (Save Processor Extended States Optimized)
158-
@FEATURE: xsaves: "xsaves";
158+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaves: "xsaves";
159159
/// XSAVES (Save Processor Extended States Supervisor)
160-
@FEATURE: xsavec: "xsavec";
160+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsavec: "xsavec";
161161
/// XSAVEC (Save Processor Extended States Compacted)
162-
@FEATURE: cmpxchg16b: "cmpxchg16b";
162+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] cmpxchg16b: "cmpxchg16b";
163163
/// CMPXCH16B (16-byte compare-and-swap instruction)
164-
@FEATURE: adx: "adx";
164+
@FEATURE: #[stable(feature = "simd_x86_adx", since = "1.33.0")] adx: "adx";
165165
/// ADX, Intel ADX (Multi-Precision Add-Carry Instruction Extensions)
166-
@FEATURE: rtm: "rtm";
166+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rtm: "rtm";
167167
/// RTM, Intel (Restricted Transactional Memory)
168168
}

crates/std_detect/src/detect/macros.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ macro_rules! features {
55
@MACRO_ATTRS: $(#[$macro_attrs:meta])*
66
$(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; )*
77
$(@NO_RUNTIME_DETECTION: $nort_feature:tt; )*
8-
$(@FEATURE: $feature:ident: $feature_lit:tt; $(#[$feature_comment:meta])*)*
8+
$(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt; $(#[$feature_comment:meta])*)*
99
) => {
1010
#[macro_export]
1111
$(#[$macro_attrs])*
12-
#[allow_internal_unstable(stdsimd_internal,stdsimd)]
12+
#[allow_internal_unstable(stdsimd_internal,stdsimd,staged_api)]
1313
macro_rules! $macro_name {
1414
$(
1515
($feature_lit) => {
16-
cfg!(target_feature = $feature_lit) ||
17-
$crate::detect::check_for($crate::detect::Feature::$feature)
16+
$crate::detect::__is_feature_detected::$feature()
1817
};
1918
)*
2019
$(
@@ -70,5 +69,26 @@ macro_rules! features {
7069
}
7170
}
7271
}
72+
73+
/// Each function performs run-time feature detection for a single
74+
/// feature. This allow us to use stability attributes on a per feature
75+
/// basis.
76+
///
77+
/// PLEASE: do not use this, it is an implementation detail subject
78+
/// to change.
79+
#[doc(hidden)]
80+
pub mod __is_feature_detected {
81+
$(
82+
83+
/// PLEASE: do not use this, it is an implementation detail
84+
/// subject to change.
85+
#[doc(hidden)]
86+
#[$stability_attr]
87+
pub fn $feature() -> bool {
88+
cfg!(target_feature = $feature_lit) ||
89+
$crate::detect::check_for($crate::detect::Feature::$feature)
90+
}
91+
)*
92+
}
7393
};
7494
}

crates/std_detect/src/detect/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ cfg_if! {
6161
}
6262
}
6363
}
64-
pub use self::arch::Feature;
64+
pub use self::arch::{Feature, __is_feature_detected};
6565

6666
mod bit;
6767
mod cache;

0 commit comments

Comments
 (0)