blob: 9dfb28c30422cb9797c3f7bba3b0e6b0355e77e3 [file] [log] [blame]
Daniel Dunbaraba5fb82009-08-13 23:36:34 +00001//===- 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
12#include "llvm/MC/MCContext.h"
13#include "llvm/MC/MCInst.h"
14#include "llvm/MC/MCSectionMachO.h"
15#include "llvm/MC/MCSymbol.h"
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000016
17using namespace llvm;
18
19namespace {
20
21 class MCNullStreamer : public MCStreamer {
22 public:
23 MCNullStreamer(MCContext &Context) : MCStreamer(Context) {}
24
25 /// @name MCStreamer Interface
26 /// @{
27
Rafael Espindolaf667d922010-09-15 21:48:40 +000028 virtual void InitSections() {
29 }
30
Chris Lattnerf4460702009-08-18 16:46:29 +000031 virtual void SwitchSection(const MCSection *Section) {
Benjamin Kramere39017c2010-09-02 18:53:37 +000032 PrevSection = CurSection;
Chris Lattnerf4460702009-08-18 16:46:29 +000033 CurSection = Section;
34 }
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000035
Chris Lattneraab52842010-03-09 23:12:18 +000036 virtual void EmitLabel(MCSymbol *Symbol) {
37 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
38 assert(CurSection && "Cannot emit before setting section!");
39 Symbol->setSection(*CurSection);
40 }
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000041
Chris Lattner685508c2010-01-23 06:39:22 +000042 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000043
Daniel Dunbar897ffad2009-08-31 08:09:28 +000044 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
Rafael Espindola16145972010-11-01 14:28:48 +000045 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol){}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000046
Chris Lattner685508c2010-01-23 06:39:22 +000047 virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute){}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000048
49 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
Chris Lattner72afa952010-05-08 19:54:22 +000050
51 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
52 virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
53 virtual void EmitCOFFSymbolType(int Type) {}
54 virtual void EndCOFFSymbolDef() {}
55
Chris Lattner91dac6d2010-01-25 07:52:13 +000056 virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
Chris Lattnerb1301f72010-01-23 07:47:02 +000057 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Daniel Dunbar6a715dc2009-08-30 06:17:16 +000058 unsigned ByteAlignment) {}
Chris Lattnerb1301f72010-01-23 07:47:02 +000059 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000060
Daniel Dunbarcf72e1c2009-08-28 05:48:22 +000061 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
Daniel Dunbar6a715dc2009-08-30 06:17:16 +000062 unsigned Size = 0, unsigned ByteAlignment = 0) {}
Eric Christopher5c87be72010-05-18 21:16:04 +000063 virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
64 uint64_t Size, unsigned ByteAlignment) {}
Chris Lattnerc35681b2010-01-19 19:46:13 +000065 virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000066
Chris Lattnerc35681b2010-01-19 19:46:13 +000067 virtual void EmitValue(const MCExpr *Value, unsigned Size,
68 unsigned AddrSpace) {}
Rafael Espindola5e874982010-11-02 17:22:24 +000069 virtual void EmitULEB128Value(const MCExpr *Value,
70 unsigned AddrSpace = 0) {}
71 virtual void EmitSLEB128Value(const MCExpr *Value,
72 unsigned AddrSpace = 0) {}
Chris Lattner3cde7602010-01-25 21:28:50 +000073 virtual void EmitGPRel32Value(const MCExpr *Value) {}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000074 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
75 unsigned ValueSize = 1,
76 unsigned MaxBytesToEmit = 0) {}
77
Kevin Enderbye83d74f2010-02-23 18:26:34 +000078 virtual void EmitCodeAlignment(unsigned ByteAlignment,
79 unsigned MaxBytesToEmit = 0) {}
80
Daniel Dunbar897ffad2009-08-31 08:09:28 +000081 virtual void EmitValueToOffset(const MCExpr *Offset,
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000082 unsigned char Value = 0) {}
83
Chris Lattner601ef332010-01-25 18:58:59 +000084 virtual void EmitFileDirective(StringRef Filename) {}
85 virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename) {}
Daniel Dunbaraba5fb82009-08-13 23:36:34 +000086 virtual void EmitInstruction(const MCInst &Inst) {}
87
88 virtual void Finish() {}
89
90 /// @}
91 };
92
93}
94
95MCStreamer *llvm::createNullStreamer(MCContext &Context) {
96 return new MCNullStreamer(Context);
97}