Skip to content

Commit 002b68d

Browse files
Rollup merge of rust-lang#150826 - s390x-asm-f16-vector, r=uweigand,tgross35
Add `f16` inline ASM support for s390x tracking issue: rust-lang#116909 cc rust-lang#125398 Support the `f16x8` type in inline assembly. Only with the `nnp-assist` feature are there any instructions that make use of this type. Based on the riscv implementation I now cast to `i16x8` when that feature is not enabled. As far as I'm aware there are no instructions operating on `f16` scalar values. Should we still add support for using them in inline assembly? r? @tgross35 cc @uweigand
2 parents a89683d + 6f12b86 commit 002b68d

3 files changed

Lines changed: 51 additions & 7 deletions

File tree

compiler/rustc_target/src/asm/s390x.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ impl S390xInlineAsmRegClass {
4242
) -> &'static [(InlineAsmType, Option<Symbol>)] {
4343
match self {
4444
Self::reg | Self::reg_addr => types! { _: I8, I16, I32, I64; },
45-
Self::freg => types! { _: F32, F64; },
45+
Self::freg => types! { _: F16, F32, F64; },
4646
Self::vreg => {
4747
if allow_experimental_reg {
4848
// non-clobber-only vector register support is unstable.
4949
types! {
50-
vector: I32, F32, I64, F64, I128, F128,
51-
VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF32(4), VecF64(2);
50+
vector: I32, F16, F32, I64, F64, I128, F128,
51+
VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF16(8), VecF32(4), VecF64(2);
5252
}
5353
} else {
5454
&[]

tests/assembly-llvm/asm/s390x-types.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
//@[s390x_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
77
//@[s390x_vector] needs-llvm-components: systemz
88
//@ compile-flags: -Zmerge-functions=disabled
9+
//@ min-llvm-version: 21
910

10-
#![feature(no_core, repr_simd, f128)]
11+
#![feature(no_core, repr_simd, f16, f128)]
1112
#![cfg_attr(s390x_vector, feature(asm_experimental_reg))]
1213
#![crate_type = "rlib"]
1314
#![no_core]
@@ -27,6 +28,8 @@ pub struct i32x4([i32; 4]);
2728
#[repr(simd)]
2829
pub struct i64x2([i64; 2]);
2930
#[repr(simd)]
31+
pub struct f16x8([f16; 8]);
32+
#[repr(simd)]
3033
pub struct f32x4([f32; 4]);
3134
#[repr(simd)]
3235
pub struct f64x2([f64; 2]);
@@ -35,6 +38,7 @@ impl Copy for i8x16 {}
3538
impl Copy for i16x8 {}
3639
impl Copy for i32x4 {}
3740
impl Copy for i64x2 {}
41+
impl Copy for f16x8 {}
3842
impl Copy for f32x4 {}
3943
impl Copy for f64x2 {}
4044

@@ -127,6 +131,12 @@ check!(reg_i32_addr, i32, reg_addr, "lgr");
127131
// CHECK: #NO_APP
128132
check!(reg_i64_addr, i64, reg_addr, "lgr");
129133

134+
// CHECK-LABEL: reg_f16:
135+
// CHECK: #APP
136+
// CHECK: ler %f{{[0-9]+}}, %f{{[0-9]+}}
137+
// CHECK: #NO_APP
138+
check!(reg_f16, f16, freg, "ler");
139+
130140
// CHECK-LABEL: reg_f32:
131141
// CHECK: #APP
132142
// CHECK: ler %f{{[0-9]+}}, %f{{[0-9]+}}
@@ -173,6 +183,13 @@ check!(vreg_i32x4, i32x4, vreg, "vlr");
173183
#[cfg(s390x_vector)]
174184
check!(vreg_i64x2, i64x2, vreg, "vlr");
175185

186+
// s390x_vector-LABEL: vreg_f16x8:
187+
// s390x_vector: #APP
188+
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
189+
// s390x_vector: #NO_APP
190+
#[cfg(s390x_vector)]
191+
check!(vreg_f16x8, f16x8, vreg, "vlr");
192+
176193
// s390x_vector-LABEL: vreg_f32x4:
177194
// s390x_vector: #APP
178195
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
@@ -208,6 +225,13 @@ check!(vreg_i64, i64, vreg, "vlr");
208225
#[cfg(s390x_vector)]
209226
check!(vreg_i128, i128, vreg, "vlr");
210227

228+
// s390x_vector-LABEL: vreg_f16:
229+
// s390x_vector: #APP
230+
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
231+
// s390x_vector: #NO_APP
232+
#[cfg(s390x_vector)]
233+
check!(vreg_f16, f16, vreg, "vlr");
234+
211235
// s390x_vector-LABEL: vreg_f32:
212236
// s390x_vector: #APP
213237
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
@@ -253,6 +277,12 @@ check_reg!(r0_i32, i32, "r0", "lr");
253277
// CHECK: #NO_APP
254278
check_reg!(r0_i64, i64, "r0", "lr");
255279

280+
// CHECK-LABEL: f0_f16:
281+
// CHECK: #APP
282+
// CHECK: ler %f0, %f0
283+
// CHECK: #NO_APP
284+
check_reg!(f0_f16, f16, "f0", "ler");
285+
256286
// CHECK-LABEL: f0_f32:
257287
// CHECK: #APP
258288
// CHECK: ler %f0, %f0
@@ -293,6 +323,13 @@ check_reg!(v0_i32x4, i32x4, "v0", "vlr");
293323
#[cfg(s390x_vector)]
294324
check_reg!(v0_i64x2, i64x2, "v0", "vlr");
295325

326+
// s390x_vector-LABEL: v0_f16x8:
327+
// s390x_vector: #APP
328+
// s390x_vector: vlr %v0, %v0
329+
// s390x_vector: #NO_APP
330+
#[cfg(s390x_vector)]
331+
check_reg!(v0_f16x8, f16x8, "v0", "vlr");
332+
296333
// s390x_vector-LABEL: v0_f32x4:
297334
// s390x_vector: #APP
298335
// s390x_vector: vlr %v0, %v0
@@ -328,6 +365,13 @@ check_reg!(v0_i64, i64, "v0", "vlr");
328365
#[cfg(s390x_vector)]
329366
check_reg!(v0_i128, i128, "v0", "vlr");
330367

368+
// s390x_vector-LABEL: v0_f16:
369+
// s390x_vector: #APP
370+
// s390x_vector: vlr %v0, %v0
371+
// s390x_vector: #NO_APP
372+
#[cfg(s390x_vector)]
373+
check_reg!(v0_f16, f16, "v0", "vlr");
374+
331375
// s390x_vector-LABEL: v0_f32:
332376
// s390x_vector: #APP
333377
// s390x_vector: vlr %v0, %v0

tests/ui/asm/s390x/bad-reg.s390x_vector.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,23 @@ error: type `u8` cannot be used with this register class
282282
LL | asm!("", in("v0") b);
283283
| ^
284284
|
285-
= note: register class `vreg` supports these types: i32, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2
285+
= note: register class `vreg` supports these types: i32, f16, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f16x8, f32x4, f64x2
286286

287287
error: type `u8` cannot be used with this register class
288288
--> $DIR/bad-reg.rs:95:28
289289
|
290290
LL | asm!("", out("v0") b);
291291
| ^
292292
|
293-
= note: register class `vreg` supports these types: i32, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2
293+
= note: register class `vreg` supports these types: i32, f16, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f16x8, f32x4, f64x2
294294

295295
error: type `u8` cannot be used with this register class
296296
--> $DIR/bad-reg.rs:108:35
297297
|
298298
LL | asm!("/* {} */", in(vreg) b);
299299
| ^
300300
|
301-
= note: register class `vreg` supports these types: i32, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2
301+
= note: register class `vreg` supports these types: i32, f16, f32, i64, f64, i128, f128, i8x16, i16x8, i32x4, i64x2, f16x8, f32x4, f64x2
302302

303303
error: type `i32` cannot be used with this register class
304304
--> $DIR/bad-reg.rs:120:27

0 commit comments

Comments
 (0)