Move MCSectionData to MCSection.h.

Another step in merging MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238158 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-05-25 22:57:48 +00:00
parent 50c2fe1d5c
commit 5e435847b0
4 changed files with 99 additions and 69 deletions

View File

@ -21,6 +21,7 @@
#include "llvm/MC/MCFixup.h" #include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCLinkerOptimizationHint.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Casting.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. // FIXME: This really doesn't belong here. See comments below.
struct IndirectSymbolData { struct IndirectSymbolData {
MCSymbol *Symbol; MCSymbol *Symbol;

View File

@ -12,6 +12,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
namespace llvm { namespace llvm {

View File

@ -14,17 +14,97 @@
#ifndef LLVM_MC_MCSECTION_H #ifndef LLVM_MC_MCSECTION_H
#define LLVM_MC_MCSECTION_H #define LLVM_MC_MCSECTION_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/MC/SectionKind.h" #include "llvm/MC/SectionKind.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
namespace llvm { namespace llvm {
class MCAssembler;
class MCAsmInfo; class MCAsmInfo;
class MCContext; class MCContext;
class MCExpr; class MCExpr;
class MCFragment;
class MCSection;
class MCSymbol; class MCSymbol;
class raw_ostream; 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 /// Instances of this class represent a uniqued identifier for a section in the
/// current translation unit. The MCContext class uniques and creates these. /// current translation unit. The MCContext class uniques and creates these.
class MCSection { class MCSection {

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSection.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
@ -47,3 +48,19 @@ void MCSection::setBundleLockState(BundleLockStateType NewState) {
} }
++BundleLockNestingDepth; ++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(); }