From a32d0e9ec0127d83c44c1d06c2fbf19fd8bfe96c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 27 May 2015 15:14:11 +0000 Subject: [PATCH] Delete MCSectionData. llvm-svn: 238331 --- llvm/include/llvm/MC/MCObjectStreamer.h | 2 +- llvm/include/llvm/MC/MCSection.h | 110 ++++++++------------------------ llvm/lib/MC/ELFObjectWriter.cpp | 4 +- llvm/lib/MC/MCAssembler.cpp | 34 +++------- llvm/lib/MC/MCMachOStreamer.cpp | 4 +- llvm/lib/MC/MCObjectStreamer.cpp | 2 +- llvm/lib/MC/MCSection.cpp | 47 +++++++------- 7 files changed, 64 insertions(+), 139 deletions(-) diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h index 0968a59..e75bc86 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -36,7 +36,7 @@ class raw_pwrite_stream; class MCObjectStreamer : public MCStreamer { MCAssembler *Assembler; MCSection *CurSectionData; - MCSectionData::iterator CurInsertionPoint; + MCSection::iterator CurInsertionPoint; bool EmitEHFrame; bool EmitDebugFrame; SmallVector PendingLabels; diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h index a085d12..96a4ef1 100644 --- a/llvm/include/llvm/MC/MCSection.h +++ b/llvm/include/llvm/MC/MCSection.h @@ -31,73 +31,6 @@ class MCSection; class MCSymbol; class raw_ostream; -class MCSectionData { - friend class MCAsmLayout; - friend class MCSection; - - MCSectionData(const MCSectionData &) = delete; - void operator=(const MCSectionData &) = delete; - -public: - typedef iplist FragmentListType; - - typedef FragmentListType::const_iterator const_iterator; - typedef FragmentListType::iterator iterator; - - typedef FragmentListType::const_reverse_iterator const_reverse_iterator; - typedef FragmentListType::reverse_iterator reverse_iterator; - -private: - FragmentListType Fragments; - MCSection *Section; - - /// \name Assembler Backend Data - /// @{ - // - // FIXME: This could all be kept private to the assembler implementation. - - /// Mapping from subsection number to insertion point for subsection numbers - /// below that number. - SmallVector, 1> SubsectionFragmentMap; - - /// @} - -public: - explicit MCSectionData(MCSection &Section); - - MCSection &getSection() const { return *Section; } - - /// \name Fragment Access - /// @{ - - const FragmentListType &getFragmentList() const { return Fragments; } - FragmentListType &getFragmentList() { return Fragments; } - - iterator begin(); - const_iterator begin() const { - return const_cast(this)->begin(); - } - - iterator end(); - const_iterator end() const { - return const_cast(this)->end(); - } - - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const { - return const_cast(this)->rbegin(); - } - - reverse_iterator rend(); - const_reverse_iterator rend() const { - return const_cast(this)->rend(); - } - - void dump(); - - /// @} -}; - /// Instances of this class represent a uniqued identifier for a section in the /// current translation unit. The MCContext class uniques and creates these. class MCSection { @@ -111,6 +44,14 @@ public: BundleLockedAlignToEnd }; + typedef iplist FragmentListType; + + typedef FragmentListType::const_iterator const_iterator; + typedef FragmentListType::iterator iterator; + + typedef FragmentListType::const_reverse_iterator const_reverse_iterator; + typedef FragmentListType::reverse_iterator reverse_iterator; + private: MCSection(const MCSection &) = delete; void operator=(const MCSection &) = delete; @@ -137,7 +78,11 @@ private: /// Whether this section has had instructions emitted into it. unsigned HasInstructions : 1; - MCSectionData Data; + FragmentListType Fragments; + + /// Mapping from subsection number to insertion point for subsection numbers + /// below that number. + SmallVector, 1> SubsectionFragmentMap; protected: MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin); @@ -185,37 +130,34 @@ public: bool hasInstructions() const { return HasInstructions; } void setHasInstructions(bool Value) { HasInstructions = Value; } - MCSectionData &getSectionData() { return Data; } - const MCSectionData &getSectionData() const { - return const_cast(this)->getSectionData(); - } - - MCSectionData::FragmentListType &getFragmentList(); - const MCSectionData::FragmentListType &getFragmentList() const { + MCSection::FragmentListType &getFragmentList() { return Fragments; } + const MCSection::FragmentListType &getFragmentList() const { return const_cast(this)->getFragmentList(); } - MCSectionData::iterator begin(); - MCSectionData::const_iterator begin() const { + MCSection::iterator begin(); + MCSection::const_iterator begin() const { return const_cast(this)->begin(); } - MCSectionData::iterator end(); - MCSectionData::const_iterator end() const { + MCSection::iterator end(); + MCSection::const_iterator end() const { return const_cast(this)->end(); } - MCSectionData::reverse_iterator rbegin(); - MCSectionData::const_reverse_iterator rbegin() const { + MCSection::reverse_iterator rbegin(); + MCSection::const_reverse_iterator rbegin() const { return const_cast(this)->rbegin(); } - MCSectionData::reverse_iterator rend(); - MCSectionData::const_reverse_iterator rend() const { + MCSection::reverse_iterator rend(); + MCSection::const_reverse_iterator rend() const { return const_cast(this)->rend(); } - MCSectionData::iterator getSubsectionInsertionPoint(unsigned Subsection); + MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection); + + void dump(); virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, const MCExpr *Subsection) const = 0; diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index b51ba75..18746d1 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1096,7 +1096,7 @@ ELFObjectWriter::createRelocationSection(MCContext &Ctx, static SmallVector getUncompressedData(const MCAsmLayout &Layout, - const MCSectionData::FragmentListType &Fragments) { + const MCSection::FragmentListType &Fragments) { SmallVector UncompressedData; for (const MCFragment &F : Fragments) { const SmallVectorImpl *Contents; @@ -1154,7 +1154,7 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec, } // Gather the uncompressed data from all the fragments. - const MCSectionData::FragmentListType &Fragments = Section.getFragmentList(); + const MCSection::FragmentListType &Fragments = Section.getFragmentList(); SmallVector UncompressedData = getUncompressedData(Layout, Fragments); diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index ec2518c..868b0f1 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -288,10 +288,6 @@ MCEncodedFragmentWithFixups::~MCEncodedFragmentWithFixups() { /* *** */ -MCSectionData::MCSectionData(MCSection &Section) : Section(&Section) {} - -/* *** */ - MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_, MCCodeEmitter &Emitter_, MCObjectWriter &Writer_, raw_ostream &OS_) @@ -744,8 +740,8 @@ void MCAssembler::writeSectionData(const MCSection *Sec, assert(Layout.getSectionFileSize(Sec) == 0 && "Invalid size for section!"); // Check that contents are only things legal inside a virtual section. - for (MCSectionData::const_iterator it = Sec->begin(), ie = Sec->end(); - it != ie; ++it) { + for (MCSection::const_iterator it = Sec->begin(), ie = Sec->end(); it != ie; + ++it) { switch (it->getKind()) { default: llvm_unreachable("Invalid fragment in virtual section!"); case MCFragment::FT_Data: { @@ -786,8 +782,8 @@ void MCAssembler::writeSectionData(const MCSection *Sec, uint64_t Start = getWriter().getStream().tell(); (void)Start; - for (MCSectionData::const_iterator it = Sec->begin(), ie = Sec->end(); - it != ie; ++it) + for (MCSection::const_iterator it = Sec->begin(), ie = Sec->end(); it != ie; + ++it) writeFragment(*this, Layout, *it); assert(getWriter().getStream().tell() - Start == @@ -837,7 +833,7 @@ void MCAssembler::Finish() { Sec->setLayoutOrder(i); unsigned FragmentIndex = 0; - for (MCSectionData::iterator iFrag = Sec->begin(), iFragEnd = Sec->end(); + for (MCSection::iterator iFrag = Sec->begin(), iFragEnd = Sec->end(); iFrag != iFragEnd; ++iFrag) iFrag->setLayoutOrder(FragmentIndex++); } @@ -865,8 +861,8 @@ void MCAssembler::Finish() { // Evaluate and apply the fixups, generating relocation entries as necessary. for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) { - for (MCSectionData::iterator it2 = it->begin(), - ie2 = it->end(); it2 != ie2; ++it2) { + for (MCSection::iterator it2 = it->begin(), ie2 = it->end(); it2 != ie2; + ++it2) { MCEncodedFragmentWithFixups *F = dyn_cast(it2); if (F) { @@ -1009,7 +1005,7 @@ bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) { MCFragment *FirstRelaxedFragment = nullptr; // Attempt to relax all the fragments in the section. - for (MCSectionData::iterator I = Sec.begin(), IE = Sec.end(); I != IE; ++I) { + for (MCSection::iterator I = Sec.begin(), IE = Sec.end(); I != IE; ++I) { // Check if this is a fragment that needs relaxation. bool RelaxedFrag = false; switch(I->getKind()) { @@ -1188,18 +1184,6 @@ void MCFragment::dump() { OS << ">"; } -void MCSectionData::dump() { - raw_ostream &OS = llvm::errs(); - - OS << "dump(); - } - OS << "]>"; -} - void MCSymbolData::dump() const { raw_ostream &OS = llvm::errs(); @@ -1225,7 +1209,7 @@ void MCAssembler::dump() { OS << " Sections:[\n "; for (iterator it = begin(), ie = end(); it != ie; ++it) { if (it != begin()) OS << ",\n "; - it->getSectionData().dump(); + it->dump(); } OS << "],\n"; OS << " Symbols:["; diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 011db48..6297340 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -479,8 +479,8 @@ void MCMachOStreamer::FinishImpl() { for (MCAssembler::iterator it = getAssembler().begin(), ie = getAssembler().end(); it != ie; ++it) { const MCSymbol *CurrentAtom = nullptr; - for (MCSectionData::iterator it2 = it->begin(), - ie2 = it->end(); it2 != ie2; ++it2) { + for (MCSection::iterator it2 = it->begin(), ie2 = it->end(); it2 != ie2; + ++it2) { if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(it2)) CurrentAtom = Symbol; it2->setAtom(CurrentAtom); diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 18d2b66..176f5e7 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -80,7 +80,7 @@ void MCObjectStreamer::reset() { if (Assembler) Assembler->reset(); CurSectionData = nullptr; - CurInsertionPoint = MCSectionData::iterator(); + CurInsertionPoint = MCSection::iterator(); EmitEHFrame = true; EmitDebugFrame = false; PendingLabels.clear(); diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp index adfc6b3..26c6aad 100644 --- a/llvm/lib/MC/MCSection.cpp +++ b/llvm/lib/MC/MCSection.cpp @@ -20,7 +20,7 @@ using namespace llvm; //===----------------------------------------------------------------------===// MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin) - : Begin(Begin), HasInstructions(false), Data(*this), Variant(V), Kind(K) {} + : Begin(Begin), HasInstructions(false), Variant(V), Kind(K) {} MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) { if (!End) @@ -52,23 +52,23 @@ void MCSection::setBundleLockState(BundleLockStateType NewState) { ++BundleLockNestingDepth; } -MCSectionData::iterator +MCSection::iterator MCSection::getSubsectionInsertionPoint(unsigned Subsection) { - if (Subsection == 0 && Data.SubsectionFragmentMap.empty()) + if (Subsection == 0 && SubsectionFragmentMap.empty()) return end(); SmallVectorImpl>::iterator MI = - std::lower_bound(Data.SubsectionFragmentMap.begin(), - Data.SubsectionFragmentMap.end(), + std::lower_bound(SubsectionFragmentMap.begin(), + SubsectionFragmentMap.end(), std::make_pair(Subsection, (MCFragment *)nullptr)); bool ExactMatch = false; - if (MI != Data.SubsectionFragmentMap.end()) { + if (MI != SubsectionFragmentMap.end()) { ExactMatch = MI->first == Subsection; if (ExactMatch) ++MI; } - MCSectionData::iterator IP; - if (MI == Data.SubsectionFragmentMap.end()) + iterator IP; + if (MI == SubsectionFragmentMap.end()) IP = end(); else IP = MI->second; @@ -76,7 +76,7 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) { // The GNU as documentation claims that subsections have an alignment of 4, // although this appears not to be the case. MCFragment *F = new MCDataFragment(); - Data.SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F)); + SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F)); getFragmentList().insert(IP, F); F->setParent(this); } @@ -84,24 +84,23 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) { return IP; } -MCSectionData::iterator MCSection::begin() { return Data.begin(); } +void MCSection::dump() { + raw_ostream &OS = llvm::errs(); -MCSectionData::iterator MCSection::end() { return Data.end(); } - -MCSectionData::reverse_iterator MCSection::rbegin() { return Data.rbegin(); } - -MCSectionData::FragmentListType &MCSection::getFragmentList() { - return Data.getFragmentList(); + OS << "dump(); + } + OS << "]>"; } -MCSectionData::iterator MCSectionData::begin() { return Fragments.begin(); } +MCSection::iterator MCSection::begin() { return Fragments.begin(); } -MCSectionData::iterator MCSectionData::end() { return Fragments.end(); } +MCSection::iterator MCSection::end() { return Fragments.end(); } -MCSectionData::reverse_iterator MCSectionData::rbegin() { - return Fragments.rbegin(); -} +MCSection::reverse_iterator MCSection::rbegin() { return Fragments.rbegin(); } -MCSectionData::reverse_iterator MCSectionData::rend() { - return Fragments.rend(); -} +MCSection::reverse_iterator MCSection::rend() { return Fragments.rend(); } -- 2.7.4