virtual bool EmitCFIRestoreState();
void EmitCFISameValue(int64_t Register);
void EmitCFIRelOffset(int64_t Register, int64_t Offset);
+ void EmitCFIAdjustCfaOffset(int64_t Adjustment);
/// EmitInstruction - Emit the given @p Instruction into the current
/// section.
case MCCFIInstruction::RelMove: {
const MachineLocation &Dst = Instr.getDestination();
const MachineLocation &Src = Instr.getSource();
+ const bool IsRelative = Instr.getOperation() == MCCFIInstruction::RelMove;
// If advancing cfa.
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
Streamer.EmitULEB128IntValue(Src.getReg());
}
- CFAOffset = -Src.getOffset();
+ if (IsRelative)
+ CFAOffset += Src.getOffset();
+ else
+ CFAOffset = -Src.getOffset();
+
Streamer.EmitULEB128IntValue(CFAOffset, 1);
return;
}
unsigned Reg = Src.getReg();
- const bool IsRelative = Instr.getOperation() == MCCFIInstruction::RelMove;
int Offset = Dst.getOffset();
if (IsRelative)
Offset -= CFAOffset;
MCAsmParserExtension *GenericParser;
MCAsmParserExtension *PlatformParser;
- // FIXME: This is not the best place to store this. To handle a (for example)
- // .cfi_rel_offset before a .cfi_def_cfa_offset we need to know the initial
- // frame state.
- int64_t LastOffset;
-
/// This is the current buffer index we're lexing from as managed by the
/// SourceMgr object.
int CurBuffer;
/// }
- int64_t adjustLastOffset(int64_t Adjustment) {
- LastOffset += Adjustment;
- return LastOffset;
- }
- void setLastOffset(int64_t Offset) {
- LastOffset = Offset;
- }
-
private:
void CheckForValidSection();
AsmParser::AsmParser(const Target &T, SourceMgr &_SM, MCContext &_Ctx,
MCStreamer &_Out, const MCAsmInfo &_MAI)
: Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM),
- GenericParser(new GenericAsmParser), PlatformParser(0), LastOffset(0),
+ GenericParser(new GenericAsmParser), PlatformParser(0),
CurBuffer(0), MacrosEnabled(true) {
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
if (getParser().ParseAbsoluteExpression(Offset))
return true;
- getParser().setLastOffset(Offset);
-
return getStreamer().EmitCFIDefCfaOffset(Offset);
}
if (getParser().ParseAbsoluteExpression(Adjustment))
return true;
- int64_t Offset = getParser().adjustLastOffset(Adjustment);
-
- return getStreamer().EmitCFIDefCfaOffset(Offset);
+ getStreamer().EmitCFIAdjustCfaOffset(Adjustment);
+ return false;
}
/// ParseDirectiveCFIDefCfaRegister
return false;
}
+void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
+ EnsureValidFrame();
+ MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
+ MCSymbol *Label = getContext().CreateTempSymbol();
+ EmitLabel(Label);
+ MachineLocation Dest(MachineLocation::VirtualFP);
+ MachineLocation Source(MachineLocation::VirtualFP, Adjustment);
+ MCCFIInstruction Instruction(MCCFIInstruction::RelMove, Label, Dest, Source);
+ CurFrame->Instructions.push_back(Instruction);
+}
+
bool MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();