2 #![allow(unused_variables)]
3 #![allow(stable_features)]
4 #![allow(overflowing_literals)]
7 // ignore-sgx no processes
8 // ignore-fuchsia must translate zircon signal to SIGILL, FIXME (#58590)
10 #![feature(repr_simd, target_feature, cfg_target_feature)]
11 #![feature(avx512_target_feature)]
13 use std::process::{Command, ExitStatus};
17 if let Some(level) = env::args().nth(1) {
18 return test::main(&level)
21 let me = env::current_exe().unwrap();
22 for level in ["sse", "avx", "avx512"].iter() {
23 let status = Command::new(&me).arg(level).status().unwrap();
25 println!("success with {}", level);
29 // We don't actually know if our computer has the requisite target features
30 // for the test below. Testing for that will get added to libstd later so
31 // for now just assume sigill means this is a machine that can't run this test.
32 if is_sigill(status) {
33 println!("sigill with {}, assuming spurious", level);
36 panic!("invalid status at {}: {}", level, status);
41 fn is_sigill(status: ExitStatus) -> bool {
42 use std::os::unix::prelude::*;
43 status.signal() == Some(4)
47 fn is_sigill(status: ExitStatus) -> bool {
48 status.code() == Some(0xc000001d)
51 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
52 #[allow(nonstandard_style)]
56 #[derive(PartialEq, Debug, Clone, Copy)]
57 struct __m128i(u64, u64);
61 #[derive(PartialEq, Debug, Clone, Copy)]
62 struct __m256i(u64, u64, u64, u64);
66 #[derive(PartialEq, Debug, Clone, Copy)]
67 struct __m512i(u64, u64, u64, u64, u64, u64, u64, u64);
69 pub fn main(level: &str) {
87 unsafe fn $main:ident(level: &str) {
92 unsafe fn $main(level: &str) {
93 let m128 = __m128i(1, 2);
94 let m256 = __m256i(3, 4, 5, 6);
95 let m512 = __m512i(7, 8, 9, 10, 11, 12, 13, 14);
96 assert_eq!(id_sse_128(m128), m128);
97 assert_eq!(id_sse_256(m256), m256);
98 assert_eq!(id_sse_512(m512), m512);
103 assert_eq!(id_avx_128(m128), m128);
104 assert_eq!(id_avx_256(m256), m256);
105 assert_eq!(id_avx_512(m512), m512);
110 assert_eq!(id_avx512_128(m128), m128);
111 assert_eq!(id_avx512_256(m256), m256);
112 assert_eq!(id_avx512_512(m512), m512);
118 unsafe fn main_normal(level: &str) { ... }
119 #[target_feature(enable = "sse2")]
120 unsafe fn main_sse(level: &str) { ... }
121 #[target_feature(enable = "avx")]
122 unsafe fn main_avx(level: &str) { ... }
123 #[target_feature(enable = "avx512bw")]
124 unsafe fn main_avx512(level: &str) { ... }
128 #[target_feature(enable = "sse2")]
129 unsafe fn id_sse_128(a: __m128i) -> __m128i {
130 assert_eq!(a, __m128i(1, 2));
134 #[target_feature(enable = "sse2")]
135 unsafe fn id_sse_256(a: __m256i) -> __m256i {
136 assert_eq!(a, __m256i(3, 4, 5, 6));
140 #[target_feature(enable = "sse2")]
141 unsafe fn id_sse_512(a: __m512i) -> __m512i {
142 assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
146 #[target_feature(enable = "avx")]
147 unsafe fn id_avx_128(a: __m128i) -> __m128i {
148 assert_eq!(a, __m128i(1, 2));
152 #[target_feature(enable = "avx")]
153 unsafe fn id_avx_256(a: __m256i) -> __m256i {
154 assert_eq!(a, __m256i(3, 4, 5, 6));
158 #[target_feature(enable = "avx")]
159 unsafe fn id_avx_512(a: __m512i) -> __m512i {
160 assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
164 #[target_feature(enable = "avx512bw")]
165 unsafe fn id_avx512_128(a: __m128i) -> __m128i {
166 assert_eq!(a, __m128i(1, 2));
170 #[target_feature(enable = "avx512bw")]
171 unsafe fn id_avx512_256(a: __m256i) -> __m256i {
172 assert_eq!(a, __m256i(3, 4, 5, 6));
176 #[target_feature(enable = "avx512bw")]
177 unsafe fn id_avx512_512(a: __m512i) -> __m512i {
178 assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
183 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
185 pub fn main(level: &str) {}