Now that DBG_LABEL is updated, we can finally make MachineMove

contain an MCSymbol instead of a label index.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98482 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-03-14 08:12:40 +00:00
parent 6ffcccab51
commit 2e9919a5e5
10 changed files with 86 additions and 124 deletions

View File

@ -22,13 +22,13 @@
#define LLVM_CODEGEN_MACHINELOCATION_H #define LLVM_CODEGEN_MACHINELOCATION_H
namespace llvm { namespace llvm {
class MCSymbol;
class MachineLocation { class MachineLocation {
private: private:
bool IsRegister; // True if location is a register. bool IsRegister; // True if location is a register.
unsigned Register; // gcc/gdb register number. unsigned Register; // gcc/gdb register number.
int Offset; // Displacement if not register. int Offset; // Displacement if not register.
public: public:
enum { enum {
// The target register number for an abstract frame pointer. The value is // The target register number for an abstract frame pointer. The value is
@ -36,20 +36,11 @@ public:
VirtualFP = ~0U VirtualFP = ~0U
}; };
MachineLocation() MachineLocation()
: IsRegister(false) : IsRegister(false), Register(0), Offset(0) {}
, Register(0)
, Offset(0)
{}
explicit MachineLocation(unsigned R) explicit MachineLocation(unsigned R)
: IsRegister(true) : IsRegister(true), Register(R), Offset(0) {}
, Register(R)
, Offset(0)
{}
MachineLocation(unsigned R, int O) MachineLocation(unsigned R, int O)
: IsRegister(false) : IsRegister(false), Register(R), Offset(O) {}
, Register(R)
, Offset(O)
{}
// Accessors // Accessors
bool isReg() const { return IsRegister; } bool isReg() const { return IsRegister; }
@ -74,29 +65,24 @@ public:
#endif #endif
}; };
/// MachineMove - This class represents the save or restore of a callee saved
/// register that exception or debug info needs to know about.
class MachineMove { class MachineMove {
private: private:
unsigned LabelID; // Label ID number for post-instruction /// Label - Symbol for post-instruction address when result of move takes
// address when result of move takes /// effect.
// effect. MCSymbol *Label;
MachineLocation Destination; // Move to location.
MachineLocation Source; // Move from location.
// Move to & from location.
MachineLocation Destination, Source;
public: public:
MachineMove() MachineMove() : Label(0) {}
: LabelID(0)
, Destination()
, Source()
{}
MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S) MachineMove(MCSymbol *label, MachineLocation &D, MachineLocation &S)
: LabelID(ID) : Label(label), Destination(D), Source(S) {}
, Destination(D)
, Source(S)
{}
// Accessors // Accessors
unsigned getLabelID() const { return LabelID; } MCSymbol *getLabel() const { return Label; }
const MachineLocation &getDestination() const { return Destination; } const MachineLocation &getDestination() const { return Destination; }
const MachineLocation &getSource() const { return Source; } const MachineLocation &getSource() const { return Source; }
}; };

View File

@ -247,13 +247,9 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
for (unsigned i = 0, N = Moves.size(); i < N; ++i) { for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
const MachineMove &Move = Moves[i]; const MachineMove &Move = Moves[i];
MCSymbol *Label = 0; MCSymbol *Label = Move.getLabel();
unsigned LabelID = Move.getLabelID();
// Throw out move if the label is invalid. // Throw out move if the label is invalid.
if (LabelID) { if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
Label = getDWLabel("label", LabelID);
if (!Label->isDefined()) continue; // Not emitted, in dead code.
}
const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource(); const MachineLocation &Src = Move.getSource();

View File

@ -68,32 +68,29 @@ JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr,
unsigned PointerSize = TD->getPointerSize(); unsigned PointerSize = TD->getPointerSize();
int stackGrowth = stackGrowthDirection == TargetFrameInfo::StackGrowsUp ? int stackGrowth = stackGrowthDirection == TargetFrameInfo::StackGrowsUp ?
PointerSize : -PointerSize; PointerSize : -PointerSize;
bool IsLocal = false; MCSymbol *BaseLabel = 0;
unsigned BaseLabelID = 0;
for (unsigned i = 0, N = Moves.size(); i < N; ++i) { for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
const MachineMove &Move = Moves[i]; const MachineMove &Move = Moves[i];
unsigned LabelID = Move.getLabelID(); MCSymbol *Label = Move.getLabel();
MCSymbol *Label = LabelID ? MMI->getLabelSym(LabelID) : 0;
// Throw out move if the label is invalid. // Throw out move if the label is invalid.
if (Label && !Label->isDefined()) if (Label && !Label->isDefined())
continue; continue;
intptr_t LabelPtr = 0; intptr_t LabelPtr = 0;
if (LabelID) LabelPtr = JCE->getLabelAddress(Label); if (Label) LabelPtr = JCE->getLabelAddress(Label);
const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource(); const MachineLocation &Src = Move.getSource();
// Advance row if new location. // Advance row if new location.
if (BaseLabelPtr && LabelID && (BaseLabelID != LabelID || !IsLocal)) { if (BaseLabelPtr && Label && BaseLabel != Label) {
JCE->emitByte(dwarf::DW_CFA_advance_loc4); JCE->emitByte(dwarf::DW_CFA_advance_loc4);
JCE->emitInt32(LabelPtr - BaseLabelPtr); JCE->emitInt32(LabelPtr - BaseLabelPtr);
BaseLabelID = LabelID; BaseLabel = Label;
BaseLabelPtr = LabelPtr; BaseLabelPtr = LabelPtr;
IsLocal = true;
} }
// If advancing cfa. // If advancing cfa.
@ -712,21 +709,20 @@ JITDwarfEmitter::GetFrameMovesSizeInBytes(intptr_t BaseLabelPtr,
for (unsigned i = 0, N = Moves.size(); i < N; ++i) { for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
const MachineMove &Move = Moves[i]; const MachineMove &Move = Moves[i];
unsigned LabelID = Move.getLabelID(); MCSymbol *Label = Move.getLabel();
MCSymbol *Label = LabelID ? MMI->getLabelSym(LabelID) : 0;
// Throw out move if the label is invalid. // Throw out move if the label is invalid.
if (Label && !Label->isDefined()) if (Label && !Label->isDefined())
continue; continue;
intptr_t LabelPtr = 0; intptr_t LabelPtr = 0;
if (LabelID) LabelPtr = JCE->getLabelAddress(Label); if (Label) LabelPtr = JCE->getLabelAddress(Label);
const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource(); const MachineLocation &Src = Move.getSource();
// Advance row if new location. // Advance row if new location.
if (BaseLabelPtr && LabelID && (BaseLabelPtr != LabelPtr || !IsLocal)) { if (BaseLabelPtr && Label && (BaseLabelPtr != LabelPtr || !IsLocal)) {
FinalSize++; FinalSize++;
FinalSize += PointerSize; FinalSize += PointerSize;
BaseLabelPtr = LabelPtr; BaseLabelPtr = LabelPtr;

View File

@ -436,7 +436,7 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
// Prepare for debug frame info. // Prepare for debug frame info.
bool hasDebugInfo = MMI && MMI->hasDebugInfo(); bool hasDebugInfo = MMI && MMI->hasDebugInfo();
unsigned FrameLabelId = 0; MCSymbol *FrameLabel = 0;
// Move MBBI back to the beginning of the function. // Move MBBI back to the beginning of the function.
MBBI = MBB.begin(); MBBI = MBB.begin();
@ -452,9 +452,8 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
FrameSize = -(FrameSize + SPUFrameInfo::minStackSize()); FrameSize = -(FrameSize + SPUFrameInfo::minStackSize());
if (hasDebugInfo) { if (hasDebugInfo) {
// Mark effective beginning of when frame pointer becomes valid. // Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID(); FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
} }
// Adjust stack pointer, spilling $lr -> 16($sp) and $sp -> -FrameSize($sp) // Adjust stack pointer, spilling $lr -> 16($sp) and $sp -> -FrameSize($sp)
@ -501,7 +500,7 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
// Show update of SP. // Show update of SP.
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize); MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize);
Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc));
// Add callee saved registers to move list. // Add callee saved registers to move list.
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
@ -511,17 +510,16 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
if (Reg == SPU::R0) continue; if (Reg == SPU::R0) continue;
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); Moves.push_back(MachineMove(FrameLabel, CSDst, CSSrc));
} }
// Mark effective beginning of when frame pointer is ready. // Mark effective beginning of when frame pointer is ready.
unsigned ReadyLabelId = MMI->NextLabelID(); MCSymbol *ReadyLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)).addSym(ReadyLabel);
.addSym(MMI->getLabelSym(ReadyLabelId));
MachineLocation FPDst(SPU::R1); MachineLocation FPDst(SPU::R1);
MachineLocation FPSrc(MachineLocation::VirtualFP); MachineLocation FPSrc(MachineLocation::VirtualFP);
Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); Moves.push_back(MachineMove(ReadyLabel, FPDst, FPSrc));
} }
} else { } else {
// This is a leaf function -- insert a branch hint iff there are // This is a leaf function -- insert a branch hint iff there are

View File

@ -1287,7 +1287,7 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
UnwindTablesMandatory; UnwindTablesMandatory;
// Prepare for frame info. // Prepare for frame info.
unsigned FrameLabelId = 0; MCSymbol *FrameLabel = 0;
// Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it, // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
// process it. // process it.
@ -1446,34 +1446,33 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
// reverse order. // reverse order.
if (needsFrameMoves) { if (needsFrameMoves) {
// Mark effective beginning of when frame pointer becomes valid. // Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID(); FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
// Show update of SP. // Show update of SP.
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(FrameLabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc));
} else { } else {
MachineLocation SP(isPPC64 ? PPC::X31 : PPC::R31); MachineLocation SP(isPPC64 ? PPC::X31 : PPC::R31);
Moves.push_back(MachineMove(FrameLabelId, SP, SP)); Moves.push_back(MachineMove(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(FrameLabelId, FPDst, FPSrc)); Moves.push_back(MachineMove(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(FrameLabelId, LRDst, LRSrc)); Moves.push_back(MachineMove(FrameLabel, LRDst, LRSrc));
} }
} }
unsigned ReadyLabelId = 0; MCSymbol *ReadyLabel = 0;
// If there is a frame pointer, copy R1 into R31 // If there is a frame pointer, copy R1 into R31
if (HasFP) { if (HasFP) {
@ -1488,21 +1487,20 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
} }
if (needsFrameMoves) { if (needsFrameMoves) {
ReadyLabelId = MMI->NextLabelID(); ReadyLabel = MMI->getLabelSym(MMI->NextLabelID());
// Mark effective beginning of when frame pointer is ready. // Mark effective beginning of when frame pointer is ready.
BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(PPC::DBG_LABEL)).addSym(ReadyLabel);
.addSym(MMI->getLabelSym(ReadyLabelId));
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(ReadyLabelId, FPDst, FPSrc)); Moves.push_back(MachineMove(ReadyLabel, FPDst, FPSrc));
} }
} }
if (needsFrameMoves) { if (needsFrameMoves) {
unsigned LabelId = HasFP ? ReadyLabelId : FrameLabelId; MCSymbol *Label = HasFP ? ReadyLabel : FrameLabel;
// Add callee saved registers to move list. // Add callee saved registers to move list.
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
@ -1512,7 +1510,7 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
if (Reg == PPC::LR || Reg == PPC::LR8 || Reg == PPC::RM) continue; if (Reg == PPC::LR || Reg == PPC::LR8 || Reg == PPC::RM) continue;
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(LabelId, CSDst, CSSrc)); Moves.push_back(MachineMove(Label, CSDst, CSSrc));
} }
} }
} }

View File

@ -797,7 +797,7 @@ static int mergeSPUpdates(MachineBasicBlock &MBB,
} }
void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF, void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF,
unsigned LabelId, MCSymbol *Label,
unsigned FramePtr) const { unsigned FramePtr) const {
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
@ -860,7 +860,7 @@ void X86RegisterInfo::emitCalleeSavedFrameMoves(MachineFunction &MF,
MachineLocation CSDst(MachineLocation::VirtualFP, Offset); MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg); MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(LabelId, CSDst, CSSrc)); Moves.push_back(MachineMove(Label, CSDst, CSSrc));
} }
} }
@ -959,26 +959,25 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
if (needsFrameMoves) { if (needsFrameMoves) {
// Mark the place where EBP/RBP was saved. // Mark the place where EBP/RBP was saved.
unsigned FrameLabelId = MMI->NextLabelID(); MCSymbol *FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)) BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
// Define the current CFA rule to use the provided offset. // Define the current CFA rule to use the provided offset.
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(FrameLabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(FrameLabel, SPDst, SPSrc));
} else { } else {
// FIXME: Verify & implement for FP // FIXME: Verify & implement for FP
MachineLocation SPDst(StackPtr); MachineLocation SPDst(StackPtr);
MachineLocation SPSrc(StackPtr, stackGrowth); MachineLocation SPSrc(StackPtr, stackGrowth);
Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(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(FrameLabelId, FPDst, FPSrc)); Moves.push_back(MachineMove(FrameLabel, FPDst, FPSrc));
} }
// Update EBP with the new base value... // Update EBP with the new base value...
@ -988,14 +987,13 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
if (needsFrameMoves) { if (needsFrameMoves) {
// Mark effective beginning of when frame pointer becomes valid. // Mark effective beginning of when frame pointer becomes valid.
unsigned FrameLabelId = MMI->NextLabelID(); MCSymbol *FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)) BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
// 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(FrameLabelId, FPDst, FPSrc)); Moves.push_back(MachineMove(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.
@ -1029,16 +1027,15 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
if (!HasFP && needsFrameMoves) { if (!HasFP && needsFrameMoves) {
// Mark callee-saved push instruction. // Mark callee-saved push instruction.
unsigned LabelId = MMI->NextLabelID(); MCSymbol *Label = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)) BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addSym(Label);
.addSym(MMI->getLabelSym(LabelId));
// Define the current CFA rule to use the provided offset. // Define the current CFA rule to use the provided offset.
unsigned Ptr = StackSize ? unsigned Ptr = StackSize ?
MachineLocation::VirtualFP : StackPtr; MachineLocation::VirtualFP : StackPtr;
MachineLocation SPDst(Ptr); MachineLocation SPDst(Ptr);
MachineLocation SPSrc(Ptr, StackOffset); MachineLocation SPSrc(Ptr, StackOffset);
Moves.push_back(MachineMove(LabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(Label, SPDst, SPSrc));
StackOffset += stackGrowth; StackOffset += stackGrowth;
} }
} }
@ -1102,9 +1099,8 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
if ((NumBytes || PushedRegs) && needsFrameMoves) { if ((NumBytes || PushedRegs) && needsFrameMoves) {
// Mark end of stack pointer adjustment. // Mark end of stack pointer adjustment.
unsigned LabelId = MMI->NextLabelID(); MCSymbol *Label = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)) BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addSym(Label);
.addSym(MMI->getLabelSym(LabelId));
if (!HasFP && NumBytes) { if (!HasFP && NumBytes) {
// Define the current CFA rule to use the provided offset. // Define the current CFA rule to use the provided offset.
@ -1112,18 +1108,18 @@ void X86RegisterInfo::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(LabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(Label, SPDst, SPSrc));
} else { } else {
// FIXME: Verify & implement for FP // FIXME: Verify & implement for FP
MachineLocation SPDst(StackPtr); MachineLocation SPDst(StackPtr);
MachineLocation SPSrc(StackPtr, stackGrowth); MachineLocation SPSrc(StackPtr, stackGrowth);
Moves.push_back(MachineMove(LabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(Label, SPDst, SPSrc));
} }
} }
// Emit DWARF info specifying the offsets of the callee-saved registers. // Emit DWARF info specifying the offsets of the callee-saved registers.
if (PushedRegs) if (PushedRegs)
emitCalleeSavedFrameMoves(MF, LabelId, HasFP ? FramePtr : StackPtr); emitCalleeSavedFrameMoves(MF, Label, HasFP ? FramePtr : StackPtr);
} }
} }

View File

@ -149,7 +149,7 @@ public:
void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
RegScavenger *RS = NULL) const; RegScavenger *RS = NULL) const;
void emitCalleeSavedFrameMoves(MachineFunction &MF, unsigned LabelId, void emitCalleeSavedFrameMoves(MachineFunction &MF, MCSymbol *Label,
unsigned FramePtr) const; unsigned FramePtr) const;
void emitPrologue(MachineFunction &MF) const; void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;

View File

@ -429,11 +429,9 @@ bool XCoreInstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
storeRegToStackSlot(MBB, MI, it->getReg(), true, storeRegToStackSlot(MBB, MI, it->getReg(), true,
it->getFrameIdx(), it->getRegClass()); it->getFrameIdx(), it->getRegClass());
if (emitFrameMoves) { if (emitFrameMoves) {
unsigned SaveLabelId = MMI->NextLabelID(); MCSymbol *SaveLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MI, DL, get(XCore::DBG_LABEL)) BuildMI(MBB, MI, DL, get(XCore::DBG_LABEL)).addSym(SaveLabel);
.addSym(MMI->getLabelSym(SaveLabelId)); XFI->getSpillLabels().push_back(std::make_pair(SaveLabel, *it));
XFI->getSpillLabels().push_back(
std::pair<unsigned, CalleeSavedInfo>(SaveLabelId, *it));
} }
} }
return true; return true;

View File

@ -31,7 +31,7 @@ private:
int LRSpillSlot; int LRSpillSlot;
int FPSpillSlot; int FPSpillSlot;
int VarArgsFrameIndex; int VarArgsFrameIndex;
std::vector<std::pair<unsigned, CalleeSavedInfo> > SpillLabels; std::vector<std::pair<MCSymbol*, CalleeSavedInfo> > SpillLabels;
public: public:
XCoreFunctionInfo() : XCoreFunctionInfo() :
@ -60,7 +60,7 @@ public:
void setFPSpillSlot(int off) { FPSpillSlot = off; } void setFPSpillSlot(int off) { FPSpillSlot = off; }
int getFPSpillSlot() const { return FPSpillSlot; } int getFPSpillSlot() const { return FPSpillSlot; }
std::vector<std::pair<unsigned, CalleeSavedInfo> >&getSpillLabels() { std::vector<std::pair<MCSymbol*, CalleeSavedInfo> > &getSpillLabels() {
return SpillLabels; return SpillLabels;
} }
}; };

View File

@ -456,18 +456,17 @@ void XCoreRegisterInfo::emitPrologue(MachineFunction &MF) const {
std::vector<MachineMove> &Moves = MMI->getFrameMoves(); std::vector<MachineMove> &Moves = MMI->getFrameMoves();
// Show update of SP. // Show update of SP.
unsigned FrameLabelId = MMI->NextLabelID(); MCSymbol *FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
MachineLocation SPDst(MachineLocation::VirtualFP); MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize * 4); MachineLocation SPSrc(MachineLocation::VirtualFP, -FrameSize * 4);
Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); Moves.push_back(MachineMove(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(FrameLabelId, CSDst, CSSrc)); Moves.push_back(MachineMove(FrameLabel, CSDst, CSSrc));
} }
} }
if (saveLR) { if (saveLR) {
@ -476,13 +475,11 @@ void XCoreRegisterInfo::emitPrologue(MachineFunction &MF) const {
MBB.addLiveIn(XCore::LR); MBB.addLiveIn(XCore::LR);
if (emitFrameMoves) { if (emitFrameMoves) {
unsigned SaveLRLabelId = MMI->NextLabelID(); MCSymbol *SaveLRLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)).addSym(SaveLRLabel);
.addSym(MMI->getLabelSym(SaveLRLabelId));
MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset); MachineLocation CSDst(MachineLocation::VirtualFP, LRSpillOffset);
MachineLocation CSSrc(XCore::LR); MachineLocation CSSrc(XCore::LR);
MMI->getFrameMoves().push_back(MachineMove(SaveLRLabelId, MMI->getFrameMoves().push_back(MachineMove(SaveLRLabel, CSDst, CSSrc));
CSDst, CSSrc));
} }
} }
} }
@ -494,13 +491,11 @@ void XCoreRegisterInfo::emitPrologue(MachineFunction &MF) const {
// R10 is live-in. It is killed at the spill. // R10 is live-in. It is killed at the spill.
MBB.addLiveIn(XCore::R10); MBB.addLiveIn(XCore::R10);
if (emitFrameMoves) { if (emitFrameMoves) {
unsigned SaveR10LabelId = MMI->NextLabelID(); MCSymbol *SaveR10Label = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)).addSym(SaveR10Label);
.addSym(MMI->getLabelSym(SaveR10LabelId));
MachineLocation CSDst(MachineLocation::VirtualFP, FPSpillOffset); MachineLocation CSDst(MachineLocation::VirtualFP, FPSpillOffset);
MachineLocation CSSrc(XCore::R10); MachineLocation CSSrc(XCore::R10);
MMI->getFrameMoves().push_back(MachineMove(SaveR10LabelId, MMI->getFrameMoves().push_back(MachineMove(SaveR10Label, CSDst, CSSrc));
CSDst, CSSrc));
} }
// Set the FP from the SP. // Set the FP from the SP.
unsigned FramePtr = XCore::R10; unsigned FramePtr = XCore::R10;
@ -508,22 +503,21 @@ void XCoreRegisterInfo::emitPrologue(MachineFunction &MF) const {
.addImm(0); .addImm(0);
if (emitFrameMoves) { if (emitFrameMoves) {
// Show FP is now valid. // Show FP is now valid.
unsigned FrameLabelId = MMI->NextLabelID(); MCSymbol *FrameLabel = MMI->getLabelSym(MMI->NextLabelID());
BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)) BuildMI(MBB, MBBI, dl, TII.get(XCore::DBG_LABEL)).addSym(FrameLabel);
.addSym(MMI->getLabelSym(FrameLabelId));
MachineLocation SPDst(FramePtr); MachineLocation SPDst(FramePtr);
MachineLocation SPSrc(MachineLocation::VirtualFP); MachineLocation SPSrc(MachineLocation::VirtualFP);
MMI->getFrameMoves().push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); MMI->getFrameMoves().push_back(MachineMove(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<MachineMove> &Moves = MMI->getFrameMoves();
std::vector<std::pair<unsigned, 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) {
unsigned SpillLabel = SpillLabels[I].first; MCSymbol *SpillLabel = SpillLabels[I].first;
CalleeSavedInfo &CSI = SpillLabels[I].second; CalleeSavedInfo &CSI = SpillLabels[I].second;
int Offset = MFI->getObjectOffset(CSI.getFrameIdx()); int Offset = MFI->getObjectOffset(CSI.getFrameIdx());
unsigned Reg = CSI.getReg(); unsigned Reg = CSI.getReg();