llvm.org GIT mirror llvm / 011e4db
llvm-mc: Add dummy MCStreamer implementation, (eventually) for use in profiling. - Currently unused. - A few other random comment fixes lumped in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78960 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
4 changed file(s) with 79 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
220220 virtual void Finish() = 0;
221221 };
222222
223 /// createNullStreamer - Create a dummy machine code streamer, which does
224 /// nothing. This is useful for timing the assembler front end.
225 MCStreamer *createNullStreamer(MCContext &Ctx);
226
223227 /// createAsmStreamer - Create a machine code streamer which will print out
224228 /// assembly for the native target, suitable for compiling with a native
225229 /// assembler.
216216 /// the current host. If no close target can be found, this returns null
217217 /// and sets the Error string to a reason.
218218 ///
219 /// Mainted for compatibility through 2.6.
219 /// Maintained for compatibility through 2.6.
220220 static const Target *getClosestTargetForJIT(std::string &Error);
221221
222222 /// @}
154154
155155 void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
156156 switch (Flag) {
157 default: assert(0 && "Invalid flag!");
157158 case SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
158159 }
159160 OS << '\n';
214215
215216 void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
216217 unsigned Size, unsigned Pow2Alignment) {
217 // Note: a .zerofill directive does not switch sections
218 // FIXME: Really we would like the segment and section names as well as the
219 // section type to be separate values instead of embedded in the name. Not
220 // all assemblers understand all this stuff though.
218 // Note: a .zerofill directive does not switch sections.
221219 OS << ".zerofill ";
222220
223221 // This is a mach-o specific directive.
224222 const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
225223 OS << '"' << MOSection->getSegmentName() << ","
226224 << MOSection->getSectionName() << '"';
227
228225
229226 if (Symbol != NULL) {
230227 OS << ',' << Symbol << ',' << Size;
0 //===- lib/MC/MCNullStreamer.cpp - Dummy Streamer Implementation ----------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/MC/MCStreamer.h"
10
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 #include "llvm/MC/MCValue.h"
16
17 using namespace llvm;
18
19 namespace {
20
21 class MCNullStreamer : public MCStreamer {
22 public:
23 MCNullStreamer(MCContext &Context) : MCStreamer(Context) {}
24
25 /// @name MCStreamer Interface
26 /// @{
27
28 virtual void SwitchSection(MCSection *Section) {}
29
30 virtual void EmitLabel(MCSymbol *Symbol) {}
31
32 virtual void EmitAssemblerFlag(AssemblerFlag Flag) {}
33
34 virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
35 bool MakeAbsolute = false) {}
36
37 virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute) {}
38
39 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
40
41 virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {}
42
43 virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
44 unsigned Pow2Alignment, bool IsLocal) {}
45
46 virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = NULL,
47 unsigned Size = 0, unsigned Pow2Alignment = 0) {}
48
49 virtual void EmitBytes(const StringRef &Data) {}
50
51 virtual void EmitValue(const MCValue &Value, unsigned Size) {}
52
53 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
54 unsigned ValueSize = 1,
55 unsigned MaxBytesToEmit = 0) {}
56
57 virtual void EmitValueToOffset(const MCValue &Offset,
58 unsigned char Value = 0) {}
59
60 virtual void EmitInstruction(const MCInst &Inst) {}
61
62 virtual void Finish() {}
63
64 /// @}
65 };
66
67 }
68
69 MCStreamer *llvm::createNullStreamer(MCContext &Context) {
70 return new MCNullStreamer(Context);
71 }