Rollup merge of #48513 - alexcrichton:simd, r=JoshTriplett
std: Add `arch` and `simd` modules This commit imports the `stdsimd` crate into the standard library, creating an `arch` and `simd` module inside of both libcore and libstd. Both of these modules are **unstable** and will continue to be so until RFC 2335 is stabilized. As a brief recap, the modules are organized as so: * `arch` contains all current architectures with intrinsics, for example `std::arch::x86`, `std::arch::x86_64`, `std::arch::arm`, etc. These modules contain all of the intrinsics defined for the platform, like `_mm_set1_epi8`. * In the standard library, the `arch` module also exports a `is_target_feature_detected` macro which performs runtime detection to determine whether a target feature is available at runtime. * The `simd` module contains experimental versions of strongly-typed lane-aware SIMD primitives, to be fully fleshed out in a future RFC. The main purpose of this commit is to start pulling in all these intrinsics and such into the standard library on nightly and allow testing and such. This'll help allow users to easily kick the tires and see if intrinsics work as well as allow us to test out all the infrastructure for moving the intrinsics into the standard library.
This commit is contained in:
commit
6f07aaa428
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -50,3 +50,6 @@
|
||||
[submodule "src/llvm-emscripten"]
|
||||
path = src/llvm-emscripten
|
||||
url = https://github.com/rust-lang/llvm
|
||||
[submodule "src/stdsimd"]
|
||||
path = src/stdsimd
|
||||
url = https://github.com/rust-lang-nursery/stdsimd
|
||||
|
@ -68,16 +68,21 @@
|
||||
#![feature(allow_internal_unstable)]
|
||||
#![feature(asm)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(attr_literals)]
|
||||
#![feature(cfg_target_feature)]
|
||||
#![feature(cfg_target_has_atomic)]
|
||||
#![feature(concat_idents)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(doc_spotlight)]
|
||||
#![feature(fundamental)]
|
||||
#![feature(i128_type)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
#![feature(intrinsics)]
|
||||
#![feature(iterator_flatten)]
|
||||
#![feature(iterator_repeat_with)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(link_llvm_intrinsics)]
|
||||
#![feature(never_type)]
|
||||
#![feature(no_core)]
|
||||
#![feature(on_unimplemented)]
|
||||
@ -85,15 +90,17 @@
|
||||
#![feature(prelude_import)]
|
||||
#![feature(repr_simd, platform_intrinsics)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustc_const_unstable)]
|
||||
#![feature(simd_ffi)]
|
||||
#![feature(specialization)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(target_feature)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(untagged_unions)]
|
||||
#![feature(unwind_attributes)]
|
||||
#![feature(doc_spotlight)]
|
||||
#![feature(rustc_const_unstable)]
|
||||
#![feature(iterator_repeat_with)]
|
||||
#![feature(iterator_flatten)]
|
||||
|
||||
#![cfg_attr(stage0, allow(unused_attributes))]
|
||||
|
||||
#[prelude_import]
|
||||
#[allow(unused)]
|
||||
@ -179,3 +186,21 @@ mod char_private;
|
||||
mod iter_private;
|
||||
mod tuple;
|
||||
mod unit;
|
||||
|
||||
// Pull in the the `coresimd` crate directly into libcore. This is where all the
|
||||
// architecture-specific (and vendor-specific) intrinsics are defined. AKA
|
||||
// things like SIMD and such. Note that the actual source for all this lies in a
|
||||
// different repository, rust-lang-nursery/stdsimd. That's why the setup here is
|
||||
// a bit wonky.
|
||||
#[path = "../stdsimd/coresimd/mod.rs"]
|
||||
#[allow(missing_docs, missing_debug_implementations, dead_code)]
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(not(stage0))] // allow changes to how stdsimd works in stage0
|
||||
mod coresimd;
|
||||
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(not(stage0))]
|
||||
pub use coresimd::simd;
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(not(stage0))]
|
||||
pub use coresimd::arch;
|
||||
|
@ -299,6 +299,7 @@
|
||||
#![feature(rand)]
|
||||
#![feature(raw)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(stdsimd)]
|
||||
#![feature(sip_hash_13)]
|
||||
#![feature(slice_bytes)]
|
||||
#![feature(slice_concat_ext)]
|
||||
@ -501,6 +502,35 @@ mod memchr;
|
||||
// compiler
|
||||
pub mod rt;
|
||||
|
||||
// Pull in the the `stdsimd` crate directly into libstd. This is the same as
|
||||
// libcore's arch/simd modules where the source of truth here is in a different
|
||||
// repository, but we pull things in here manually to get it into libstd.
|
||||
//
|
||||
// Note that the #[cfg] here is intended to do two things. First it allows us to
|
||||
// change the rustc implementation of intrinsics in stage0 by not compiling simd
|
||||
// intrinsics in stage0. Next it doesn't compile anything in test mode as
|
||||
// stdsimd has tons of its own tests which we don't want to run.
|
||||
#[path = "../stdsimd/stdsimd/mod.rs"]
|
||||
#[allow(missing_debug_implementations, missing_docs, dead_code)]
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(all(not(stage0), not(test)))]
|
||||
mod stdsimd;
|
||||
|
||||
// A "fake" module needed by the `stdsimd` module to compile, not actually
|
||||
// exported though.
|
||||
#[cfg(not(stage0))]
|
||||
mod coresimd {
|
||||
pub use core::arch;
|
||||
pub use core::simd;
|
||||
}
|
||||
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(all(not(stage0), not(test)))]
|
||||
pub use stdsimd::simd;
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(all(not(stage0), not(test)))]
|
||||
pub use stdsimd::arch;
|
||||
|
||||
// Include a number of private modules that exist solely to provide
|
||||
// the rustdoc documentation for primitive types. Using `include!`
|
||||
// because rustdoc only looks for these modules at the crate level.
|
||||
|
1
src/stdsimd
Submodule
1
src/stdsimd
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 678cbd325c84070c9dbe4303969fbd2734c0b4ee
|
@ -71,6 +71,7 @@ fn filter_dirs(path: &Path) -> bool {
|
||||
"src/librustc/mir/interpret",
|
||||
"src/librustc_mir/interpret",
|
||||
"src/target",
|
||||
"src/stdsimd",
|
||||
];
|
||||
skip.iter().any(|p| path.ends_with(p))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user