AsmPrinter: Refactor DwarfStringPool::getEntry(), NFC

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
This commit is contained in:
Duncan P. N. Exon Smith
2015-05-24 16:06:08 +00:00
parent 556ca517ab
commit 8d2d4e2637
2 changed files with 11 additions and 14 deletions

View File

@@ -12,10 +12,8 @@
using namespace llvm; using namespace llvm;
static std::pair<MCSymbol *, unsigned> & std::pair<MCSymbol *, unsigned> &DwarfStringPool::getEntry(AsmPrinter &Asm,
getEntry(AsmPrinter &Asm, StringRef Str) {
StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> &Pool,
StringRef Prefix, StringRef Str) {
std::pair<MCSymbol *, unsigned> &Entry = Pool[Str]; std::pair<MCSymbol *, unsigned> &Entry = Pool[Str];
if (!Entry.first) { if (!Entry.first) {
Entry.second = Pool.size() - 1; Entry.second = Pool.size() - 1;
@@ -24,14 +22,6 @@ getEntry(AsmPrinter &Asm,
return Entry; 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, void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
MCSection *OffsetSection) { MCSection *OffsetSection) {
if (Pool.empty()) if (Pool.empty())

View File

@@ -37,13 +37,20 @@ public:
/// \brief Returns an entry into the string pool with the given /// \brief Returns an entry into the string pool with the given
/// string text. /// 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 /// \brief Returns the index into the string pool with the given
/// string text. /// 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(); } bool empty() const { return Pool.empty(); }
private:
std::pair<MCSymbol *, unsigned> &getEntry(AsmPrinter &Asm, StringRef Str);
}; };
} }
#endif #endif