diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-21 00:25:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-21 00:25:49 +0000 |
commit | 74dd8547db8d57522675caed4153a0d47e942575 (patch) | |
tree | 2c31d7c615c0bac9582d7eb1814d8bdc3fcc5487 /llvm/lib/CodeGen/AsmPrinter/DIE.cpp | |
parent | 2d0d096bd16838d7c77422918400514c7c5e5aa0 (diff) | |
download | bcm5719-llvm-74dd8547db8d57522675caed4153a0d47e942575.tar.gz bcm5719-llvm-74dd8547db8d57522675caed4153a0d47e942575.zip |
Make AsmPrinter::EmitLabelOffsetDifference a static helper and simplify.
It had exactly one caller in a position where we know hasSetDirective is true.
llvm-svn: 220250
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DIE.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 25dec5893c6..50ea369b432 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/IR/DataLayout.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Debug.h" @@ -372,6 +373,29 @@ void DIEString::print(raw_ostream &O) const { // DIEEntry Implementation //===----------------------------------------------------------------------===// +/// Emit something like ".long Hi+Offset-Lo" where the size in bytes of the +/// directive is specified by Size and Hi/Lo specify the labels. +static void emitLabelOffsetDifference(MCStreamer &Streamer, const MCSymbol *Hi, + uint64_t Offset, const MCSymbol *Lo, + unsigned Size) { + MCContext &Context = Streamer.getContext(); + + // Emit Hi+Offset - Lo + // Get the Hi+Offset expression. + const MCExpr *Plus = + MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Hi, Context), + MCConstantExpr::Create(Offset, Context), Context); + + // Get the Hi+Offset-Lo expression. + const MCExpr *Diff = MCBinaryExpr::CreateSub( + Plus, MCSymbolRefExpr::Create(Lo, Context), Context); + + // Otherwise, emit with .set (aka assignment). + MCSymbol *SetLabel = Context.CreateTempSymbol(); + Streamer.EmitAssignment(SetLabel, Diff); + Streamer.EmitSymbolValue(SetLabel, Size); +} + /// EmitValue - Emit debug information entry offset. /// void DIEEntry::EmitValue(AsmPrinter *AP, dwarf::Form Form) const { @@ -390,9 +414,9 @@ void DIEEntry::EmitValue(AsmPrinter *AP, dwarf::Form Form) const { AP->EmitLabelPlusOffset(CU->getSectionSym(), Addr, DIEEntry::getRefAddrSize(AP)); else - AP->EmitLabelOffsetDifference(CU->getSectionSym(), Addr, - CU->getSectionSym(), - DIEEntry::getRefAddrSize(AP)); + emitLabelOffsetDifference(AP->OutStreamer, CU->getSectionSym(), Addr, + CU->getSectionSym(), + DIEEntry::getRefAddrSize(AP)); } else AP->EmitInt32(Entry.getOffset()); } |