From 28c9ea3c13dfb8f6bb3226ba511d189135fcb140 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 24 Nov 2012 02:01:08 +0000 Subject: Refactor how MCCFIInstructions are created. Give MCCFIInstruction a single, private constructor and add helper static methods that create each type of cfi instruction. This is is preparation for changing its representation. The representation with a pair MachineLocations older than MC and has been abused quiet a bit to support more cfi instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168532 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCDwarf.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/MC/MCDwarf.cpp') diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 85b47fe..c9b21e3 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -1264,8 +1264,21 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, TranslateMachineLocation(MRI, Moves[i].getDestination()); const MachineLocation &Src = TranslateMachineLocation(MRI, Moves[i].getSource()); - MCCFIInstruction Inst(Label, Dst, Src); - Instructions.push_back(Inst); + + if (Dst.isReg()) { + assert(Dst.getReg() == MachineLocation::VirtualFP); + assert(!Src.isReg()); + MCCFIInstruction Inst = + MCCFIInstruction::createDefCfa(Label, Src.getReg(), -Src.getOffset()); + Instructions.push_back(Inst); + } else { + assert(Src.isReg()); + unsigned Reg = Src.getReg(); + int Offset = Dst.getOffset(); + MCCFIInstruction Inst = + MCCFIInstruction::createCFIOffset(Label, Reg, Offset); + Instructions.push_back(Inst); + } } EmitCFIInstructions(streamer, Instructions, NULL); -- cgit v1.1