• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
MCNullStreamer(MCContext & Context)22     MCNullStreamer(MCContext &Context) : MCStreamer(SK_NullStreamer, Context) {}
23 
24     /// @name MCStreamer Interface
25     /// @{
26 
InitToTextSection()27     virtual void InitToTextSection() {
28     }
29 
InitSections()30     virtual void InitSections() {
31     }
32 
ChangeSection(const MCSection * Section)33     virtual void ChangeSection(const MCSection *Section) {
34     }
35 
EmitLabel(MCSymbol * Symbol)36     virtual void EmitLabel(MCSymbol *Symbol) {
37       assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
38       assert(getCurrentSection() && "Cannot emit before setting section!");
39       Symbol->setSection(*getCurrentSection());
40     }
EmitDebugLabel(MCSymbol * Symbol)41     virtual void EmitDebugLabel(MCSymbol *Symbol) {
42       EmitLabel(Symbol);
43     }
EmitAssemblerFlag(MCAssemblerFlag Flag)44     virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {}
EmitThumbFunc(MCSymbol * Func)45     virtual void EmitThumbFunc(MCSymbol *Func) {}
46 
EmitAssignment(MCSymbol * Symbol,const MCExpr * Value)47     virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
EmitWeakReference(MCSymbol * Alias,const MCSymbol * Symbol)48     virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol){}
EmitDwarfAdvanceLineAddr(int64_t LineDelta,const MCSymbol * LastLabel,const MCSymbol * Label,unsigned PointerSize)49     virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
50                                           const MCSymbol *LastLabel,
51                                           const MCSymbol *Label,
52                                           unsigned PointerSize) {}
53 
EmitSymbolAttribute(MCSymbol * Symbol,MCSymbolAttr Attribute)54     virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){}
55 
EmitSymbolDesc(MCSymbol * Symbol,unsigned DescValue)56     virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
57 
BeginCOFFSymbolDef(const MCSymbol * Symbol)58     virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
EmitCOFFSymbolStorageClass(int StorageClass)59     virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
EmitCOFFSymbolType(int Type)60     virtual void EmitCOFFSymbolType(int Type) {}
EndCOFFSymbolDef()61     virtual void EndCOFFSymbolDef() {}
EmitCOFFSecRel32(MCSymbol const * Symbol)62     virtual void EmitCOFFSecRel32(MCSymbol const *Symbol) {}
63 
EmitELFSize(MCSymbol * Symbol,const MCExpr * Value)64     virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
EmitCommonSymbol(MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)65     virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
66                                   unsigned ByteAlignment) {}
EmitLocalCommonSymbol(MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)67     virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
68                                        unsigned ByteAlignment) {}
EmitZerofill(const MCSection * Section,MCSymbol * Symbol=0,uint64_t Size=0,unsigned ByteAlignment=0)69     virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
70                               uint64_t Size = 0, unsigned ByteAlignment = 0) {}
EmitTBSSSymbol(const MCSection * Section,MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)71     virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
72                                 uint64_t Size, unsigned ByteAlignment) {}
EmitBytes(StringRef Data,unsigned AddrSpace)73     virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
74 
EmitValueImpl(const MCExpr * Value,unsigned Size,unsigned AddrSpace)75     virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
76                                unsigned AddrSpace) {}
EmitULEB128Value(const MCExpr * Value)77     virtual void EmitULEB128Value(const MCExpr *Value) {}
EmitSLEB128Value(const MCExpr * Value)78     virtual void EmitSLEB128Value(const MCExpr *Value) {}
EmitGPRel32Value(const MCExpr * Value)79     virtual void EmitGPRel32Value(const MCExpr *Value) {}
EmitValueToAlignment(unsigned ByteAlignment,int64_t Value=0,unsigned ValueSize=1,unsigned MaxBytesToEmit=0)80     virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
81                                       unsigned ValueSize = 1,
82                                       unsigned MaxBytesToEmit = 0) {}
83 
EmitCodeAlignment(unsigned ByteAlignment,unsigned MaxBytesToEmit=0)84     virtual void EmitCodeAlignment(unsigned ByteAlignment,
85                                    unsigned MaxBytesToEmit = 0) {}
86 
EmitValueToOffset(const MCExpr * Offset,unsigned char Value=0)87     virtual bool EmitValueToOffset(const MCExpr *Offset,
88                                    unsigned char Value = 0) { return false; }
89 
EmitFileDirective(StringRef Filename)90     virtual void EmitFileDirective(StringRef Filename) {}
EmitDwarfFileDirective(unsigned FileNo,StringRef Directory,StringRef Filename,unsigned CUID=0)91     virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
92                                         StringRef Filename, unsigned CUID = 0) {
93       return false;
94     }
EmitDwarfLocDirective(unsigned FileNo,unsigned Line,unsigned Column,unsigned Flags,unsigned Isa,unsigned Discriminator,StringRef FileName)95     virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
96                                        unsigned Column, unsigned Flags,
97                                        unsigned Isa, unsigned Discriminator,
98                                        StringRef FileName) {}
EmitInstruction(const MCInst & Inst)99     virtual void EmitInstruction(const MCInst &Inst) {}
100 
EmitBundleAlignMode(unsigned AlignPow2)101     virtual void EmitBundleAlignMode(unsigned AlignPow2) {}
EmitBundleLock(bool AlignToEnd)102     virtual void EmitBundleLock(bool AlignToEnd) {}
EmitBundleUnlock()103     virtual void EmitBundleUnlock() {}
104 
FinishImpl()105     virtual void FinishImpl() {}
106 
EmitCFIEndProcImpl(MCDwarfFrameInfo & Frame)107     virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
108       RecordProcEnd(Frame);
109     }
110 
111     /// @}
112 
classof(const MCStreamer * S)113     static bool classof(const MCStreamer *S) {
114       return S->getKind() == SK_NullStreamer;
115     }
116 
117   };
118 
119 }
120 
createNullStreamer(MCContext & Context)121 MCStreamer *llvm::createNullStreamer(MCContext &Context) {
122   return new MCNullStreamer(Context);
123 }
124