Skip to content

Commit 458eac2

Browse files
committed
[SystemZ] Support the 'N' code for the odd register in inline-asm.
The odd register of a (128 bit) register pair is accessed with the 'N' code with an inline assembly operand. Review: Ulrich Weigand Differential Revision: https://reviews.llvm.org/D105502
1 parent 2b2ffb7 commit 458eac2

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,18 @@ void SystemZAsmPrinter::emitMachineConstantPoolValue(
764764
bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
765765
const char *ExtraCode,
766766
raw_ostream &OS) {
767-
if (ExtraCode)
768-
return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS);
767+
const MCRegisterInfo &MRI = *TM.getMCRegisterInfo();
768+
MachineOperand MO = MI->getOperand(OpNo);
769+
if (ExtraCode) {
770+
if (ExtraCode[0] == 'N' && !ExtraCode[1] && MO.isReg() &&
771+
SystemZ::GR128BitRegClass.contains(MO.getReg()))
772+
MO.setReg(MRI.getSubReg(MO.getReg(), SystemZ::subreg_l64));
773+
else
774+
return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS);
775+
}
769776
SystemZMCInstLower Lower(MF->getContext(), *this);
770-
MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo)));
771-
SystemZInstPrinter::printOperand(MO, MAI, OS);
777+
MCOperand MCOp(Lower.lowerOperand(MO));
778+
SystemZInstPrinter::printOperand(MCOp, MAI, OS);
772779
return false;
773780
}
774781

llvm/test/CodeGen/SystemZ/inline-asm-i128.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=s390x-linux-gnu -no-integrated-as < %s | FileCheck %s
33
;
4+
45
; Test i128 (tied) operands.
56

67
define i32 @fun0(i8* %p1, i32 signext %l1, i8* %p2, i32 signext %l2, i8 zeroext %pad) {
@@ -118,3 +119,19 @@ entry:
118119
store volatile i128 %IAsm, i128* %Dst
119120
ret void
120121
}
122+
123+
; Test access of the odd register using 'N'.
124+
define i64 @fun5(i64 %b) {
125+
; CHECK-LABEL: fun5:
126+
; CHECK: # %bb.0: # %entry
127+
; CHECK-NEXT: lgr %r1, %r2
128+
; CHECK-NEXT: lghi %r0, 0
129+
; CHECK-NEXT: #APP
130+
; CHECK-NEXT: lgr %r2,%r1
131+
; CHECK-NEXT: #NO_APP
132+
; CHECK-NEXT: br %r14
133+
entry:
134+
%Ins = zext i64 %b to i128
135+
%Res = tail call i64 asm "\09lgr\09$0,${1:N}", "=d,d"(i128 %Ins)
136+
ret i64 %Res
137+
}

0 commit comments

Comments
 (0)