2022-10-28 17:34:29 -05:00
|
|
|
//! These tests just check that the macros are available in std.
|
2019-01-21 11:42:04 -06:00
|
|
|
|
|
|
|
#![cfg_attr(
|
|
|
|
any(
|
|
|
|
all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
|
|
|
|
all(target_arch = "powerpc", target_os = "linux"),
|
|
|
|
all(target_arch = "powerpc64", target_os = "linux"),
|
|
|
|
),
|
|
|
|
feature(stdsimd)
|
|
|
|
)]
|
|
|
|
|
|
|
|
#[test]
|
2019-12-22 16:42:04 -06:00
|
|
|
#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))]
|
2019-01-21 11:42:04 -06:00
|
|
|
fn arm_linux() {
|
2022-01-28 03:36:04 -06:00
|
|
|
use std::arch::is_arm_feature_detected;
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-start
|
|
|
|
println!("aes: {}", is_arm_feature_detected!("aes"));
|
|
|
|
println!("crc: {}", is_arm_feature_detected!("crc"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("neon: {}", is_arm_feature_detected!("neon"));
|
|
|
|
println!("pmull: {}", is_arm_feature_detected!("pmull"));
|
2021-06-01 11:01:47 -05:00
|
|
|
println!("sha2: {}", is_arm_feature_detected!("sha2"));
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-end
|
2019-01-21 11:42:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-12-22 16:42:04 -06:00
|
|
|
#[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))]
|
2019-01-21 11:42:04 -06:00
|
|
|
fn aarch64_linux() {
|
2022-01-28 03:36:04 -06:00
|
|
|
use std::arch::is_aarch64_feature_detected;
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-start
|
|
|
|
println!("aes: {}", is_aarch64_feature_detected!("aes"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("bf16: {}", is_aarch64_feature_detected!("bf16"));
|
|
|
|
println!("bti: {}", is_aarch64_feature_detected!("bti"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("crc: {}", is_aarch64_feature_detected!("crc"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("dit: {}", is_aarch64_feature_detected!("dit"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("dpb2: {}", is_aarch64_feature_detected!("dpb2"));
|
|
|
|
println!("dpb: {}", is_aarch64_feature_detected!("dpb"));
|
|
|
|
println!("f32mm: {}", is_aarch64_feature_detected!("f32mm"));
|
|
|
|
println!("f64mm: {}", is_aarch64_feature_detected!("f64mm"));
|
|
|
|
println!("fcma: {}", is_aarch64_feature_detected!("fcma"));
|
2021-06-01 11:01:47 -05:00
|
|
|
println!("fhm: {}", is_aarch64_feature_detected!("fhm"));
|
|
|
|
println!("flagm: {}", is_aarch64_feature_detected!("flagm"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
|
2021-06-01 11:01:47 -05:00
|
|
|
println!("frintts: {}", is_aarch64_feature_detected!("frintts"));
|
|
|
|
println!("i8mm: {}", is_aarch64_feature_detected!("i8mm"));
|
|
|
|
println!("jsconv: {}", is_aarch64_feature_detected!("jsconv"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("lse2: {}", is_aarch64_feature_detected!("lse2"));
|
|
|
|
println!("lse: {}", is_aarch64_feature_detected!("lse"));
|
|
|
|
println!("mte: {}", is_aarch64_feature_detected!("mte"));
|
|
|
|
println!("neon: {}", is_aarch64_feature_detected!("neon"));
|
|
|
|
println!("paca: {}", is_aarch64_feature_detected!("paca"));
|
|
|
|
println!("pacg: {}", is_aarch64_feature_detected!("pacg"));
|
|
|
|
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
|
|
|
|
println!("rand: {}", is_aarch64_feature_detected!("rand"));
|
|
|
|
println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2"));
|
|
|
|
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
|
|
|
|
println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
|
|
|
|
println!("sb: {}", is_aarch64_feature_detected!("sb"));
|
2021-06-01 11:01:47 -05:00
|
|
|
println!("sha2: {}", is_aarch64_feature_detected!("sha2"));
|
|
|
|
println!("sha3: {}", is_aarch64_feature_detected!("sha3"));
|
|
|
|
println!("sm4: {}", is_aarch64_feature_detected!("sm4"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("ssbs: {}", is_aarch64_feature_detected!("ssbs"));
|
|
|
|
println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes"));
|
|
|
|
println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm"));
|
|
|
|
println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3"));
|
|
|
|
println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4"));
|
|
|
|
println!("sve2: {}", is_aarch64_feature_detected!("sve2"));
|
|
|
|
println!("sve: {}", is_aarch64_feature_detected!("sve"));
|
|
|
|
println!("tme: {}", is_aarch64_feature_detected!("tme"));
|
|
|
|
// tidy-alphabetical-end
|
2019-01-21 11:42:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
|
|
|
|
fn powerpc_linux() {
|
2022-01-28 03:36:04 -06:00
|
|
|
use std::arch::is_powerpc_feature_detected;
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-start
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
|
|
|
|
println!("power8: {}", is_powerpc_feature_detected!("power8"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
|
|
|
|
// tidy-alphabetical-end
|
2019-01-21 11:42:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
|
|
|
|
fn powerpc64_linux() {
|
2022-01-28 03:36:04 -06:00
|
|
|
use std::arch::is_powerpc64_feature_detected;
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-start
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
|
|
|
|
println!("power8: {}", is_powerpc64_feature_detected!("power8"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
|
|
|
|
// tidy-alphabetical-end
|
2019-01-21 11:42:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
|
|
fn x86_all() {
|
2022-01-28 03:36:04 -06:00
|
|
|
use std::arch::is_x86_feature_detected;
|
|
|
|
|
2020-10-26 02:15:23 -05:00
|
|
|
// the below is the set of features we can test at runtime, but don't actually
|
|
|
|
// use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list
|
|
|
|
|
|
|
|
println!("abm: {:?}", is_x86_feature_detected!("abm")); // this is a synonym for lzcnt but we test it anyways
|
|
|
|
println!("mmx: {:?}", is_x86_feature_detected!("mmx"));
|
|
|
|
println!("tsc: {:?}", is_x86_feature_detected!("tsc"));
|
|
|
|
|
2020-10-25 10:53:25 -05:00
|
|
|
// the below is in alphabetical order and matches
|
|
|
|
// the order of X86_ALLOWED_FEATURES in rustc_codegen_ssa's target_features.rs
|
|
|
|
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-start
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("adx: {:?}", is_x86_feature_detected!("adx"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("aes: {:?}", is_x86_feature_detected!("aes"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("avx2: {:?}", is_x86_feature_detected!("avx2"));
|
|
|
|
println!("avx512bf16: {:?}", is_x86_feature_detected!("avx512bf16"));
|
|
|
|
println!("avx512bitalg: {:?}", is_x86_feature_detected!("avx512bitalg"));
|
|
|
|
println!("avx512bw: {:?}", is_x86_feature_detected!("avx512bw"));
|
|
|
|
println!("avx512cd: {:?}", is_x86_feature_detected!("avx512cd"));
|
|
|
|
println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq"));
|
|
|
|
println!("avx512er: {:?}", is_x86_feature_detected!("avx512er"));
|
|
|
|
println!("avx512f: {:?}", is_x86_feature_detected!("avx512f"));
|
|
|
|
println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma"));
|
|
|
|
println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf"));
|
|
|
|
println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl"));
|
|
|
|
println!("avx512vnni: {:?}", is_x86_feature_detected!("avx512vnni"));
|
|
|
|
println!("avx512vp2intersect: {:?}", is_x86_feature_detected!("avx512vp2intersect"));
|
|
|
|
println!("avx512vpopcntdq: {:?}", is_x86_feature_detected!("avx512vpopcntdq"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("avx: {:?}", is_x86_feature_detected!("avx"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));
|
|
|
|
println!("bmi2: {:?}", is_x86_feature_detected!("bmi2"));
|
|
|
|
println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b"));
|
|
|
|
println!("f16c: {:?}", is_x86_feature_detected!("f16c"));
|
|
|
|
println!("fma: {:?}", is_x86_feature_detected!("fma"));
|
|
|
|
println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
|
2023-01-26 04:09:32 -06:00
|
|
|
println!("gfni: {:?}", is_x86_feature_detected!("gfni"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
|
2020-10-25 11:27:22 -05:00
|
|
|
//println!("movbe: {:?}", is_x86_feature_detected!("movbe")); // movbe is unsupported as a target feature
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq"));
|
|
|
|
println!("popcnt: {:?}", is_x86_feature_detected!("popcnt"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("rdrand: {:?}", is_x86_feature_detected!("rdrand"));
|
|
|
|
println!("rdseed: {:?}", is_x86_feature_detected!("rdseed"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("rtm: {:?}", is_x86_feature_detected!("rtm"));
|
|
|
|
println!("sha: {:?}", is_x86_feature_detected!("sha"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
|
|
|
|
println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
|
|
|
|
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"));
|
2022-10-14 15:01:18 -05:00
|
|
|
println!("sse: {:?}", is_x86_feature_detected!("sse"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
|
2023-01-26 04:09:32 -06:00
|
|
|
println!("vaes: {:?}", is_x86_feature_detected!("vaes"));
|
|
|
|
println!("vpclmulqdq: {:?}", is_x86_feature_detected!("vpclmulqdq"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
|
2020-10-25 10:53:25 -05:00
|
|
|
println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
|
2019-01-21 11:42:04 -06:00
|
|
|
println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
|
|
|
|
println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
|
2022-10-14 15:01:18 -05:00
|
|
|
// tidy-alphabetical-end
|
2019-01-21 11:42:04 -06:00
|
|
|
}
|