Add support for subsections to the ELF assembler. Fixes PR8717.
[oota-llvm.git] / lib / MC / MCNullStreamer.cpp
1 //===- lib/MC/MCNullStreamer.cpp - Dummy Streamer Implementation ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/MC/MCContext.h"
12 #include "llvm/MC/MCInst.h"
13 #include "llvm/MC/MCSectionMachO.h"
14 #include "llvm/MC/MCSymbol.h"
15
16 using namespace llvm;
17
18 namespace {
19
20   class MCNullStreamer : public MCStreamer {
21   public:
22     MCNullStreamer(MCContext &Context) : MCStreamer(SK_NullStreamer, Context) {}
23
24     /// @name MCStreamer Interface
25     /// @{
26
27     virtual void InitToTextSection() {
28     }
29
30     virtual void InitSections() {
31     }
32
33     virtual void ChangeSection(const MCSection *Section,
34                                const MCExpr *Subsection) {
35     }
36
37     virtual void EmitLabel(MCSymbol *Symbol) {
38       assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
39       assert(getCurrentSection().first &&"Cannot emit before setting section!");
40       Symbol->setSection(*getCurrentSection().first);
41     }
42     virtual void EmitDebugLabel(MCSymbol *Symbol) {
43       EmitLabel(Symbol);
44     }
45     virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {}
46     virtual void EmitThumbFunc(MCSymbol *Func) {}
47
48     virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
49     virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol){}
50     virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
51                                           const MCSymbol *LastLabel,
52                                           const MCSymbol *Label,
53                                           unsigned PointerSize) {}
54
55     virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){}
56
57     virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
58
59     virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
60     virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
61     virtual void EmitCOFFSymbolType(int Type) {}
62     virtual void EndCOFFSymbolDef() {}
63     virtual void EmitCOFFSecRel32(MCSymbol const *Symbol) {}
64
65     virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
66     virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
67                                   unsigned ByteAlignment) {}
68     virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
69                                        unsigned ByteAlignment) {}
70     virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
71                               uint64_t Size = 0, unsigned ByteAlignment = 0) {}
72     virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
73                                 uint64_t Size, unsigned ByteAlignment) {}
74     virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
75
76     virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
77                                unsigned AddrSpace) {}
78     virtual void EmitULEB128Value(const MCExpr *Value) {}
79     virtual void EmitSLEB128Value(const MCExpr *Value) {}
80     virtual void EmitGPRel32Value(const MCExpr *Value) {}
81     virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
82                                       unsigned ValueSize = 1,
83                                       unsigned MaxBytesToEmit = 0) {}
84
85     virtual void EmitCodeAlignment(unsigned ByteAlignment,
86                                    unsigned MaxBytesToEmit = 0) {}
87
88     virtual bool EmitValueToOffset(const MCExpr *Offset,
89                                    unsigned char Value = 0) { return false; }
90
91     virtual void EmitFileDirective(StringRef Filename) {}
92     virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
93                                         StringRef Filename, unsigned CUID = 0) {
94       return false;
95     }
96     virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
97                                        unsigned Column, unsigned Flags,
98                                        unsigned Isa, unsigned Discriminator,
99                                        StringRef FileName) {}
100     virtual void EmitInstruction(const MCInst &Inst) {}
101
102     virtual void EmitBundleAlignMode(unsigned AlignPow2) {}
103     virtual void EmitBundleLock(bool AlignToEnd) {}
104     virtual void EmitBundleUnlock() {}
105
106     virtual void FinishImpl() {}
107
108     virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
109       RecordProcEnd(Frame);
110     }
111
112     /// @}
113
114     static bool classof(const MCStreamer *S) {
115       return S->getKind() == SK_NullStreamer;
116     }
117
118   };
119
120 }
121
122 MCStreamer *llvm::createNullStreamer(MCContext &Context) {
123   return new MCNullStreamer(Context);
124 }