mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Replace PROLOG_LABEL with a new CFI_INSTRUCTION.
The old system was fairly convoluted: * A temporary label was created. * A single PROLOG_LABEL was created with it. * A few MCCFIInstructions were created with the same label. The semantics were that the cfi instructions were mapped to the PROLOG_LABEL via the temporary label. The output position was that of the PROLOG_LABEL. The temporary label itself was used only for doing the mapping. The new CFI_INSTRUCTION has a 1:1 mapping to MCCFIInstructions and points to one by holding an index into the CFI instructions of this function. I did consider removing MMI.getFrameInstructions completelly and having CFI_INSTRUCTION own a MCCFIInstruction, but MCCFIInstructions have non trivial constructors and destructors and are somewhat big, so the this setup is probably better. The net result is that we don't create temporary labels that are never used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203204 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -353,9 +353,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
assert((isDarwinABI || isSVR4ABI) &&
|
||||
"Currently only Darwin and SVR4 ABIs are supported for PowerPC.");
|
||||
|
||||
// Prepare for frame info.
|
||||
MCSymbol *FrameLabel = 0;
|
||||
|
||||
// Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
|
||||
// process it.
|
||||
if (!isSVR4ABI)
|
||||
@ -561,36 +558,37 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
// Add the "machine moves" for the instructions we generated above, but in
|
||||
// reverse order.
|
||||
if (needsFrameMoves) {
|
||||
// Mark effective beginning of when frame pointer becomes valid.
|
||||
FrameLabel = MMI.getContext().CreateTempSymbol();
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::PROLOG_LABEL)).addSym(FrameLabel);
|
||||
|
||||
// Show update of SP.
|
||||
assert(NegFrameSize);
|
||||
MMI.addFrameInst(
|
||||
MCCFIInstruction::createDefCfaOffset(FrameLabel, NegFrameSize));
|
||||
unsigned CFIIndex = MMI.addFrameInst(
|
||||
MCCFIInstruction::createDefCfaOffset(nullptr, NegFrameSize));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION)).addCFIIndex(CFIIndex);
|
||||
|
||||
if (HasFP) {
|
||||
unsigned Reg = MRI->getDwarfRegNum(FPReg, true);
|
||||
MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(FrameLabel, Reg, FPOffset));
|
||||
CFIIndex = MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(nullptr, Reg, FPOffset));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
}
|
||||
|
||||
if (HasBP) {
|
||||
unsigned Reg = MRI->getDwarfRegNum(BPReg, true);
|
||||
MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(FrameLabel, Reg, BPOffset));
|
||||
CFIIndex = MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(nullptr, Reg, BPOffset));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
}
|
||||
|
||||
if (MustSaveLR) {
|
||||
unsigned Reg = MRI->getDwarfRegNum(LRReg, true);
|
||||
MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(FrameLabel, Reg, LROffset));
|
||||
CFIIndex = MMI.addFrameInst(
|
||||
MCCFIInstruction::createOffset(nullptr, Reg, LROffset));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
}
|
||||
}
|
||||
|
||||
MCSymbol *ReadyLabel = 0;
|
||||
|
||||
// If there is a frame pointer, copy R1 into R31
|
||||
if (HasFP) {
|
||||
BuildMI(MBB, MBBI, dl, OrInst, FPReg)
|
||||
@ -598,19 +596,17 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
.addReg(SPReg);
|
||||
|
||||
if (needsFrameMoves) {
|
||||
ReadyLabel = MMI.getContext().CreateTempSymbol();
|
||||
|
||||
// Mark effective beginning of when frame pointer is ready.
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::PROLOG_LABEL)).addSym(ReadyLabel);
|
||||
|
||||
unsigned Reg = MRI->getDwarfRegNum(FPReg, true);
|
||||
MMI.addFrameInst(MCCFIInstruction::createDefCfaRegister(ReadyLabel, Reg));
|
||||
unsigned CFIIndex = MMI.addFrameInst(
|
||||
MCCFIInstruction::createDefCfaRegister(nullptr, Reg));
|
||||
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (needsFrameMoves) {
|
||||
MCSymbol *Label = HasFP ? ReadyLabel : FrameLabel;
|
||||
|
||||
// Add callee saved registers to move list.
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
@ -631,14 +627,18 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
// For 64-bit SVR4 when we have spilled CRs, the spill location
|
||||
// is SP+8, not a frame-relative slot.
|
||||
if (isSVR4ABI && isPPC64 && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
|
||||
MMI.addFrameInst(MCCFIInstruction::createOffset(
|
||||
Label, MRI->getDwarfRegNum(PPC::CR2, true), 8));
|
||||
unsigned CFIIndex = MMI.addFrameInst(MCCFIInstruction::createOffset(
|
||||
nullptr, MRI->getDwarfRegNum(PPC::CR2, true), 8));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
|
||||
MMI.addFrameInst(MCCFIInstruction::createOffset(
|
||||
Label, MRI->getDwarfRegNum(Reg, true), Offset));
|
||||
unsigned CFIIndex = MMI.addFrameInst(MCCFIInstruction::createOffset(
|
||||
nullptr, MRI->getDwarfRegNum(Reg, true), Offset));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(PPC::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user