summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/MC/MCAssembler.h38
-rw-r--r--llvm/include/llvm/MC/MCSection.h36
2 files changed, 46 insertions, 28 deletions
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index 368846a6efe..427c1099d58 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -12,6 +12,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/ilist.h"
@@ -551,11 +552,11 @@ class MCAssembler {
friend class MCAsmLayout;
public:
- typedef iplist<MCSectionData> SectionDataListType;
+ typedef SetVector<MCSection *> SectionListType;
typedef std::vector<const MCSymbol *> SymbolDataListType;
- typedef SectionDataListType::const_iterator const_iterator;
- typedef SectionDataListType::iterator iterator;
+ typedef pointee_iterator<SectionListType::const_iterator> const_iterator;
+ typedef pointee_iterator<SectionListType::iterator> iterator;
typedef pointee_iterator<SymbolDataListType::const_iterator>
const_symbol_iterator;
@@ -599,17 +600,12 @@ private:
raw_ostream &OS;
- iplist<MCSectionData> Sections;
+ SectionListType Sections;
SymbolDataListType Symbols;
DenseSet<const MCSymbol *> LocalsUsedInReloc;
- /// The map of sections to their associated assembler backend data.
- //
- // FIXME: Avoid this indirection?
- DenseMap<const MCSection *, MCSectionData *> SectionMap;
-
std::vector<IndirectSymbolData> IndirectSymbols;
std::vector<DataRegionData> DataRegions;
@@ -888,24 +884,22 @@ public:
/// \name Backend Data Access
/// @{
- MCSectionData &getSectionData(const MCSection &Section) const {
- MCSectionData *Entry = SectionMap.lookup(&Section);
- assert(Entry && "Missing section data!");
- return *Entry;
+ MCSectionData &getSectionData(MCSection &Section) {
+ assert(Sections.count(&Section) && "Unknown Seciton");
+ return Section.getSectionData();
+ }
+
+ const MCSectionData &getSectionData(const MCSection &Section) const {
+ return const_cast<MCAssembler *>(this)
+ ->getSectionData(const_cast<MCSection &>(Section));
}
MCSectionData &getOrCreateSectionData(MCSection &Section,
bool *Created = nullptr) {
- MCSectionData *&Entry = SectionMap[&Section];
-
+ bool C = Sections.insert(&Section);
if (Created)
- *Created = !Entry;
- if (!Entry) {
- Entry = new MCSectionData(Section);
- Sections.push_back(Entry);
- }
-
- return *Entry;
+ *Created = C;
+ return Section.getSectionData();
}
bool hasSymbolData(const MCSymbol &Symbol) const { return Symbol.hasData(); }
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index 5b1aeda126d..5ca83398bd0 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -31,7 +31,7 @@ class MCSection;
class MCSymbol;
class raw_ostream;
-class MCSectionData : public ilist_node<MCSectionData> {
+class MCSectionData {
friend class MCAsmLayout;
MCSectionData(const MCSectionData &) = delete;
@@ -62,9 +62,7 @@ private:
/// @}
public:
- // Only for use as sentinel.
- MCSectionData();
- MCSectionData(MCSection &Section);
+ explicit MCSectionData(MCSection &Section);
MCSection &getSection() const { return *Section; }
@@ -144,9 +142,10 @@ private:
/// Whether this section has had instructions emitted into it.
unsigned HasInstructions : 1;
+ MCSectionData Data;
+
protected:
- MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
- : Begin(Begin), HasInstructions(false), Variant(V), Kind(K) {}
+ MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin);
SectionVariant Variant;
SectionKind Kind;
@@ -191,6 +190,31 @@ public:
bool hasInstructions() const { return HasInstructions; }
void setHasInstructions(bool Value) { HasInstructions = Value; }
+ MCSectionData &getSectionData() { return Data; }
+ const MCSectionData &getSectionData() const {
+ return const_cast<MCSection *>(this)->getSectionData();
+ }
+
+ MCSectionData::FragmentListType &getFragmentList();
+ const MCSectionData::FragmentListType &getFragmentList() const {
+ return const_cast<MCSection *>(this)->getFragmentList();
+ }
+
+ MCSectionData::iterator begin();
+ MCSectionData::const_iterator begin() const {
+ return const_cast<MCSection *>(this)->begin();
+ }
+
+ MCSectionData::iterator end();
+ MCSectionData::const_iterator end() const {
+ return const_cast<MCSection *>(this)->end();
+ }
+
+ MCSectionData::reverse_iterator rend();
+ MCSectionData::const_reverse_iterator rend() const {
+ return const_cast<MCSection *>(this)->rend();
+ }
+
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
const MCExpr *Subsection) const = 0;
OpenPOWER on IntegriCloud