[PATCH] D49778: Fix "Q" and "R" inline assembly template modifiers for big-endian Arm
Jackson Woodruff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 25 00:06:41 PDT 2018
Jackson created this revision.
Jackson added reviewers: t.p.northover, echristo.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.
Consider the endianness of the target when printing register names. This is in line with the documentation at http://llvm.org/docs/LangRef.html#asm-template-argument-modifiers
Repository:
rL LLVM
https://reviews.llvm.org/D49778
Files:
lib/Target/ARM/ARMAsmPrinter.cpp
test/CodeGen/ARM/print-registers-be.ll
Index: test/CodeGen/ARM/print-registers-be.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/print-registers-be.ll
@@ -0,0 +1,12 @@
+; RUN: llc -mtriple=armeb-arm-none-eabi < %s -o -| FileCheck %s
+
+define dso_local void @_Z3fooi(i32 %a) local_unnamed_addr #0 {
+entry:
+; CHECK: @ plain: [[LOW_REG:r[0-9]+]]
+; CHECK: @ Q: [[HIGH_REG:r[0-9]+]]
+; CHECK: @ R: [[LOW_REG]]
+; CHECK: @ H: [[HIGH_REG]]
+ tail call void asm sideeffect "\0A // plain: $0\0A // Q: ${0:Q}\0A // R: ${0:R}\0A // H: ${0:H}\0A ", "r"(i64 1) #1
+ ret void
+}
+
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -358,7 +358,17 @@
unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags);
unsigned RC;
+ bool FirstHalf;
+ const ARMBaseTargetMachine &ATM =
+ static_cast<const ARMBaseTargetMachine &>(TM);
InlineAsm::hasRegClassConstraint(Flags, RC);
+ if (ExtraCode[0] == 'Q') {
+ FirstHalf = ATM.isLittleEndian();
+ } else {
+ // ExtraCode[0] == 'R'.
+ FirstHalf = !ATM.isLittleEndian();
+ }
+
if (RC == ARM::GPRPairRegClassID) {
if (NumVals != 1)
return true;
@@ -366,14 +376,14 @@
if (!MO.isReg())
return true;
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
- unsigned Reg = TRI->getSubReg(MO.getReg(), ExtraCode[0] == 'Q' ?
+ unsigned Reg = TRI->getSubReg(MO.getReg(), FirstHalf ?
ARM::gsub_0 : ARM::gsub_1);
O << ARMInstPrinter::getRegisterName(Reg);
return false;
}
if (NumVals != 2)
return true;
- unsigned RegOp = ExtraCode[0] == 'Q' ? OpNum : OpNum + 1;
+ unsigned RegOp = FirstHalf ? OpNum : OpNum + 1;
if (RegOp >= MI->getNumOperands())
return true;
const MachineOperand &MO = MI->getOperand(RegOp);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49778.157198.patch
Type: text/x-patch
Size: 2051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180725/d80c589b/attachment.bin>
More information about the llvm-commits
mailing list