diff options
author | Jim Laskey <jlaskey@mac.com> | 2007-01-24 18:45:13 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2007-01-24 18:45:13 +0000 |
commit | f6c63fec92287dfbfd128c876e8753f0e57bd0c3 (patch) | |
tree | 9c238012e1844cc08b6c24536c7d0177642a439e /llvm/lib/Target/PowerPC | |
parent | 8a75518f0bbb708a9bffbb275e4c47edad853ce8 (diff) | |
download | bcm5719-llvm-f6c63fec92287dfbfd128c876e8753f0e57bd0c3.tar.gz bcm5719-llvm-f6c63fec92287dfbfd128c876e8753f0e57bd0c3.zip |
Repair debug frames as a prelude to eh_frames. Switched to using MachineMoves
by value so that clean up is less confusing (these vectors tend to be small.)
llvm-svn: 33488
Diffstat (limited to 'llvm/lib/Target/PowerPC')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp | 58 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCRegisterInfo.h | 2 |
2 files changed, 44 insertions, 16 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp index e4bea7c4a40..465960afda4 100644 --- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -762,6 +762,10 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const { MachineFrameInfo *MFI = MF.getFrameInfo(); MachineDebugInfo *DebugInfo = MFI->getMachineDebugInfo(); + // Prepare for debug frame info. + bool hasInfo = DebugInfo && DebugInfo->hasInfo(); + unsigned FrameLabelId = 0; + // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it, // process it. for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) { @@ -821,6 +825,12 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const { unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); unsigned MaxAlign = MFI->getMaxAlignment(); + if (hasInfo) { + // Mark effective beginning of when frame pointer becomes valid. + FrameLabelId = DebugInfo->NextLabelID(); + BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(FrameLabelId); + } + // Adjust stack pointer: r1 += NegFrameSize. // If there is a preferred stack alignment, align R1 now if (!IsPPC64) { @@ -866,26 +876,44 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const { } } - if (DebugInfo && DebugInfo->hasInfo()) { - std::vector<MachineMove *> &Moves = DebugInfo->getFrameMoves(); - unsigned LabelID = DebugInfo->NextLabelID(); + if (hasInfo) { + std::vector<MachineMove> &Moves = DebugInfo->getFrameMoves(); - // Mark effective beginning of when frame pointer becomes valid. - BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(LabelID); + if (NegFrameSize) { + // Show update of SP. + MachineLocation SPDst(MachineLocation::VirtualFP); + MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize); + Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); + } else { + MachineLocation SP(IsPPC64 ? PPC::X31 : PPC::R31); + Moves.push_back(MachineMove(FrameLabelId, SP, SP)); + } - // Show update of SP. - MachineLocation SPDst(MachineLocation::VirtualFP); - MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize); - Moves.push_back(new MachineMove(LabelID, SPDst, SPSrc)); + if (HasFP) { + MachineLocation FPDst(MachineLocation::VirtualFP, FPOffset); + MachineLocation FPSrc(IsPPC64 ? PPC::X31 : PPC::R31); + Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc)); + } // Add callee saved registers to move list. const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); for (unsigned I = 0, E = CSI.size(); I != E; ++I) { - MachineLocation CSDst(MachineLocation::VirtualFP, - MFI->getObjectOffset(CSI[I].getFrameIdx())); - MachineLocation CSSrc(CSI[I].getReg()); - Moves.push_back(new MachineMove(LabelID, CSDst, CSSrc)); + int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx()); + unsigned Reg = CSI[I].getReg(); + if (Reg == PPC::LR || Reg == PPC::LR8) continue; + MachineLocation CSDst(MachineLocation::VirtualFP, Offset); + MachineLocation CSSrc(Reg); + Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); } + + // Mark effective beginning of when frame pointer is ready. + unsigned ReadyLabelId = DebugInfo->NextLabelID(); + BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(ReadyLabelId); + + MachineLocation FPDst(HasFP ? (IsPPC64 ? PPC::X31 : PPC::R31) : + (IsPPC64 ? PPC::X1 : PPC::R1)); + MachineLocation FPSrc(MachineLocation::VirtualFP); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); } // If there is a frame pointer, copy R1 into R31 @@ -983,12 +1011,12 @@ unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const { return hasFP(MF) ? PPC::X31 : PPC::X1; } -void PPCRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves) +void PPCRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const { // Initial state of the frame pointer is R1. MachineLocation Dst(MachineLocation::VirtualFP); MachineLocation Src(PPC::R1, 0); - Moves.push_back(new MachineMove(0, Dst, Src)); + Moves.push_back(MachineMove(0, Dst, Src)); } #include "PPCGenRegisterInfo.inc" diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.h b/llvm/lib/Target/PowerPC/PPCRegisterInfo.h index 5408c9f0c42..7d35c6a26ae 100644 --- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.h +++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.h @@ -81,7 +81,7 @@ public: // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; - void getInitialFrameState(std::vector<MachineMove *> &Moves) const; + void getInitialFrameState(std::vector<MachineMove> &Moves) const; }; } // end namespace llvm |