blob: 23489095893e22d8e55f59e62fcd2906b3a4b13b [file] [log] [blame]
Daniel Dunbara11af532009-06-24 01:03:06 +00001//===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===//
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"
Daniel Dunbar4a0abd82009-08-27 00:51:57 +000011#include "llvm/ADT/SmallString.h"
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +000012#include "llvm/MC/MCAsmInfo.h"
Daniel Dunbar4a0abd82009-08-27 00:51:57 +000013#include "llvm/MC/MCCodeEmitter.h"
Daniel Dunbara11af532009-06-24 01:03:06 +000014#include "llvm/MC/MCContext.h"
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +000015#include "llvm/MC/MCExpr.h"
Daniel Dunbarabde2982009-07-01 06:35:03 +000016#include "llvm/MC/MCInst.h"
Chris Lattner90edac02009-09-14 03:02:37 +000017#include "llvm/MC/MCInstPrinter.h"
Chris Lattnerf9bdedd2009-08-10 18:15:01 +000018#include "llvm/MC/MCSectionMachO.h"
Daniel Dunbara11af532009-06-24 01:03:06 +000019#include "llvm/MC/MCSymbol.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000020#include "llvm/Support/ErrorHandling.h"
Chris Lattner663c2d22009-08-19 06:12:02 +000021#include "llvm/Support/MathExtras.h"
Daniel Dunbar4a0abd82009-08-27 00:51:57 +000022#include "llvm/Support/Format.h"
Daniel Dunbara11af532009-06-24 01:03:06 +000023#include "llvm/Support/raw_ostream.h"
24using namespace llvm;
25
26namespace {
27
Chris Lattner46a947d2009-08-17 04:17:34 +000028class MCAsmStreamer : public MCStreamer {
29 raw_ostream &OS;
Chris Lattner33adcfb2009-08-22 21:43:10 +000030 const MCAsmInfo &MAI;
Chris Lattner16582022010-01-20 06:39:07 +000031 bool IsLittleEndian;
Chris Lattner90edac02009-09-14 03:02:37 +000032 MCInstPrinter *InstPrinter;
Daniel Dunbar4a0abd82009-08-27 00:51:57 +000033 MCCodeEmitter *Emitter;
Chris Lattner46a947d2009-08-17 04:17:34 +000034public:
Chris Lattneraf76e592009-08-22 20:48:53 +000035 MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const MCAsmInfo &tai,
Chris Lattner16582022010-01-20 06:39:07 +000036 bool isLittleEndian, MCInstPrinter *_Printer,
37 MCCodeEmitter *_Emitter)
Chris Lattner90edac02009-09-14 03:02:37 +000038 : MCStreamer(Context), OS(_OS), MAI(tai), InstPrinter(_Printer),
Daniel Dunbar4a0abd82009-08-27 00:51:57 +000039 Emitter(_Emitter) {}
Chris Lattner46a947d2009-08-17 04:17:34 +000040 ~MCAsmStreamer() {}
Daniel Dunbara11af532009-06-24 01:03:06 +000041
Chris Lattner16582022010-01-20 06:39:07 +000042 bool isLittleEndian() const { return IsLittleEndian; }
43
Chris Lattner46a947d2009-08-17 04:17:34 +000044 /// @name MCStreamer Interface
45 /// @{
Daniel Dunbara11af532009-06-24 01:03:06 +000046
Chris Lattner975780b2009-08-17 05:49:08 +000047 virtual void SwitchSection(const MCSection *Section);
Daniel Dunbara11af532009-06-24 01:03:06 +000048
Chris Lattner46a947d2009-08-17 04:17:34 +000049 virtual void EmitLabel(MCSymbol *Symbol);
Daniel Dunbara11af532009-06-24 01:03:06 +000050
Chris Lattner46a947d2009-08-17 04:17:34 +000051 virtual void EmitAssemblerFlag(AssemblerFlag Flag);
Daniel Dunbara11af532009-06-24 01:03:06 +000052
Daniel Dunbar821e3332009-08-31 08:09:28 +000053 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
Daniel Dunbara11af532009-06-24 01:03:06 +000054
Chris Lattner46a947d2009-08-17 04:17:34 +000055 virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute);
Kevin Enderbya5c78322009-07-13 21:03:15 +000056
Chris Lattner46a947d2009-08-17 04:17:34 +000057 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
Daniel Dunbara11af532009-06-24 01:03:06 +000058
Chris Lattner46a947d2009-08-17 04:17:34 +000059 virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
Daniel Dunbar7092c7e2009-08-30 06:17:16 +000060 unsigned ByteAlignment);
Kevin Enderby95cf30c2009-07-14 18:17:10 +000061
Daniel Dunbar8751b942009-08-28 05:48:22 +000062 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
Daniel Dunbar7092c7e2009-08-30 06:17:16 +000063 unsigned Size = 0, unsigned ByteAlignment = 0);
Kevin Enderby71148242009-07-14 21:35:03 +000064
Chris Lattneraaec2052010-01-19 19:46:13 +000065 virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
Chris Lattner4e4db7a2009-07-07 20:30:46 +000066
Chris Lattneraaec2052010-01-19 19:46:13 +000067 virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace);
Chris Lattner32ae3fe2010-01-19 22:03:38 +000068 virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace);
69
Chris Lattneraaec2052010-01-19 19:46:13 +000070 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
71 unsigned AddrSpace);
Chris Lattner9be3fee2009-07-10 22:20:30 +000072
Chris Lattner46a947d2009-08-17 04:17:34 +000073 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
74 unsigned ValueSize = 1,
75 unsigned MaxBytesToEmit = 0);
Daniel Dunbara11af532009-06-24 01:03:06 +000076
Daniel Dunbar821e3332009-08-31 08:09:28 +000077 virtual void EmitValueToOffset(const MCExpr *Offset,
Chris Lattner46a947d2009-08-17 04:17:34 +000078 unsigned char Value = 0);
79
80 virtual void EmitInstruction(const MCInst &Inst);
Daniel Dunbara11af532009-06-24 01:03:06 +000081
Chris Lattner46a947d2009-08-17 04:17:34 +000082 virtual void Finish();
83
84 /// @}
85};
Daniel Dunbar84a29262009-06-24 19:25:34 +000086
Chris Lattner46a947d2009-08-17 04:17:34 +000087} // end anonymous namespace.
Daniel Dunbara11af532009-06-24 01:03:06 +000088
Daniel Dunbar304f6a42009-06-25 21:03:18 +000089static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
90 assert(Bytes && "Invalid size!");
91 return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
92}
93
Daniel Dunbar821e3332009-08-31 08:09:28 +000094static inline const MCExpr *truncateToSize(const MCExpr *Value,
95 unsigned Bytes) {
96 // FIXME: Do we really need this routine?
97 return Value;
Daniel Dunbar304f6a42009-06-25 21:03:18 +000098}
99
Chris Lattner975780b2009-08-17 05:49:08 +0000100void MCAsmStreamer::SwitchSection(const MCSection *Section) {
Chris Lattner6c2f9e12009-08-19 05:49:37 +0000101 assert(Section && "Cannot switch to a null section!");
Daniel Dunbara11af532009-06-24 01:03:06 +0000102 if (Section != CurSection) {
103 CurSection = Section;
Chris Lattner33adcfb2009-08-22 21:43:10 +0000104 Section->PrintSwitchToSection(MAI, OS);
Daniel Dunbara11af532009-06-24 01:03:06 +0000105 }
106}
107
108void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
Daniel Dunbar8906ff12009-08-22 07:22:36 +0000109 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000110 assert(CurSection && "Cannot emit before setting section!");
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000111
Chris Lattner10b318b2010-01-17 21:43:43 +0000112 OS << *Symbol << ":\n";
Daniel Dunbar8906ff12009-08-22 07:22:36 +0000113 Symbol->setSection(*CurSection);
Daniel Dunbara11af532009-06-24 01:03:06 +0000114}
115
Kevin Enderbyf96db462009-07-16 17:56:39 +0000116void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
117 switch (Flag) {
Daniel Dunbar011e4db2009-08-13 23:36:34 +0000118 default: assert(0 && "Invalid flag!");
Kevin Enderbyf96db462009-07-16 17:56:39 +0000119 case SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
120 }
121 OS << '\n';
Kevin Enderbya5c78322009-07-13 21:03:15 +0000122}
123
Daniel Dunbar821e3332009-08-31 08:09:28 +0000124void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
Daniel Dunbar8906ff12009-08-22 07:22:36 +0000125 // Only absolute symbols can be redefined.
126 assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
127 "Cannot define a symbol twice!");
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000128
Chris Lattner8cb9a3b2010-01-18 00:37:40 +0000129 OS << *Symbol << " = " << *Value << '\n';
Daniel Dunbarfffff912009-10-16 01:34:54 +0000130
131 // FIXME: Lift context changes into super class.
Daniel Dunbar75773ff2009-10-16 01:57:39 +0000132 // FIXME: Set associated section.
Daniel Dunbarfffff912009-10-16 01:34:54 +0000133 Symbol->setValue(Value);
Daniel Dunbara11af532009-06-24 01:03:06 +0000134}
135
Daniel Dunbarfffff912009-10-16 01:34:54 +0000136void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
Daniel Dunbara11af532009-06-24 01:03:06 +0000137 SymbolAttr Attribute) {
138 switch (Attribute) {
Daniel Dunbar7eb85192009-10-16 01:58:15 +0000139 case Global: OS << ".globl"; break;
140 case Hidden: OS << ".hidden"; break;
Daniel Dunbard814b212009-06-24 16:36:52 +0000141 case IndirectSymbol: OS << ".indirect_symbol"; break;
Daniel Dunbar7eb85192009-10-16 01:58:15 +0000142 case Internal: OS << ".internal"; break;
143 case LazyReference: OS << ".lazy_reference"; break;
144 case NoDeadStrip: OS << ".no_dead_strip"; break;
145 case PrivateExtern: OS << ".private_extern"; break;
146 case Protected: OS << ".protected"; break;
147 case Reference: OS << ".reference"; break;
148 case Weak: OS << ".weak"; break;
Daniel Dunbard814b212009-06-24 16:36:52 +0000149 case WeakDefinition: OS << ".weak_definition"; break;
Daniel Dunbar7eb85192009-10-16 01:58:15 +0000150 case WeakReference: OS << ".weak_reference"; break;
Daniel Dunbara11af532009-06-24 01:03:06 +0000151 }
152
Chris Lattner10b318b2010-01-17 21:43:43 +0000153 OS << ' ' << *Symbol << '\n';
Daniel Dunbara11af532009-06-24 01:03:06 +0000154}
155
Kevin Enderby95cf30c2009-07-14 18:17:10 +0000156void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
Chris Lattner10b318b2010-01-17 21:43:43 +0000157 OS << ".desc" << ' ' << *Symbol << ',' << DescValue << '\n';
Kevin Enderby95cf30c2009-07-14 18:17:10 +0000158}
159
Chris Lattner4e4db7a2009-07-07 20:30:46 +0000160void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
Daniel Dunbar7092c7e2009-08-30 06:17:16 +0000161 unsigned ByteAlignment) {
Chris Lattner4ed54382010-01-19 06:01:04 +0000162 OS << MAI.getCOMMDirective() << *Symbol << ',' << Size;
163 if (ByteAlignment != 0 && MAI.getCOMMDirectiveTakesAlignment()) {
164 if (MAI.getAlignmentIsInBytes())
165 OS << ',' << ByteAlignment;
166 else
167 OS << ',' << Log2_32(ByteAlignment);
168 }
Chris Lattner4e4db7a2009-07-07 20:30:46 +0000169 OS << '\n';
170}
171
Daniel Dunbar8751b942009-08-28 05:48:22 +0000172void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
Daniel Dunbar7092c7e2009-08-30 06:17:16 +0000173 unsigned Size, unsigned ByteAlignment) {
Daniel Dunbar011e4db2009-08-13 23:36:34 +0000174 // Note: a .zerofill directive does not switch sections.
Chris Lattner93b6db32009-08-08 23:39:42 +0000175 OS << ".zerofill ";
176
177 // This is a mach-o specific directive.
Chris Lattnerff4bc462009-08-10 01:39:42 +0000178 const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
Daniel Dunbar12de0df2009-08-14 18:51:45 +0000179 OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
Chris Lattner93b6db32009-08-08 23:39:42 +0000180
Chris Lattner9be3fee2009-07-10 22:20:30 +0000181 if (Symbol != NULL) {
Chris Lattner10b318b2010-01-17 21:43:43 +0000182 OS << ',' << *Symbol << ',' << Size;
Daniel Dunbar7092c7e2009-08-30 06:17:16 +0000183 if (ByteAlignment != 0)
184 OS << ',' << Log2_32(ByteAlignment);
Chris Lattner9be3fee2009-07-10 22:20:30 +0000185 }
186 OS << '\n';
187}
188
Chris Lattneraaec2052010-01-19 19:46:13 +0000189void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000190 assert(CurSection && "Cannot emit contents before setting section!");
Chris Lattneraaec2052010-01-19 19:46:13 +0000191 const char *Directive = MAI.getData8bitsDirective(AddrSpace);
Daniel Dunbar9a7e2cc2009-07-27 21:49:56 +0000192 for (unsigned i = 0, e = Data.size(); i != e; ++i)
Chris Lattneraaec2052010-01-19 19:46:13 +0000193 OS << Directive << (unsigned)(unsigned char)Data[i] << '\n';
Daniel Dunbara11af532009-06-24 01:03:06 +0000194}
195
Chris Lattner32ae3fe2010-01-19 22:03:38 +0000196/// EmitIntValue - Special case of EmitValue that avoids the client having
197/// to pass in a MCExpr for constant integers.
198void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size,
199 unsigned AddrSpace) {
200 assert(CurSection && "Cannot emit contents before setting section!");
201 // Need target hooks to know how to print this.
202 const char *Directive = 0;
203 switch (Size) {
204 default: break;
205 case 1: Directive = MAI.getData8bitsDirective(AddrSpace); break;
206 case 2: Directive = MAI.getData16bitsDirective(AddrSpace); break;
207 case 4: Directive = MAI.getData32bitsDirective(AddrSpace); break;
208 case 8: Directive = MAI.getData64bitsDirective(AddrSpace); break;
209 }
210
211 assert(Directive && "Invalid size for machine code value!");
212 OS << Directive << truncateToSize(Value, Size) << '\n';
213}
214
Chris Lattneraaec2052010-01-19 19:46:13 +0000215void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size,
216 unsigned AddrSpace) {
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000217 assert(CurSection && "Cannot emit contents before setting section!");
Daniel Dunbara11af532009-06-24 01:03:06 +0000218 // Need target hooks to know how to print this.
Chris Lattner32ae3fe2010-01-19 22:03:38 +0000219 const char *Directive = 0;
Daniel Dunbara11af532009-06-24 01:03:06 +0000220 switch (Size) {
Chris Lattner32ae3fe2010-01-19 22:03:38 +0000221 default: break;
222 case 1: Directive = MAI.getData8bitsDirective(AddrSpace); break;
223 case 2: Directive = MAI.getData16bitsDirective(AddrSpace); break;
224 case 4: Directive = MAI.getData32bitsDirective(AddrSpace); break;
225 case 8: Directive = MAI.getData64bitsDirective(AddrSpace); break;
Daniel Dunbara11af532009-06-24 01:03:06 +0000226 }
Chris Lattneraaec2052010-01-19 19:46:13 +0000227
Chris Lattner32ae3fe2010-01-19 22:03:38 +0000228 assert(Directive && "Invalid size for machine code value!");
229 OS << Directive << *truncateToSize(Value, Size) << '\n';
Daniel Dunbara11af532009-06-24 01:03:06 +0000230}
231
Chris Lattner6113b3d2010-01-19 18:52:28 +0000232/// EmitFill - Emit NumBytes bytes worth of the value specified by
233/// FillValue. This implements directives such as '.space'.
Chris Lattneraaec2052010-01-19 19:46:13 +0000234void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
235 unsigned AddrSpace) {
Chris Lattner8a6d7ac2010-01-19 18:58:52 +0000236 if (NumBytes == 0) return;
237
Chris Lattneraaec2052010-01-19 19:46:13 +0000238 if (AddrSpace == 0)
239 if (const char *ZeroDirective = MAI.getZeroDirective()) {
240 OS << ZeroDirective << NumBytes;
241 if (FillValue != 0)
242 OS << ',' << (int)FillValue;
243 OS << '\n';
244 return;
245 }
246
247 // Emit a byte at a time.
248 MCStreamer::EmitFill(NumBytes, FillValue, AddrSpace);
Chris Lattner6113b3d2010-01-19 18:52:28 +0000249}
250
Daniel Dunbar84a29262009-06-24 19:25:34 +0000251void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
252 unsigned ValueSize,
253 unsigned MaxBytesToEmit) {
Chris Lattner663c2d22009-08-19 06:12:02 +0000254 // Some assemblers don't support non-power of two alignments, so we always
255 // emit alignments as a power of two if possible.
256 if (isPowerOf2_32(ByteAlignment)) {
Chris Lattner6e579c62009-08-19 06:35:36 +0000257 switch (ValueSize) {
258 default: llvm_unreachable("Invalid size for machine code value!");
Chris Lattner33adcfb2009-08-22 21:43:10 +0000259 case 1: OS << MAI.getAlignDirective(); break;
260 // FIXME: use MAI for this!
Chris Lattner6e579c62009-08-19 06:35:36 +0000261 case 2: OS << ".p2alignw "; break;
262 case 4: OS << ".p2alignl "; break;
263 case 8: llvm_unreachable("Unsupported alignment size!");
264 }
Chris Lattner663c2d22009-08-19 06:12:02 +0000265
Chris Lattner33adcfb2009-08-22 21:43:10 +0000266 if (MAI.getAlignmentIsInBytes())
Chris Lattner663c2d22009-08-19 06:12:02 +0000267 OS << ByteAlignment;
268 else
269 OS << Log2_32(ByteAlignment);
Daniel Dunbar84a29262009-06-24 19:25:34 +0000270
Chris Lattner663c2d22009-08-19 06:12:02 +0000271 if (Value || MaxBytesToEmit) {
Chris Lattner579531c2009-09-03 04:01:10 +0000272 OS << ", 0x";
273 OS.write_hex(truncateToSize(Value, ValueSize));
Chris Lattner663c2d22009-08-19 06:12:02 +0000274
275 if (MaxBytesToEmit)
276 OS << ", " << MaxBytesToEmit;
277 }
278 OS << '\n';
279 return;
280 }
281
282 // Non-power of two alignment. This is not widely supported by assemblers.
Chris Lattner33adcfb2009-08-22 21:43:10 +0000283 // FIXME: Parameterize this based on MAI.
Daniel Dunbar84a29262009-06-24 19:25:34 +0000284 switch (ValueSize) {
Chris Lattner663c2d22009-08-19 06:12:02 +0000285 default: llvm_unreachable("Invalid size for machine code value!");
286 case 1: OS << ".balign"; break;
287 case 2: OS << ".balignw"; break;
288 case 4: OS << ".balignl"; break;
289 case 8: llvm_unreachable("Unsupported alignment size!");
Daniel Dunbar84a29262009-06-24 19:25:34 +0000290 }
291
Chris Lattner663c2d22009-08-19 06:12:02 +0000292 OS << ' ' << ByteAlignment;
Daniel Dunbar304f6a42009-06-25 21:03:18 +0000293 OS << ", " << truncateToSize(Value, ValueSize);
Daniel Dunbar84a29262009-06-24 19:25:34 +0000294 if (MaxBytesToEmit)
295 OS << ", " << MaxBytesToEmit;
296 OS << '\n';
297}
298
Daniel Dunbar821e3332009-08-31 08:09:28 +0000299void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
Daniel Dunbar84a29262009-06-24 19:25:34 +0000300 unsigned char Value) {
301 // FIXME: Verify that Offset is associated with the current section.
Chris Lattner8cb9a3b2010-01-18 00:37:40 +0000302 OS << ".org " << *Offset << ", " << (unsigned) Value << '\n';
Daniel Dunbar84a29262009-06-24 19:25:34 +0000303}
304
Daniel Dunbara11af532009-06-24 01:03:06 +0000305void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
Daniel Dunbar71d259b2009-06-24 17:00:42 +0000306 assert(CurSection && "Cannot emit contents before setting section!");
Daniel Dunbarc22e0b22009-08-14 03:48:55 +0000307
308 // If we have an AsmPrinter, use that to print.
Chris Lattner90edac02009-09-14 03:02:37 +0000309 if (InstPrinter) {
310 InstPrinter->printInst(&Inst);
Chris Lattner1b6570e2009-09-13 22:24:34 +0000311 OS << '\n';
Daniel Dunbara356aea2009-08-27 07:58:57 +0000312
313 // Show the encoding if we have a code emitter.
314 if (Emitter) {
315 SmallString<256> Code;
316 raw_svector_ostream VecOS(Code);
317 Emitter->EncodeInstruction(Inst, VecOS);
318 VecOS.flush();
319
320 OS.indent(20);
321 OS << " # encoding: [";
322 for (unsigned i = 0, e = Code.size(); i != e; ++i) {
323 if (i)
324 OS << ',';
325 OS << format("%#04x", uint8_t(Code[i]));
326 }
327 OS << "]\n";
328 }
329
Daniel Dunbarc22e0b22009-08-14 03:48:55 +0000330 return;
331 }
332
333 // Otherwise fall back to a structural printing for now. Eventually we should
334 // always have access to the target specific printer.
Chris Lattner684c593d2009-09-03 05:46:51 +0000335 Inst.print(OS, &MAI);
Daniel Dunbar8c2eebe2009-08-31 08:08:38 +0000336 OS << '\n';
Daniel Dunbara11af532009-06-24 01:03:06 +0000337}
338
339void MCAsmStreamer::Finish() {
340 OS.flush();
341}
342
Daniel Dunbarc22e0b22009-08-14 03:48:55 +0000343MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS,
Chris Lattner16582022010-01-20 06:39:07 +0000344 const MCAsmInfo &MAI, bool isLittleEndian,
345 MCInstPrinter *IP,
Daniel Dunbar4a0abd82009-08-27 00:51:57 +0000346 MCCodeEmitter *CE) {
Chris Lattner16582022010-01-20 06:39:07 +0000347 return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, IP, CE);
Daniel Dunbara11af532009-06-24 01:03:06 +0000348}