Skip to content

Commit 4a3760d

Browse files
committed
[SystemZ] Improve handling of inline asm constraints.
The "{=v0}" constraint did not result in the expected error message in the abscence of the vector facility, because 'v0' matches as a string into the AnyRegBitRegClass in common code. This patch adds checks for vector support in case of "{v" and soft-float in case of "{f" to remedy this. Review: Ulrich Weigand.
1 parent 5687acf commit 4a3760d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,10 @@ SystemZTargetLowering::getRegForInlineAsmConstraint(
11631163
return parseRegisterNumber(Constraint, &SystemZ::GR64BitRegClass,
11641164
SystemZMC::GR64Regs, 16);
11651165
}
1166-
if (Constraint[1] == 'f' && !useSoftFloat()) {
1166+
if (Constraint[1] == 'f') {
1167+
if (useSoftFloat())
1168+
return std::make_pair(
1169+
0u, static_cast<const TargetRegisterClass *>(nullptr));
11671170
if (VT == MVT::f32)
11681171
return parseRegisterNumber(Constraint, &SystemZ::FP32BitRegClass,
11691172
SystemZMC::FP32Regs, 16);
@@ -1174,6 +1177,9 @@ SystemZTargetLowering::getRegForInlineAsmConstraint(
11741177
SystemZMC::FP64Regs, 16);
11751178
}
11761179
if (Constraint[1] == 'v') {
1180+
if (!Subtarget.hasVector())
1181+
return std::make_pair(
1182+
0u, static_cast<const TargetRegisterClass *>(nullptr));
11771183
if (VT == MVT::f32)
11781184
return parseRegisterNumber(Constraint, &SystemZ::VR32BitRegClass,
11791185
SystemZMC::VR32Regs, 32);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: not llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 2>&1 | FileCheck %s
2+
;
3+
; Verify that inline asms cannot use fp/vector registers with soft-float.
4+
5+
define <2 x i64> @f1() {
6+
%ret = call <2 x i64> asm "", "={v0}" ()
7+
ret <2 x i64> %ret
8+
}
9+
10+
; CHECK: error: couldn't allocate output register for constraint '{v0}'

0 commit comments

Comments
 (0)