Skip to content

Commit 9ce64ac

Browse files
committed
s390x: f16 vectors in assembly
1 parent bca37a2 commit 9ce64ac

5 files changed

Lines changed: 32 additions & 6 deletions

File tree

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,12 @@ fn llvm_fixup_input<'ll, 'tcx>(
10431043
) if element.primitive() == Primitive::Float(Float::F16) => {
10441044
bx.bitcast(value, bx.type_vector(bx.type_i16(), count))
10451045
}
1046+
(S390x(S390xInlineAsmRegClass::vreg), BackendRepr::SimdVector { element, count: 8 })
1047+
if element.primitive() == Primitive::Float(Float::F16)
1048+
&& !any_target_feature_enabled(bx, instance, &[sym::nnp_assist]) =>
1049+
{
1050+
bx.bitcast(value, bx.type_vector(bx.type_i16(), 8))
1051+
}
10461052
(LoongArch(LoongArchInlineAsmRegClass::freg), BackendRepr::Scalar(s))
10471053
if s.primitive() == Primitive::Float(Float::F16) =>
10481054
{

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ symbols! {
15561556
next,
15571557
niko,
15581558
nll,
1559+
nnp_assist: "nnp-assist",
15591560
no,
15601561
no_builtins,
15611562
no_core,

compiler/rustc_target/src/asm/s390x.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl S390xInlineAsmRegClass {
4848
// non-clobber-only vector register support is unstable.
4949
types! {
5050
vector: I32, F32, I64, F64, I128, F128,
51-
VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF32(4), VecF64(2);
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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
//@ add-minicore
2-
//@ revisions: s390x s390x_vector
2+
//@ revisions: s390x s390x_vector s390x_nnp_assist
33
//@ assembly-output: emit-asm
44
//@[s390x] compile-flags: --target s390x-unknown-linux-gnu
55
//@[s390x] needs-llvm-components: systemz
66
//@[s390x_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
77
//@[s390x_vector] needs-llvm-components: systemz
8+
//@[s390x_nnp_assist] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+nnp-assist --cfg=s390x_vector
9+
//@[s390x_nnp_assist] needs-llvm-components: systemz
810
//@ compile-flags: -Zmerge-functions=disabled
911

10-
#![feature(no_core, repr_simd, f128)]
12+
#![feature(no_core, repr_simd, f16, f128)]
1113
#![cfg_attr(s390x_vector, feature(asm_experimental_reg))]
1214
#![crate_type = "rlib"]
1315
#![no_core]
@@ -27,6 +29,8 @@ pub struct i32x4([i32; 4]);
2729
#[repr(simd)]
2830
pub struct i64x2([i64; 2]);
2931
#[repr(simd)]
32+
pub struct f16x8([f16; 8]);
33+
#[repr(simd)]
3034
pub struct f32x4([f32; 4]);
3135
#[repr(simd)]
3236
pub struct f64x2([f64; 2]);
@@ -35,6 +39,7 @@ impl Copy for i8x16 {}
3539
impl Copy for i16x8 {}
3640
impl Copy for i32x4 {}
3741
impl Copy for i64x2 {}
42+
impl Copy for f16x8 {}
3843
impl Copy for f32x4 {}
3944
impl Copy for f64x2 {}
4045

@@ -173,6 +178,13 @@ check!(vreg_i32x4, i32x4, vreg, "vlr");
173178
#[cfg(s390x_vector)]
174179
check!(vreg_i64x2, i64x2, vreg, "vlr");
175180

181+
// s390x_vector-LABEL: vreg_f16x8:
182+
// s390x_vector: #APP
183+
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
184+
// s390x_vector: #NO_APP
185+
#[cfg(s390x_vector)]
186+
check!(vreg_f16x8, f16x8, vreg, "vlr");
187+
176188
// s390x_vector-LABEL: vreg_f32x4:
177189
// s390x_vector: #APP
178190
// s390x_vector: vlr %v{{[0-9]+}}, %v{{[0-9]+}}
@@ -293,6 +305,13 @@ check_reg!(v0_i32x4, i32x4, "v0", "vlr");
293305
#[cfg(s390x_vector)]
294306
check_reg!(v0_i64x2, i64x2, "v0", "vlr");
295307

308+
// s390x_vector-LABEL: v0_f16x8:
309+
// s390x_vector: #APP
310+
// s390x_vector: vlr %v0, %v0
311+
// s390x_vector: #NO_APP
312+
#[cfg(s390x_vector)]
313+
check_reg!(v0_f16x8, f16x8, "v0", "vlr");
314+
296315
// s390x_vector-LABEL: v0_f32x4:
297316
// s390x_vector: #APP
298317
// 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, 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, 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, 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)