diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-10 20:58:29 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-10 20:58:29 +0000 |
commit | 46836a783ab29f9cb49655d8b9cb8f5538a626fe (patch) | |
tree | c7c88f0bf9b27fff7c734fa98f5d315dfc6dfd08 /include | |
parent | d80066eea98a3d5540d895bb77bc1ad50037f9e9 (diff) |
MC: Move the backend section and symbol data maps to MCAssembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98186 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCAssembler.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 882929f2ee..0a296cd297 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -10,6 +10,7 @@ #ifndef LLVM_MC_MCASSEMBLER_H #define LLVM_MC_MCASSEMBLER_H +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" @@ -587,6 +588,16 @@ private: iplist<MCSymbolData> Symbols; + /// The map of sections to their associated assembler backend data. + // + // FIXME: Avoid this indirection? + DenseMap<const MCSection*, MCSectionData*> SectionMap; + + /// The map of symbols to their associated assembler backend data. + // + // FIXME: Avoid this indirection? + DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap; + std::vector<IndirectSymbolData> IndirectSymbols; unsigned SubsectionsViaSymbols : 1; @@ -673,6 +684,44 @@ public: size_t indirect_symbol_size() const { return IndirectSymbols.size(); } /// @} + /// @name Backend Data Access + /// @{ + + MCSectionData &getSectionData(const MCSection &Section) { + MCSectionData *&Entry = SectionMap[&Section]; + assert(Entry && "Missing section data!"); + return *Entry; + } + + MCSectionData &getOrCreateSectionData(const MCSection &Section, + bool *Created = 0) { + MCSectionData *&Entry = SectionMap[&Section]; + + if (Created) *Created = !Entry; + if (!Entry) + Entry = new MCSectionData(Section, this); + + return *Entry; + } + + MCSymbolData &getSymbolData(const MCSymbol &Symbol) { + MCSymbolData *&Entry = SymbolMap[&Symbol]; + assert(Entry && "Missing symbol data!"); + return *Entry; + } + + MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol, + bool *Created = 0) { + MCSymbolData *&Entry = SymbolMap[&Symbol]; + + if (Created) *Created = !Entry; + if (!Entry) + Entry = new MCSymbolData(Symbol, 0, 0, this); + + return *Entry; + } + + /// @} void dump(); }; |