[PATCH] D23367: [SystemZ] Use valid base/index registers for memory constraints
Zhan Jun Liau via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 18 14:52:26 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279157: [SystemZ] Use valid base/index regs for inline asm (authored by zhanjunl).
Changed prior to commit:
https://reviews.llvm.org/D23367?vs=67584&id=68619#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23367
Files:
llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
llvm/trunk/test/CodeGen/SystemZ/asm-02.ll
Index: llvm/trunk/test/CodeGen/SystemZ/asm-02.ll
===================================================================
--- llvm/trunk/test/CodeGen/SystemZ/asm-02.ll
+++ llvm/trunk/test/CodeGen/SystemZ/asm-02.ll
@@ -74,8 +74,8 @@
; Check that LAY is used if there is an index but the displacement is too large
define void @f7(i64 %base, i64 %index) {
; CHECK-LABEL: f7:
-; CHECK: lay %r0, 4096(%r3,%r2)
-; CHECK: blah 0(%r0)
+; CHECK: lay %r1, 4096(%r3,%r2)
+; CHECK: blah 0(%r1)
; CHECK: br %r14
%add = add i64 %base, 4096
%addi = add i64 %add, %index
Index: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
===================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -1375,6 +1375,29 @@
}
if (selectBDXAddr(Form, DispRange, Op, Base, Disp, Index)) {
+ const TargetRegisterClass *TRC =
+ Subtarget->getRegisterInfo()->getPointerRegClass(*MF);
+ SDLoc DL(Base);
+ SDValue RC = CurDAG->getTargetConstant(TRC->getID(), DL, MVT::i32);
+
+ // Make sure that the base address doesn't go into %r0.
+ // If it's a TargetFrameIndex or a fixed register, we shouldn't do anything.
+ if (Base.getOpcode() != ISD::TargetFrameIndex &&
+ Base.getOpcode() != ISD::Register) {
+ Base =
+ SDValue(CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS,
+ DL, Base.getValueType(),
+ Base, RC), 0);
+ }
+
+ // Make sure that the index register isn't assigned to %r0 either.
+ if (Index.getOpcode() != ISD::Register) {
+ Index =
+ SDValue(CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS,
+ DL, Index.getValueType(),
+ Index, RC), 0);
+ }
+
OutOps.push_back(Base);
OutOps.push_back(Disp);
OutOps.push_back(Index);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23367.68619.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160818/f9d48ae1/attachment-0001.bin>
More information about the llvm-commits
mailing list