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