Remove LastOffset from the asm parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129378 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-04-12 18:53:30 +00:00
parent f9ce2cba42
commit 5d7dcd3335
4 changed files with 21 additions and 21 deletions

View File

@ -448,6 +448,7 @@ namespace llvm {
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.

View File

@ -523,6 +523,7 @@ void FrameEmitterImpl::EmitCFIInstruction(MCStreamer &Streamer,
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 @@ void FrameEmitterImpl::EmitCFIInstruction(MCStreamer &Streamer,
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 @@ void FrameEmitterImpl::EmitCFIInstruction(MCStreamer &Streamer,
unsigned Reg = Src.getReg();
const bool IsRelative = Instr.getOperation() == MCCFIInstruction::RelMove;
int Offset = Dst.getOffset();
if (IsRelative)
Offset -= CFAOffset;

View File

@ -81,11 +81,6 @@ private:
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 @@ public:
/// }
int64_t adjustLastOffset(int64_t Adjustment) {
LastOffset += Adjustment;
return LastOffset;
}
void setLastOffset(int64_t Offset) {
LastOffset = Offset;
}
private:
void CheckForValidSection();
@ -337,7 +324,7 @@ enum { DEFAULT_ADDRSPACE = 0 };
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 @@ bool GenericAsmParser::ParseDirectiveCFIDefCfaOffset(StringRef,
if (getParser().ParseAbsoluteExpression(Offset))
return true;
getParser().setLastOffset(Offset);
return getStreamer().EmitCFIDefCfaOffset(Offset);
}
@ -2347,9 +2332,8 @@ bool GenericAsmParser::ParseDirectiveCFIAdjustCfaOffset(StringRef,
if (getParser().ParseAbsoluteExpression(Adjustment))
return true;
int64_t Offset = getParser().adjustLastOffset(Adjustment);
return getStreamer().EmitCFIDefCfaOffset(Offset);
getStreamer().EmitCFIAdjustCfaOffset(Adjustment);
return false;
}
/// ParseDirectiveCFIDefCfaRegister

View File

@ -197,6 +197,17 @@ bool MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
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();