Skip to content

Commit 22e8f1e

Browse files
committed
Add some basic tests
1 parent 18840b0 commit 22e8f1e

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// only-aarch64
2+
3+
#![feature(repr_simd)]
4+
#![feature(simd_ffi)]
5+
#![allow(non_camel_case_types)]
6+
#![cfg(target_arch = "aarch64")]
7+
8+
#[repr(simd)]
9+
struct v1024(i128, i128, i128, i128, i128, i128, i128, i128);
10+
11+
extern {
12+
fn foo(x: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
13+
fn bar(x: i32, y: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
14+
fn baz(x: i32) -> v1024; //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
15+
16+
fn qux_fail(x: v64); //~ ERROR use of SIMD type `v64` in FFI requires `#[target_feature(enable = "neon")]`
17+
#[target_feature(enable = "neon")]
18+
fn qux(x: v64);
19+
20+
fn quux_fail(x: v64i); //~ ERROR use of SIMD type `v64i` in FFI requires `#[target_feature(enable = "neon")]`
21+
#[target_feature(enable = "neon")]
22+
fn quux(x: v64i);
23+
24+
fn quuux_fail(x: v128); //~ ERROR use of SIMD type `v128` in FFI requires `#[target_feature(enable = "neon")]`
25+
#[target_feature(enable = "neon")]
26+
fn quuux(x: v128);
27+
28+
fn quuuux_fail(x: v128i); //~ ERROR use of SIMD type `v128i` in FFI requires `#[target_feature(enable = "neon")]`
29+
#[target_feature(enable = "neon")]
30+
fn quuuux(x: v128); //~ ERROR use of SIMD type `v128i` in FFI not supported by any target features
31+
}
32+
33+
fn main() {}
34+
35+
#[repr(simd)]
36+
struct v128(i32, i32, i32, i32);
37+
38+
#[repr(simd)]
39+
struct v64(i32, i32);
40+
41+
#[repr(simd)]
42+
struct v128i(i64, i64);
43+
44+
#[repr(simd)]
45+
struct v64i(i64);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// only-arm
2+
3+
#![feature(repr_simd)]
4+
#![feature(simd_ffi)]
5+
#![allow(non_camel_case_types)]
6+
#![cfg(target_arch = "arm")]
7+
8+
#[repr(simd)]
9+
struct v1024(i128, i128, i128, i128, i128, i128, i128, i128);
10+
11+
extern {
12+
fn foo(x: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
13+
fn bar(x: i32, y: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
14+
fn baz(x: i32) -> v1024; //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
15+
16+
fn qux_fail(x: v64); //~ ERROR use of SIMD type `v64` in FFI requires `#[target_feature(enable = "neon")]`
17+
#[target_feature(enable = "neon")]
18+
fn qux(x: v64);
19+
20+
fn quux_fail(x: v64i); //~ ERROR use of SIMD type `v64i` in FFI not supported by any target features
21+
#[target_feature(enable = "neon")]
22+
fn quux_fail2(x: v64i); //~ ERROR use of SIMD type `v64i` in FFI not supported by any target features
23+
24+
fn quuux_fail(x: v128); //~ ERROR use of SIMD type `v128` in FFI requires `#[target_feature(enable = "neon")]`
25+
#[target_feature(enable = "neon")]
26+
fn quuux(x: v128);
27+
28+
fn quuuux_fail(x: v128i); //~ ERROR use of SIMD type `v128i` in FFI not supported by any target features
29+
#[target_feature(enable = "neon")]
30+
fn quuuux_fail2(x: v128i); //~ ERROR use of SIMD type `v128i` in FFI not supported by any target features
31+
}
32+
33+
fn main() {}
34+
35+
#[repr(simd)]
36+
struct v128(i32, i32, i32, i32);
37+
38+
#[repr(simd)]
39+
struct v64(i32, i32);
40+
41+
#[repr(simd)]
42+
struct v128i(i64, i64);
43+
44+
#[repr(simd)]
45+
struct v64i(i64);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// only-x86
2+
3+
#![feature(repr_simd)]
4+
#![feature(simd_ffi)]
5+
#![feature(avx512_target_feature)]
6+
#![allow(non_camel_case_types)]
7+
#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
8+
9+
#[repr(simd)]
10+
struct v1024(i128, i128, i128, i128, i128, i128, i128, i128);
11+
12+
extern {
13+
fn foo(x: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
14+
fn bar(x: i32, y: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
15+
fn baz(x: i32) -> v1024; //~ ERROR use of SIMD type `v1024` in FFI not supported by any target features
16+
17+
fn qux_fail(x: v128); //~ ERROR use of SIMD type `v128` in FFI requires `#[target_feature(enable = "sse")]`
18+
#[target_feature(enable = "sse")]
19+
fn qux(x: v128);
20+
#[target_feature(enable = "sse4.2")]
21+
fn qux2(x: v128);
22+
#[target_feature(enable = "ssse3")]
23+
fn qux3(x: v128);
24+
#[target_feature(enable = "avx")]
25+
fn qux4(x: v128);
26+
#[target_feature(enable = "avx2")]
27+
fn qux5(x: v128);
28+
#[target_feature(enable = "avx512f")]
29+
fn qux6(x: v128);
30+
31+
fn quux_fail(x: v256); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx")]`
32+
#[target_feature(enable = "sse4.2")]
33+
fn quux_fail2(x: v256); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx")]`
34+
#[target_feature(enable = "avx")]
35+
fn quux(x: v256);
36+
#[target_feature(enable = "avx2")]
37+
fn quux2(x: v256);
38+
#[target_feature(enable = "avx512f")]
39+
fn quux3(x: v256);
40+
41+
fn quuux_fail(x: v512); //~ ERROR use of SIMD type `v512` in FFI requires `#[target_feature(enable = "avx512f")]`
42+
#[target_feature(enable = "sse")]
43+
fn quuux_fail2(x: v512); //~ ERROR use of SIMD type `v512` in FFI requires `#[target_feature(enable = "avx512f")]`
44+
#[target_feature(enable = "avx2")]
45+
fn quuux_fail3(x: v512); //~ ERROR use of SIMD type `v512` in FFI requires `#[target_feature(enable = "avx512f")]`
46+
#[target_feature(enable = "avx512f")]
47+
fn quuux(x: v512);
48+
}
49+
50+
fn main() {}
51+
52+
#[repr(simd)]
53+
struct v128(i128);
54+
55+
#[repr(simd)]
56+
struct v256(i128, i128);
57+
58+
#[repr(simd)]
59+
struct v512(i128, i128, i128, i128);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// only-x86
2+
// compile-flags: -C no-prepopulate-passes
3+
4+
#![crate_type = "lib"]
5+
6+
pub unsafe fn bar() { foo() }
7+
8+
extern "C" {
9+
// CHECK-LABEL: declare void @foo()
10+
// CHECK-SAME: [[ATTRS:#[0-9]+]]
11+
// CHECK-DAG: attributes [[ATTRS]] = { {{.*}}"target-features"="+avx2"{{.*}} }
12+
#[target_feature(enable = "avx2")]
13+
pub fn foo();
14+
}

0 commit comments

Comments
 (0)