Change getFrameMoves to return a const reference.

To add a frame now there is a dedicated addFrameMove which also takes
care of constructing the move itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181657 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2013-05-11 02:38:11 +00:00
parent baf81af759
commit d84ccfaf50
10 changed files with 52 additions and 58 deletions

View File

@ -234,7 +234,12 @@ public:
/// getFrameMoves - Returns a reference to a list of moves done in the current /// getFrameMoves - Returns a reference to a list of moves done in the current
/// function's prologue. Used to construct frame maps for debug and exception /// function's prologue. Used to construct frame maps for debug and exception
/// handling comsumers. /// handling comsumers.
std::vector<MachineMove> &getFrameMoves() { return FrameMoves; } const std::vector<MachineMove> &getFrameMoves() { return FrameMoves; }
void addFrameMove(MCSymbol *Label, const MachineLocation &Dst,
const MachineLocation &Src) {
FrameMoves.push_back(MachineMove(Label, Dst, Src));
}
/// getCompactUnwindEncoding - Returns the compact unwind encoding for a /// getCompactUnwindEncoding - Returns the compact unwind encoding for a
/// function if the target supports the encoding. This encoding replaces a /// function if the target supports the encoding. This encoding replaces a

View File

@ -636,11 +636,12 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) {
OutStreamer.EmitCompactUnwindEncoding(MMI->getCompactUnwindEncoding()); OutStreamer.EmitCompactUnwindEncoding(MMI->getCompactUnwindEncoding());
MachineModuleInfo &MMI = MF->getMMI(); MachineModuleInfo &MMI = MF->getMMI();
std::vector<MachineMove> &Moves = MMI.getFrameMoves(); const std::vector<MachineMove> &Moves = MMI.getFrameMoves();
bool FoundOne = false; bool FoundOne = false;
(void)FoundOne; (void)FoundOne;
for (std::vector<MachineMove>::iterator I = Moves.begin(), for (std::vector<MachineMove>::const_iterator I = Moves.begin(),
E = Moves.end(); I != E; ++I) { E = Moves.end();
I != E; ++I) {
if (I->getLabel() == Label) { if (I->getLabel() == Label) {
EmitCFIFrameMove(*I); EmitCFIFrameMove(*I);
FoundOne = true; FoundOne = true;

View File

@ -54,7 +54,6 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
MachineModuleInfo &MMI = MF.getMMI(); MachineModuleInfo &MMI = MF.getMMI();
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
bool NeedsFrameMoves = MMI.hasDebugInfo() bool NeedsFrameMoves = MMI.hasDebugInfo()
|| MF.getFunction()->needsUnwindTableEntry(); || MF.getFunction()->needsUnwindTableEntry();
@ -98,7 +97,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Dst(MachineLocation::VirtualFP);
MachineLocation Src(AArch64::XSP, NumInitialBytes); MachineLocation Src(AArch64::XSP, NumInitialBytes);
Moves.push_back(MachineMove(SPLabel, Dst, Src)); MMI.addFrameMove(SPLabel, Dst, Src);
} }
// Otherwise we need to set the frame pointer and/or add a second stack // Otherwise we need to set the frame pointer and/or add a second stack
@ -133,7 +132,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
.addSym(FPLabel); .addSym(FPLabel);
MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Dst(MachineLocation::VirtualFP);
MachineLocation Src(AArch64::X29, -MFI->getObjectOffset(X29FrameIdx)); MachineLocation Src(AArch64::X29, -MFI->getObjectOffset(X29FrameIdx));
Moves.push_back(MachineMove(FPLabel, Dst, Src)); MMI.addFrameMove(FPLabel, Dst, Src);
} }
FPNeedsSetting = false; FPNeedsSetting = false;
@ -165,7 +164,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Dst(MachineLocation::VirtualFP);
MachineLocation Src(AArch64::XSP, NumResidualBytes + NumInitialBytes); MachineLocation Src(AArch64::XSP, NumResidualBytes + NumInitialBytes);
Moves.push_back(MachineMove(CSLabel, Dst, Src)); MMI.addFrameMove(CSLabel, Dst, Src);
} }
// And any callee-saved registers (it's fine to leave them to the end here, // And any callee-saved registers (it's fine to leave them to the end here,
@ -183,7 +182,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation Dst(MachineLocation::VirtualFP, MachineLocation Dst(MachineLocation::VirtualFP,
MFI->getObjectOffset(I->getFrameIdx())); MFI->getObjectOffset(I->getFrameIdx()));
MachineLocation Src(I->getReg()); MachineLocation Src(I->getReg());
Moves.push_back(MachineMove(CSLabel, Dst, Src)); MMI.addFrameMove(CSLabel, Dst, Src);
} }
} }
} }

View File

@ -113,8 +113,6 @@ void HexagonFrameLowering::emitPrologue(MachineFunction &MF) const {
MO.setImm(MFI->getMaxCallFrameSize()); MO.setImm(MFI->getMaxCallFrameSize());
} }
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
if (needsFrameMoves) { if (needsFrameMoves) {
// Advance CFA. DW_CFA_def_cfa // Advance CFA. DW_CFA_def_cfa
unsigned FPReg = QRI->getFrameRegister(); unsigned FPReg = QRI->getFrameRegister();
@ -122,17 +120,17 @@ void HexagonFrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Dst(MachineLocation::VirtualFP);
MachineLocation Src(FPReg, -8); MachineLocation Src(FPReg, -8);
Moves.push_back(MachineMove(0, Dst, Src)); MMI.addFrameMove(0, Dst, Src);
// R31 = (R31 - #4) // R31 = (R31 - #4)
MachineLocation LRDst(RAReg, -4); MachineLocation LRDst(RAReg, -4);
MachineLocation LRSrc(RAReg); MachineLocation LRSrc(RAReg);
Moves.push_back(MachineMove(0, LRDst, LRSrc)); MMI.addFrameMove(0, LRDst, LRSrc);
// R30 = (R30 - #8) // R30 = (R30 - #8)
MachineLocation SPDst(FPReg, -8); MachineLocation SPDst(FPReg, -8);
MachineLocation SPSrc(FPReg); MachineLocation SPSrc(FPReg);
Moves.push_back(MachineMove(0, SPDst, SPSrc)); MMI.addFrameMove(0, SPDst, SPSrc);
} }
// //

View File

@ -40,7 +40,6 @@ void Mips16FrameLowering::emitPrologue(MachineFunction &MF) const {
if (StackSize == 0 && !MFI->adjustsStack()) return; if (StackSize == 0 && !MFI->adjustsStack()) return;
MachineModuleInfo &MMI = MF.getMMI(); MachineModuleInfo &MMI = MF.getMMI();
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
MachineLocation DstML, SrcML; MachineLocation DstML, SrcML;
// Adjust stack. // Adjust stack.
@ -52,22 +51,22 @@ void Mips16FrameLowering::emitPrologue(MachineFunction &MF) const {
TII.get(TargetOpcode::PROLOG_LABEL)).addSym(AdjustSPLabel); TII.get(TargetOpcode::PROLOG_LABEL)).addSym(AdjustSPLabel);
DstML = MachineLocation(MachineLocation::VirtualFP); DstML = MachineLocation(MachineLocation::VirtualFP);
SrcML = MachineLocation(MachineLocation::VirtualFP, -StackSize); SrcML = MachineLocation(MachineLocation::VirtualFP, -StackSize);
Moves.push_back(MachineMove(AdjustSPLabel, DstML, SrcML)); MMI.addFrameMove(AdjustSPLabel, DstML, SrcML);
MCSymbol *CSLabel = MMI.getContext().CreateTempSymbol(); MCSymbol *CSLabel = MMI.getContext().CreateTempSymbol();
BuildMI(MBB, MBBI, dl, BuildMI(MBB, MBBI, dl,
TII.get(TargetOpcode::PROLOG_LABEL)).addSym(CSLabel); TII.get(TargetOpcode::PROLOG_LABEL)).addSym(CSLabel);
DstML = MachineLocation(MachineLocation::VirtualFP, -8); DstML = MachineLocation(MachineLocation::VirtualFP, -8);
SrcML = MachineLocation(Mips::S1); SrcML = MachineLocation(Mips::S1);
Moves.push_back(MachineMove(CSLabel, DstML, SrcML)); MMI.addFrameMove(CSLabel, DstML, SrcML);
DstML = MachineLocation(MachineLocation::VirtualFP, -12); DstML = MachineLocation(MachineLocation::VirtualFP, -12);
SrcML = MachineLocation(Mips::S0); SrcML = MachineLocation(Mips::S0);
Moves.push_back(MachineMove(CSLabel, DstML, SrcML)); MMI.addFrameMove(CSLabel, DstML, SrcML);
DstML = MachineLocation(MachineLocation::VirtualFP, -4); DstML = MachineLocation(MachineLocation::VirtualFP, -4);
SrcML = MachineLocation(Mips::RA); SrcML = MachineLocation(Mips::RA);
Moves.push_back(MachineMove(CSLabel, DstML, SrcML)); MMI.addFrameMove(CSLabel, DstML, SrcML);
if (hasFP(MF)) if (hasFP(MF))
BuildMI(MBB, MBBI, dl, TII.get(Mips::MoveR3216), Mips::S0) BuildMI(MBB, MBBI, dl, TII.get(Mips::MoveR3216), Mips::S0)

View File

@ -262,7 +262,6 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
if (StackSize == 0 && !MFI->adjustsStack()) return; if (StackSize == 0 && !MFI->adjustsStack()) return;
MachineModuleInfo &MMI = MF.getMMI(); MachineModuleInfo &MMI = MF.getMMI();
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
MachineLocation DstML, SrcML; MachineLocation DstML, SrcML;
// Adjust stack. // Adjust stack.
@ -274,7 +273,7 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
TII.get(TargetOpcode::PROLOG_LABEL)).addSym(AdjustSPLabel); TII.get(TargetOpcode::PROLOG_LABEL)).addSym(AdjustSPLabel);
DstML = MachineLocation(MachineLocation::VirtualFP); DstML = MachineLocation(MachineLocation::VirtualFP);
SrcML = MachineLocation(MachineLocation::VirtualFP, -StackSize); SrcML = MachineLocation(MachineLocation::VirtualFP, -StackSize);
Moves.push_back(MachineMove(AdjustSPLabel, DstML, SrcML)); MMI.addFrameMove(AdjustSPLabel, DstML, SrcML);
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
@ -306,13 +305,13 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
if (!STI.isLittle()) if (!STI.isLittle())
std::swap(SrcML0, SrcML1); std::swap(SrcML0, SrcML1);
Moves.push_back(MachineMove(CSLabel, DstML0, SrcML0)); MMI.addFrameMove(CSLabel, DstML0, SrcML0);
Moves.push_back(MachineMove(CSLabel, DstML1, SrcML1)); MMI.addFrameMove(CSLabel, DstML1, SrcML1);
} else { } else {
// Reg is either in CPURegs or FGR32. // Reg is either in CPURegs or FGR32.
DstML = MachineLocation(MachineLocation::VirtualFP, Offset); DstML = MachineLocation(MachineLocation::VirtualFP, Offset);
SrcML = MachineLocation(Reg); SrcML = MachineLocation(Reg);
Moves.push_back(MachineMove(CSLabel, DstML, SrcML)); MMI.addFrameMove(CSLabel, DstML, SrcML);
} }
} }
} }
@ -337,7 +336,7 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
int64_t Offset = MFI->getObjectOffset(MipsFI->getEhDataRegFI(I)); int64_t Offset = MFI->getObjectOffset(MipsFI->getEhDataRegFI(I));
DstML = MachineLocation(MachineLocation::VirtualFP, Offset); DstML = MachineLocation(MachineLocation::VirtualFP, Offset);
SrcML = MachineLocation(ehDataReg(I)); SrcML = MachineLocation(ehDataReg(I));
Moves.push_back(MachineMove(CSLabel2, DstML, SrcML)); MMI.addFrameMove(CSLabel2, DstML, SrcML);
} }
} }
@ -352,7 +351,7 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
TII.get(TargetOpcode::PROLOG_LABEL)).addSym(SetFPLabel); TII.get(TargetOpcode::PROLOG_LABEL)).addSym(SetFPLabel);
DstML = MachineLocation(FP); DstML = MachineLocation(FP);
SrcML = MachineLocation(MachineLocation::VirtualFP); SrcML = MachineLocation(MachineLocation::VirtualFP);
Moves.push_back(MachineMove(SetFPLabel, DstML, SrcML)); MMI.addFrameMove(SetFPLabel, DstML, SrcML);
} }
} }

View File

@ -515,8 +515,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
} }
} }
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
// Add the "machine moves" for the instructions we generated above, but in // Add the "machine moves" for the instructions we generated above, but in
// reverse order. // reverse order.
if (needsFrameMoves) { if (needsFrameMoves) {
@ -528,22 +526,22 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
if (NegFrameSize) { if (NegFrameSize) {
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize); MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize);
Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); MMI.addFrameMove(FrameLabel, SPDst, SPSrc);
} else { } else {
MachineLocation SP(isPPC64 ? PPC::X31 : PPC::R31); MachineLocation SP(isPPC64 ? PPC::X31 : PPC::R31);
Moves.push_back(MachineMove(FrameLabel, SP, SP)); MMI.addFrameMove(FrameLabel, SP, SP);
} }
if (HasFP) { if (HasFP) {
MachineLocation FPDst(MachineLocation::VirtualFP, FPOffset); MachineLocation FPDst(MachineLocation::VirtualFP, FPOffset);
MachineLocation FPSrc(isPPC64 ? PPC::X31 : PPC::R31); MachineLocation FPSrc(isPPC64 ? PPC::X31 : PPC::R31);
Moves.push_back(MachineMove(FrameLabel, FPDst, FPSrc)); MMI.addFrameMove(FrameLabel, FPDst, FPSrc);
} }
if (MustSaveLR) { if (MustSaveLR) {
MachineLocation LRDst(MachineLocation::VirtualFP, LROffset); MachineLocation LRDst(MachineLocation::VirtualFP, LROffset);
MachineLocation LRSrc(isPPC64 ? PPC::LR8 : PPC::LR); MachineLocation LRSrc(isPPC64 ? PPC::LR8 : PPC::LR);
Moves.push_back(MachineMove(FrameLabel, LRDst, LRSrc)); MMI.addFrameMove(FrameLabel, LRDst, LRSrc);
} }
} }
@ -570,7 +568,7 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation FPDst(HasFP ? (isPPC64 ? PPC::X31 : PPC::R31) : MachineLocation FPDst(HasFP ? (isPPC64 ? PPC::X31 : PPC::R31) :
(isPPC64 ? PPC::X1 : PPC::R1)); (isPPC64 ? PPC::X1 : PPC::R1));
MachineLocation FPSrc(MachineLocation::VirtualFP); MachineLocation FPSrc(MachineLocation::VirtualFP);
Moves.push_back(MachineMove(ReadyLabel, FPDst, FPSrc)); MMI.addFrameMove(ReadyLabel, FPDst, FPSrc);
} }
} }
@ -602,14 +600,14 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
&& (PPC::CR2 <= Reg && Reg <= PPC::CR4)) { && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
MachineLocation CSDst(PPC::X1, 8); MachineLocation CSDst(PPC::X1, 8);
MachineLocation CSSrc(PPC::CR2); MachineLocation CSSrc(PPC::CR2);
Moves.push_back(MachineMove(Label, CSDst, CSSrc)); MMI.addFrameMove(Label, CSDst, CSSrc);
continue; continue;
} }
int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(Label, CSDst, CSSrc)); MMI.addFrameMove(Label, CSDst, CSSrc);
} }
} }
} }

View File

@ -297,7 +297,6 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF) const {
SystemZMachineFunctionInfo *ZFI = MF.getInfo<SystemZMachineFunctionInfo>(); SystemZMachineFunctionInfo *ZFI = MF.getInfo<SystemZMachineFunctionInfo>();
MachineBasicBlock::iterator MBBI = MBB.begin(); MachineBasicBlock::iterator MBBI = MBB.begin();
MachineModuleInfo &MMI = MF.getMMI(); MachineModuleInfo &MMI = MF.getMMI();
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
const std::vector<CalleeSavedInfo> &CSI = MFFrame->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFFrame->getCalleeSavedInfo();
bool HasFP = hasFP(MF); bool HasFP = hasFP(MF);
DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
@ -323,7 +322,7 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF) const {
int64_t Offset = SPOffsetFromCFA + RegSpillOffsets[Reg]; int64_t Offset = SPOffsetFromCFA + RegSpillOffsets[Reg];
MachineLocation StackSlot(MachineLocation::VirtualFP, Offset); MachineLocation StackSlot(MachineLocation::VirtualFP, Offset);
MachineLocation RegValue(Reg); MachineLocation RegValue(Reg);
Moves.push_back(MachineMove(GPRSaveLabel, StackSlot, RegValue)); MMI.addFrameMove(GPRSaveLabel, StackSlot, RegValue);
} }
} }
} }
@ -340,7 +339,7 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF) const {
.addSym(AdjustSPLabel); .addSym(AdjustSPLabel);
MachineLocation FPDest(MachineLocation::VirtualFP); MachineLocation FPDest(MachineLocation::VirtualFP);
MachineLocation FPSrc(MachineLocation::VirtualFP, SPOffsetFromCFA + Delta); MachineLocation FPSrc(MachineLocation::VirtualFP, SPOffsetFromCFA + Delta);
Moves.push_back(MachineMove(AdjustSPLabel, FPDest, FPSrc)); MMI.addFrameMove(AdjustSPLabel, FPDest, FPSrc);
SPOffsetFromCFA += Delta; SPOffsetFromCFA += Delta;
} }
@ -355,7 +354,7 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF) const {
.addSym(SetFPLabel); .addSym(SetFPLabel);
MachineLocation HardFP(SystemZ::R11D); MachineLocation HardFP(SystemZ::R11D);
MachineLocation VirtualFP(MachineLocation::VirtualFP); MachineLocation VirtualFP(MachineLocation::VirtualFP);
Moves.push_back(MachineMove(SetFPLabel, HardFP, VirtualFP)); MMI.addFrameMove(SetFPLabel, HardFP, VirtualFP);
// Mark the FramePtr as live at the beginning of every block except // Mark the FramePtr as live at the beginning of every block except
// the entry block. (We'll have marked R11 as live on entry when // the entry block. (We'll have marked R11 as live on entry when
@ -386,7 +385,7 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation Slot(MachineLocation::VirtualFP, MachineLocation Slot(MachineLocation::VirtualFP,
SPOffsetFromCFA + Offset); SPOffsetFromCFA + Offset);
MachineLocation RegValue(Reg); MachineLocation RegValue(Reg);
Moves.push_back(MachineMove(FPRSaveLabel, Slot, RegValue)); MMI.addFrameMove(FPRSaveLabel, Slot, RegValue);
} }
} }
// Complete the CFI for the FPR saves, modelling them as taking effect // Complete the CFI for the FPR saves, modelling them as taking effect

View File

@ -312,7 +312,6 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
if (CSI.empty()) return; if (CSI.empty()) return;
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
const X86RegisterInfo *RegInfo = TM.getRegisterInfo(); const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
bool HasFP = hasFP(MF); bool HasFP = hasFP(MF);
@ -362,7 +361,7 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(Label, CSDst, CSSrc)); MMI.addFrameMove(Label, CSDst, CSSrc);
} }
} }
@ -732,7 +731,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
// REG < 64 => DW_CFA_offset + Reg // REG < 64 => DW_CFA_offset + Reg
// ELSE => DW_CFA_offset_extended // ELSE => DW_CFA_offset_extended
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
uint64_t NumBytes = 0; uint64_t NumBytes = 0;
int stackGrowth = -SlotSize; int stackGrowth = -SlotSize;
@ -768,17 +766,17 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
if (StackSize) { if (StackSize) {
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, 2 * stackGrowth); MachineLocation SPSrc(MachineLocation::VirtualFP, 2 * stackGrowth);
Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); MMI.addFrameMove(FrameLabel, SPDst, SPSrc);
} else { } else {
MachineLocation SPDst(StackPtr); MachineLocation SPDst(StackPtr);
MachineLocation SPSrc(StackPtr, stackGrowth); MachineLocation SPSrc(StackPtr, stackGrowth);
Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); MMI.addFrameMove(FrameLabel, SPDst, SPSrc);
} }
// Change the rule for the FramePtr to be an "offset" rule. // Change the rule for the FramePtr to be an "offset" rule.
MachineLocation FPDst(MachineLocation::VirtualFP, 2 * stackGrowth); MachineLocation FPDst(MachineLocation::VirtualFP, 2 * stackGrowth);
MachineLocation FPSrc(FramePtr); MachineLocation FPSrc(FramePtr);
Moves.push_back(MachineMove(FrameLabel, FPDst, FPSrc)); MMI.addFrameMove(FrameLabel, FPDst, FPSrc);
} }
// Update EBP with the new base value. // Update EBP with the new base value.
@ -796,7 +794,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
// Define the current CFA to use the EBP/RBP register. // Define the current CFA to use the EBP/RBP register.
MachineLocation FPDst(FramePtr); MachineLocation FPDst(FramePtr);
MachineLocation FPSrc(MachineLocation::VirtualFP); MachineLocation FPSrc(MachineLocation::VirtualFP);
Moves.push_back(MachineMove(FrameLabel, FPDst, FPSrc)); MMI.addFrameMove(FrameLabel, FPDst, FPSrc);
} }
// Mark the FramePtr as live-in in every block except the entry. // Mark the FramePtr as live-in in every block except the entry.
@ -827,7 +825,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
unsigned Ptr = StackSize ? MachineLocation::VirtualFP : StackPtr; unsigned Ptr = StackSize ? MachineLocation::VirtualFP : StackPtr;
MachineLocation SPDst(Ptr); MachineLocation SPDst(Ptr);
MachineLocation SPSrc(Ptr, StackOffset); MachineLocation SPSrc(Ptr, StackOffset);
Moves.push_back(MachineMove(Label, SPDst, SPSrc)); MMI.addFrameMove(Label, SPDst, SPSrc);
StackOffset += stackGrowth; StackOffset += stackGrowth;
} }
} }
@ -965,11 +963,11 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, MachineLocation SPSrc(MachineLocation::VirtualFP,
-StackSize + stackGrowth); -StackSize + stackGrowth);
Moves.push_back(MachineMove(Label, SPDst, SPSrc)); MMI.addFrameMove(Label, SPDst, SPSrc);
} else { } else {
MachineLocation SPDst(StackPtr); MachineLocation SPDst(StackPtr);
MachineLocation SPSrc(StackPtr, stackGrowth); MachineLocation SPSrc(StackPtr, stackGrowth);
Moves.push_back(MachineMove(Label, SPDst, SPSrc)); MMI.addFrameMove(Label, SPDst, SPSrc);
} }
} }

View File

@ -132,7 +132,6 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
BuildMI(MBB, MBBI, dl, TII.get(Opcode)).addImm(FrameSize); BuildMI(MBB, MBBI, dl, TII.get(Opcode)).addImm(FrameSize);
if (emitFrameMoves) { if (emitFrameMoves) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves();
// Show update of SP. // Show update of SP.
MCSymbol *FrameLabel = MMI->getContext().CreateTempSymbol(); MCSymbol *FrameLabel = MMI->getContext().CreateTempSymbol();
@ -140,12 +139,12 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize * 4); MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize * 4);
Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc)); MMI->addFrameMove(FrameLabel, SPDst, SPSrc);
if (LRSavedOnEntry) { if (LRSavedOnEntry) {
MachineLocation CSDst(MachineLocation::VirtualFP, 0); MachineLocation CSDst(MachineLocation::VirtualFP, 0);
MachineLocation CSSrc(XCore::LR); MachineLocation CSSrc(XCore::LR);
Moves.push_back(MachineMove(FrameLabel, CSDst, CSSrc)); MMI->addFrameMove(FrameLabel, CSDst, CSSrc);
} }
} }
} }
@ -159,7 +158,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveLRLabel); BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveLRLabel);
MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset); MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset);
MachineLocation CSSrc(XCore::LR); MachineLocation CSSrc(XCore::LR);
MMI->getFrameMoves().push_back(MachineMove(SaveLRLabel, CSDst, CSSrc)); MMI->addFrameMove(SaveLRLabel, CSDst, CSSrc);
} }
} }
@ -174,7 +173,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveR10Label); BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(SaveR10Label);
MachineLocation CSDst(MachineLocation::VirtualFP, FPSpillOffset); MachineLocation CSDst(MachineLocation::VirtualFP, FPSpillOffset);
MachineLocation CSSrc(XCore::R10); MachineLocation CSSrc(XCore::R10);
MMI->getFrameMoves().push_back(MachineMove(SaveR10Label, CSDst, CSSrc)); MMI->addFrameMove(SaveR10Label, CSDst, CSSrc);
} }
// Set the FP from the SP. // Set the FP from the SP.
unsigned FramePtr = XCore::R10; unsigned FramePtr = XCore::R10;
@ -186,13 +185,12 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(FrameLabel); BuildMI(MBB, MBBI, dl, TII.get(XCore::PROLOG_LABEL)).addSym(FrameLabel);
MachineLocation SPDst(FramePtr); MachineLocation SPDst(FramePtr);
MachineLocation SPSrc(MachineLocation::VirtualFP); MachineLocation SPSrc(MachineLocation::VirtualFP);
MMI->getFrameMoves().push_back(MachineMove(FrameLabel, SPDst, SPSrc)); MMI->addFrameMove(FrameLabel, SPDst, SPSrc);
} }
} }
if (emitFrameMoves) { if (emitFrameMoves) {
// Frame moves for callee saved. // Frame moves for callee saved.
std::vector<MachineMove> &Moves = MMI->getFrameMoves();
std::vector<std::pair<MCSymbol*, CalleeSavedInfo> >&SpillLabels = std::vector<std::pair<MCSymbol*, CalleeSavedInfo> >&SpillLabels =
XFI->getSpillLabels(); XFI->getSpillLabels();
for (unsigned I = 0, E = SpillLabels.size(); I != E; ++I) { for (unsigned I = 0, E = SpillLabels.size(); I != E; ++I) {
@ -202,7 +200,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
unsigned Reg = CSI.getReg(); unsigned Reg = CSI.getReg();
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(SpillLabel, CSDst, CSSrc)); MMI->addFrameMove(SpillLabel, CSDst, CSSrc);
} }
} }
} }