Enforce staged_api on a per-feature basis

This commit is contained in:
gnzlbg 2019-09-16 16:56:12 +02:00 committed by gnzlbg
parent 1f44c1407d
commit 599bcf28ad
9 changed files with 87 additions and 67 deletions

View file

@ -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)
}

View file

@ -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
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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)
}

View file

@ -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)
}
)*
}
};
}

View file

@ -61,7 +61,7 @@ cfg_if! {
}
}
}
pub use self::arch::Feature;
pub use self::arch::{Feature, __is_feature_detected};
mod bit;
mod cache;