]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/simd/simd-target-feature-mixup.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![allow(unused_variables)]
13 #![allow(stable_features)]
14 #![allow(overflowing_literals)]
18 #![feature(repr_simd, target_feature, cfg_target_feature)]
19 #![feature(avx512_target_feature)]
21 use std
::process
::{Command, ExitStatus}
;
25 if let Some(level
) = env
::args().nth(1) {
26 return test
::main(&level
)
29 let me
= env
::current_exe().unwrap();
30 for level
in ["sse", "avx", "avx512"].iter() {
31 let status
= Command
::new(&me
).arg(level
).status().unwrap();
33 println
!("success with {}", level
);
37 // We don't actually know if our computer has the requisite target features
38 // for the test below. Testing for that will get added to libstd later so
39 // for now just assume sigill means this is a machine that can't run this test.
40 if is_sigill(status
) {
41 println
!("sigill with {}, assuming spurious", level
);
44 panic
!("invalid status at {}: {}", level
, status
);
49 fn is_sigill(status
: ExitStatus
) -> bool
{
50 use std
::os
::unix
::prelude
::*;
51 status
.signal() == Some(4)
55 fn is_sigill(status
: ExitStatus
) -> bool
{
56 status
.code() == Some(0xc000001d)
59 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
60 #[allow(nonstandard_style)]
64 #[derive(PartialEq, Debug, Clone, Copy)]
65 struct __m128i(u64, u64);
69 #[derive(PartialEq, Debug, Clone, Copy)]
70 struct __m256i(u64, u64, u64, u64);
74 #[derive(PartialEq, Debug, Clone, Copy)]
75 struct __m512i(u64, u64, u64, u64, u64, u64, u64, u64);
77 pub fn main(level
: &str) {
95 unsafe fn $main
:ident(level
: &str) {
100 unsafe fn $
main(level
: &str) {
101 let m128
= __m128i(1, 2);
102 let m256
= __m256i(3, 4, 5, 6);
103 let m512
= __m512i(7, 8, 9, 10, 11, 12, 13, 14);
104 assert_eq
!(id_sse_128(m128
), m128
);
105 assert_eq
!(id_sse_256(m256
), m256
);
106 assert_eq
!(id_sse_512(m512
), m512
);
111 assert_eq
!(id_avx_128(m128
), m128
);
112 assert_eq
!(id_avx_256(m256
), m256
);
113 assert_eq
!(id_avx_512(m512
), m512
);
118 assert_eq
!(id_avx512_128(m128
), m128
);
119 assert_eq
!(id_avx512_256(m256
), m256
);
120 assert_eq
!(id_avx512_512(m512
), m512
);
126 unsafe fn main_normal(level
: &str) { ... }
127 #[target_feature(enable = "sse2")]
128 unsafe fn main_sse(level
: &str) { ... }
129 #[target_feature(enable = "avx")]
130 unsafe fn main_avx(level
: &str) { ... }
131 #[target_feature(enable = "avx512bw")]
132 unsafe fn main_avx512(level
: &str) { ... }
136 #[target_feature(enable = "sse2")]
137 unsafe fn id_sse_128(a
: __m128i
) -> __m128i
{
138 assert_eq
!(a
, __m128i(1, 2));
142 #[target_feature(enable = "sse2")]
143 unsafe fn id_sse_256(a
: __m256i
) -> __m256i
{
144 assert_eq
!(a
, __m256i(3, 4, 5, 6));
148 #[target_feature(enable = "sse2")]
149 unsafe fn id_sse_512(a
: __m512i
) -> __m512i
{
150 assert_eq
!(a
, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
154 #[target_feature(enable = "avx")]
155 unsafe fn id_avx_128(a
: __m128i
) -> __m128i
{
156 assert_eq
!(a
, __m128i(1, 2));
160 #[target_feature(enable = "avx")]
161 unsafe fn id_avx_256(a
: __m256i
) -> __m256i
{
162 assert_eq
!(a
, __m256i(3, 4, 5, 6));
166 #[target_feature(enable = "avx")]
167 unsafe fn id_avx_512(a
: __m512i
) -> __m512i
{
168 assert_eq
!(a
, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
172 #[target_feature(enable = "avx512bw")]
173 unsafe fn id_avx512_128(a
: __m128i
) -> __m128i
{
174 assert_eq
!(a
, __m128i(1, 2));
178 #[target_feature(enable = "avx512bw")]
179 unsafe fn id_avx512_256(a
: __m256i
) -> __m256i
{
180 assert_eq
!(a
, __m256i(3, 4, 5, 6));
184 #[target_feature(enable = "avx512bw")]
185 unsafe fn id_avx512_512(a
: __m512i
) -> __m512i
{
186 assert_eq
!(a
, __m512i(7, 8, 9, 10, 11, 12, 13, 14));
191 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
193 pub fn main(level
: &str) {}