Be consistent about being virtual and returning void in the cfi methods.

Implement the ones that were missing in the asm streamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129413 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-04-12 23:59:07 +00:00
parent 55e6419b12
commit 066c2f495a
4 changed files with 108 additions and 88 deletions

View File

@ -435,20 +435,19 @@ namespace llvm {
void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
int PointerSize);
virtual bool EmitCFIStartProc();
virtual bool EmitCFIEndProc();
virtual bool EmitCFIDefCfa(int64_t Register, int64_t Offset);
virtual bool EmitCFIDefCfaOffset(int64_t Offset);
virtual bool EmitCFIDefCfaRegister(int64_t Register);
virtual bool EmitCFIOffset(int64_t Register, int64_t Offset);
virtual bool EmitCFIPersonality(const MCSymbol *Sym,
unsigned Encoding);
virtual bool EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
virtual bool EmitCFIRememberState();
virtual bool EmitCFIRestoreState();
void EmitCFISameValue(int64_t Register);
void EmitCFIRelOffset(int64_t Register, int64_t Offset);
void EmitCFIAdjustCfaOffset(int64_t Adjustment);
virtual void EmitCFIStartProc();
virtual void EmitCFIEndProc();
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
virtual void EmitCFIDefCfaOffset(int64_t Offset);
virtual void EmitCFIDefCfaRegister(int64_t Register);
virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
virtual void EmitCFIRememberState();
virtual void EmitCFIRestoreState();
virtual void EmitCFISameValue(int64_t Register);
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
/// EmitInstruction - Emit the given @p Instruction into the current
/// section.

View File

@ -184,13 +184,19 @@ public:
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator);
virtual bool EmitCFIStartProc();
virtual bool EmitCFIEndProc();
virtual bool EmitCFIDefCfaOffset(int64_t Offset);
virtual bool EmitCFIDefCfaRegister(int64_t Register);
virtual bool EmitCFIOffset(int64_t Register, int64_t Offset);
virtual bool EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
virtual bool EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
virtual void EmitCFIStartProc();
virtual void EmitCFIEndProc();
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
virtual void EmitCFIDefCfaOffset(int64_t Offset);
virtual void EmitCFIDefCfaRegister(int64_t Register);
virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
virtual void EmitCFIRememberState();
virtual void EmitCFIRestoreState();
virtual void EmitCFISameValue(int64_t Register);
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
virtual void EmitFnStart();
virtual void EmitFnEnd();
@ -714,75 +720,93 @@ void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
EmitEOL();
}
bool MCAsmStreamer::EmitCFIStartProc() {
if (this->MCStreamer::EmitCFIStartProc())
return true;
void MCAsmStreamer::EmitCFIStartProc() {
MCStreamer::EmitCFIStartProc();
OS << "\t.cfi_startproc";
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFIEndProc() {
if (this->MCStreamer::EmitCFIEndProc())
return true;
void MCAsmStreamer::EmitCFIEndProc() {
MCStreamer::EmitCFIEndProc();
OS << "\t.cfi_endproc";
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
if (this->MCStreamer::EmitCFIDefCfaOffset(Offset))
return true;
void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
abort();
}
void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
MCStreamer::EmitCFIDefCfaOffset(Offset);
OS << "\t.cfi_def_cfa_offset " << Offset;
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
if (this->MCStreamer::EmitCFIDefCfaRegister(Register))
return true;
void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
MCStreamer::EmitCFIDefCfaRegister(Register);
OS << "\t.cfi_def_cfa_register " << Register;
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
if (this->MCStreamer::EmitCFIOffset(Register, Offset))
return true;
void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
this->MCStreamer::EmitCFIOffset(Register, Offset);
OS << "\t.cfi_offset " << Register << ", " << Offset;
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
unsigned Encoding) {
if (this->MCStreamer::EmitCFIPersonality(Sym, Encoding))
return true;
MCStreamer::EmitCFIPersonality(Sym, Encoding);
OS << "\t.cfi_personality " << Encoding << ", " << *Sym;
EmitEOL();
return false;
}
bool MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
if (this->MCStreamer::EmitCFILsda(Sym, Encoding))
return true;
void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
MCStreamer::EmitCFILsda(Sym, Encoding);
OS << "\t.cfi_lsda " << Encoding << ", " << *Sym;
EmitEOL();
}
return false;
void MCAsmStreamer::EmitCFIRememberState() {
MCStreamer::EmitCFIRememberState();
OS << "\t.cfi_remember_state";
EmitEOL();
}
void MCAsmStreamer::EmitCFIRestoreState() {
MCStreamer::EmitCFIRestoreState();
OS << "\t.cfi_restore_state";
EmitEOL();
}
void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
MCStreamer::EmitCFISameValue(Register);
OS << "\t.cfi_same_value " << Register;
EmitEOL();
}
void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
MCStreamer::EmitCFIRelOffset(Register, Offset);
OS << "\t.cfi_rel_offset " << Register << ", " << Offset;
EmitEOL();
}
void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
MCStreamer::EmitCFIAdjustCfaOffset(Adjustment);
OS << "\t.cfi_adjust_cfa_offset " << Adjustment;
EmitEOL();
}
void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {

View File

@ -2269,13 +2269,15 @@ bool GenericAsmParser::ParseDirectiveStabs(StringRef Directive,
/// ::= .cfi_startproc
bool GenericAsmParser::ParseDirectiveCFIStartProc(StringRef,
SMLoc DirectiveLoc) {
return getStreamer().EmitCFIStartProc();
getStreamer().EmitCFIStartProc();
return false;
}
/// ParseDirectiveCFIEndProc
/// ::= .cfi_endproc
bool GenericAsmParser::ParseDirectiveCFIEndProc(StringRef, SMLoc DirectiveLoc) {
return getStreamer().EmitCFIEndProc();
getStreamer().EmitCFIEndProc();
return false;
}
/// ParseRegisterOrRegisterNumber - parse register name or number.
@ -2310,7 +2312,8 @@ bool GenericAsmParser::ParseDirectiveCFIDefCfa(StringRef,
if (getParser().ParseAbsoluteExpression(Offset))
return true;
return getStreamer().EmitCFIDefCfa(Register, Offset);
getStreamer().EmitCFIDefCfa(Register, Offset);
return false;
}
/// ParseDirectiveCFIDefCfaOffset
@ -2321,7 +2324,8 @@ bool GenericAsmParser::ParseDirectiveCFIDefCfaOffset(StringRef,
if (getParser().ParseAbsoluteExpression(Offset))
return true;
return getStreamer().EmitCFIDefCfaOffset(Offset);
getStreamer().EmitCFIDefCfaOffset(Offset);
return false;
}
/// ParseDirectiveCFIAdjustCfaOffset
@ -2344,7 +2348,8 @@ bool GenericAsmParser::ParseDirectiveCFIDefCfaRegister(StringRef,
if (ParseRegisterOrRegisterNumber(Register, DirectiveLoc))
return true;
return getStreamer().EmitCFIDefCfaRegister(Register);
getStreamer().EmitCFIDefCfaRegister(Register);
return false;
}
/// ParseDirectiveCFIOffset
@ -2363,7 +2368,8 @@ bool GenericAsmParser::ParseDirectiveCFIOffset(StringRef, SMLoc DirectiveLoc) {
if (getParser().ParseAbsoluteExpression(Offset))
return true;
return getStreamer().EmitCFIOffset(Register, Offset);
getStreamer().EmitCFIOffset(Register, Offset);
return false;
}
/// ParseDirectiveCFIRelOffset
@ -2434,25 +2440,28 @@ bool GenericAsmParser::ParseDirectiveCFIPersonalityOrLsda(StringRef IDVal,
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
if (IDVal == ".cfi_personality")
return getStreamer().EmitCFIPersonality(Sym, Encoding);
getStreamer().EmitCFIPersonality(Sym, Encoding);
else {
assert(IDVal == ".cfi_lsda");
return getStreamer().EmitCFILsda(Sym, Encoding);
getStreamer().EmitCFILsda(Sym, Encoding);
}
return false;
}
/// ParseDirectiveCFIRememberState
/// ::= .cfi_remember_state
bool GenericAsmParser::ParseDirectiveCFIRememberState(StringRef IDVal,
SMLoc DirectiveLoc) {
return getStreamer().EmitCFIRememberState();
getStreamer().EmitCFIRememberState();
return false;
}
/// ParseDirectiveCFIRestoreState
/// ::= .cfi_remember_state
bool GenericAsmParser::ParseDirectiveCFIRestoreState(StringRef IDVal,
SMLoc DirectiveLoc) {
return getStreamer().EmitCFIRestoreState();
getStreamer().EmitCFIRestoreState();
return false;
}
/// ParseDirectiveCFISameValue

View File

@ -152,28 +152,24 @@ void MCStreamer::EnsureValidFrame() {
report_fatal_error("No open frame");
}
bool MCStreamer::EmitCFIStartProc() {
void MCStreamer::EmitCFIStartProc() {
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
if (CurFrame && !CurFrame->End) {
if (CurFrame && !CurFrame->End)
report_fatal_error("Starting a frame before finishing the previous one!");
return true;
}
MCDwarfFrameInfo Frame;
Frame.Begin = getContext().CreateTempSymbol();
EmitLabel(Frame.Begin);
FrameInfos.push_back(Frame);
return false;
}
bool MCStreamer::EmitCFIEndProc() {
void MCStreamer::EmitCFIEndProc() {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
CurFrame->End = getContext().CreateTempSymbol();
EmitLabel(CurFrame->End);
return false;
}
bool MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
MCSymbol *Label = getContext().CreateTempSymbol();
@ -182,10 +178,9 @@ bool MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
MachineLocation Source(Register, -Offset);
MCCFIInstruction Instruction(Label, Dest, Source);
CurFrame->Instructions.push_back(Instruction);
return false;
}
bool MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
void MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
MCSymbol *Label = getContext().CreateTempSymbol();
@ -194,7 +189,6 @@ bool MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
MachineLocation Source(MachineLocation::VirtualFP, -Offset);
MCCFIInstruction Instruction(Label, Dest, Source);
CurFrame->Instructions.push_back(Instruction);
return false;
}
void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
@ -208,7 +202,7 @@ void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
CurFrame->Instructions.push_back(Instruction);
}
bool MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
void MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
MCSymbol *Label = getContext().CreateTempSymbol();
@ -217,10 +211,9 @@ bool MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
MachineLocation Source(MachineLocation::VirtualFP);
MCCFIInstruction Instruction(Label, Dest, Source);
CurFrame->Instructions.push_back(Instruction);
return false;
}
bool MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
MCSymbol *Label = getContext().CreateTempSymbol();
@ -229,7 +222,6 @@ bool MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
MachineLocation Source(Register, Offset);
MCCFIInstruction Instruction(Label, Dest, Source);
CurFrame->Instructions.push_back(Instruction);
return false;
}
void MCStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
@ -243,34 +235,31 @@ void MCStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
CurFrame->Instructions.push_back(Instruction);
}
bool MCStreamer::EmitCFIPersonality(const MCSymbol *Sym,
void MCStreamer::EmitCFIPersonality(const MCSymbol *Sym,
unsigned Encoding) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
CurFrame->Personality = Sym;
CurFrame->PersonalityEncoding = Encoding;
return false;
}
bool MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
CurFrame->Lsda = Sym;
CurFrame->LsdaEncoding = Encoding;
return false;
}
bool MCStreamer::EmitCFIRememberState() {
void MCStreamer::EmitCFIRememberState() {
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
MCSymbol *Label = getContext().CreateTempSymbol();
EmitLabel(Label);
MCCFIInstruction Instruction(MCCFIInstruction::Remember, Label);
CurFrame->Instructions.push_back(Instruction);
return false;
}
bool MCStreamer::EmitCFIRestoreState() {
void MCStreamer::EmitCFIRestoreState() {
// FIXME: Error if there is no matching cfi_remember_state.
EnsureValidFrame();
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
@ -278,7 +267,6 @@ bool MCStreamer::EmitCFIRestoreState() {
EmitLabel(Label);
MCCFIInstruction Instruction(MCCFIInstruction::Restore, Label);
CurFrame->Instructions.push_back(Instruction);
return false;
}
void MCStreamer::EmitCFISameValue(int64_t Register) {