Skip to content

Commit c5af59d

Browse files
authored
Unrolled build for #145661
Rollup merge of #145661 - folkertdev:s390x-codegen-test-cleanup, r=dianqk update some s390x codegen tests By using `minicore`, `&raw` and removing use of `link_llvm_intrinsics`
2 parents 6ba0ce4 + 609c38d commit c5af59d

File tree

3 files changed

+46
-59
lines changed

3 files changed

+46
-59
lines changed

tests/assembly-llvm/s390x-vector-abi.rs

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ revisions: z10 z10_vector z13 z13_no_vector
2+
//@ add-core-stubs
23
// ignore-tidy-linelength
34
//@ assembly-output: emit-asm
45
//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled
@@ -18,24 +19,8 @@
1819
// Cases where vector feature is disabled are rejected.
1920
// See tests/ui/simd-abi-checks-s390x.rs for test for them.
2021

21-
#[lang = "pointee_sized"]
22-
pub trait PointeeSized {}
23-
24-
#[lang = "meta_sized"]
25-
pub trait MetaSized: PointeeSized {}
26-
27-
#[lang = "sized"]
28-
pub trait Sized: MetaSized {}
29-
#[lang = "copy"]
30-
pub trait Copy {}
31-
#[lang = "freeze"]
32-
pub trait Freeze {}
33-
34-
impl<T: Copy, const N: usize> Copy for [T; N] {}
35-
36-
#[lang = "phantom_data"]
37-
pub struct PhantomData<T: ?Sized>;
38-
impl<T: ?Sized> Copy for PhantomData<T> {}
22+
extern crate minicore;
23+
use minicore::*;
3924

4025
#[repr(simd)]
4126
pub struct i8x8([i8; 8]);
@@ -52,8 +37,6 @@ pub struct WrapperWithZst<T>(T, PhantomData<()>);
5237
#[repr(transparent)]
5338
pub struct TransparentWrapper<T>(T);
5439

55-
impl Copy for i8 {}
56-
impl Copy for i64 {}
5740
impl Copy for i8x8 {}
5841
impl Copy for i8x16 {}
5942
impl Copy for i8x32 {}
@@ -221,23 +204,23 @@ unsafe extern "C" fn vector_transparent_wrapper_ret_large(
221204
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
222205
#[no_mangle]
223206
unsafe extern "C" fn vector_arg_small(x: i8x8) -> i64 {
224-
unsafe { *(&x as *const i8x8 as *const i64) }
207+
unsafe { *(&raw const x as *const i64) }
225208
}
226209
// CHECK-LABEL: vector_arg:
227210
// CHECK: vlgvg %r2, %v24, 0
228211
// CHECK-NEXT: br %r14
229212
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
230213
#[no_mangle]
231214
unsafe extern "C" fn vector_arg(x: i8x16) -> i64 {
232-
unsafe { *(&x as *const i8x16 as *const i64) }
215+
unsafe { *(&raw const x as *const i64) }
233216
}
234217
// CHECK-LABEL: vector_arg_large:
235218
// CHECK: lg %r2, 0(%r2)
236219
// CHECK-NEXT: br %r14
237220
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
238221
#[no_mangle]
239222
unsafe extern "C" fn vector_arg_large(x: i8x32) -> i64 {
240-
unsafe { *(&x as *const i8x32 as *const i64) }
223+
unsafe { *(&raw const x as *const i64) }
241224
}
242225

243226
// CHECK-LABEL: vector_wrapper_arg_small:
@@ -246,23 +229,23 @@ unsafe extern "C" fn vector_arg_large(x: i8x32) -> i64 {
246229
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
247230
#[no_mangle]
248231
unsafe extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 {
249-
unsafe { *(&x as *const Wrapper<i8x8> as *const i64) }
232+
unsafe { *(&raw const x as *const i64) }
250233
}
251234
// CHECK-LABEL: vector_wrapper_arg:
252235
// CHECK: vlgvg %r2, %v24, 0
253236
// CHECK-NEXT: br %r14
254237
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
255238
#[no_mangle]
256239
unsafe extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 {
257-
unsafe { *(&x as *const Wrapper<i8x16> as *const i64) }
240+
unsafe { *(&raw const x as *const i64) }
258241
}
259242
// CHECK-LABEL: vector_wrapper_arg_large:
260243
// CHECK: lg %r2, 0(%r2)
261244
// CHECK-NEXT: br %r14
262245
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
263246
#[no_mangle]
264247
unsafe extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 {
265-
unsafe { *(&x as *const Wrapper<i8x32> as *const i64) }
248+
unsafe { *(&raw const x as *const i64) }
266249
}
267250

268251
// https://github.com/rust-lang/rust/pull/131586#discussion_r1837071121
@@ -272,7 +255,7 @@ unsafe extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 {
272255
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
273256
#[no_mangle]
274257
unsafe extern "C" fn vector_wrapper_padding_arg(x: WrapperAlign16<i8x8>) -> i64 {
275-
unsafe { *(&x as *const WrapperAlign16<i8x8> as *const i64) }
258+
unsafe { *(&raw const x as *const i64) }
276259
}
277260

278261
// CHECK-LABEL: vector_wrapper_with_zst_arg_small:
@@ -282,23 +265,23 @@ unsafe extern "C" fn vector_wrapper_padding_arg(x: WrapperAlign16<i8x8>) -> i64
282265
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
283266
#[no_mangle]
284267
unsafe extern "C" fn vector_wrapper_with_zst_arg_small(x: WrapperWithZst<i8x8>) -> i64 {
285-
unsafe { *(&x as *const WrapperWithZst<i8x8> as *const i64) }
268+
unsafe { *(&raw const x as *const i64) }
286269
}
287270
// CHECK-LABEL: vector_wrapper_with_zst_arg:
288271
// CHECK: lg %r2, 0(%r2)
289272
// CHECK-NEXT: br %r14
290273
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
291274
#[no_mangle]
292275
unsafe extern "C" fn vector_wrapper_with_zst_arg(x: WrapperWithZst<i8x16>) -> i64 {
293-
unsafe { *(&x as *const WrapperWithZst<i8x16> as *const i64) }
276+
unsafe { *(&raw const x as *const i64) }
294277
}
295278
// CHECK-LABEL: vector_wrapper_with_zst_arg_large:
296279
// CHECK: lg %r2, 0(%r2)
297280
// CHECK-NEXT: br %r14
298281
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
299282
#[no_mangle]
300283
unsafe extern "C" fn vector_wrapper_with_zst_arg_large(x: WrapperWithZst<i8x32>) -> i64 {
301-
unsafe { *(&x as *const WrapperWithZst<i8x32> as *const i64) }
284+
unsafe { *(&raw const x as *const i64) }
302285
}
303286

304287
// CHECK-LABEL: vector_transparent_wrapper_arg_small:
@@ -307,21 +290,21 @@ unsafe extern "C" fn vector_wrapper_with_zst_arg_large(x: WrapperWithZst<i8x32>)
307290
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
308291
#[no_mangle]
309292
unsafe extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 {
310-
unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) }
293+
unsafe { *(&raw const x as *const i64) }
311294
}
312295
// CHECK-LABEL: vector_transparent_wrapper_arg:
313296
// CHECK: vlgvg %r2, %v24, 0
314297
// CHECK-NEXT: br %r14
315298
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
316299
#[no_mangle]
317300
unsafe extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 {
318-
unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) }
301+
unsafe { *(&raw const x as *const i64) }
319302
}
320303
// CHECK-LABEL: vector_transparent_wrapper_arg_large:
321304
// CHECK: lg %r2, 0(%r2)
322305
// CHECK-NEXT: br %r14
323306
#[cfg_attr(no_vector, target_feature(enable = "vector"))]
324307
#[no_mangle]
325308
unsafe extern "C" fn vector_transparent_wrapper_arg_large(x: TransparentWrapper<i8x32>) -> i64 {
326-
unsafe { *(&x as *const TransparentWrapper<i8x32> as *const i64) }
309+
unsafe { *(&raw const x as *const i64) }
327310
}

tests/codegen-llvm/s390x-simd.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#![crate_type = "rlib"]
88
#![feature(no_core, asm_experimental_arch)]
9-
#![feature(s390x_target_feature, simd_ffi, link_llvm_intrinsics, repr_simd)]
9+
#![feature(s390x_target_feature, simd_ffi, intrinsics, repr_simd)]
1010
#![no_core]
1111

1212
extern crate minicore;
@@ -30,16 +30,20 @@ struct f32x4([f32; 4]);
3030
#[repr(simd)]
3131
struct f64x2([f64; 2]);
3232

33-
#[allow(improper_ctypes)]
34-
extern "C" {
35-
#[link_name = "llvm.smax.v16i8"]
36-
fn vmxb(a: i8x16, b: i8x16) -> i8x16;
37-
#[link_name = "llvm.smax.v8i16"]
38-
fn vmxh(a: i16x8, b: i16x8) -> i16x8;
39-
#[link_name = "llvm.smax.v4i32"]
40-
fn vmxf(a: i32x4, b: i32x4) -> i32x4;
41-
#[link_name = "llvm.smax.v2i64"]
42-
fn vmxg(a: i64x2, b: i64x2) -> i64x2;
33+
impl Copy for i8x16 {}
34+
impl Copy for i16x8 {}
35+
impl Copy for i32x4 {}
36+
impl Copy for i64x2 {}
37+
38+
#[rustc_intrinsic]
39+
unsafe fn simd_ge<T, U>(x: T, y: T) -> U;
40+
41+
#[rustc_intrinsic]
42+
unsafe fn simd_select<M, V>(mask: M, a: V, b: V) -> V;
43+
44+
#[inline(always)]
45+
unsafe fn simd_max<T: Copy>(a: T, b: T) -> T {
46+
simd_select(simd_ge::<T, T>(a, b), a, b)
4347
}
4448

4549
// CHECK-LABEL: define <16 x i8> @max_i8x16
@@ -48,7 +52,7 @@ extern "C" {
4852
#[no_mangle]
4953
#[target_feature(enable = "vector")]
5054
pub unsafe extern "C" fn max_i8x16(a: i8x16, b: i8x16) -> i8x16 {
51-
vmxb(a, b)
55+
simd_max(a, b)
5256
}
5357

5458
// CHECK-LABEL: define <8 x i16> @max_i16x8
@@ -57,7 +61,7 @@ pub unsafe extern "C" fn max_i8x16(a: i8x16, b: i8x16) -> i8x16 {
5761
#[no_mangle]
5862
#[target_feature(enable = "vector")]
5963
pub unsafe extern "C" fn max_i16x8(a: i16x8, b: i16x8) -> i16x8 {
60-
vmxh(a, b)
64+
simd_max(a, b)
6165
}
6266

6367
// CHECK-LABEL: define <4 x i32> @max_i32x4
@@ -66,7 +70,7 @@ pub unsafe extern "C" fn max_i16x8(a: i16x8, b: i16x8) -> i16x8 {
6670
#[no_mangle]
6771
#[target_feature(enable = "vector")]
6872
pub unsafe extern "C" fn max_i32x4(a: i32x4, b: i32x4) -> i32x4 {
69-
vmxf(a, b)
73+
simd_max(a, b)
7074
}
7175

7276
// CHECK-LABEL: define <2 x i64> @max_i64x2
@@ -75,7 +79,7 @@ pub unsafe extern "C" fn max_i32x4(a: i32x4, b: i32x4) -> i32x4 {
7579
#[no_mangle]
7680
#[target_feature(enable = "vector")]
7781
pub unsafe extern "C" fn max_i64x2(a: i64x2, b: i64x2) -> i64x2 {
78-
vmxg(a, b)
82+
simd_max(a, b)
7983
}
8084

8185
// CHECK-LABEL: define <4 x float> @choose_f32x4
@@ -108,7 +112,7 @@ pub unsafe extern "C" fn max_wrapper_i8x16(a: Wrapper<i8x16>, b: Wrapper<i8x16>)
108112
// CHECK: call <16 x i8> @llvm.smax.v16i8
109113
// CHECK-SAME: <16 x i8>
110114
// CHECK-SAME: <16 x i8>
111-
Wrapper(vmxb(a.0, b.0))
115+
Wrapper(simd_max(a.0, b.0))
112116
}
113117

114118
#[no_mangle]
@@ -122,7 +126,7 @@ pub unsafe extern "C" fn max_wrapper_i64x2(a: Wrapper<i64x2>, b: Wrapper<i64x2>)
122126
// CHECK: call <2 x i64> @llvm.smax.v2i64
123127
// CHECK-SAME: <2 x i64>
124128
// CHECK-SAME: <2 x i64>
125-
Wrapper(vmxg(a.0, b.0))
129+
Wrapper(simd_max(a.0, b.0))
126130
}
127131

128132
#[no_mangle]

tests/ui/abi/simd-abi-checks-s390x.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,47 +110,47 @@ extern "C" fn vector_transparent_wrapper_ret_large(
110110
#[no_mangle]
111111
extern "C" fn vector_arg_small(x: i8x8) -> i64 {
112112
//~^ ERROR requires the `vector` target feature, which is not enabled
113-
unsafe { *(&x as *const i8x8 as *const i64) }
113+
unsafe { *(&raw const x as *const i64) }
114114
}
115115
#[no_mangle]
116116
extern "C" fn vector_arg(x: i8x16) -> i64 {
117117
//~^ ERROR requires the `vector` target feature, which is not enabled
118-
unsafe { *(&x as *const i8x16 as *const i64) }
118+
unsafe { *(&raw const x as *const i64) }
119119
}
120120
#[no_mangle]
121121
extern "C" fn vector_arg_large(x: i8x32) -> i64 {
122122
// Ok
123-
unsafe { *(&x as *const i8x32 as *const i64) }
123+
unsafe { *(&raw const x as *const i64) }
124124
}
125125

126126
#[no_mangle]
127127
extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 {
128128
//~^ ERROR requires the `vector` target feature, which is not enabled
129-
unsafe { *(&x as *const Wrapper<i8x8> as *const i64) }
129+
unsafe { *(&raw const x as *const i64) }
130130
}
131131
#[no_mangle]
132132
extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 {
133133
//~^ ERROR requires the `vector` target feature, which is not enabled
134-
unsafe { *(&x as *const Wrapper<i8x16> as *const i64) }
134+
unsafe { *(&raw const x as *const i64) }
135135
}
136136
#[no_mangle]
137137
extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 {
138138
// Ok
139-
unsafe { *(&x as *const Wrapper<i8x32> as *const i64) }
139+
unsafe { *(&raw const x as *const i64) }
140140
}
141141

142142
#[no_mangle]
143143
extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 {
144144
//~^ ERROR requires the `vector` target feature, which is not enabled
145-
unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) }
145+
unsafe { *(&raw const x as *const i64) }
146146
}
147147
#[no_mangle]
148148
extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 {
149149
//~^ ERROR requires the `vector` target feature, which is not enabled
150-
unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) }
150+
unsafe { *(&raw const x as *const i64) }
151151
}
152152
#[no_mangle]
153153
extern "C" fn vector_transparent_wrapper_arg_large(x: TransparentWrapper<i8x32>) -> i64 {
154154
// Ok
155-
unsafe { *(&x as *const TransparentWrapper<i8x32> as *const i64) }
155+
unsafe { *(&raw const x as *const i64) }
156156
}

0 commit comments

Comments
 (0)