Skip to content

Commit d755531

Browse files
committed
refactor run-time detection module
1 parent d64fede commit d755531

29 files changed

+1035
-950
lines changed

coresimd/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,17 @@ pub mod arch {
8585
/// Platform-specific intrinsics for the `mips` platform.
8686
///
8787
/// See the [module documentation](../index.html) for more details.
88-
#[cfg(target_arch = "mips")]
88+
#[cfg(any(target_arch = "mips", dox))]
89+
#[doc(cfg(target_arch = "mips"))]
8990
pub mod mips {
9091
pub use coresimd::mips::*;
9192
}
9293

9394
/// Platform-specific intrinsics for the `mips64` platform.
9495
///
9596
/// See the [module documentation](../index.html) for more details.
96-
#[cfg(target_arch = "mips64")]
97+
#[cfg(any(target_arch = "mips64", dox))]
98+
#[doc(cfg(target_arch = "mips64"))]
9799
pub mod mips64 {
98100
pub use coresimd::mips::*;
99101
}
@@ -113,7 +115,7 @@ mod aarch64;
113115
#[cfg(target_arch = "wasm32")]
114116
mod wasm32;
115117

116-
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
118+
#[cfg(any(target_arch = "mips", target_arch = "mips64", dox))]
117119
mod mips;
118120

119121
mod nvptx;

crates/coresimd/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
simd_ffi, target_feature, cfg_target_feature, i128_type, asm,
1414
integer_atomics, stmt_expr_attributes, core_intrinsics,
1515
crate_in_paths, no_core, attr_literals, rustc_attrs, stdsimd,
16-
staged_api, fn_must_use, core_float, core_slice_ext, align_offset)]
16+
staged_api, fn_must_use, core_float, core_slice_ext, align_offset,
17+
doc_cfg)]
1718
#![cfg_attr(test,
1819
feature(proc_macro, test, attr_literals, abi_vectorcall,
1920
untagged_unions))]

crates/stdsimd/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! [stdsimd]: https://rust-lang-nursery.github.io/stdsimd/x86_64/stdsimd/
99
1010
#![feature(const_fn, integer_atomics, staged_api, stdsimd)]
11-
#![feature(cfg_target_feature)]
11+
#![feature(cfg_target_feature, doc_cfg)]
1212
#![cfg_attr(feature = "cargo-clippy", allow(shadow_reuse))]
1313
#![cfg_attr(target_os = "linux", feature(linkage))]
1414
#![no_std]
@@ -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+
}

0 commit comments

Comments
 (0)