Skip to content

Commit 5bea452

Browse files
authored
Start adding stability attributes (#327)
To integrate into the standard library this crate needs *at least* a stability attribute on the macro itself but this commit also beings by adding unstable attributes to the exported modules as well. This should help everything be unstable-by-default and we can start iterating from there in the standard library. This commit also does away with the `coresimd::vendor` module internal implementation detail, instead directly creating the `arch` module to allow easily documenting it in this crate and having the docs show up in rust-lang/rust.
1 parent 0df4359 commit 5bea452

File tree

15 files changed

+66
-45
lines changed

15 files changed

+66
-45
lines changed

coresimd/mod.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// Platform independent SIMD vector types and operations.
2+
#[unstable(feature = "stdsimd", issue = "0")]
23
pub mod simd {
34
pub use coresimd::v128::*;
45
pub use coresimd::v256::*;
@@ -7,20 +8,28 @@ pub mod simd {
78
}
89

910
/// Platform dependent vendor intrinsics.
10-
pub mod vendor {
11-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
12-
pub use coresimd::x86::*;
11+
#[unstable(feature = "stdsimd", issue = "0")]
12+
pub mod arch {
13+
#[cfg(target_arch = "x86")]
14+
pub mod x86 {
15+
pub use coresimd::x86::*;
16+
}
1317

14-
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
15-
pub use coresimd::arm::*;
18+
#[cfg(target_arch = "x86_64")]
19+
pub mod x86_64 {
20+
pub use coresimd::x86::*;
21+
}
1622

17-
#[cfg(target_arch = "aarch64")]
18-
pub use coresimd::aarch64::*;
23+
#[cfg(target_arch = "arm")]
24+
pub mod arm {
25+
pub use coresimd::arm::*;
26+
}
1927

20-
// FIXME: rust does not expose the nvptx and nvptx64 targets yet
21-
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64",
22-
target_arch = "arm", target_arch = "aarch64")))]
23-
pub use coresimd::nvptx::*;
28+
#[cfg(target_arch = "aarch64")]
29+
pub mod aarch64 {
30+
pub use coresimd::arm::*;
31+
pub use coresimd::aarch64::*;
32+
}
2433
}
2534

2635
#[macro_use]

coresimd/x86/i586/avx2.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ pub unsafe fn _mm256_shuffle_epi8(a: __m256i, b: __m256i) -> __m256i {
20172017
///
20182018
/// ```rust
20192019
/// # #![feature(cfg_target_feature)]
2020-
/// # #![feature(target_feature)]
2020+
/// # #![feature(target_feature, stdsimd)]
20212021
/// #
20222022
/// # #[macro_use] extern crate stdsimd;
20232023
/// #
@@ -2623,7 +2623,7 @@ pub unsafe fn _mm256_subs_epu8(a: __m256i, b: __m256i) -> __m256i {
26232623
///
26242624
/// ```rust
26252625
/// # #![feature(cfg_target_feature)]
2626-
/// # #![feature(target_feature)]
2626+
/// # #![feature(target_feature, stdsimd)]
26272627
/// #
26282628
/// # #[macro_use] extern crate stdsimd;
26292629
/// #
@@ -2672,7 +2672,7 @@ pub unsafe fn _mm256_unpackhi_epi8(a: __m256i, b: __m256i) -> __m256i {
26722672
///
26732673
/// ```rust
26742674
/// # #![feature(cfg_target_feature)]
2675-
/// # #![feature(target_feature)]
2675+
/// # #![feature(target_feature, stdsimd)]
26762676
/// #
26772677
/// # #[macro_use] extern crate stdsimd;
26782678
/// #
@@ -2720,7 +2720,7 @@ pub unsafe fn _mm256_unpacklo_epi8(a: __m256i, b: __m256i) -> __m256i {
27202720
///
27212721
/// ```rust
27222722
/// # #![feature(cfg_target_feature)]
2723-
/// # #![feature(target_feature)]
2723+
/// # #![feature(target_feature, stdsimd)]
27242724
/// #
27252725
/// # #[macro_use] extern crate stdsimd;
27262726
/// #
@@ -2764,7 +2764,7 @@ pub unsafe fn _mm256_unpackhi_epi16(a: __m256i, b: __m256i) -> __m256i {
27642764
///
27652765
/// ```rust
27662766
/// # #![feature(cfg_target_feature)]
2767-
/// # #![feature(target_feature)]
2767+
/// # #![feature(target_feature, stdsimd)]
27682768
/// #
27692769
/// # #[macro_use] extern crate stdsimd;
27702770
/// #
@@ -2808,7 +2808,7 @@ pub unsafe fn _mm256_unpacklo_epi16(a: __m256i, b: __m256i) -> __m256i {
28082808
///
28092809
/// ```rust
28102810
/// # #![feature(cfg_target_feature)]
2811-
/// # #![feature(target_feature)]
2811+
/// # #![feature(target_feature, stdsimd)]
28122812
/// #
28132813
/// # #[macro_use] extern crate stdsimd;
28142814
/// #
@@ -2851,7 +2851,7 @@ pub unsafe fn _mm256_unpackhi_epi32(a: __m256i, b: __m256i) -> __m256i {
28512851
///
28522852
/// ```rust
28532853
/// # #![feature(cfg_target_feature)]
2854-
/// # #![feature(target_feature)]
2854+
/// # #![feature(target_feature, stdsimd)]
28552855
/// #
28562856
/// # #[macro_use] extern crate stdsimd;
28572857
/// #
@@ -2891,7 +2891,7 @@ pub unsafe fn _mm256_unpacklo_epi32(a: __m256i, b: __m256i) -> __m256i {
28912891
///
28922892
/// ```rust
28932893
/// # #![feature(cfg_target_feature)]
2894-
/// # #![feature(target_feature)]
2894+
/// # #![feature(target_feature, stdsimd)]
28952895
/// #
28962896
/// # #[macro_use] extern crate stdsimd;
28972897
/// #
@@ -2930,7 +2930,7 @@ pub unsafe fn _mm256_unpackhi_epi64(a: __m256i, b: __m256i) -> __m256i {
29302930
///
29312931
/// ```rust
29322932
/// # #![feature(cfg_target_feature)]
2933-
/// # #![feature(target_feature)]
2933+
/// # #![feature(target_feature, stdsimd)]
29342934
/// #
29352935
/// # #[macro_use] extern crate stdsimd;
29362936
/// #

coresimd/x86/i586/sse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ pub unsafe fn _mm_movemask_ps(a: __m128) -> i32 {
867867
///
868868
/// ```rust
869869
/// # #![feature(cfg_target_feature)]
870-
/// # #![feature(target_feature)]
870+
/// # #![feature(target_feature, stdsimd)]
871871
/// #
872872
/// # #[macro_use] extern crate stdsimd;
873873
/// #
@@ -921,7 +921,7 @@ pub unsafe fn _mm_loadh_pi(a: __m128, p: *const __m64) -> __m128 {
921921
///
922922
/// ```rust
923923
/// # #![feature(cfg_target_feature)]
924-
/// # #![feature(target_feature)]
924+
/// # #![feature(target_feature, stdsimd)]
925925
/// #
926926
/// # #[macro_use] extern crate stdsimd;
927927
/// #

coresimd/x86/i586/sse41.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ pub unsafe fn _mm_ceil_ss(a: __m128, b: __m128) -> __m128 {
551551
/// Rounding is done according to the rounding parameter, which can be one of:
552552
///
553553
/// ```
554+
/// #![feature(stdsimd)]
555+
///
554556
/// extern crate stdsimd;
555557
///
556558
/// #[cfg(target_arch = "x86")]
@@ -588,6 +590,8 @@ pub unsafe fn _mm_round_pd(a: __m128d, rounding: i32) -> __m128d {
588590
/// Rounding is done according to the rounding parameter, which can be one of:
589591
///
590592
/// ```
593+
/// #![feature(stdsimd)]
594+
///
591595
/// extern crate stdsimd;
592596
///
593597
/// #[cfg(target_arch = "x86")]
@@ -627,6 +631,8 @@ pub unsafe fn _mm_round_ps(a: __m128, rounding: i32) -> __m128 {
627631
/// Rounding is done according to the rounding parameter, which can be one of:
628632
///
629633
/// ```
634+
/// #![feature(stdsimd)]
635+
///
630636
/// extern crate stdsimd;
631637
///
632638
/// #[cfg(target_arch = "x86")]
@@ -666,6 +672,8 @@ pub unsafe fn _mm_round_sd(a: __m128d, b: __m128d, rounding: i32) -> __m128d {
666672
/// Rounding is done according to the rounding parameter, which can be one of:
667673
///
668674
/// ```
675+
/// #![feature(stdsimd)]
676+
///
669677
/// extern crate stdsimd;
670678
///
671679
/// #[cfg(target_arch = "x86")]

coresimd/x86/i586/sse42.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub unsafe fn _mm_cmpistrm(a: __m128i, b: __m128i, imm8: i32) -> __m128i {
9898
/// ```
9999
/// # #![feature(cfg_target_feature)]
100100
/// # #![feature(target_feature)]
101+
/// # #![feature(stdsimd)]
101102
/// #
102103
/// # #[macro_use] extern crate stdsimd;
103104
/// #
@@ -141,6 +142,7 @@ pub unsafe fn _mm_cmpistrm(a: __m128i, b: __m128i, imm8: i32) -> __m128i {
141142
/// ```
142143
/// # #![feature(cfg_target_feature)]
143144
/// # #![feature(target_feature)]
145+
/// # #![feature(stdsimd)]
144146
/// #
145147
/// # #[macro_use] extern crate stdsimd;
146148
/// #
@@ -182,6 +184,7 @@ pub unsafe fn _mm_cmpistrm(a: __m128i, b: __m128i, imm8: i32) -> __m128i {
182184
/// ```
183185
/// # #![feature(cfg_target_feature)]
184186
/// # #![feature(target_feature)]
187+
/// # #![feature(stdsimd)]
185188
/// #
186189
/// # #[macro_use] extern crate stdsimd;
187190
/// #
@@ -223,6 +226,7 @@ pub unsafe fn _mm_cmpistrm(a: __m128i, b: __m128i, imm8: i32) -> __m128i {
223226
/// ```
224227
/// # #![feature(cfg_target_feature)]
225228
/// # #![feature(target_feature)]
229+
/// # #![feature(stdsimd)]
226230
/// #
227231
/// # #[macro_use] extern crate stdsimd;
228232
/// #
@@ -416,6 +420,7 @@ pub unsafe fn _mm_cmpestrm(
416420
/// ```
417421
/// # #![feature(cfg_target_feature)]
418422
/// # #![feature(target_feature)]
423+
/// # #![feature(stdsimd)]
419424
/// #
420425
/// # #[macro_use] extern crate stdsimd;
421426
/// #

coresimd/x86/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ types! {
5454
/// # Examples
5555
///
5656
/// ```
57-
/// # #![feature(cfg_target_feature, target_feature)]
57+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
5858
/// # #[macro_use]
5959
/// # extern crate stdsimd;
6060
/// # fn main() {
@@ -100,7 +100,7 @@ types! {
100100
/// # Examples
101101
///
102102
/// ```
103-
/// # #![feature(cfg_target_feature, target_feature)]
103+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
104104
/// # #[macro_use]
105105
/// # extern crate stdsimd;
106106
/// # fn main() {
@@ -139,7 +139,7 @@ types! {
139139
/// # Examples
140140
///
141141
/// ```
142-
/// # #![feature(cfg_target_feature, target_feature)]
142+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
143143
/// # #[macro_use]
144144
/// # extern crate stdsimd;
145145
/// # fn main() {
@@ -178,7 +178,7 @@ types! {
178178
/// # Examples
179179
///
180180
/// ```
181-
/// # #![feature(cfg_target_feature, target_feature)]
181+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
182182
/// # #[macro_use]
183183
/// # extern crate stdsimd;
184184
/// # fn main() {
@@ -221,7 +221,7 @@ types! {
221221
/// # Examples
222222
///
223223
/// ```
224-
/// # #![feature(cfg_target_feature, target_feature)]
224+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
225225
/// # #[macro_use]
226226
/// # extern crate stdsimd;
227227
/// # fn main() {
@@ -260,7 +260,7 @@ types! {
260260
/// # Examples
261261
///
262262
/// ```
263-
/// # #![feature(cfg_target_feature, target_feature)]
263+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
264264
/// # #[macro_use]
265265
/// # extern crate stdsimd;
266266
/// # fn main() {
@@ -299,7 +299,7 @@ types! {
299299
/// # Examples
300300
///
301301
/// ```
302-
/// # #![feature(cfg_target_feature, target_feature)]
302+
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
303303
/// # #[macro_use]
304304
/// # extern crate stdsimd;
305305
/// # fn main() {

crates/coresimd/src/lib.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#![feature(const_fn, link_llvm_intrinsics, platform_intrinsics, repr_simd,
1515
simd_ffi, target_feature, cfg_target_feature, i128_type, asm,
1616
integer_atomics, stmt_expr_attributes, core_intrinsics,
17-
crate_in_paths, no_core, attr_literals, rustc_attrs)]
17+
crate_in_paths, no_core, attr_literals, rustc_attrs, stdsimd,
18+
staged_api)]
1819
#![cfg_attr(test, feature(proc_macro, test, attr_literals, abi_vectorcall))]
1920
#![cfg_attr(feature = "cargo-clippy",
2021
allow(inline_always, too_many_arguments, cast_sign_loss,
@@ -24,6 +25,7 @@
2425
many_single_char_names))]
2526
#![cfg_attr(test, allow(unused_imports))]
2627
#![no_core]
28+
#![unstable(feature = "stdsimd", issue = "0")]
2729

2830
#[cfg_attr(not(test), macro_use)]
2931
extern crate core as _core;
@@ -41,19 +43,9 @@ extern crate stdsimd;
4143
#[path = "../../../coresimd/mod.rs"]
4244
mod coresimd;
4345

46+
pub use coresimd::arch;
4447
pub use coresimd::simd;
4548

46-
pub mod arch {
47-
#[cfg(target_arch = "x86")]
48-
pub mod x86 { pub use coresimd::vendor::*; }
49-
#[cfg(target_arch = "x86_64")]
50-
pub mod x86_64 { pub use coresimd::vendor::*; }
51-
#[cfg(target_arch = "arm")]
52-
pub mod arm { pub use coresimd::vendor::*; }
53-
#[cfg(target_arch = "aarch64")]
54-
pub mod aarch64 { pub use coresimd::vendor::*; }
55-
}
56-
5749
#[allow(unused_imports)]
5850
use _core::clone;
5951
#[allow(unused_imports)]

crates/coresimd/tests/cpu-detection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(cfg_target_feature)]
1+
#![feature(cfg_target_feature, stdsimd)]
22
#![cfg_attr(feature = "strict", deny(warnings))]
33
#![cfg_attr(feature = "cargo-clippy",
44
allow(option_unwrap_used, print_stdout, use_debug))]

crates/stdsimd/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//! # Example
3333
//!
3434
//! ```rust
35-
//! #![feature(cfg_target_feature, target_feature)]
35+
//! #![feature(cfg_target_feature, target_feature, stdsimd)]
3636
//!
3737
//! #[macro_use]
3838
//! extern crate stdsimd;
@@ -132,9 +132,10 @@
132132
//! [simd_soundness_bug]: https://github.com/rust-lang/rust/issues/44367
133133
//! [target_feature_impr]: https://github.com/rust-lang/rust/issues/44839
134134
135-
#![feature(const_fn, integer_atomics)]
135+
#![feature(const_fn, integer_atomics, staged_api, stdsimd)]
136136
#![cfg_attr(target_os = "linux", feature(linkage))]
137137
#![no_std]
138+
#![unstable(feature = "stdsimd", issue = "0")]
138139

139140
extern crate std as _std;
140141
extern crate coresimd;

crates/stdsimd/tests/cpu-detection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(cfg_target_feature)]
1+
#![feature(cfg_target_feature, stdsimd)]
22
#![cfg_attr(feature = "strict", deny(warnings))]
33
#![cfg_attr(feature = "cargo-clippy",
44
allow(option_unwrap_used, use_debug, print_stdout))]

stdsimd/arch/detect/aarch64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::cache;
55
use super::linux;
66

77
#[macro_export]
8+
#[unstable(feature = "stdsimd", issue = "0")]
89
macro_rules! is_target_feature_detected {
910
("neon") => {
1011
// FIXME: this should be removed once we rename Aarch64 neon to asimd

stdsimd/arch/detect/arm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::cache;
55
use super::linux;
66

77
#[macro_export]
8+
#[unstable(feature = "stdsimd", issue = "0")]
89
macro_rules! is_target_feature_detected {
910
("neon") => {
1011
$crate::arch::detect::check_for($crate::arch::detect::Feature::neon)

stdsimd/arch/detect/powerpc64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::cache;
44
use super::linux;
55

66
#[macro_export]
7+
#[unstable(feature = "stdsimd", issue = "0")]
78
macro_rules! is_target_feature_detected {
89
("altivec") => {
910
$crate::arch::detect::check_for($crate::arch::detect::Feature::altivec)

stdsimd/arch/detect/x86.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use coresimd::arch::x86_64::*;
2626
use super::{bit, cache};
2727

2828
#[macro_export]
29+
#[unstable(feature = "stdsimd", issue = "0")]
2930
macro_rules! is_target_feature_detected {
3031
("aes") => {
3132
$crate::arch::detect::check_for(

stdsimd/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#[unstable(feature = "stdsimd", issue = "0")]
12
pub mod arch {
23
pub use coresimd::arch::*;
34
pub mod detect;
45
}
56

7+
#[unstable(feature = "stdsimd", issue = "0")]
68
pub use coresimd::simd;

0 commit comments

Comments
 (0)