]>
Commit | Line | Data |
---|---|---|
1 | //! These tests just check that the macros are available in libstd. | |
2 | ||
3 | #![cfg_attr( | |
4 | any( | |
5 | all(target_arch = "arm", any(target_os = "linux", target_os = "android")), | |
6 | all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")), | |
7 | all(target_arch = "powerpc", target_os = "linux"), | |
8 | all(target_arch = "powerpc64", target_os = "linux"), | |
9 | any(target_arch = "x86", target_arch = "x86_64"), | |
10 | ), | |
11 | feature(stdsimd) | |
12 | )] | |
13 | ||
14 | #[test] | |
15 | #[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))] | |
16 | fn arm_linux() { | |
17 | println!("neon: {}", is_arm_feature_detected!("neon")); | |
18 | println!("pmull: {}", is_arm_feature_detected!("pmull")); | |
19 | } | |
20 | ||
21 | #[test] | |
22 | #[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))] | |
23 | fn aarch64_linux() { | |
24 | println!("fp: {}", is_aarch64_feature_detected!("fp")); | |
25 | println!("fp16: {}", is_aarch64_feature_detected!("fp16")); | |
26 | println!("neon: {}", is_aarch64_feature_detected!("neon")); | |
27 | println!("asimd: {}", is_aarch64_feature_detected!("asimd")); | |
28 | println!("sve: {}", is_aarch64_feature_detected!("sve")); | |
29 | println!("crc: {}", is_aarch64_feature_detected!("crc")); | |
30 | println!("lse: {}", is_aarch64_feature_detected!("lse")); | |
31 | println!("rdm: {}", is_aarch64_feature_detected!("rdm")); | |
32 | println!("rcpc: {}", is_aarch64_feature_detected!("rcpc")); | |
33 | println!("dotprod: {}", is_aarch64_feature_detected!("dotprod")); | |
34 | println!("tme: {}", is_aarch64_feature_detected!("tme")); | |
35 | } | |
36 | ||
37 | #[test] | |
38 | #[cfg(all(target_arch = "powerpc", target_os = "linux"))] | |
39 | fn powerpc_linux() { | |
40 | println!("altivec: {}", is_powerpc_feature_detected!("altivec")); | |
41 | println!("vsx: {}", is_powerpc_feature_detected!("vsx")); | |
42 | println!("power8: {}", is_powerpc_feature_detected!("power8")); | |
43 | } | |
44 | ||
45 | #[test] | |
46 | #[cfg(all(target_arch = "powerpc64", target_os = "linux"))] | |
47 | fn powerpc64_linux() { | |
48 | println!("altivec: {}", is_powerpc64_feature_detected!("altivec")); | |
49 | println!("vsx: {}", is_powerpc64_feature_detected!("vsx")); | |
50 | println!("power8: {}", is_powerpc64_feature_detected!("power8")); | |
51 | } | |
52 | ||
53 | #[test] | |
54 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | |
55 | fn x86_all() { | |
56 | // the below is the set of features we can test at runtime, but don't actually | |
57 | // use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list | |
58 | ||
59 | println!("abm: {:?}", is_x86_feature_detected!("abm")); // this is a synonym for lzcnt but we test it anyways | |
60 | println!("mmx: {:?}", is_x86_feature_detected!("mmx")); | |
61 | println!("tsc: {:?}", is_x86_feature_detected!("tsc")); | |
62 | ||
63 | // the below is in alphabetical order and matches | |
64 | // the order of X86_ALLOWED_FEATURES in rustc_codegen_ssa's target_features.rs | |
65 | ||
66 | println!("adx: {:?}", is_x86_feature_detected!("adx")); | |
67 | println!("aes: {:?}", is_x86_feature_detected!("aes")); | |
68 | println!("avx: {:?}", is_x86_feature_detected!("avx")); | |
69 | println!("avx2: {:?}", is_x86_feature_detected!("avx2")); | |
70 | println!("avx512bf16: {:?}", is_x86_feature_detected!("avx512bf16")); | |
71 | println!("avx512bitalg: {:?}", is_x86_feature_detected!("avx512bitalg")); | |
72 | println!("avx512bw: {:?}", is_x86_feature_detected!("avx512bw")); | |
73 | println!("avx512cd: {:?}", is_x86_feature_detected!("avx512cd")); | |
74 | println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq")); | |
75 | println!("avx512er: {:?}", is_x86_feature_detected!("avx512er")); | |
76 | println!("avx512f: {:?}", is_x86_feature_detected!("avx512f")); | |
77 | println!("avx512gfni: {:?}", is_x86_feature_detected!("avx512gfni")); | |
78 | println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma")); | |
79 | println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf")); | |
80 | println!("avx512vaes: {:?}", is_x86_feature_detected!("avx512vaes")); | |
81 | println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi")); | |
82 | println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2")); | |
83 | println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl")); | |
84 | println!("avx512vnni: {:?}", is_x86_feature_detected!("avx512vnni")); | |
85 | println!("avx512vp2intersect: {:?}", is_x86_feature_detected!("avx512vp2intersect")); | |
86 | println!("avx512vpclmulqdq: {:?}", is_x86_feature_detected!("avx512vpclmulqdq")); | |
87 | println!("avx512vpopcntdq: {:?}", is_x86_feature_detected!("avx512vpopcntdq")); | |
88 | println!("bmi1: {:?}", is_x86_feature_detected!("bmi1")); | |
89 | println!("bmi2: {:?}", is_x86_feature_detected!("bmi2")); | |
90 | println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b")); | |
91 | println!("f16c: {:?}", is_x86_feature_detected!("f16c")); | |
92 | println!("fma: {:?}", is_x86_feature_detected!("fma")); | |
93 | println!("fxsr: {:?}", is_x86_feature_detected!("fxsr")); | |
94 | println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt")); | |
95 | //println!("movbe: {:?}", is_x86_feature_detected!("movbe")); // movbe is unsupported as a target feature | |
96 | println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq")); | |
97 | println!("popcnt: {:?}", is_x86_feature_detected!("popcnt")); | |
98 | println!("rdrand: {:?}", is_x86_feature_detected!("rdrand")); | |
99 | println!("rdseed: {:?}", is_x86_feature_detected!("rdseed")); | |
100 | println!("rtm: {:?}", is_x86_feature_detected!("rtm")); | |
101 | println!("sha: {:?}", is_x86_feature_detected!("sha")); | |
102 | println!("sse: {:?}", is_x86_feature_detected!("sse")); | |
103 | println!("sse2: {:?}", is_x86_feature_detected!("sse2")); | |
104 | println!("sse3: {:?}", is_x86_feature_detected!("sse3")); | |
105 | println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1")); | |
106 | println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2")); | |
107 | println!("sse4a: {:?}", is_x86_feature_detected!("sse4a")); | |
108 | println!("ssse3: {:?}", is_x86_feature_detected!("ssse3")); | |
109 | println!("tbm: {:?}", is_x86_feature_detected!("tbm")); | |
110 | println!("xsave: {:?}", is_x86_feature_detected!("xsave")); | |
111 | println!("xsavec: {:?}", is_x86_feature_detected!("xsavec")); | |
112 | println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt")); | |
113 | println!("xsaves: {:?}", is_x86_feature_detected!("xsaves")); | |
114 | } |