]>
Commit | Line | Data |
---|---|---|
f25598a0 | 1 | //! These tests just check that the macros are available in std. |
9fa01778 | 2 | |
8faf50e0 | 3 | #![cfg_attr( |
9fa01778 XL |
4 | any( |
5 | all(target_arch = "arm", any(target_os = "linux", target_os = "android")), | |
9fa01778 XL |
6 | all(target_arch = "powerpc", target_os = "linux"), |
7 | all(target_arch = "powerpc64", target_os = "linux"), | |
8 | ), | |
9 | feature(stdsimd) | |
8faf50e0 | 10 | )] |
0531ce1d | 11 | |
0531ce1d | 12 | #[test] |
dfeec247 | 13 | #[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))] |
0531ce1d | 14 | fn arm_linux() { |
5099ac24 | 15 | use std::arch::is_arm_feature_detected; |
2b03887a FG |
16 | // tidy-alphabetical-start |
17 | println!("aes: {}", is_arm_feature_detected!("aes")); | |
18 | println!("crc: {}", is_arm_feature_detected!("crc")); | |
19 | println!("crypto: {}", is_arm_feature_detected!("crypto")); | |
0531ce1d XL |
20 | println!("neon: {}", is_arm_feature_detected!("neon")); |
21 | println!("pmull: {}", is_arm_feature_detected!("pmull")); | |
94222f64 | 22 | println!("sha2: {}", is_arm_feature_detected!("sha2")); |
2b03887a | 23 | // tidy-alphabetical-end |
0531ce1d XL |
24 | } |
25 | ||
26 | #[test] | |
dfeec247 | 27 | #[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))] |
0531ce1d | 28 | fn aarch64_linux() { |
5099ac24 | 29 | use std::arch::is_aarch64_feature_detected; |
2b03887a FG |
30 | // tidy-alphabetical-start |
31 | println!("aes: {}", is_aarch64_feature_detected!("aes")); | |
8faf50e0 | 32 | println!("asimd: {}", is_aarch64_feature_detected!("asimd")); |
2b03887a FG |
33 | println!("bf16: {}", is_aarch64_feature_detected!("bf16")); |
34 | println!("bti: {}", is_aarch64_feature_detected!("bti")); | |
0531ce1d | 35 | println!("crc: {}", is_aarch64_feature_detected!("crc")); |
2b03887a | 36 | println!("dit: {}", is_aarch64_feature_detected!("dit")); |
8faf50e0 | 37 | println!("dotprod: {}", is_aarch64_feature_detected!("dotprod")); |
2b03887a FG |
38 | println!("dpb2: {}", is_aarch64_feature_detected!("dpb2")); |
39 | println!("dpb: {}", is_aarch64_feature_detected!("dpb")); | |
40 | println!("f32mm: {}", is_aarch64_feature_detected!("f32mm")); | |
41 | println!("f64mm: {}", is_aarch64_feature_detected!("f64mm")); | |
42 | println!("fcma: {}", is_aarch64_feature_detected!("fcma")); | |
94222f64 | 43 | println!("fhm: {}", is_aarch64_feature_detected!("fhm")); |
94222f64 | 44 | println!("flagm: {}", is_aarch64_feature_detected!("flagm")); |
2b03887a | 45 | println!("fp16: {}", is_aarch64_feature_detected!("fp16")); |
94222f64 XL |
46 | println!("frintts: {}", is_aarch64_feature_detected!("frintts")); |
47 | println!("i8mm: {}", is_aarch64_feature_detected!("i8mm")); | |
94222f64 | 48 | println!("jsconv: {}", is_aarch64_feature_detected!("jsconv")); |
2b03887a FG |
49 | println!("lse2: {}", is_aarch64_feature_detected!("lse2")); |
50 | println!("lse: {}", is_aarch64_feature_detected!("lse")); | |
51 | println!("mte: {}", is_aarch64_feature_detected!("mte")); | |
52 | println!("neon: {}", is_aarch64_feature_detected!("neon")); | |
53 | println!("paca: {}", is_aarch64_feature_detected!("paca")); | |
54 | println!("pacg: {}", is_aarch64_feature_detected!("pacg")); | |
55 | println!("pmull: {}", is_aarch64_feature_detected!("pmull")); | |
56 | println!("rand: {}", is_aarch64_feature_detected!("rand")); | |
57 | println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2")); | |
58 | println!("rcpc: {}", is_aarch64_feature_detected!("rcpc")); | |
59 | println!("rdm: {}", is_aarch64_feature_detected!("rdm")); | |
60 | println!("sb: {}", is_aarch64_feature_detected!("sb")); | |
94222f64 XL |
61 | println!("sha2: {}", is_aarch64_feature_detected!("sha2")); |
62 | println!("sha3: {}", is_aarch64_feature_detected!("sha3")); | |
63 | println!("sm4: {}", is_aarch64_feature_detected!("sm4")); | |
2b03887a FG |
64 | println!("ssbs: {}", is_aarch64_feature_detected!("ssbs")); |
65 | println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes")); | |
66 | println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm")); | |
67 | println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3")); | |
68 | println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4")); | |
69 | println!("sve2: {}", is_aarch64_feature_detected!("sve2")); | |
70 | println!("sve: {}", is_aarch64_feature_detected!("sve")); | |
71 | println!("tme: {}", is_aarch64_feature_detected!("tme")); | |
72 | // tidy-alphabetical-end | |
8faf50e0 XL |
73 | } |
74 | ||
75 | #[test] | |
76 | #[cfg(all(target_arch = "powerpc", target_os = "linux"))] | |
77 | fn powerpc_linux() { | |
5099ac24 | 78 | use std::arch::is_powerpc_feature_detected; |
2b03887a | 79 | // tidy-alphabetical-start |
8faf50e0 | 80 | println!("altivec: {}", is_powerpc_feature_detected!("altivec")); |
8faf50e0 | 81 | println!("power8: {}", is_powerpc_feature_detected!("power8")); |
2b03887a FG |
82 | println!("vsx: {}", is_powerpc_feature_detected!("vsx")); |
83 | // tidy-alphabetical-end | |
0531ce1d XL |
84 | } |
85 | ||
86 | #[test] | |
87 | #[cfg(all(target_arch = "powerpc64", target_os = "linux"))] | |
88 | fn powerpc64_linux() { | |
5099ac24 | 89 | use std::arch::is_powerpc64_feature_detected; |
2b03887a | 90 | // tidy-alphabetical-start |
8faf50e0 | 91 | println!("altivec: {}", is_powerpc64_feature_detected!("altivec")); |
8faf50e0 | 92 | println!("power8: {}", is_powerpc64_feature_detected!("power8")); |
2b03887a FG |
93 | println!("vsx: {}", is_powerpc64_feature_detected!("vsx")); |
94 | // tidy-alphabetical-end | |
0531ce1d XL |
95 | } |
96 | ||
97 | #[test] | |
98 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | |
99 | fn x86_all() { | |
5099ac24 FG |
100 | use std::arch::is_x86_feature_detected; |
101 | ||
fc512014 XL |
102 | // the below is the set of features we can test at runtime, but don't actually |
103 | // use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list | |
104 | ||
105 | println!("abm: {:?}", is_x86_feature_detected!("abm")); // this is a synonym for lzcnt but we test it anyways | |
106 | println!("mmx: {:?}", is_x86_feature_detected!("mmx")); | |
107 | println!("tsc: {:?}", is_x86_feature_detected!("tsc")); | |
108 | ||
109 | // the below is in alphabetical order and matches | |
110 | // the order of X86_ALLOWED_FEATURES in rustc_codegen_ssa's target_features.rs | |
111 | ||
2b03887a | 112 | // tidy-alphabetical-start |
fc512014 | 113 | println!("adx: {:?}", is_x86_feature_detected!("adx")); |
8faf50e0 | 114 | println!("aes: {:?}", is_x86_feature_detected!("aes")); |
fc512014 XL |
115 | println!("avx2: {:?}", is_x86_feature_detected!("avx2")); |
116 | println!("avx512bf16: {:?}", is_x86_feature_detected!("avx512bf16")); | |
117 | println!("avx512bitalg: {:?}", is_x86_feature_detected!("avx512bitalg")); | |
118 | println!("avx512bw: {:?}", is_x86_feature_detected!("avx512bw")); | |
119 | println!("avx512cd: {:?}", is_x86_feature_detected!("avx512cd")); | |
120 | println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq")); | |
121 | println!("avx512er: {:?}", is_x86_feature_detected!("avx512er")); | |
122 | println!("avx512f: {:?}", is_x86_feature_detected!("avx512f")); | |
123 | println!("avx512gfni: {:?}", is_x86_feature_detected!("avx512gfni")); | |
124 | println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma")); | |
125 | println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf")); | |
126 | println!("avx512vaes: {:?}", is_x86_feature_detected!("avx512vaes")); | |
fc512014 | 127 | println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2")); |
2b03887a | 128 | println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi")); |
fc512014 XL |
129 | println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl")); |
130 | println!("avx512vnni: {:?}", is_x86_feature_detected!("avx512vnni")); | |
131 | println!("avx512vp2intersect: {:?}", is_x86_feature_detected!("avx512vp2intersect")); | |
132 | println!("avx512vpclmulqdq: {:?}", is_x86_feature_detected!("avx512vpclmulqdq")); | |
133 | println!("avx512vpopcntdq: {:?}", is_x86_feature_detected!("avx512vpopcntdq")); | |
2b03887a | 134 | println!("avx: {:?}", is_x86_feature_detected!("avx")); |
fc512014 XL |
135 | println!("bmi1: {:?}", is_x86_feature_detected!("bmi1")); |
136 | println!("bmi2: {:?}", is_x86_feature_detected!("bmi2")); | |
137 | println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b")); | |
138 | println!("f16c: {:?}", is_x86_feature_detected!("f16c")); | |
139 | println!("fma: {:?}", is_x86_feature_detected!("fma")); | |
140 | println!("fxsr: {:?}", is_x86_feature_detected!("fxsr")); | |
141 | println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt")); | |
142 | //println!("movbe: {:?}", is_x86_feature_detected!("movbe")); // movbe is unsupported as a target feature | |
143 | println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq")); | |
144 | println!("popcnt: {:?}", is_x86_feature_detected!("popcnt")); | |
8faf50e0 XL |
145 | println!("rdrand: {:?}", is_x86_feature_detected!("rdrand")); |
146 | println!("rdseed: {:?}", is_x86_feature_detected!("rdseed")); | |
fc512014 XL |
147 | println!("rtm: {:?}", is_x86_feature_detected!("rtm")); |
148 | println!("sha: {:?}", is_x86_feature_detected!("sha")); | |
0531ce1d XL |
149 | println!("sse2: {:?}", is_x86_feature_detected!("sse2")); |
150 | println!("sse3: {:?}", is_x86_feature_detected!("sse3")); | |
8faf50e0 XL |
151 | println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1")); |
152 | println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2")); | |
0531ce1d | 153 | println!("sse4a: {:?}", is_x86_feature_detected!("sse4a")); |
2b03887a | 154 | println!("sse: {:?}", is_x86_feature_detected!("sse")); |
fc512014 | 155 | println!("ssse3: {:?}", is_x86_feature_detected!("ssse3")); |
8faf50e0 | 156 | println!("tbm: {:?}", is_x86_feature_detected!("tbm")); |
0531ce1d | 157 | println!("xsave: {:?}", is_x86_feature_detected!("xsave")); |
fc512014 | 158 | println!("xsavec: {:?}", is_x86_feature_detected!("xsavec")); |
8faf50e0 XL |
159 | println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt")); |
160 | println!("xsaves: {:?}", is_x86_feature_detected!("xsaves")); | |
2b03887a | 161 | // tidy-alphabetical-end |
0531ce1d | 162 | } |