llvm.org GIT mirror llvm / a1f7c26
Simplify the logic for deciding when to initialize the sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199971 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
8 changed file(s) with 17 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
4444 /// @name MCStreamer Interface
4545 /// @{
4646
47 virtual void InitSections();
47 virtual void InitSections(bool Force);
4848 virtual void ChangeSection(const MCSection *Section,
4949 const MCExpr *Subsection);
5050 virtual void EmitLabel(MCSymbol *Symbol);
156156 /// values saved by PushSection.
157157 SmallVector, 4> SectionStack;
158158
159 bool AutoInitSections;
160
161159 protected:
162160 MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer);
163161
329327 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
330328 }
331329
332 /// Initialize the streamer.
333 void InitStreamer() {
334 if (AutoInitSections)
335 InitSections();
336 }
337
338 /// Tell this MCStreamer to call InitSections upon initialization.
339 void setAutoInitSections(bool AutoInitSections) {
340 this->AutoInitSections = AutoInitSections;
341 }
342
343 /// InitSections - Create the default sections and set the initial one.
344 virtual void InitSections();
330 /// Create the default sections and set the initial one.
331 ///
332 /// @param Force - If false, a text streamer implementation can be a nop.
333 /// Used by CodeGen to avoid starting every file with '.text'.
334 virtual void InitSections(bool Force = true);
345335
346336 /// AssignSection - Sets the symbol's section.
347337 ///
162162 const_cast(getObjFileLowering())
163163 .Initialize(OutContext, TM);
164164
165 OutStreamer.InitStreamer();
165 OutStreamer.InitSections(false);
166166
167167 Mang = new Mangler(TM.getDataLayout());
168168
207207 *Context, *MAB, Out,
208208 MCE, hasMCRelaxAll(),
209209 hasMCNoExecStack()));
210 AsmStreamer.get()->setAutoInitSections(true);
211210 break;
212211 }
213212 case CGFT_Null:
126126
127127 virtual void ChangeSection(const MCSection *Section,
128128 const MCExpr *Subsection);
129
130 virtual void InitSections(bool Force) {
131 if (Force)
132 SwitchSection(getContext().getObjectFileInfo()->getTextSection());
133 }
129134
130135 virtual void EmitLabel(MCSymbol *Symbol);
131136 virtual void EmitDebugLabel(MCSymbol *Symbol);
3737 MCELFStreamer::~MCELFStreamer() {
3838 }
3939
40 void MCELFStreamer::InitSections() {
40 void MCELFStreamer::InitSections(bool Force) {
4141 // This emulates the same behavior of GNU as. This makes it easier
4242 // to compare the output as the major sections are in the same order.
4343 SwitchSection(getContext().getObjectFileInfo()->getTextSection());
2828
2929 MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer)
3030 : Context(Ctx), TargetStreamer(TargetStreamer), EmitEHFrame(true),
31 EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0),
32 AutoInitSections(false) {
31 EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0) {
3332 SectionStack.push_back(std::pair());
3433 if (TargetStreamer)
3534 TargetStreamer->setStreamer(this);
200199 MCSymbol *EHSymbol) {
201200 }
202201
203 void MCStreamer::InitSections() {
202 void MCStreamer::InitSections(bool Force) {
204203 SwitchSection(getContext().getObjectFileInfo()->getTextSection());
205204 }
206205
4949
5050 // MCStreamer interface
5151
52 virtual void InitSections();
52 virtual void InitSections(bool Force);
5353 virtual void EmitLabel(MCSymbol *Symbol);
5454 virtual void EmitDebugLabel(MCSymbol *Symbol);
5555 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
122122
123123 // MCStreamer interface
124124
125 void WinCOFFStreamer::InitSections() {
125 void WinCOFFStreamer::InitSections(bool Force) {
126126 // FIXME: this is identical to the ELF one.
127127 // This emulates the same behavior of GNU as. This makes it easier
128128 // to compare the output as the major sections are in the same order.