class MCObjectStreamer : public MCStreamer {
MCAssembler *Assembler;
MCSection *CurSectionData;
- MCSectionData::iterator CurInsertionPoint;
+ MCSection::iterator CurInsertionPoint;
bool EmitEHFrame;
bool EmitDebugFrame;
SmallVector<MCSymbolData *, 2> PendingLabels;
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 {
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;
/// 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);
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;
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;
}
// 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);
/* *** */
-MCSectionData::MCSectionData(MCSection &Section) : Section(&Section) {}
-
-/* *** */
-
MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
raw_ostream &OS_)
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: {
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 ==
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++);
}
// 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) {
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()) {
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();
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:[";
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);
if (Assembler)
Assembler->reset();
CurSectionData = nullptr;
- CurInsertionPoint = MCSectionData::iterator();
+ CurInsertionPoint = MCSection::iterator();
EmitEHFrame = true;
EmitDebugFrame = false;
PendingLabels.clear();
//===----------------------------------------------------------------------===//
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)
++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;
// 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);
}
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(); }