mod tuple;
mod unit;
-// Pull in 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.
+// Pull in the `core_arch` crate directly into libcore. The contents of
+// `core_arch` are in a different repository: rust-lang-nursery/stdsimd.
+//
+// `core_arch` depends on libcore, but the contents of this module are
+// set up in such a way that directly pulling it here works such that the
+// crate uses the this crate as its libcore.
#[allow(unused_macros)]
macro_rules! test_v16 { ($item:item) => {}; }
#[allow(unused_macros)]
macro_rules! test_v512 { ($item:item) => {}; }
#[allow(unused_macros)]
macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } }
-#[path = "../stdsimd/coresimd/mod.rs"]
+#[path = "../stdsimd/crates/core_arch/src/mod.rs"]
#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
#[unstable(feature = "stdsimd", issue = "48556")]
-mod coresimd;
+mod core_arch;
#[stable(feature = "simd_arch", since = "1.27.0")]
-pub use coresimd::arch;
+pub use core_arch::arch;
// Public module declarations and re-exports
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::any;
+#[stable(feature = "simd_arch", since = "1.27.0")]
+#[doc(no_inline)]
+pub use core::arch;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::cell;
#[stable(feature = "rust1", since = "1.0.0")]
// compiler
pub mod rt;
-// Pull in 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.
+// Pull in the `std_detect` crate directly into libstd. The contents of
+// `std_detect` are in a different repository: rust-lang-nursery/stdsimd.
//
-// 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"]
+// `std_detect` depends on libstd, but the contents of this module are
+// set up in such a way that directly pulling it here works such that the
+// crate uses the this crate as its libstd.
+#[path = "../stdsimd/crates/std_detect/src/mod.rs"]
#[allow(missing_debug_implementations, missing_docs, dead_code)]
#[unstable(feature = "stdsimd", issue = "48556")]
#[cfg(not(test))]
-mod stdsimd;
-
-// A "fake" module needed by the `stdsimd` module to compile, not actually
-// exported though.
-mod coresimd {
- pub use core::arch;
-}
+mod std_detect;
-#[stable(feature = "simd_arch", since = "1.27.0")]
+#[doc(hidden)]
+#[unstable(feature = "stdsimd", issue = "48556")]
#[cfg(not(test))]
-pub use stdsimd::arch;
+pub use std_detect::detect;
// Include a number of private modules that exist solely to provide
// the rustdoc documentation for primitive types. Using `include!`
--- /dev/null
+//! These tests just check that the macros are available in libstd.
+
+#![cfg_attr(
+ any(
+ all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
+ all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")),
+ all(target_arch = "powerpc", target_os = "linux"),
+ all(target_arch = "powerpc64", target_os = "linux"),
+ ),
+ feature(stdsimd)
+)]
+
+#[test]
+#[cfg(all(target_arch = "arm",
+ any(target_os = "linux", target_os = "android")))]
+fn arm_linux() {
+ println!("neon: {}", is_arm_feature_detected!("neon"));
+ println!("pmull: {}", is_arm_feature_detected!("pmull"));
+}
+
+#[test]
+#[cfg(all(
+ target_arch = "aarch64",
+ any(target_os = "linux", target_os = "android")
+))]
+fn aarch64_linux() {
+ println!("fp: {}", is_aarch64_feature_detected!("fp"));
+ println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
+ println!("neon: {}", is_aarch64_feature_detected!("neon"));
+ println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
+ println!("sve: {}", is_aarch64_feature_detected!("sve"));
+ println!("crc: {}", is_aarch64_feature_detected!("crc"));
+ println!("crypto: {}", is_aarch64_feature_detected!("crypto"));
+ println!("lse: {}", is_aarch64_feature_detected!("lse"));
+ println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
+ println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
+ println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
+}
+
+#[test]
+#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
+fn powerpc_linux() {
+ println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
+ println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
+ println!("power8: {}", is_powerpc_feature_detected!("power8"));
+}
+
+#[test]
+#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
+fn powerpc64_linux() {
+ println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
+ println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
+ println!("power8: {}", is_powerpc64_feature_detected!("power8"));
+}
+
+#[test]
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+fn x86_all() {
+ println!("aes: {:?}", is_x86_feature_detected!("aes"));
+ println!("pcmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq"));
+ println!("rdrand: {:?}", is_x86_feature_detected!("rdrand"));
+ println!("rdseed: {:?}", is_x86_feature_detected!("rdseed"));
+ println!("tsc: {:?}", is_x86_feature_detected!("tsc"));
+ println!("mmx: {:?}", is_x86_feature_detected!("mmx"));
+ println!("sse: {:?}", is_x86_feature_detected!("sse"));
+ println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
+ println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
+ println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
+ println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1"));
+ println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2"));
+ println!("sse4a: {:?}", is_x86_feature_detected!("sse4a"));
+ println!("sha: {:?}", is_x86_feature_detected!("sha"));
+ println!("avx: {:?}", is_x86_feature_detected!("avx"));
+ println!("avx2: {:?}", is_x86_feature_detected!("avx2"));
+ println!("avx512f {:?}", is_x86_feature_detected!("avx512f"));
+ println!("avx512cd {:?}", is_x86_feature_detected!("avx512cd"));
+ println!("avx512er {:?}", is_x86_feature_detected!("avx512er"));
+ println!("avx512pf {:?}", is_x86_feature_detected!("avx512pf"));
+ println!("avx512bw {:?}", is_x86_feature_detected!("avx512bw"));
+ println!("avx512dq {:?}", is_x86_feature_detected!("avx512dq"));
+ println!("avx512vl {:?}", is_x86_feature_detected!("avx512vl"));
+ println!("avx512_ifma {:?}", is_x86_feature_detected!("avx512ifma"));
+ println!("avx512_vbmi {:?}", is_x86_feature_detected!("avx512vbmi"));
+ println!(
+ "avx512_vpopcntdq {:?}",
+ is_x86_feature_detected!("avx512vpopcntdq")
+ );
+ println!("fma: {:?}", is_x86_feature_detected!("fma"));
+ println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));
+ println!("bmi2: {:?}", is_x86_feature_detected!("bmi2"));
+ println!("abm: {:?}", is_x86_feature_detected!("abm"));
+ println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
+ println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
+ println!("popcnt: {:?}", is_x86_feature_detected!("popcnt"));
+ println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
+ println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
+ println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
+ println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
+ println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
+}