Some refactoring suggested by Anton Korobeynikov.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129600 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-04-15 20:32:03 +00:00
parent ca3f6a3925
commit 126ae68152
3 changed files with 30 additions and 41 deletions

View File

@ -391,6 +391,7 @@ namespace llvm {
/// frame.
void EmitFrameMoves(const std::vector<MachineMove> &Moves,
MCSymbol *BaseLabel, bool isEH) const;
void EmitCFIFrameMove(const MachineMove &Move) const;
void EmitCFIFrameMoves(const std::vector<MachineMove> &Moves) const;
//===------------------------------------------------------------------===//

View File

@ -644,24 +644,7 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) {
}
}
assert(Move);
const MachineLocation &Dst = Move->getDestination();
const MachineLocation &Src = Move->getSource();
const TargetAsmInfo &AsmInfo = OutContext.getTargetAsmInfo();
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
if (Src.getReg() == MachineLocation::VirtualFP)
OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
else {
unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
OutStreamer.EmitCFIDefCfa(Reg, -Src.getOffset());
}
} else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
unsigned Reg = AsmInfo.getDwarfRegNum(Dst.getReg(), true);
OutStreamer.EmitCFIDefCfaRegister(Reg);
} else {
unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
OutStreamer.EmitCFIOffset(Reg, -Dst.getOffset());
}
EmitCFIFrameMove(*Move);
}
/// EmitFunctionBody - This method emits the body and trailer for a

View File

@ -277,37 +277,42 @@ void AsmPrinter::EmitFrameMoves(const std::vector<MachineMove> &Moves,
}
}
/// EmitFrameMoves - Emit a frame instruction.
void AsmPrinter::EmitCFIFrameMove(const MachineMove &Move) const {
const TargetRegisterInfo *RI = TM.getRegisterInfo();
const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource();
// If advancing cfa.
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
assert(!Src.isReg() && "Machine move not supported yet.");
if (Src.getReg() == MachineLocation::VirtualFP) {
OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
} else {
assert("Machine move not supported yet");
// Reg + Offset
}
} else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
assert(Dst.isReg() && "Machine move not supported yet.");
OutStreamer.EmitCFIDefCfaRegister(RI->getDwarfRegNum(Dst.getReg(), true));
} else {
assert(!Dst.isReg() && "Machine move not supported yet.");
OutStreamer.EmitCFIOffset(RI->getDwarfRegNum(Src.getReg(), true),
-Dst.getOffset());
}
}
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
/// frame.
void AsmPrinter::EmitCFIFrameMoves(const std::vector<MachineMove> &Moves) const {
const TargetRegisterInfo *RI = TM.getRegisterInfo();
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
const MachineMove &Move = Moves[i];
MCSymbol *Label = Move.getLabel();
// Throw out move if the label is invalid.
if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
const MachineLocation &Dst = Move.getDestination();
const MachineLocation &Src = Move.getSource();
// If advancing cfa.
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
assert(!Src.isReg() && "Machine move not supported yet.");
if (Src.getReg() == MachineLocation::VirtualFP) {
OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
} else {
assert("Machine move not supported yet");
// Reg + Offset
}
} else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
assert(Dst.isReg() && "Machine move not supported yet.");
OutStreamer.EmitCFIDefCfaRegister(RI->getDwarfRegNum(Dst.getReg(), true));
} else {
assert(!Dst.isReg() && "Machine move not supported yet.");
OutStreamer.EmitCFIOffset(RI->getDwarfRegNum(Src.getReg(), true),
Dst.getOffset());
}
EmitCFIFrameMove(Move);
}
}