diff options
| author | Zhan Jun Liau <zhanjunl@ca.ibm.com> | 2016-08-18 21:44:15 +0000 |
|---|---|---|
| committer | Zhan Jun Liau <zhanjunl@ca.ibm.com> | 2016-08-18 21:44:15 +0000 |
| commit | cf2f4b32512f2c5fdd2e39aa1bbb76a563afd19d (patch) | |
| tree | 4927d0c2fa79c46b600a33b78a617e45847e1f38 /llvm/lib/Target/SystemZ | |
| parent | 36bde4f81da32f91cdcde493535dd63dbba87967 (diff) | |
| download | bcm5719-llvm-cf2f4b32512f2c5fdd2e39aa1bbb76a563afd19d.tar.gz bcm5719-llvm-cf2f4b32512f2c5fdd2e39aa1bbb76a563afd19d.zip | |
[SystemZ] Use valid base/index regs for inline asm
Summary:
Inline asm memory constraints can have the base or index register be assigned
to %r0 right now. Make sure that we assign only ADDR64 registers to the base
and index.
Reviewers: uweigand
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D23367
llvm-svn: 279157
Diffstat (limited to 'llvm/lib/Target/SystemZ')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp index c74d396e3aa..5677fdaaff2 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp @@ -1375,6 +1375,29 @@ SelectInlineAsmMemoryOperand(const SDValue &Op, } 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); |

