Skip to content

Commit 598d836

Browse files
committed
Stabilize x86/x86_64 SIMD
This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably this commit is stabilizing: * The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside. * The `is_x86_feature_detected!` macro in the standard library * The `#[target_feature(enable = "...")]` attribute * The `#[cfg(target_feature = "...")]` matcher Stabilization of the module and intrinsics were primarily done in rust-lang/stdarch#414 and the two attribute stabilizations are done in this commit. The standard library is also tweaked a bit with the new way that stdsimd is integrated. Note that other architectures like `std::arch::arm` are not stabilized as part of this commit, they will likely stabilize in the future after they've been implemented and fleshed out. Similarly the `std::simd` module is also not being stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64` is stabilized in this commit either (MMX), only SSE and up types and intrinsics are stabilized. Closes rust-lang#29717 Closes rust-lang#44839 Closes rust-lang#48556
1 parent d6a2dd9 commit 598d836

9 files changed

+26
-97
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
url = https://github.com/rust-lang/llvm
5050
[submodule "src/stdsimd"]
5151
path = src/stdsimd
52-
url = https://github.com/rust-lang-nursery/stdsimd
52+
url = https://github.com/alexcrichton/stdsimd
5353
[submodule "src/tools/lld"]
5454
path = src/tools/lld
5555
url = https://github.com/rust-lang/lld.git

src/libcore/lib.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
#![feature(asm)]
6969
#![feature(associated_type_defaults)]
7070
#![feature(attr_literals)]
71-
#![feature(cfg_target_feature)]
7271
#![feature(cfg_target_has_atomic)]
7372
#![feature(concat_idents)]
7473
#![feature(const_fn)]
@@ -96,11 +95,13 @@
9695
#![feature(specialization)]
9796
#![feature(staged_api)]
9897
#![feature(stmt_expr_attributes)]
99-
#![feature(target_feature)]
10098
#![feature(unboxed_closures)]
10199
#![feature(untagged_unions)]
102100
#![feature(unwind_attributes)]
103101

102+
#![cfg_attr(stage0, feature(target_feature))]
103+
#![cfg_attr(stage0, feature(cfg_target_feature))]
104+
104105
#[prelude_import]
105106
#[allow(unused)]
106107
use prelude::v1::*;
@@ -204,6 +205,20 @@ mod unit;
204205
// things like SIMD and such. Note that the actual source for all this lies in a
205206
// different repository, rust-lang-nursery/stdsimd. That's why the setup here is
206207
// a bit wonky.
208+
#[allow(unused_macros)]
209+
macro_rules! test_v16 { ($item:item) => {}; }
210+
#[allow(unused_macros)]
211+
macro_rules! test_v32 { ($item:item) => {}; }
212+
#[allow(unused_macros)]
213+
macro_rules! test_v64 { ($item:item) => {}; }
214+
#[allow(unused_macros)]
215+
macro_rules! test_v128 { ($item:item) => {}; }
216+
#[allow(unused_macros)]
217+
macro_rules! test_v256 { ($item:item) => {}; }
218+
#[allow(unused_macros)]
219+
macro_rules! test_v512 { ($item:item) => {}; }
220+
#[allow(unused_macros)]
221+
macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } }
207222
#[path = "../stdsimd/coresimd/mod.rs"]
208223
#[allow(missing_docs, missing_debug_implementations, dead_code)]
209224
#[unstable(feature = "stdsimd", issue = "48556")]
@@ -213,6 +228,6 @@ mod coresimd;
213228
#[unstable(feature = "stdsimd", issue = "48556")]
214229
#[cfg(not(stage0))]
215230
pub use coresimd::simd;
216-
#[unstable(feature = "stdsimd", issue = "48556")]
231+
#[stable(feature = "simd_arch", since = "1.27.0")]
217232
#[cfg(not(stage0))]
218233
pub use coresimd::arch;

src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ mod coresimd {
525525
#[unstable(feature = "stdsimd", issue = "48556")]
526526
#[cfg(all(not(stage0), not(test)))]
527527
pub use stdsimd::simd;
528-
#[unstable(feature = "stdsimd", issue = "48556")]
528+
#[stable(feature = "simd_arch", since = "1.27.0")]
529529
#[cfg(all(not(stage0), not(test)))]
530530
pub use stdsimd::arch;
531531

src/libsyntax/feature_gate.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,6 @@ declare_features! (
231231
// allow `repr(simd)`, and importing the various simd intrinsics
232232
(active, repr_simd, "1.4.0", Some(27731), None),
233233

234-
// Allows cfg(target_feature = "...").
235-
(active, cfg_target_feature, "1.4.0", Some(29717), None),
236-
237234
// allow `extern "platform-intrinsic" { ... }`
238235
(active, platform_intrinsics, "1.4.0", Some(27731), None),
239236

@@ -293,9 +290,6 @@ declare_features! (
293290

294291
(active, use_extern_macros, "1.15.0", Some(35896), None),
295292

296-
// Allows #[target_feature(...)]
297-
(active, target_feature, "1.15.0", None, None),
298-
299293
// `extern "ptx-*" fn()`
300294
(active, abi_ptx, "1.15.0", None, None),
301295

@@ -574,6 +568,10 @@ declare_features! (
574568
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
575569
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
576570
(accepted, generic_param_attrs, "1.26.0", Some(48848), None),
571+
// Allows cfg(target_feature = "...").
572+
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
573+
// Allows #[target_feature(...)]
574+
(accepted, target_feature, "1.27.0", None, None),
577575
);
578576

579577
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -918,10 +916,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
918916
"the `#[naked]` attribute \
919917
is an experimental feature",
920918
cfg_fn!(naked_functions))),
921-
("target_feature", Whitelisted, Gated(
922-
Stability::Unstable, "target_feature",
923-
"the `#[target_feature]` attribute is an experimental feature",
924-
cfg_fn!(target_feature))),
919+
("target_feature", Normal, Ungated),
925920
("export_name", Whitelisted, Ungated),
926921
("inline", Whitelisted, Ungated),
927922
("link", Whitelisted, Ungated),
@@ -1052,7 +1047,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
10521047
// cfg(...)'s that are feature gated
10531048
const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[
10541049
// (name in cfg, feature, function to check if the feature is enabled)
1055-
("target_feature", "cfg_target_feature", cfg_fn!(cfg_target_feature)),
10561050
("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)),
10571051
("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)),
10581052
("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)),

src/stdsimd

src/test/ui/feature-gate-cfg-target-feature.rs

-21
This file was deleted.

src/test/ui/feature-gate-cfg-target-feature.stderr

-35
This file was deleted.

src/test/ui/feature-gate-target_feature.rs

-13
This file was deleted.

src/test/ui/feature-gate-target_feature.stderr

-11
This file was deleted.

0 commit comments

Comments
 (0)