|  | 
| 1 | 1 | //! Aarch64 run-time features. | 
| 2 | 2 | 
 | 
| 3 |  | -/// Checks if `aarch64` feature is enabled. | 
| 4 |  | -#[macro_export] | 
| 5 |  | -#[unstable(feature = "stdsimd", issue = "27731")] | 
| 6 |  | -#[allow_internal_unstable(stdsimd_internal,stdsimd)] | 
| 7 |  | -macro_rules! is_aarch64_feature_detected { | 
| 8 |  | -    ("neon") => { | 
| 9 |  | -        // FIXME: this should be removed once we rename Aarch64 neon to asimd | 
| 10 |  | -        cfg!(target_feature = "neon") || | 
| 11 |  | -            $crate::detect::check_for($crate::detect::Feature::asimd) | 
| 12 |  | -    }; | 
| 13 |  | -    ("asimd") => { | 
| 14 |  | -        cfg!(target_feature = "neon") || | 
| 15 |  | -            $crate::detect::check_for($crate::detect::Feature::asimd) | 
| 16 |  | -    }; | 
| 17 |  | -    ("pmull") => { | 
| 18 |  | -        cfg!(target_feature = "pmull") || | 
| 19 |  | -            $crate::detect::check_for($crate::detect::Feature::pmull) | 
| 20 |  | -    }; | 
| 21 |  | -    ("fp") => { | 
| 22 |  | -        cfg!(target_feature = "fp") || | 
| 23 |  | -            $crate::detect::check_for($crate::detect::Feature::fp) | 
| 24 |  | -    }; | 
| 25 |  | -    ("fp16") => { | 
| 26 |  | -        cfg!(target_feature = "fp16") || | 
| 27 |  | -            $crate::detect::check_for($crate::detect::Feature::fp16) | 
| 28 |  | -    }; | 
| 29 |  | -    ("sve") => { | 
| 30 |  | -        cfg!(target_feature = "sve") || | 
| 31 |  | -            $crate::detect::check_for($crate::detect::Feature::sve) | 
| 32 |  | -    }; | 
| 33 |  | -    ("crc") => { | 
| 34 |  | -        cfg!(target_feature = "crc") || | 
| 35 |  | -            $crate::detect::check_for($crate::detect::Feature::crc) | 
| 36 |  | -    }; | 
| 37 |  | -    ("crypto") => { | 
| 38 |  | -        cfg!(target_feature = "crypto") || | 
| 39 |  | -            $crate::detect::check_for($crate::detect::Feature::crypto) | 
| 40 |  | -    }; | 
| 41 |  | -    ("lse") => { | 
| 42 |  | -        cfg!(target_feature = "lse") || | 
| 43 |  | -            $crate::detect::check_for($crate::detect::Feature::lse) | 
| 44 |  | -    }; | 
| 45 |  | -    ("rdm") => { | 
| 46 |  | -        cfg!(target_feature = "rdm") || | 
| 47 |  | -            $crate::detect::check_for($crate::detect::Feature::rdm) | 
| 48 |  | -    }; | 
| 49 |  | -    ("rcpc") => { | 
| 50 |  | -        cfg!(target_feature = "rcpc") || | 
| 51 |  | -            $crate::detect::check_for($crate::detect::Feature::rcpc) | 
| 52 |  | -    }; | 
| 53 |  | -    ("dotprod") => { | 
| 54 |  | -        cfg!(target_feature = "dotprod") || | 
| 55 |  | -            $crate::detect::check_for($crate::detect::Feature::dotprod) | 
| 56 |  | -    }; | 
| 57 |  | -    ("ras") => { | 
| 58 |  | -        compile_error!("\"ras\" feature cannot be detected at run-time") | 
| 59 |  | -    }; | 
| 60 |  | -    ("v8.1a") => { | 
| 61 |  | -        compile_error!("\"v8.1a\" feature cannot be detected at run-time") | 
| 62 |  | -    }; | 
| 63 |  | -    ("v8.2a") => { | 
| 64 |  | -        compile_error!("\"v8.2a\" feature cannot be detected at run-time") | 
| 65 |  | -    }; | 
| 66 |  | -    ("v8.3a") => { | 
| 67 |  | -        compile_error!("\"v8.3a\" feature cannot be detected at run-time") | 
| 68 |  | -    }; | 
| 69 |  | -    ($t:tt,) => { | 
| 70 |  | -        is_aarch64_feature_detected!($t); | 
| 71 |  | -    }; | 
| 72 |  | -    ($t:tt) => { compile_error!(concat!("unknown aarch64 target feature: ", $t)) }; | 
| 73 |  | -} | 
| 74 |  | - | 
| 75 |  | -/// ARM Aarch64 CPU Feature enum. Each variant denotes a position in a bitset | 
| 76 |  | -/// for a particular feature. | 
| 77 |  | -/// | 
| 78 |  | -/// PLEASE: do not use this, it is an implementation detail subject to change. | 
| 79 |  | -#[doc(hidden)] | 
| 80 |  | -#[allow(non_camel_case_types)] | 
| 81 |  | -#[repr(u8)] | 
| 82 |  | -#[unstable(feature = "stdsimd_internal", issue = "0")] | 
| 83 |  | -pub enum Feature { | 
|  | 3 | +features! { | 
|  | 4 | +    @TARGET: aarch64; | 
|  | 5 | +    @MACRO_NAME: is_aarch64_feature_detected; | 
|  | 6 | +    @MACRO_ATTRS: | 
|  | 7 | +    /// Checks if `aarch64` feature is enabled. | 
|  | 8 | +    #[unstable(feature = "stdsimd", issue = "27731")] | 
|  | 9 | +    @BIND_FEATURE_NAME: "asimd"; "neon"; | 
|  | 10 | +    @NO_RUNTIME_DETECTION: "ras"; | 
|  | 11 | +    @NO_RUNTIME_DETECTION: "v8.1a"; | 
|  | 12 | +    @NO_RUNTIME_DETECTION: "v8.2a"; | 
|  | 13 | +    @NO_RUNTIME_DETECTION: "v8.3a"; | 
|  | 14 | +    @FEATURE: asimd: "neon"; | 
| 84 | 15 |     /// ARM Advanced SIMD (ASIMD) | 
| 85 |  | -    asimd, | 
|  | 16 | +    @FEATURE: pmull: "pmull"; | 
| 86 | 17 |     /// Polynomial Multiply | 
| 87 |  | -    pmull, | 
|  | 18 | +    @FEATURE: fp: "fp"; | 
| 88 | 19 |     /// Floating point support | 
| 89 |  | -    fp, | 
|  | 20 | +    @FEATURE: fp16: "fp16"; | 
| 90 | 21 |     /// Half-float support. | 
| 91 |  | -    fp16, | 
|  | 22 | +    @FEATURE: sve: "sve"; | 
| 92 | 23 |     /// Scalable Vector Extension (SVE) | 
| 93 |  | -    sve, | 
|  | 24 | +    @FEATURE: crc: "crc"; | 
| 94 | 25 |     /// CRC32 (Cyclic Redundancy Check) | 
| 95 |  | -    crc, | 
|  | 26 | +    @FEATURE: crypto: "crypto"; | 
| 96 | 27 |     /// Crypto: AES + PMULL + SHA1 + SHA2 | 
| 97 |  | -    crypto, | 
|  | 28 | +    @FEATURE: lse: "lse"; | 
| 98 | 29 |     /// Atomics (Large System Extension) | 
| 99 |  | -    lse, | 
|  | 30 | +    @FEATURE: rdm: "rdm"; | 
| 100 | 31 |     /// Rounding Double Multiply (ASIMDRDM) | 
| 101 |  | -    rdm, | 
|  | 32 | +    @FEATURE: rcpc: "rcpc"; | 
| 102 | 33 |     /// Release consistent Processor consistent (RcPc) | 
| 103 |  | -    rcpc, | 
|  | 34 | +    @FEATURE: dotprod: "dotprod"; | 
| 104 | 35 |     /// Vector Dot-Product (ASIMDDP) | 
| 105 |  | -    dotprod, | 
| 106 | 36 | } | 
0 commit comments