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