[llvm] r238331 - Delete MCSectionData.

Rafael Espindola rafael.espindola at gmail.com
Wed May 27 08:14:11 PDT 2015


Author: rafael
Date: Wed May 27 10:14:11 2015
New Revision: 238331

URL: http://llvm.org/viewvc/llvm-project?rev=238331&view=rev
Log:
Delete MCSectionData.

Modified:
    llvm/trunk/include/llvm/MC/MCObjectStreamer.h
    llvm/trunk/include/llvm/MC/MCSection.h
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp
    llvm/trunk/lib/MC/MCObjectStreamer.cpp
    llvm/trunk/lib/MC/MCSection.cpp

Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Wed May 27 10:14:11 2015
@@ -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<MCSymbolData *, 2> PendingLabels;

Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Wed May 27 10:14:11 2015
@@ -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<MCFragment> 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<std::pair<unsigned, MCFragment *>, 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<MCSectionData *>(this)->begin();
-  }
-
-  iterator end();
-  const_iterator end() const {
-    return const_cast<MCSectionData *>(this)->end();
-  }
-
-  reverse_iterator rbegin();
-  const_reverse_iterator rbegin() const {
-    return const_cast<MCSectionData *>(this)->rbegin();
-  }
-
-  reverse_iterator rend();
-  const_reverse_iterator rend() const {
-    return const_cast<MCSectionData *>(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<MCFragment> 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<std::pair<unsigned, MCFragment *>, 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<MCSection *>(this)->getSectionData();
-  }
-
-  MCSectionData::FragmentListType &getFragmentList();
-  const MCSectionData::FragmentListType &getFragmentList() const {
+  MCSection::FragmentListType &getFragmentList() { return Fragments; }
+  const MCSection::FragmentListType &getFragmentList() const {
     return const_cast<MCSection *>(this)->getFragmentList();
   }
 
-  MCSectionData::iterator begin();
-  MCSectionData::const_iterator begin() const {
+  MCSection::iterator begin();
+  MCSection::const_iterator begin() const {
     return const_cast<MCSection *>(this)->begin();
   }
 
-  MCSectionData::iterator end();
-  MCSectionData::const_iterator end() const {
+  MCSection::iterator end();
+  MCSection::const_iterator end() const {
     return const_cast<MCSection *>(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<MCSection *>(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<MCSection *>(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;

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed May 27 10:14:11 2015
@@ -1096,7 +1096,7 @@ ELFObjectWriter::createRelocationSection
 
 static SmallVector<char, 128>
 getUncompressedData(const MCAsmLayout &Layout,
-                    const MCSectionData::FragmentListType &Fragments) {
+                    const MCSection::FragmentListType &Fragments) {
   SmallVector<char, 128> UncompressedData;
   for (const MCFragment &F : Fragments) {
     const SmallVectorImpl<char> *Contents;
@@ -1154,7 +1154,7 @@ void ELFObjectWriter::writeSectionData(c
   }
 
   // Gather the uncompressed data from all the fragments.
-  const MCSectionData::FragmentListType &Fragments = Section.getFragmentList();
+  const MCSection::FragmentListType &Fragments = Section.getFragmentList();
   SmallVector<char, 128> UncompressedData =
       getUncompressedData(Layout, Fragments);
 

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed May 27 10:14:11 2015
@@ -288,10 +288,6 @@ MCEncodedFragmentWithFixups::~MCEncodedF
 
 /* *** */
 
-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
     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
   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<MCEncodedFragmentWithFixups>(it2);
       if (F) {
@@ -1009,7 +1005,7 @@ bool MCAssembler::layoutSectionOnce(MCAs
   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 << "<MCSectionData";
-  OS << " Fragments:[\n      ";
-  for (iterator it = begin(), ie = end(); it != ie; ++it) {
-    if (it != begin()) OS << ",\n      ";
-    it->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:[";

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Wed May 27 10:14:11 2015
@@ -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);

Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Wed May 27 10:14:11 2015
@@ -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();

Modified: llvm/trunk/lib/MC/MCSection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSection.cpp?rev=238331&r1=238330&r2=238331&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSection.cpp (original)
+++ llvm/trunk/lib/MC/MCSection.cpp Wed May 27 10:14:11 2015
@@ -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(Bundl
   ++BundleLockNestingDepth;
 }
 
-MCSectionData::iterator
+MCSection::iterator
 MCSection::getSubsectionInsertionPoint(unsigned Subsection) {
-  if (Subsection == 0 && Data.SubsectionFragmentMap.empty())
+  if (Subsection == 0 && SubsectionFragmentMap.empty())
     return end();
 
   SmallVectorImpl<std::pair<unsigned, MCFragment *>>::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(u
     // 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(u
   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 << "<MCSection";
+  OS << " Fragments:[\n      ";
+  for (auto it = begin(), ie = end(); it != ie; ++it) {
+    if (it != begin())
+      OS << ",\n      ";
+    it->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(); }





More information about the llvm-commits mailing list