Have getCurrentSectionData return a MCSection.

I will fix the name shortly.

llvm-svn: 238204
This commit is contained in:
Rafael Espindola 2015-05-26 14:48:11 +00:00
parent e6e287df74
commit 3d2aeb2e20
4 changed files with 19 additions and 26 deletions

View File

@ -36,7 +36,7 @@ class raw_pwrite_stream;
/// implementation. /// implementation.
class MCObjectStreamer : public MCStreamer { class MCObjectStreamer : public MCStreamer {
MCAssembler *Assembler; MCAssembler *Assembler;
MCSectionData *CurSectionData; MCSection *CurSectionData;
MCSectionData::iterator CurInsertionPoint; MCSectionData::iterator CurInsertionPoint;
bool EmitEHFrame; bool EmitEHFrame;
bool EmitDebugFrame; bool EmitDebugFrame;
@ -65,16 +65,14 @@ public:
void EmitCFISections(bool EH, bool Debug) override; void EmitCFISections(bool EH, bool Debug) override;
protected: protected:
MCSectionData *getCurrentSectionData() const { MCSection *getCurrentSectionData() const { return CurSectionData; }
return CurSectionData;
}
MCFragment *getCurrentFragment() const; MCFragment *getCurrentFragment() const;
void insert(MCFragment *F) { void insert(MCFragment *F) {
flushPendingLabels(F); flushPendingLabels(F);
CurSectionData->getFragmentList().insert(CurInsertionPoint, F); CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
F->setParent(&CurSectionData->getSection()); F->setParent(CurSectionData);
} }
/// Get a data fragment to write into, creating a new one if the current /// Get a data fragment to write into, creating a new one if the current

View File

@ -39,7 +39,7 @@
using namespace llvm; using namespace llvm;
bool MCELFStreamer::isBundleLocked() const { bool MCELFStreamer::isBundleLocked() const {
return getCurrentSectionData()->getSection().isBundleLocked(); return getCurrentSectionData()->isBundleLocked();
} }
MCELFStreamer::~MCELFStreamer() { MCELFStreamer::~MCELFStreamer() {
@ -146,9 +146,7 @@ static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
void MCELFStreamer::ChangeSection(MCSection *Section, void MCELFStreamer::ChangeSection(MCSection *Section,
const MCExpr *Subsection) { const MCExpr *Subsection) {
MCSectionData *CurSectionData = getCurrentSectionData(); MCSection *CurSection = getCurrentSectionData();
MCSection *CurSection =
CurSectionData ? &CurSectionData->getSection() : nullptr;
if (CurSection && isBundleLocked()) if (CurSection && isBundleLocked())
report_fatal_error("Unterminated .bundle_lock when changing a section"); report_fatal_error("Unterminated .bundle_lock when changing a section");
@ -203,7 +201,7 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
// important for matching the string table that 'as' generates. // important for matching the string table that 'as' generates.
IndirectSymbolData ISD; IndirectSymbolData ISD;
ISD.Symbol = Symbol; ISD.Symbol = Symbol;
ISD.Section = &getCurrentSectionData()->getSection(); ISD.Section = getCurrentSectionData();
getAssembler().getIndirectSymbols().push_back(ISD); getAssembler().getIndirectSymbols().push_back(ISD);
return true; return true;
} }
@ -508,8 +506,7 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst,
MCDataFragment *DF; MCDataFragment *DF;
if (Assembler.isBundlingEnabled()) { if (Assembler.isBundlingEnabled()) {
MCSectionData *SD = getCurrentSectionData(); MCSection &Sec = *getCurrentSectionData();
MCSection &Sec = SD->getSection();
if (Assembler.getRelaxAll() && isBundleLocked()) if (Assembler.getRelaxAll() && isBundleLocked())
// If the -mc-relax-all flag is used and we are bundle-locked, we re-use // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
// the current bundle group. // the current bundle group.
@ -577,8 +574,7 @@ void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
} }
void MCELFStreamer::EmitBundleLock(bool AlignToEnd) { void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
MCSectionData *SD = getCurrentSectionData(); MCSection &Sec = *getCurrentSectionData();
MCSection &Sec = SD->getSection();
// Sanity checks // Sanity checks
// //
@ -599,8 +595,7 @@ void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
} }
void MCELFStreamer::EmitBundleUnlock() { void MCELFStreamer::EmitBundleUnlock() {
MCSectionData *SD = getCurrentSectionData(); MCSection &Sec = *getCurrentSectionData();
MCSection &Sec = SD->getSection();
// Sanity checks // Sanity checks
if (!getAssembler().isBundlingEnabled()) if (!getAssembler().isBundlingEnabled())
@ -659,9 +654,7 @@ void MCELFStreamer::Flush() {
void MCELFStreamer::FinishImpl() { void MCELFStreamer::FinishImpl() {
// Ensure the last section gets aligned if necessary. // Ensure the last section gets aligned if necessary.
MCSectionData *CurSectionData = getCurrentSectionData(); MCSection *CurSection = getCurrentSectionData();
MCSection *CurSection =
CurSectionData ? &CurSectionData->getSection() : nullptr;
setSectionAlignmentForBundling(getAssembler(), CurSection); setSectionAlignmentForBundling(getAssembler(), CurSection);
EmitFrames(nullptr); EmitFrames(nullptr);

View File

@ -287,7 +287,7 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
// important for matching the string table that 'as' generates. // important for matching the string table that 'as' generates.
IndirectSymbolData ISD; IndirectSymbolData ISD;
ISD.Symbol = Symbol; ISD.Symbol = Symbol;
ISD.Section = &getCurrentSectionData()->getSection(); ISD.Section = getCurrentSectionData();
getAssembler().getIndirectSymbols().push_back(ISD); getAssembler().getIndirectSymbols().push_back(ISD);
return true; return true;
} }

View File

@ -43,7 +43,7 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) {
if (!F) { if (!F) {
F = new MCDataFragment(); F = new MCDataFragment();
CurSectionData->getFragmentList().insert(CurInsertionPoint, F); CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
F->setParent(&CurSectionData->getSection()); F->setParent(CurSectionData);
} }
for (MCSymbolData *SD : PendingLabels) { for (MCSymbolData *SD : PendingLabels) {
SD->setFragment(F); SD->setFragment(F);
@ -212,7 +212,8 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section,
flushPendingLabels(nullptr); flushPendingLabels(nullptr);
bool Created; bool Created;
CurSectionData = &getAssembler().getOrCreateSectionData(*Section, &Created); getAssembler().getOrCreateSectionData(*Section, &Created);
CurSectionData = Section;
int64_t IntSubsection = 0; int64_t IntSubsection = 0;
if (Subsection && if (Subsection &&
@ -221,7 +222,8 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section,
if (IntSubsection < 0 || IntSubsection > 8192) if (IntSubsection < 0 || IntSubsection > 8192)
report_fatal_error("Subsection number out of range"); report_fatal_error("Subsection number out of range");
CurInsertionPoint = CurInsertionPoint =
CurSectionData->getSubsectionInsertionPoint(unsigned(IntSubsection)); CurSectionData->getSectionData().getSubsectionInsertionPoint(
unsigned(IntSubsection));
return Created; return Created;
} }
@ -238,8 +240,8 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
MCStreamer::EmitInstruction(Inst, STI); MCStreamer::EmitInstruction(Inst, STI);
MCSectionData *SD = getCurrentSectionData(); MCSection *Sec = getCurrentSectionData();
SD->getSection().setHasInstructions(true); Sec->setHasInstructions(true);
// Now that a machine instruction has been assembled into this section, make // Now that a machine instruction has been assembled into this section, make
// a line entry for any .loc directive that has been seen. // a line entry for any .loc directive that has been seen.
@ -258,7 +260,7 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst,
// group. We want to emit all such instructions into the same data // group. We want to emit all such instructions into the same data
// fragment. // fragment.
if (Assembler.getRelaxAll() || if (Assembler.getRelaxAll() ||
(Assembler.isBundlingEnabled() && SD->getSection().isBundleLocked())) { (Assembler.isBundlingEnabled() && Sec->isBundleLocked())) {
MCInst Relaxed; MCInst Relaxed;
getAssembler().getBackend().relaxInstruction(Inst, Relaxed); getAssembler().getBackend().relaxInstruction(Inst, Relaxed);
while (getAssembler().getBackend().mayNeedRelaxation(Relaxed)) while (getAssembler().getBackend().mayNeedRelaxation(Relaxed))