summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-23 21:04:59 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-23 21:04:59 +0000
commite226b08ee99cb1e868e4f48e847199d7fd21aee7 (patch)
tree8ee1a16929dd115ebbca411cb0299506ad562ef5 /llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
parentbe558888499e98ed4c1f0a20ce9178114e86a5e2 (diff)
downloadbcm5719-llvm-e226b08ee99cb1e868e4f48e847199d7fd21aee7.tar.gz
bcm5719-llvm-e226b08ee99cb1e868e4f48e847199d7fd21aee7.zip
Separate out the DWARF address pool into its own type/files.
llvm-svn: 207022
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp b/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
new file mode 100644
index 00000000000..81ef619ba77
--- /dev/null
+++ b/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
@@ -0,0 +1,36 @@
+
+#include "AddressPool.h"
+#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
+
+using namespace llvm;
+
+class MCExpr;
+
+unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
+ auto IterBool =
+ Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
+ return IterBool.first->second.Number;
+}
+
+// Emit addresses into the section given.
+void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) {
+ if (Pool.empty())
+ return;
+
+ // Start the dwarf addr section.
+ Asm.OutStreamer.SwitchSection(AddrSection);
+
+ // Order the address pool entries by ID
+ SmallVector<const MCExpr *, 64> Entries(Pool.size());
+
+ for (const auto &I : Pool)
+ Entries[I.second.Number] =
+ I.second.TLS
+ ? Asm.getObjFileLowering().getDebugThreadLocalSymbol(I.first)
+ : MCSymbolRefExpr::Create(I.first, Asm.OutContext);
+
+ for (const MCExpr *Entry : Entries)
+ Asm.OutStreamer.EmitValue(Entry, Asm.getDataLayout().getPointerSize());
+}
OpenPOWER on IntegriCloud