diff options
Diffstat (limited to 'lib/Target/ARM/ThumbInstrInfo.cpp')
-rw-r--r-- | lib/Target/ARM/ThumbInstrInfo.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/Target/ARM/ThumbInstrInfo.cpp b/lib/Target/ARM/ThumbInstrInfo.cpp index 075d940bcc..d9a499dacd 100644 --- a/lib/Target/ARM/ThumbInstrInfo.cpp +++ b/lib/Target/ARM/ThumbInstrInfo.cpp @@ -23,7 +23,7 @@ using namespace llvm; ThumbInstrInfo::ThumbInstrInfo(const ARMSubtarget &STI) - : ARMBaseInstrInfo(STI) { + : ARMBaseInstrInfo(STI), RI(*this, STI) { } bool ThumbInstrInfo::isMoveInstr(const MachineInstr &MI, @@ -114,6 +114,37 @@ bool ThumbInstrInfo::copyRegToReg(MachineBasicBlock &MBB, return false; } +bool ThumbInstrInfo:: +canFoldMemoryOperand(const MachineInstr *MI, + const SmallVectorImpl<unsigned> &Ops) const { + if (Ops.size() != 1) return false; + + unsigned OpNum = Ops[0]; + unsigned Opc = MI->getOpcode(); + switch (Opc) { + default: break; + case ARM::tMOVr: + case ARM::tMOVlor2hir: + case ARM::tMOVhir2lor: + case ARM::tMOVhir2hir: { + if (OpNum == 0) { // move -> store + unsigned SrcReg = MI->getOperand(1).getReg(); + if (RI.isPhysicalRegister(SrcReg) && !RI.isLowRegister(SrcReg)) + // tSpill cannot take a high register operand. + return false; + } else { // move -> load + unsigned DstReg = MI->getOperand(0).getReg(); + if (RI.isPhysicalRegister(DstReg) && !RI.isLowRegister(DstReg)) + // tRestore cannot target a high register operand. + return false; + } + return true; + } + } + + return false; +} + void ThumbInstrInfo:: storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned SrcReg, bool isKill, int FI, @@ -244,7 +275,6 @@ MachineInstr *ThumbInstrInfo:: foldMemoryOperandImpl(MachineFunction &MF, MachineInstr *MI, const SmallVectorImpl<unsigned> &Ops, int FI) const { if (Ops.size() != 1) return NULL; - const ARMRegisterInfo &RI = getRegisterInfo(); unsigned OpNum = Ops[0]; unsigned Opc = MI->getOpcode(); |