the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / lib / MC / MCLoggingStreamer.cpp
blob46ea9b844a6a0e96e61fa856fe9e9ca4371951e1
1 //===- lib/MC/MCLoggingStreamer.cpp - API Logging Streamer ----------------===//
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 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/ADT/OwningPtr.h"
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/Support/raw_ostream.h"
14 using namespace llvm;
16 namespace {
18 class MCLoggingStreamer : public MCStreamer {
19 llvm::OwningPtr<MCStreamer> Child;
21 raw_ostream &OS;
23 public:
24 MCLoggingStreamer(MCStreamer *_Child, raw_ostream &_OS)
25 : MCStreamer(_Child->getContext()), Child(_Child), OS(_OS) {}
27 void LogCall(const char *Function) {
28 OS << Function << "\n";
31 void LogCall(const char *Function, const Twine &Message) {
32 OS << Function << ": " << Message << "\n";
35 virtual bool isVerboseAsm() const { return Child->isVerboseAsm(); }
37 virtual bool hasRawTextSupport() const { return Child->hasRawTextSupport(); }
39 virtual raw_ostream &GetCommentOS() { return Child->GetCommentOS(); }
41 virtual void AddComment(const Twine &T) {
42 LogCall("AddComment", T);
43 return Child->AddComment(T);
46 virtual void AddBlankLine() {
47 LogCall("AddBlankLine");
48 return Child->AddBlankLine();
51 virtual void ChangeSection(const MCSection *Section) {
52 LogCall("ChangeSection");
53 return Child->ChangeSection(Section);
56 virtual void InitSections() {
57 LogCall("InitSections");
58 return Child->InitSections();
61 virtual void EmitLabel(MCSymbol *Symbol) {
62 LogCall("EmitLabel");
63 return Child->EmitLabel(Symbol);
66 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {
67 LogCall("EmitAssemblerFlag");
68 return Child->EmitAssemblerFlag(Flag);
71 virtual void EmitThumbFunc(MCSymbol *Func) {
72 LogCall("EmitThumbFunc");
73 return Child->EmitThumbFunc(Func);
76 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
77 LogCall("EmitAssignment");
78 return Child->EmitAssignment(Symbol, Value);
81 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
82 LogCall("EmitWeakReference");
83 return Child->EmitWeakReference(Alias, Symbol);
86 virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
87 const MCSymbol *LastLabel,
88 const MCSymbol *Label) {
89 LogCall("EmitDwarfAdvanceLineAddr");
90 return Child->EmitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label);
93 virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) {
94 LogCall("EmitSymbolAttribute");
95 return Child->EmitSymbolAttribute(Symbol, Attribute);
98 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
99 LogCall("EmitSymbolDesc");
100 return Child->EmitSymbolDesc(Symbol, DescValue);
103 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {
104 LogCall("BeginCOFFSymbolDef");
105 return Child->BeginCOFFSymbolDef(Symbol);
108 virtual void EmitCOFFSymbolStorageClass(int StorageClass) {
109 LogCall("EmitCOFFSymbolStorageClass");
110 return Child->EmitCOFFSymbolStorageClass(StorageClass);
113 virtual void EmitCOFFSymbolType(int Type) {
114 LogCall("EmitCOFFSymbolType");
115 return Child->EmitCOFFSymbolType(Type);
118 virtual void EndCOFFSymbolDef() {
119 LogCall("EndCOFFSymbolDef");
120 return Child->EndCOFFSymbolDef();
123 virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
124 LogCall("EmitELFSize");
125 return Child->EmitELFSize(Symbol, Value);
128 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
129 unsigned ByteAlignment) {
130 LogCall("EmitCommonSymbol");
131 return Child->EmitCommonSymbol(Symbol, Size, ByteAlignment);
134 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {
135 LogCall("EmitLocalCommonSymbol");
136 return Child->EmitLocalCommonSymbol(Symbol, Size);
139 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
140 unsigned Size = 0, unsigned ByteAlignment = 0) {
141 LogCall("EmitZerofill");
142 return Child->EmitZerofill(Section, Symbol, Size, ByteAlignment);
145 virtual void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol,
146 uint64_t Size, unsigned ByteAlignment = 0) {
147 LogCall("EmitTBSSSymbol");
148 return Child->EmitTBSSSymbol(Section, Symbol, Size, ByteAlignment);
151 virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {
152 LogCall("EmitBytes");
153 return Child->EmitBytes(Data, AddrSpace);
156 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
157 unsigned AddrSpace){
158 LogCall("EmitValue");
159 return Child->EmitValueImpl(Value, Size, AddrSpace);
162 virtual void EmitULEB128Value(const MCExpr *Value) {
163 LogCall("EmitULEB128Value");
164 return Child->EmitULEB128Value(Value);
167 virtual void EmitSLEB128Value(const MCExpr *Value) {
168 LogCall("EmitSLEB128Value");
169 return Child->EmitSLEB128Value(Value);
172 virtual void EmitGPRel32Value(const MCExpr *Value) {
173 LogCall("EmitGPRel32Value");
174 return Child->EmitGPRel32Value(Value);
177 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
178 unsigned AddrSpace) {
179 LogCall("EmitFill");
180 return Child->EmitFill(NumBytes, FillValue, AddrSpace);
183 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
184 unsigned ValueSize = 1,
185 unsigned MaxBytesToEmit = 0) {
186 LogCall("EmitValueToAlignment");
187 return Child->EmitValueToAlignment(ByteAlignment, Value,
188 ValueSize, MaxBytesToEmit);
191 virtual void EmitCodeAlignment(unsigned ByteAlignment,
192 unsigned MaxBytesToEmit = 0) {
193 LogCall("EmitCodeAlignment");
194 return Child->EmitCodeAlignment(ByteAlignment, MaxBytesToEmit);
197 virtual void EmitValueToOffset(const MCExpr *Offset,
198 unsigned char Value = 0) {
199 LogCall("EmitValueToOffset");
200 return Child->EmitValueToOffset(Offset, Value);
203 virtual void EmitFileDirective(StringRef Filename) {
204 LogCall("EmitFileDirective", "FileName:" + Filename);
205 return Child->EmitFileDirective(Filename);
208 virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
209 LogCall("EmitDwarfFileDirective",
210 "FileNo:" + Twine(FileNo) + " Filename:" + Filename);
211 return Child->EmitDwarfFileDirective(FileNo, Filename);
214 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
215 unsigned Column, unsigned Flags,
216 unsigned Isa, unsigned Discriminator,
217 StringRef FileName) {
218 LogCall("EmitDwarfLocDirective",
219 "FileNo:" + Twine(FileNo) + " Line:" + Twine(Line) +
220 " Column:" + Twine(Column) + " Flags:" + Twine(Flags) +
221 " Isa:" + Twine(Isa) + " Discriminator:" + Twine(Discriminator));
222 return Child->EmitDwarfLocDirective(FileNo, Line, Column, Flags,
223 Isa, Discriminator, FileName);
226 virtual void EmitInstruction(const MCInst &Inst) {
227 LogCall("EmitInstruction");
228 return Child->EmitInstruction(Inst);
231 virtual void EmitRawText(StringRef String) {
232 LogCall("EmitRawText", "\"" + String + "\"");
233 return Child->EmitRawText(String);
236 virtual void Finish() {
237 LogCall("Finish");
238 return Child->Finish();
243 } // end anonymous namespace.
245 MCStreamer *llvm::createLoggingStreamer(MCStreamer *Child, raw_ostream &OS) {
246 return new MCLoggingStreamer(Child, OS);