Skip to content

Commit a7f5eb3

Browse files
committed
refactor run-time detection module
1 parent 701f167 commit a7f5eb3

28 files changed

+1032
-948
lines changed

coresimd/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,17 @@ pub mod arch {
8989
/// Platform-specific intrinsics for the `mips` platform.
9090
///
9191
/// See the [module documentation](../index.html) for more details.
92-
#[cfg(target_arch = "mips")]
92+
#[cfg(any(target_arch = "mips", dox))]
93+
#[doc(cfg(target_arch = "mips"))]
9394
pub mod mips {
9495
pub use coresimd::mips::*;
9596
}
9697

9798
/// Platform-specific intrinsics for the `mips64` platform.
9899
///
99100
/// See the [module documentation](../index.html) for more details.
100-
#[cfg(target_arch = "mips64")]
101+
#[cfg(any(target_arch = "mips64", dox))]
102+
#[doc(cfg(target_arch = "mips64"))]
101103
pub mod mips64 {
102104
pub use coresimd::mips::*;
103105
}
@@ -117,7 +119,7 @@ mod aarch64;
117119
#[cfg(target_arch = "wasm32")]
118120
mod wasm32;
119121

120-
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
122+
#[cfg(any(target_arch = "mips", target_arch = "mips64", dox))]
121123
mod mips;
122124

123125
mod nvptx;

crates/stdsimd/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ extern crate std;
2828
mod stdsimd;
2929

3030
pub use stdsimd::*;
31+
32+
#[allow(unused_imports)]
33+
use _std::prelude;
34+
#[allow(unused_imports)]
35+
use _std::fs;
36+
#[allow(unused_imports)]
37+
use _std::io;

stdsimd/arch/detect/aarch64.rs

Lines changed: 0 additions & 228 deletions
This file was deleted.

stdsimd/arch/detect/arch/aarch64.rs

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

stdsimd/arch/detect/arch/arm.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//! Run-time feature detection on ARM Aarch32.
2+
3+
#[macro_export]
4+
#[unstable(feature = "stdsimd", issue = "0")]
5+
macro_rules! is_arm_feature_detected {
6+
("neon") => {
7+
cfg!(target_feature = "neon") ||
8+
$crate::arch::detect::check_for($crate::arch::detect::Feature::neon)
9+
};
10+
("pmull") => {
11+
cfg!(target_feature = "pmull") ||
12+
$crate::arch::detect::check_for($crate::arch::detect::Feature::pmull)
13+
};
14+
($t:tt) => { compile_error!(concat!("unknown arm target feature: ", $t)) };
15+
}
16+
17+
/// ARM CPU Feature enum. Each variant denotes a position in a bitset for a
18+
/// particular feature.
19+
///
20+
/// PLEASE: do not use this, it is an implementation detail subject to change.
21+
#[doc(hidden)]
22+
#[allow(non_camel_case_types)]
23+
#[repr(u8)]
24+
pub enum Feature {
25+
/// ARM Advanced SIMD (NEON) - Aarch32
26+
neon,
27+
/// Polynomial Multiply
28+
pmull,
29+
}

0 commit comments

Comments
 (0)