LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCNullStreamer.cpp
Go to the documentation of this file.
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(Context, 0) {}
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  AssignSection(Symbol, 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 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){
56  return true;
57  }
58 
59  virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
60 
61  virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
62  virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
63  virtual void EmitCOFFSymbolType(int Type) {}
64  virtual void EndCOFFSymbolDef() {}
65  virtual void EmitCOFFSecRel32(MCSymbol const *Symbol) {}
66 
67  virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
68  virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
69  unsigned ByteAlignment) {}
70  virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
71  unsigned ByteAlignment) {}
72  virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
73  uint64_t Size = 0, unsigned ByteAlignment = 0) {}
74  virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
75  uint64_t Size, unsigned ByteAlignment) {}
76  virtual void EmitBytes(StringRef Data) {}
77 
78  virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) {}
79  virtual void EmitULEB128Value(const MCExpr *Value) {}
80  virtual void EmitSLEB128Value(const MCExpr *Value) {}
81  virtual void EmitGPRel32Value(const MCExpr *Value) {}
82  virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
83  unsigned ValueSize = 1,
84  unsigned MaxBytesToEmit = 0) {}
85 
86  virtual void EmitCodeAlignment(unsigned ByteAlignment,
87  unsigned MaxBytesToEmit = 0) {}
88 
89  virtual bool EmitValueToOffset(const MCExpr *Offset,
90  unsigned char Value = 0) { return false; }
91 
92  virtual void EmitFileDirective(StringRef Filename) {}
93  virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
94  StringRef Filename, unsigned CUID = 0) {
95  return false;
96  }
97  virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
98  unsigned Column, unsigned Flags,
99  unsigned Isa, unsigned Discriminator,
100  StringRef FileName) {}
101  virtual void EmitInstruction(const MCInst &Inst) {}
102 
103  virtual void EmitBundleAlignMode(unsigned AlignPow2) {}
104  virtual void EmitBundleLock(bool AlignToEnd) {}
105  virtual void EmitBundleUnlock() {}
106 
107  virtual void FinishImpl() {}
108 
109  virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
110  RecordProcEnd(Frame);
111  }
112  };
113 
114 }
115 
117  return new MCNullStreamer(Context);
118 }
MCStreamer * createNullStreamer(MCContext &Ctx)
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:204
MCSymbolAttr
Definition: MCDirectives.h:19
MCAssemblerFlag
Definition: MCDirectives.h:47
LLVM Value Representation.
Definition: Value.h:66
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:100