]> git.proxmox.com Git - rustc.git/blame - library/std/tests/run-time-detect.rs
New upstream version 1.54.0+dfsg1
[rustc.git] / library / std / tests / run-time-detect.rs
CommitLineData
9fa01778
XL
1//! These tests just check that the macros are available in libstd.
2
8faf50e0 3#![cfg_attr(
9fa01778
XL
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"),
74b04a01 9 any(target_arch = "x86", target_arch = "x86_64"),
9fa01778
XL
10 ),
11 feature(stdsimd)
8faf50e0 12)]
0531ce1d 13
0531ce1d 14#[test]
dfeec247 15#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))]
0531ce1d
XL
16fn arm_linux() {
17 println!("neon: {}", is_arm_feature_detected!("neon"));
18 println!("pmull: {}", is_arm_feature_detected!("pmull"));
19}
20
21#[test]
dfeec247 22#[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))]
0531ce1d
XL
23fn 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"));
8faf50e0 27 println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
0531ce1d
XL
28 println!("sve: {}", is_aarch64_feature_detected!("sve"));
29 println!("crc: {}", is_aarch64_feature_detected!("crc"));
0531ce1d
XL
30 println!("lse: {}", is_aarch64_feature_detected!("lse"));
31 println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
32 println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
8faf50e0 33 println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
f9f354fc 34 println!("tme: {}", is_aarch64_feature_detected!("tme"));
8faf50e0
XL
35}
36
37#[test]
38#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
39fn 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"));
0531ce1d
XL
43}
44
45#[test]
46#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
47fn powerpc64_linux() {
8faf50e0 48 println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
0531ce1d 49 println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
8faf50e0 50 println!("power8: {}", is_powerpc64_feature_detected!("power8"));
0531ce1d
XL
51}
52
53#[test]
54#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
55fn x86_all() {
fc512014
XL
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"));
8faf50e0 67 println!("aes: {:?}", is_x86_feature_detected!("aes"));
fc512014
XL
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"));
8faf50e0
XL
98 println!("rdrand: {:?}", is_x86_feature_detected!("rdrand"));
99 println!("rdseed: {:?}", is_x86_feature_detected!("rdseed"));
fc512014
XL
100 println!("rtm: {:?}", is_x86_feature_detected!("rtm"));
101 println!("sha: {:?}", is_x86_feature_detected!("sha"));
0531ce1d
XL
102 println!("sse: {:?}", is_x86_feature_detected!("sse"));
103 println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
104 println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
8faf50e0
XL
105 println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1"));
106 println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2"));
0531ce1d 107 println!("sse4a: {:?}", is_x86_feature_detected!("sse4a"));
fc512014 108 println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
8faf50e0 109 println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
0531ce1d 110 println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
fc512014 111 println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
8faf50e0
XL
112 println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
113 println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
0531ce1d 114}