[llvm-commits] [llvm] r129378 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCDwarf.cpp lib/MC/MCParser/AsmParser.cpp lib/MC/MCStreamer.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue Apr 12 11:53:30 PDT 2011
Author: rafael
Date: Tue Apr 12 13:53:30 2011
New Revision: 129378
URL: http://llvm.org/viewvc/llvm-project?rev=129378&view=rev
Log:
Remove LastOffset from the asm parser.
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCDwarf.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=129378&r1=129377&r2=129378&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Apr 12 13:53:30 2011
@@ -448,6 +448,7 @@
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.
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=129378&r1=129377&r2=129378&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Tue Apr 12 13:53:30 2011
@@ -523,6 +523,7 @@
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) {
@@ -535,7 +536,11 @@
Streamer.EmitULEB128IntValue(Src.getReg());
}
- CFAOffset = -Src.getOffset();
+ if (IsRelative)
+ CFAOffset += Src.getOffset();
+ else
+ CFAOffset = -Src.getOffset();
+
Streamer.EmitULEB128IntValue(CFAOffset, 1);
return;
}
@@ -549,7 +554,6 @@
unsigned Reg = Src.getReg();
- const bool IsRelative = Instr.getOperation() == MCCFIInstruction::RelMove;
int Offset = Dst.getOffset();
if (IsRelative)
Offset -= CFAOffset;
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=129378&r1=129377&r2=129378&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Apr 12 13:53:30 2011
@@ -81,11 +81,6 @@
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;
@@ -145,14 +140,6 @@
/// }
- int64_t adjustLastOffset(int64_t Adjustment) {
- LastOffset += Adjustment;
- return LastOffset;
- }
- void setLastOffset(int64_t Offset) {
- LastOffset = Offset;
- }
-
private:
void CheckForValidSection();
@@ -337,7 +324,7 @@
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));
@@ -2334,8 +2321,6 @@
if (getParser().ParseAbsoluteExpression(Offset))
return true;
- getParser().setLastOffset(Offset);
-
return getStreamer().EmitCFIDefCfaOffset(Offset);
}
@@ -2347,9 +2332,8 @@
if (getParser().ParseAbsoluteExpression(Adjustment))
return true;
- int64_t Offset = getParser().adjustLastOffset(Adjustment);
-
- return getStreamer().EmitCFIDefCfaOffset(Offset);
+ getStreamer().EmitCFIAdjustCfaOffset(Adjustment);
+ return false;
}
/// ParseDirectiveCFIDefCfaRegister
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=129378&r1=129377&r2=129378&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Tue Apr 12 13:53:30 2011
@@ -197,6 +197,17 @@
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();
More information about the llvm-commits
mailing list