llvm/lib/MC
Eli Bendersky 030f63a397 Expose an InitToTextSection through MCStreamer.
The aim of this patch is to fix the following piece of code in the
platform-independent AsmParser:

void AsmParser::CheckForValidSection() {
  if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) {
    TokError("expected section directive before assembly directive");
    Out.SwitchSection(Ctx.getMachOSection(
                        "__TEXT", "__text",
                        MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
                        0, SectionKind::getText()));
  }
}

This was added for the "-n" option of llvm-mc.

The proposed fix adds another virtual method to MCStreamer, called
InitToTextSection. Conceptually, it's similar to the existing
InitSections which initializes all common sections and switches to
text. The new method is implemented by each platform streamer in a way
that it sees fit. So AsmParser can now do this:

void AsmParser::CheckForValidSection() {
  if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) {
    TokError("expected section directive before assembly directive");
    Out.InitToTextSection();
  }
}

Which is much more reasonable.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172450 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 19:04:57 +00:00
..
MCDisassembler Remove edis - the enhanced disassembler. Fixes PR14654. 2012-12-19 19:55:47 +00:00
MCParser Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
CMakeLists.txt Remove MCTargetAsmLexer and its derived classes now that edis, 2012-12-20 14:43:30 +00:00
ELFObjectWriter.cpp Remove redundant 'llvm::' qualifications 2013-01-13 16:01:15 +00:00
LLVMBuild.txt
MachObjectWriter.cpp Add more reset methods to make all objects that the backend may use for outputting code have a reset, some are not used but were declared for completeness 2012-12-14 18:52:11 +00:00
Makefile
MCAsmBackend.cpp MachO: direct-to-object attribute for data-in-code markers. 2012-10-01 22:20:54 +00:00
MCAsmInfo.cpp This patch is needed to make c++ exceptions work for mips16. 2012-12-16 04:00:45 +00:00
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
MCAssembler.cpp Simplify the code a bit: MCRelaxableFragment doesn't need a separate getInstSize 2013-01-08 22:05:10 +00:00
MCAtom.cpp
MCCodeEmitter.cpp
MCCodeGenInfo.cpp
MCContext.cpp Formatting. 2012-12-18 00:42:26 +00:00
MCDisassembler.cpp
MCDwarf.cpp These functions have default arguments of 0 for the last arg. Use 2013-01-09 01:57:54 +00:00
MCELF.cpp Added Mapping Symbols for ARM ELF 2012-12-07 16:50:23 +00:00
MCELFObjectTargetWriter.cpp Initial TOC support for PowerPC64 object creation 2012-10-25 12:27:42 +00:00
MCELFStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
MCExpr.cpp This patch improves the 64-bit PowerPC InitialExec TLS support by providing 2012-12-14 17:02:38 +00:00
MCInst.cpp
MCInstPrinter.cpp Try to unbreak the build on hosts that don't transitively pull in a definition for int64_t. 2012-12-05 18:31:11 +00:00
MCInstrAnalysis.cpp
MCLabel.cpp
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
MCModule.cpp
MCNullStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
MCObjectFileInfo.cpp PowerPC: EH adjustments 2013-01-09 17:08:15 +00:00
MCObjectStreamer.cpp These functions have default arguments of 0 for the last arg. Use 2013-01-09 01:35:34 +00:00
MCObjectWriter.cpp
MCPureStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00
MCRegisterInfo.cpp
MCSection.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCSectionCOFF.cpp
MCSectionELF.cpp
MCSectionMachO.cpp
MCStreamer.cpp Last in the series of removing unnecessary '0' arguments for 2013-01-09 03:52:05 +00:00
MCSubtargetInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCSymbol.cpp
MCValue.cpp
MCWin64EH.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
SubtargetFeature.cpp Symbol hygiene: Make sure declarations and definitions match, make helper functions static. 2012-10-20 12:53:26 +00:00
WinCOFFObjectWriter.cpp Remove redundant 'llvm::' qualifications 2013-01-13 16:01:15 +00:00
WinCOFFStreamer.cpp Expose an InitToTextSection through MCStreamer. 2013-01-14 19:04:57 +00:00