Implement MCAsmStreamer::EmitDwarfAdvanceFrameAddr.

llvm-svn: 130585
This commit is contained in:
Rafael Espindola 2011-04-30 03:21:04 +00:00
parent 1f41ab05f5
commit 1d1eced025
4 changed files with 40 additions and 22 deletions

View File

@ -67,6 +67,12 @@ namespace llvm {
protected: protected:
MCStreamer(MCContext &Ctx); MCStreamer(MCContext &Ctx);
const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
const MCSymbol *B);
const MCExpr *ForceExpAbs(MCStreamer *Streamer, MCContext &Context,
const MCExpr* Expr);
public: public:
virtual ~MCStreamer(); virtual ~MCStreamer();

View File

@ -127,6 +127,8 @@ public:
virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel, const MCSymbol *LastLabel,
const MCSymbol *Label); const MCSymbol *Label);
virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
const MCSymbol *Label);
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
@ -324,6 +326,15 @@ void MCAsmStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta,
getContext().getTargetAsmInfo().getPointerSize()); getContext().getTargetAsmInfo().getPointerSize());
} }
void MCAsmStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
const MCSymbol *Label) {
EmitIntValue(dwarf::DW_CFA_advance_loc4, 1);
const MCExpr *AddrDelta = BuildSymbolDiff(getContext(), Label, LastLabel);
AddrDelta = ForceExpAbs(this, getContext(), AddrDelta);
EmitValue(AddrDelta, 4);
}
void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
MCSymbolAttr Attribute) { MCSymbolAttr Attribute) {
switch (Attribute) { switch (Attribute) {

View File

@ -121,16 +121,6 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
SD.setOffset(F->getContents().size()); SD.setOffset(F->getContents().size());
} }
static const MCExpr *ForceExpAbs(MCObjectStreamer *Streamer,
MCContext &Context, const MCExpr* Expr) {
if (Context.getAsmInfo().hasAggressiveSymbolFolding())
return Expr;
MCSymbol *ABS = Context.CreateTempSymbol();
Streamer->EmitAssignment(ABS, Expr);
return MCSymbolRefExpr::Create(ABS, Context);
}
void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) { void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) {
int64_t IntValue; int64_t IntValue;
if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) {
@ -205,18 +195,6 @@ void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst) {
IF->getCode().append(Code.begin(), Code.end()); IF->getCode().append(Code.begin(), Code.end());
} }
static const MCExpr *BuildSymbolDiff(MCContext &Context,
const MCSymbol *A, const MCSymbol *B) {
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
const MCExpr *ARef =
MCSymbolRefExpr::Create(A, Variant, Context);
const MCExpr *BRef =
MCSymbolRefExpr::Create(B, Variant, Context);
const MCExpr *AddrDelta =
MCBinaryExpr::Create(MCBinaryExpr::Sub, ARef, BRef, Context);
return AddrDelta;
}
void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta, void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel, const MCSymbol *LastLabel,
const MCSymbol *Label) { const MCSymbol *Label) {

View File

@ -28,6 +28,29 @@ MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx) {
MCStreamer::~MCStreamer() { MCStreamer::~MCStreamer() {
} }
const MCExpr *MCStreamer::BuildSymbolDiff(MCContext &Context,
const MCSymbol *A,
const MCSymbol *B) {
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
const MCExpr *ARef =
MCSymbolRefExpr::Create(A, Variant, Context);
const MCExpr *BRef =
MCSymbolRefExpr::Create(B, Variant, Context);
const MCExpr *AddrDelta =
MCBinaryExpr::Create(MCBinaryExpr::Sub, ARef, BRef, Context);
return AddrDelta;
}
const MCExpr *MCStreamer::ForceExpAbs(MCStreamer *Streamer,
MCContext &Context, const MCExpr* Expr) {
if (Context.getAsmInfo().hasAggressiveSymbolFolding())
return Expr;
MCSymbol *ABS = Context.CreateTempSymbol();
Streamer->EmitAssignment(ABS, Expr);
return MCSymbolRefExpr::Create(ABS, Context);
}
raw_ostream &MCStreamer::GetCommentOS() { raw_ostream &MCStreamer::GetCommentOS() {
// By default, discard comments. // By default, discard comments.
return nulls(); return nulls();