AsmPrinter: Refactor DwarfStringPool::getEntry(), NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 24 May 2015 16:06:08 +0000 (16:06 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 24 May 2015 16:06:08 +0000 (16:06 +0000)
Move `DwarfStringPool`'s `getEntry()` to the header (and make it a
member function) in preparation for calculating symbol offsets
on-the-fly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238112 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
lib/CodeGen/AsmPrinter/DwarfStringPool.h

index b7a421f5a1be1a2cdabdd977d600422fbcd6ba08..fc98ed4b78464295b609c605bf729de3c237bf26 100644 (file)
 
 using namespace llvm;
 
-static std::pair<MCSymbol *, unsigned> &
-getEntry(AsmPrinter &Asm,
-         StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> &Pool,
-         StringRef Prefix, StringRef Str) {
+std::pair<MCSymbol *, unsigned> &DwarfStringPool::getEntry(AsmPrinter &Asm,
+                                                           StringRef Str) {
   std::pair<MCSymbol *, unsigned> &Entry = Pool[Str];
   if (!Entry.first) {
     Entry.second = Pool.size() - 1;
@@ -24,14 +22,6 @@ getEntry(AsmPrinter &Asm,
   return Entry;
 }
 
-MCSymbol *DwarfStringPool::getSymbol(AsmPrinter &Asm, StringRef Str) {
-  return getEntry(Asm, Pool, Prefix, Str).first;
-}
-
-unsigned DwarfStringPool::getIndex(AsmPrinter &Asm, StringRef Str) {
-  return getEntry(Asm, Pool, Prefix, Str).second;
-}
-
 void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
                            MCSection *OffsetSection) {
   if (Pool.empty())
index 9f32b98e2b338ceb4014d34e64114fef3d9dffbe..ba0d595c14092c58969d1e5bc82c673210e72f4f 100644 (file)
@@ -37,13 +37,20 @@ public:
 
   /// \brief Returns an entry into the string pool with the given
   /// string text.
-  MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str);
+  MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str) {
+    return getEntry(Asm, Str).first;
+  }
 
   /// \brief Returns the index into the string pool with the given
   /// string text.
-  unsigned getIndex(AsmPrinter &Asm, StringRef Str);
+  unsigned getIndex(AsmPrinter &Asm, StringRef Str) {
+    return getEntry(Asm, Str).second;
+  }
 
   bool empty() const { return Pool.empty(); }
+
+private:
+  std::pair<MCSymbol *, unsigned> &getEntry(AsmPrinter &Asm, StringRef Str);
 };
 }
 #endif