Skip to content

Commit 64d0bb2

Browse files
committed
wasm, arm need simd to be explicitly enabled
1 parent b5f5f62 commit 64d0bb2

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

tests/codegen/const-vector.rs

+3-21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(repr_simd)]
99
#![feature(rustc_attrs)]
1010
#![feature(simd_ffi)]
11+
#![feature(arm_target_feature)]
1112
#![allow(non_camel_case_types)]
1213

1314
// Setting up structs that can be used as const vectors
@@ -28,40 +29,21 @@ pub struct Simd<T, const N: usize>([T; N]);
2829

2930
extern "unadjusted" {
3031
fn test_i8x2(a: i8x2);
31-
}
32-
33-
extern "unadjusted" {
3432
fn test_i8x2_two_args(a: i8x2, b: i8x2);
35-
}
36-
37-
extern "unadjusted" {
3833
fn test_i8x2_mixed_args(a: i8x2, c: i32, b: i8x2);
39-
}
40-
41-
extern "unadjusted" {
4234
fn test_i8x2_arr(a: i8x2);
43-
}
44-
45-
extern "unadjusted" {
4635
fn test_f32x2(a: f32x2);
47-
}
48-
49-
extern "unadjusted" {
5036
fn test_f32x2_arr(a: f32x2);
51-
}
52-
53-
extern "unadjusted" {
5437
fn test_simd(a: Simd<i32, 4>);
55-
}
56-
57-
extern "unadjusted" {
5838
fn test_simd_unaligned(a: Simd<i32, 3>);
5939
}
6040

6141
// Ensure the packed variant of the simd struct does not become a const vector
6242
// if the size is not a power of 2
6343
// CHECK: %"Simd<i32, 3>" = type { [3 x i32] }
6444

45+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
46+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
6547
pub fn do_call() {
6648
unsafe {
6749
// CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>

tests/codegen/repr/transparent.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// For LoongArch: see codegen/loongarch-abi
1010

1111
#![crate_type = "lib"]
12-
#![feature(repr_simd, transparent_unions)]
12+
#![feature(repr_simd, transparent_unions, arm_target_feature)]
1313

1414
use std::marker::PhantomData;
1515

@@ -139,6 +139,8 @@ pub struct Vector(f32x4);
139139

140140
// CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1)
141141
#[no_mangle]
142+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
143+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
142144
pub extern "C" fn test_Vector(_: Vector) -> Vector {
143145
loop {}
144146
}

tests/codegen/simd/extract-insert-dyn.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@compile-flags: -C opt-level=3 -C no-prepopulate-passes
22

3-
#![feature(core_intrinsics, repr_simd)]
3+
#![feature(core_intrinsics, repr_simd, arm_target_feature)]
44
#![no_std]
55
#![crate_type = "lib"]
66
#![allow(non_camel_case_types)]
@@ -21,55 +21,71 @@ pub struct i8x16([i8; 16]);
2121
// CHECK-LABEL: dyn_simd_extract
2222
// CHECK: extractelement <16 x i8> %x, i32 %idx
2323
#[no_mangle]
24+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
25+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
2426
unsafe extern "C" fn dyn_simd_extract(x: i8x16, idx: u32) -> i8 {
2527
simd_extract_dyn(x, idx)
2628
}
2729

2830
// CHECK-LABEL: literal_dyn_simd_extract
2931
// CHECK: extractelement <16 x i8> %x, i32 7
3032
#[no_mangle]
33+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
34+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
3135
unsafe extern "C" fn literal_dyn_simd_extract(x: i8x16) -> i8 {
3236
simd_extract_dyn(x, 7)
3337
}
3438

3539
// CHECK-LABEL: const_dyn_simd_extract
3640
// CHECK: extractelement <16 x i8> %x, i32 7
3741
#[no_mangle]
42+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
43+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
3844
unsafe extern "C" fn const_dyn_simd_extract(x: i8x16) -> i8 {
3945
simd_extract_dyn(x, const { 3 + 4 })
4046
}
4147

4248
// CHECK-LABEL: const_simd_extract
4349
// CHECK: extractelement <16 x i8> %x, i32 7
4450
#[no_mangle]
51+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
52+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
4553
unsafe extern "C" fn const_simd_extract(x: i8x16) -> i8 {
4654
simd_extract(x, const { 3 + 4 })
4755
}
4856

4957
// CHECK-LABEL: dyn_simd_insert
5058
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 %idx
5159
#[no_mangle]
60+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
61+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
5262
unsafe extern "C" fn dyn_simd_insert(x: i8x16, e: i8, idx: u32) -> i8x16 {
5363
simd_insert_dyn(x, idx, e)
5464
}
5565

5666
// CHECK-LABEL: literal_dyn_simd_insert
5767
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
5868
#[no_mangle]
69+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
70+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
5971
unsafe extern "C" fn literal_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 {
6072
simd_insert_dyn(x, 7, e)
6173
}
6274

6375
// CHECK-LABEL: const_dyn_simd_insert
6476
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
6577
#[no_mangle]
78+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
79+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
6680
unsafe extern "C" fn const_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 {
6781
simd_insert_dyn(x, const { 3 + 4 }, e)
6882
}
6983

7084
// CHECK-LABEL: const_simd_insert
7185
// CHECK: insertelement <16 x i8> %x, i8 %e, i32 7
7286
#[no_mangle]
87+
#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))]
88+
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
7389
unsafe extern "C" fn const_simd_insert(x: i8x16, e: i8) -> i8x16 {
7490
simd_insert(x, const { 3 + 4 }, e)
7591
}

0 commit comments

Comments
 (0)