From 919ce81d38ae7707ffdfba2ab775bda3b7c79db3 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 27 May 2015 13:37:28 +0000 Subject: [PATCH] Move getSubsectionInsertionPoint to MCSection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238320 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCSection.h | 5 +++-- lib/MC/MCAssembler.cpp | 31 ------------------------------- lib/MC/MCObjectStreamer.cpp | 3 +-- lib/MC/MCSection.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 2e155bbc325..7f9d976b959 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -33,6 +33,7 @@ class raw_ostream; class MCSectionData { friend class MCAsmLayout; + friend class MCSection; MCSectionData(const MCSectionData &) = delete; void operator=(const MCSectionData &) = delete; @@ -96,8 +97,6 @@ public: bool empty() const; - iterator getSubsectionInsertionPoint(unsigned Subsection); - void dump(); /// @} @@ -220,6 +219,8 @@ public: return const_cast(this)->rend(); } + MCSectionData::iterator getSubsectionInsertionPoint(unsigned Subsection); + virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, const MCExpr *Subsection) const = 0; diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 187fd1fd547..ec2518c77dd 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -290,37 +290,6 @@ MCEncodedFragmentWithFixups::~MCEncodedFragmentWithFixups() { MCSectionData::MCSectionData(MCSection &Section) : Section(&Section) {} -MCSectionData::iterator -MCSectionData::getSubsectionInsertionPoint(unsigned Subsection) { - if (Subsection == 0 && SubsectionFragmentMap.empty()) - return end(); - - SmallVectorImpl >::iterator MI = - std::lower_bound(SubsectionFragmentMap.begin(), SubsectionFragmentMap.end(), - std::make_pair(Subsection, (MCFragment *)nullptr)); - bool ExactMatch = false; - if (MI != SubsectionFragmentMap.end()) { - ExactMatch = MI->first == Subsection; - if (ExactMatch) - ++MI; - } - iterator IP; - if (MI == SubsectionFragmentMap.end()) - IP = end(); - else - IP = MI->second; - if (!ExactMatch && Subsection != 0) { - // The GNU as documentation claims that subsections have an alignment of 4, - // although this appears not to be the case. - MCFragment *F = new MCDataFragment(); - SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F)); - getFragmentList().insert(IP, F); - F->setParent(&getSection()); - } - - return IP; -} - /* *** */ MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_, diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index c1b20717db3..18d2b66b2ae 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -221,8 +221,7 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, if (IntSubsection < 0 || IntSubsection > 8192) report_fatal_error("Subsection number out of range"); CurInsertionPoint = - CurSectionData->getSectionData().getSubsectionInsertionPoint( - unsigned(IntSubsection)); + CurSectionData->getSubsectionInsertionPoint(unsigned(IntSubsection)); return Created; } diff --git a/lib/MC/MCSection.cpp b/lib/MC/MCSection.cpp index fca74748641..91df312689c 100644 --- a/lib/MC/MCSection.cpp +++ b/lib/MC/MCSection.cpp @@ -52,6 +52,38 @@ void MCSection::setBundleLockState(BundleLockStateType NewState) { ++BundleLockNestingDepth; } +MCSectionData::iterator +MCSection::getSubsectionInsertionPoint(unsigned Subsection) { + if (Subsection == 0 && Data.SubsectionFragmentMap.empty()) + return end(); + + SmallVectorImpl>::iterator MI = + std::lower_bound(Data.SubsectionFragmentMap.begin(), + Data.SubsectionFragmentMap.end(), + std::make_pair(Subsection, (MCFragment *)nullptr)); + bool ExactMatch = false; + if (MI != Data.SubsectionFragmentMap.end()) { + ExactMatch = MI->first == Subsection; + if (ExactMatch) + ++MI; + } + MCSectionData::iterator IP; + if (MI == Data.SubsectionFragmentMap.end()) + IP = end(); + else + IP = MI->second; + if (!ExactMatch && Subsection != 0) { + // 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)); + getFragmentList().insert(IP, F); + F->setParent(this); + } + + return IP; +} + MCSectionData::iterator MCSection::begin() { return Data.begin(); } MCSectionData::iterator MCSection::end() { return Data.end(); } -- 2.34.1