diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-12-07 20:11:46 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-12-07 20:11:46 +0000 |
commit | 52f21e35e83d9c644aa40d557816ea647288c99d (patch) | |
tree | 97467d5c47852edebb61c0533ea4cd044f4cb6f9 /lib/Target/ARM/ARMFrameInfo.cpp | |
parent | c4ba09da6064c61ff75890987d6e73a5fc7a6125 (diff) |
Code clean up; no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMFrameInfo.cpp')
-rw-r--r-- | lib/Target/ARM/ARMFrameInfo.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/Target/ARM/ARMFrameInfo.cpp b/lib/Target/ARM/ARMFrameInfo.cpp index bcd776c466..be1bd5542b 100644 --- a/lib/Target/ARM/ARMFrameInfo.cpp +++ b/lib/Target/ARM/ARMFrameInfo.cpp @@ -529,7 +529,6 @@ void ARMFrameInfo::emitPushInst(MachineBasicBlock &MBB, Regs.push_back(std::make_pair(Reg, isKill)); } - // It's illegal to emit push instruction without operands. if (!Regs.empty()) { MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), ARM::SP).addReg(ARM::SP)); @@ -568,31 +567,30 @@ void ARMFrameInfo::emitPopInst(MachineBasicBlock &MBB, ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); DebugLoc DL = MI->getDebugLoc(); - MachineInstrBuilder MIB = BuildMI(MF, DL, TII.get(Opc)); - MIB.addReg(ARM::SP, getDefRegState(true)); - MIB.addReg(ARM::SP); - AddDefaultPred(MIB); - bool NumRegs = false; + bool DeleteRet = false; + SmallVector<unsigned, 4> Regs; for (unsigned i = CSI.size(); i != 0; --i) { unsigned Reg = CSI[i-1].getReg(); if (!(Func)(Reg, STI.isTargetDarwin())) continue; if (Reg == ARM::LR && !isVarArg) { Reg = ARM::PC; - unsigned Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; - (*MIB).setDesc(TII.get(Opc)); - MI = MBB.erase(MI); + Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; + // Fold the return instruction into the LDM. + DeleteRet = true; } - MIB.addReg(Reg, RegState::Define); - NumRegs = true; + Regs.push_back(Reg); } - // It's illegal to emit pop instruction without operands. - if (NumRegs) - MBB.insert(MI, &*MIB); - else - MF.DeleteMachineInstr(MIB); + if (!Regs.empty()) { + MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), + ARM::SP).addReg(ARM::SP)); + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + MIB.addReg(Regs[i], getDefRegState(true)); + if (DeleteRet) + MI->eraseFromParent(); + } } bool ARMFrameInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |