[llvm] r238158 - Move MCSectionData to MCSection.h.

Rafael Espindola rafael.espindola at gmail.com
Mon May 25 15:57:49 PDT 2015


Author: rafael
Date: Mon May 25 17:57:48 2015
New Revision: 238158

URL: http://llvm.org/viewvc/llvm-project?rev=238158&view=rev
Log:
Move MCSectionData to MCSection.h.

Another step in merging MCSectionData and MCSection.

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

Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=238158&r1=238157&r2=238158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon May 25 17:57:48 2015
@@ -21,6 +21,7 @@
 #include "llvm/MC/MCFixup.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCLinkerOptimizationHint.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/Casting.h"
@@ -530,75 +531,6 @@ public:
   }
 };
 
-// FIXME: Should this be a separate class, or just merged into MCSection? Since
-// we anticipate the fast path being through an MCAssembler, the only reason to
-// keep it out is for API abstraction.
-class MCSectionData : public ilist_node<MCSectionData> {
-  friend class MCAsmLayout;
-
-  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:
-  // Only for use as sentinel.
-  MCSectionData();
-  MCSectionData(MCSection &Section);
-
-  MCSection &getSection() const { return *Section; }
-
-  /// \name Fragment Access
-  /// @{
-
-  const FragmentListType &getFragmentList() const { return Fragments; }
-  FragmentListType &getFragmentList() { return Fragments; }
-
-  iterator begin() { return Fragments.begin(); }
-  const_iterator begin() const { return Fragments.begin(); }
-
-  iterator end() { return Fragments.end(); }
-  const_iterator end() const { return Fragments.end(); }
-
-  reverse_iterator rbegin() { return Fragments.rbegin(); }
-  const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
-
-  reverse_iterator rend() { return Fragments.rend(); }
-  const_reverse_iterator rend() const { return Fragments.rend(); }
-
-  size_t size() const { return Fragments.size(); }
-
-  bool empty() const { return Fragments.empty(); }
-
-  iterator getSubsectionInsertionPoint(unsigned Subsection);
-
-  void dump();
-
-  /// @}
-};
-
 // FIXME: This really doesn't belong here. See comments below.
 struct IndirectSymbolData {
   MCSymbol *Symbol;

Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=238158&r1=238157&r2=238158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Mon May 25 17:57:48 2015
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/MC/MCAssembler.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
 
 namespace llvm {

Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=238158&r1=238157&r2=238158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Mon May 25 17:57:48 2015
@@ -14,17 +14,97 @@
 #ifndef LLVM_MC_MCSECTION_H
 #define LLVM_MC_MCSECTION_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ilist.h"
+#include "llvm/ADT/ilist_node.h"
 #include "llvm/MC/SectionKind.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
+class MCAssembler;
 class MCAsmInfo;
 class MCContext;
 class MCExpr;
+class MCFragment;
+class MCSection;
 class MCSymbol;
 class raw_ostream;
 
+class MCSectionData : public ilist_node<MCSectionData> {
+  friend class MCAsmLayout;
+
+  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:
+  // Only for use as sentinel.
+  MCSectionData();
+  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();
+  }
+
+  size_t size() const;
+
+  bool empty() const;
+
+  iterator getSubsectionInsertionPoint(unsigned Subsection);
+
+  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 {

Modified: llvm/trunk/lib/MC/MCSection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSection.cpp?rev=238158&r1=238157&r2=238158&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSection.cpp (original)
+++ llvm/trunk/lib/MC/MCSection.cpp Mon May 25 17:57:48 2015
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCSymbol.h"
@@ -47,3 +48,19 @@ void MCSection::setBundleLockState(Bundl
   }
   ++BundleLockNestingDepth;
 }
+
+MCSectionData::iterator MCSectionData::begin() { return Fragments.begin(); }
+
+MCSectionData::iterator MCSectionData::end() { return Fragments.end(); }
+
+MCSectionData::reverse_iterator MCSectionData::rbegin() {
+  return Fragments.rbegin();
+}
+
+MCSectionData::reverse_iterator MCSectionData::rend() {
+  return Fragments.rend();
+}
+
+size_t MCSectionData::size() const { return Fragments.size(); }
+
+bool MCSectionData::empty() const { return Fragments.empty(); }





More information about the llvm-commits mailing list