llvm.org GIT mirror llvm / 126ae68
Some refactoring suggested by Anton Korobeynikov. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129600 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 9 years ago
3 changed file(s) with 32 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
390390 /// frame.
391391 void EmitFrameMoves(const std::vector &Moves,
392392 MCSymbol *BaseLabel, bool isEH) const;
393 void EmitCFIFrameMove(const MachineMove &Move) const;
393394 void EmitCFIFrameMoves(const std::vector &Moves) const;
394395
395396 //===------------------------------------------------------------------===//
643643 }
644644 }
645645 assert(Move);
646
647 const MachineLocation &Dst = Move->getDestination();
648 const MachineLocation &Src = Move->getSource();
649 const TargetAsmInfo &AsmInfo = OutContext.getTargetAsmInfo();
650 if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
651 if (Src.getReg() == MachineLocation::VirtualFP)
652 OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
653 else {
654 unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
655 OutStreamer.EmitCFIDefCfa(Reg, -Src.getOffset());
656 }
657 } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
658 unsigned Reg = AsmInfo.getDwarfRegNum(Dst.getReg(), true);
659 OutStreamer.EmitCFIDefCfaRegister(Reg);
660 } else {
661 unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
662 OutStreamer.EmitCFIOffset(Reg, -Dst.getOffset());
663 }
646 EmitCFIFrameMove(*Move);
664647 }
665648
666649 /// EmitFunctionBody - This method emits the body and trailer for a
276276 }
277277 }
278278
279 /// EmitFrameMoves - Emit a frame instruction.
280 void AsmPrinter::EmitCFIFrameMove(const MachineMove &Move) const {
281 const TargetRegisterInfo *RI = TM.getRegisterInfo();
282
283 const MachineLocation &Dst = Move.getDestination();
284 const MachineLocation &Src = Move.getSource();
285
286 // If advancing cfa.
287 if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
288 assert(!Src.isReg() && "Machine move not supported yet.");
289
290 if (Src.getReg() == MachineLocation::VirtualFP) {
291 OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
292 } else {
293 assert("Machine move not supported yet");
294 // Reg + Offset
295 }
296 } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
297 assert(Dst.isReg() && "Machine move not supported yet.");
298 OutStreamer.EmitCFIDefCfaRegister(RI->getDwarfRegNum(Dst.getReg(), true));
299 } else {
300 assert(!Dst.isReg() && "Machine move not supported yet.");
301 OutStreamer.EmitCFIOffset(RI->getDwarfRegNum(Src.getReg(), true),
302 -Dst.getOffset());
303 }
304 }
305
279306 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
280307 /// frame.
281308 void AsmPrinter::EmitCFIFrameMoves(const std::vector &Moves) const {
282 const TargetRegisterInfo *RI = TM.getRegisterInfo();
283
284309 for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
285310 const MachineMove &Move = Moves[i];
286311 MCSymbol *Label = Move.getLabel();
287312 // Throw out move if the label is invalid.
288313 if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
289314
290 const MachineLocation &Dst = Move.getDestination();
291 const MachineLocation &Src = Move.getSource();
292
293 // If advancing cfa.
294 if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
295 assert(!Src.isReg() && "Machine move not supported yet.");
296
297 if (Src.getReg() == MachineLocation::VirtualFP) {
298 OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
299 } else {
300 assert("Machine move not supported yet");
301 // Reg + Offset
302 }
303 } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
304 assert(Dst.isReg() && "Machine move not supported yet.");
305 OutStreamer.EmitCFIDefCfaRegister(RI->getDwarfRegNum(Dst.getReg(), true));
306 } else {
307 assert(!Dst.isReg() && "Machine move not supported yet.");
308 OutStreamer.EmitCFIOffset(RI->getDwarfRegNum(Src.getReg(), true),
309 Dst.getOffset());
310 }
311 }
312 }
315 EmitCFIFrameMove(Move);
316 }
317 }