about summary refs log tree commit diff
path: root/library/stdarch/crates/std_detect/src
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2019-09-16 16:56:12 +0200
committergnzlbg <gnzlbg@users.noreply.github.com>2019-09-16 23:43:01 +0200
commit599bcf28ad02c0ea7473a07b088553813a649487 (patch)
tree05b2222fcb2e899b31dd515e0342c94d923b071b /library/stdarch/crates/std_detect/src
parent1f44c1407dc6e6f91600f9303739ca8acbcc8194 (diff)
downloadrust-599bcf28ad02c0ea7473a07b088553813a649487.tar.gz
rust-599bcf28ad02c0ea7473a07b088553813a649487.zip
Enforce staged_api on a per-feature basis
Diffstat (limited to 'library/stdarch/crates/std_detect/src')
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs22
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/arm.rs4
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/mips.rs2
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/mips64.rs2
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs6
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs6
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/x86.rs82
-rw-r--r--library/stdarch/crates/std_detect/src/detect/macros.rs28
-rw-r--r--library/stdarch/crates/std_detect/src/detect/mod.rs2
9 files changed, 87 insertions, 67 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
index 73e54052b82..154207e5ad1 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/aarch64.rs
@@ -11,26 +11,26 @@ features! {
     @NO_RUNTIME_DETECTION: "v8.1a";
     @NO_RUNTIME_DETECTION: "v8.2a";
     @NO_RUNTIME_DETECTION: "v8.3a";
-    @FEATURE: asimd: "neon";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] asimd: "neon";
     /// ARM Advanced SIMD (ASIMD)
-    @FEATURE: pmull: "pmull";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
     /// Polynomial Multiply
-    @FEATURE: fp: "fp";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp: "fp";
     /// Floating point support
-    @FEATURE: fp16: "fp16";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] fp16: "fp16";
     /// Half-float support.
-    @FEATURE: sve: "sve";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sve: "sve";
     /// Scalable Vector Extension (SVE)
-    @FEATURE: crc: "crc";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
     /// CRC32 (Cyclic Redundancy Check)
-    @FEATURE: crypto: "crypto";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crypto: "crypto";
     /// Crypto: AES + PMULL + SHA1 + SHA2
-    @FEATURE: lse: "lse";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] lse: "lse";
     /// Atomics (Large System Extension)
-    @FEATURE: rdm: "rdm";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rdm: "rdm";
     /// Rounding Double Multiply (ASIMDRDM)
-    @FEATURE: rcpc: "rcpc";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rcpc: "rcpc";
     /// Release consistent Processor consistent (RcPc)
-    @FEATURE: dotprod: "dotprod";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] dotprod: "dotprod";
     /// Vector Dot-Product (ASIMDDP)
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/arm.rs b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
index 86dc6dbbf23..02bf654945d 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
@@ -10,8 +10,8 @@ features! {
     @NO_RUNTIME_DETECTION: "vfp2";
     @NO_RUNTIME_DETECTION: "vfp3";
     @NO_RUNTIME_DETECTION: "vfp4";
-    @FEATURE: neon: "neon";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] neon: "neon";
     /// ARM Advanced SIMD (NEON) - Aarch32
-    @FEATURE: pmull: "pmull";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
     /// Polynomial Multiply
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/mips.rs b/library/stdarch/crates/std_detect/src/detect/arch/mips.rs
index 1ac540ef737..ada81b83ec5 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/mips.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/mips.rs
@@ -6,6 +6,6 @@ features! {
     @MACRO_ATTRS:
     /// Checks if `mips` feature is enabled.
     #[unstable(feature = "stdsimd", issue = "27731")]
-    @FEATURE: msa: "msa";
+    @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
index 33ad3bca768..6a0bb159ba7 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/mips64.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/mips64.rs
@@ -6,6 +6,6 @@ features! {
     @MACRO_ATTRS:
     /// Checks if `mips64` feature is enabled.
     #[unstable(feature = "stdsimd", issue = "27731")]
-    @FEATURE: msa: "msa";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] msa: "msa";
     /// MIPS SIMD Architecture (MSA)
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs b/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs
index 6cc35a24110..44bd7f337f6 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/powerpc.rs
@@ -6,10 +6,10 @@ features! {
     @MACRO_ATTRS:
     /// Checks if `powerpc` feature is enabled.
     #[unstable(feature = "stdsimd", issue = "27731")]
-    @FEATURE: altivec: "altivec";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
     /// Altivec
-    @FEATURE: vsx: "vsx";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
     /// VSX
-    @FEATURE: power8: "power8";
+    @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
index a075c94190e..17e4d958bf1 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs
@@ -6,10 +6,10 @@ features! {
     @MACRO_ATTRS:
     /// Checks if `powerpc` feature is enabled.
     #[unstable(feature = "stdsimd", issue = "27731")]
-    @FEATURE: altivec: "altivec";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] altivec: "altivec";
     /// Altivec
-    @FEATURE: vsx: "vsx";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] vsx: "vsx";
     /// VSX
-    @FEATURE: power8: "power8";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] power8: "power8";
     /// Power8
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/x86.rs b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs
index 470b8978dbc..ae0bebdae5b 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/x86.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/x86.rs
@@ -82,87 +82,87 @@ features! {
     /// [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: aes: "aes";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] aes: "aes";
     /// AES (Advanced Encryption Standard New Instructions AES-NI)
-    @FEATURE: pclmulqdq: "pclmulqdq";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] pclmulqdq: "pclmulqdq";
     /// CLMUL (Carry-less Multiplication)
-    @FEATURE: rdrand: "rdrand";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")]  rdrand: "rdrand";
     /// RDRAND
-    @FEATURE: rdseed: "rdseed";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdseed: "rdseed";
     /// RDSEED
-    @FEATURE: tsc: "tsc";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tsc: "tsc";
     /// TSC (Time Stamp Counter)
-    @FEATURE: mmx: "mmx";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] mmx: "mmx";
     /// MMX (MultiMedia eXtensions)
-    @FEATURE: sse: "sse";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse: "sse";
     /// SSE (Streaming SIMD Extensions)
-    @FEATURE: sse2: "sse2";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse2: "sse2";
     /// SSE2 (Streaming SIMD Extensions 2)
-    @FEATURE: sse3: "sse3";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse3: "sse3";
     /// SSE3 (Streaming SIMD Extensions 3)
-    @FEATURE: ssse3: "ssse3";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ssse3: "ssse3";
     /// SSSE3 (Supplemental Streaming SIMD Extensions 3)
-    @FEATURE: sse4_1: "sse4.1";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_1: "sse4.1";
     /// SSE4.1 (Streaming SIMD Extensions 4.1)
-    @FEATURE: sse4_2: "sse4.2";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_2: "sse4.2";
     /// SSE4.2 (Streaming SIMD Extensions 4.2)
-    @FEATURE: sse4a: "sse4a";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sse4a: "sse4a";
     /// SSE4a (Streaming SIMD Extensions 4a)
-    @FEATURE: sha: "sha";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sha: "sha";
     /// SHA
-    @FEATURE: avx: "avx";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx: "avx";
     /// AVX (Advanced Vector Extensions)
-    @FEATURE: avx2: "avx2";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2";
     /// AVX2 (Advanced Vector Extensions 2)
-    @FEATURE: avx512f: "avx512f" ;
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512f: "avx512f" ;
     /// AVX-512 F (Foundation)
-    @FEATURE: avx512cd: "avx512cd" ;
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512cd: "avx512cd" ;
     /// AVX-512 CD (Conflict Detection Instructions)
-    @FEATURE: avx512er: "avx512er";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512er: "avx512er";
     /// AVX-512 ER (Expo nential and Reciprocal Instructions)
-    @FEATURE: avx512pf: "avx512pf";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512pf: "avx512pf";
     /// AVX-512 PF (Prefetch Instructions)
-    @FEATURE: avx512bw: "avx512bw";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512bw: "avx512bw";
     /// AVX-512 BW (Byte and Word Instructions)
-    @FEATURE: avx512dq: "avx512dq";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512dq: "avx512dq";
     /// AVX-512 DQ (Doubleword and Quadword)
-    @FEATURE: avx512vl: "avx512vl";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vl: "avx512vl";
     /// AVX-512 VL (Vector Length Extensions)
-    @FEATURE: avx512ifma: "avx512ifma";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512ifma: "avx512ifma";
     /// AVX-512 IFMA (Integer Fused Multiply Add)
-    @FEATURE: avx512vbmi: "avx512vbmi";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vbmi: "avx512vbmi";
     /// AVX-512 VBMI (Vector Byte Manipulation Instructions)
-    @FEATURE: avx512vpopcntdq: "avx512vpopcntdq";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] avx512vpopcntdq: "avx512vpopcntdq";
     /// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and
     /// Quadword)
-    @FEATURE: f16c: "f16c";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] f16c: "f16c";
     /// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats)
-    @FEATURE: fma: "fma";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fma: "fma";
     /// FMA (Fused Multiply Add)
-    @FEATURE: bmi1: "bmi1" ;
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi1: "bmi1" ;
     /// BMI1 (Bit Manipulation Instructions 1)
-    @FEATURE: bmi2: "bmi2" ;
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi2: "bmi2" ;
     /// BMI2 (Bit Manipulation Instructions 2)
-    @FEATURE: lzcnt: "lzcnt";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] lzcnt: "lzcnt";
     /// ABM (Advanced Bit Manipulation) / LZCNT (Leading Zero Count)
-    @FEATURE: tbm: "tbm";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] tbm: "tbm";
     /// TBM (Trailing Bit Manipulation)
-    @FEATURE: popcnt: "popcnt";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] popcnt: "popcnt";
     /// POPCNT (Population Count)
-    @FEATURE: fxsr: "fxsr";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fxsr: "fxsr";
     /// FXSR (Floating-point context fast save and restor)
-    @FEATURE: xsave: "xsave";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsave: "xsave";
     /// XSAVE (Save Processor Extended States)
-    @FEATURE: xsaveopt: "xsaveopt";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaveopt: "xsaveopt";
     /// XSAVEOPT (Save Processor Extended States Optimized)
-    @FEATURE: xsaves: "xsaves";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaves: "xsaves";
     /// XSAVES (Save Processor Extended States Supervisor)
-    @FEATURE: xsavec: "xsavec";
+    @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsavec: "xsavec";
     /// XSAVEC (Save Processor Extended States Compacted)
-    @FEATURE: cmpxchg16b: "cmpxchg16b";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] cmpxchg16b: "cmpxchg16b";
     /// CMPXCH16B (16-byte compare-and-swap instruction)
-    @FEATURE: adx: "adx";
+    @FEATURE: #[stable(feature = "simd_x86_adx", since = "1.33.0")] adx: "adx";
     /// ADX, Intel ADX (Multi-Precision Add-Carry Instruction Extensions)
-    @FEATURE: rtm: "rtm";
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] rtm: "rtm";
     /// RTM, Intel (Restricted Transactional Memory)
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/macros.rs b/library/stdarch/crates/std_detect/src/detect/macros.rs
index 09f9f524b52..8fc8b2b4060 100644
--- a/library/stdarch/crates/std_detect/src/detect/macros.rs
+++ b/library/stdarch/crates/std_detect/src/detect/macros.rs
@@ -5,16 +5,15 @@ macro_rules! features {
       @MACRO_ATTRS: $(#[$macro_attrs:meta])*
       $(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; )*
       $(@NO_RUNTIME_DETECTION: $nort_feature:tt; )*
-      $(@FEATURE: $feature:ident: $feature_lit:tt; $(#[$feature_comment:meta])*)*
+      $(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt; $(#[$feature_comment:meta])*)*
     ) => {
         #[macro_export]
         $(#[$macro_attrs])*
-        #[allow_internal_unstable(stdsimd_internal,stdsimd)]
+        #[allow_internal_unstable(stdsimd_internal,stdsimd,staged_api)]
         macro_rules! $macro_name {
             $(
                 ($feature_lit) => {
-                    cfg!(target_feature = $feature_lit) ||
-                        $crate::detect::check_for($crate::detect::Feature::$feature)
+                    $crate::detect::__is_feature_detected::$feature()
                 };
             )*
             $(
@@ -70,5 +69,26 @@ macro_rules! features {
                 }
             }
         }
+
+        /// Each function performs run-time feature detection for a single
+        /// feature. This allow us to use stability attributes on a per feature
+        /// basis.
+        ///
+        /// PLEASE: do not use this, it is an implementation detail subject
+        /// to change.
+        #[doc(hidden)]
+        pub mod __is_feature_detected {
+            $(
+
+                /// PLEASE: do not use this, it is an implementation detail
+                /// subject to change.
+                #[doc(hidden)]
+                #[$stability_attr]
+                pub fn $feature() -> bool {
+                    cfg!(target_feature = $feature_lit) ||
+                        $crate::detect::check_for($crate::detect::Feature::$feature)
+                }
+            )*
+        }
     };
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/mod.rs b/library/stdarch/crates/std_detect/src/detect/mod.rs
index 21062782b71..04db5c402ed 100644
--- a/library/stdarch/crates/std_detect/src/detect/mod.rs
+++ b/library/stdarch/crates/std_detect/src/detect/mod.rs
@@ -61,7 +61,7 @@ cfg_if! {
         }
     }
 }
-pub use self::arch::Feature;
+pub use self::arch::{Feature, __is_feature_detected};
 
 mod bit;
 mod cache;