Make the MCStreamer have a reset method and call that after finalization of the asm...
[oota-llvm.git] / include / llvm / MC / MCStreamer.h
1 //===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
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 // This file declares the MCStreamer class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSTREAMER_H
15 #define LLVM_MC_MCSTREAMER_H
16
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/MC/MCDirectives.h"
20 #include "llvm/MC/MCDwarf.h"
21 #include "llvm/MC/MCWin64EH.h"
22 #include "llvm/Support/DataTypes.h"
23
24 namespace llvm {
25   class MCAsmBackend;
26   class MCCodeEmitter;
27   class MCContext;
28   class MCExpr;
29   class MCInst;
30   class MCInstPrinter;
31   class MCSection;
32   class MCSymbol;
33   class StringRef;
34   class Twine;
35   class raw_ostream;
36   class formatted_raw_ostream;
37
38   /// MCStreamer - Streaming machine code generation interface.  This interface
39   /// is intended to provide a programatic interface that is very similar to the
40   /// level that an assembler .s file provides.  It has callbacks to emit bytes,
41   /// handle directives, etc.  The implementation of this interface retains
42   /// state to know what the current section is etc.
43   ///
44   /// There are multiple implementations of this interface: one for writing out
45   /// a .s file, and implementations that write out .o files of various formats.
46   ///
47   class MCStreamer {
48     MCContext &Context;
49
50     MCStreamer(const MCStreamer&) LLVM_DELETED_FUNCTION;
51     MCStreamer &operator=(const MCStreamer&) LLVM_DELETED_FUNCTION;
52
53     bool EmitEHFrame;
54     bool EmitDebugFrame;
55
56     std::vector<MCDwarfFrameInfo> FrameInfos;
57     MCDwarfFrameInfo *getCurrentFrameInfo();
58     MCSymbol *EmitCFICommon();
59     void EnsureValidFrame();
60
61     std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos;
62     MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
63     void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
64     void EnsureValidW64UnwindInfo();
65
66     MCSymbol* LastSymbol;
67
68     /// SectionStack - This is stack of current and previous section
69     /// values saved by PushSection.
70     SmallVector<std::pair<const MCSection *,
71                 const MCSection *>, 4> SectionStack;
72
73     bool AutoInitSections;
74
75   protected:
76     MCStreamer(MCContext &Ctx);
77
78     const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
79                                   const MCSymbol *B);
80
81     const MCExpr *ForceExpAbs(const MCExpr* Expr);
82
83     void RecordProcStart(MCDwarfFrameInfo &Frame);
84     virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
85     void RecordProcEnd(MCDwarfFrameInfo &Frame);
86     virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
87     void EmitFrames(bool usingCFI);
88
89     MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;}
90     void EmitW64Tables();
91
92   public:
93     virtual ~MCStreamer();
94
95     /// State management
96     ///
97     virtual void reset();
98
99     MCContext &getContext() const { return Context; }
100
101     unsigned getNumFrameInfos() {
102       return FrameInfos.size();
103     }
104
105     const MCDwarfFrameInfo &getFrameInfo(unsigned i) {
106       return FrameInfos[i];
107     }
108
109     ArrayRef<MCDwarfFrameInfo> getFrameInfos() {
110       return FrameInfos;
111     }
112
113     unsigned getNumW64UnwindInfos() {
114       return W64UnwindInfos.size();
115     }
116
117     MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) {
118       return *W64UnwindInfos[i];
119     }
120
121     /// @name Assembly File Formatting.
122     /// @{
123
124     /// isVerboseAsm - Return true if this streamer supports verbose assembly
125     /// and if it is enabled.
126     virtual bool isVerboseAsm() const { return false; }
127
128     /// hasRawTextSupport - Return true if this asm streamer supports emitting
129     /// unformatted text to the .s file with EmitRawText.
130     virtual bool hasRawTextSupport() const { return false; }
131
132     /// AddComment - Add a comment that can be emitted to the generated .s
133     /// file if applicable as a QoI issue to make the output of the compiler
134     /// more readable.  This only affects the MCAsmStreamer, and only when
135     /// verbose assembly output is enabled.
136     ///
137     /// If the comment includes embedded \n's, they will each get the comment
138     /// prefix as appropriate.  The added comment should not end with a \n.
139     virtual void AddComment(const Twine &T) {}
140
141     /// GetCommentOS - Return a raw_ostream that comments can be written to.
142     /// Unlike AddComment, you are required to terminate comments with \n if you
143     /// use this method.
144     virtual raw_ostream &GetCommentOS();
145
146     /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
147     virtual void AddBlankLine() {}
148
149     /// @}
150
151     /// @name Symbol & Section Management
152     /// @{
153
154     /// getCurrentSection - Return the current section that the streamer is
155     /// emitting code to.
156     const MCSection *getCurrentSection() const {
157       if (!SectionStack.empty())
158         return SectionStack.back().first;
159       return NULL;
160     }
161
162     /// getPreviousSection - Return the previous section that the streamer is
163     /// emitting code to.
164     const MCSection *getPreviousSection() const {
165       if (!SectionStack.empty())
166         return SectionStack.back().second;
167       return NULL;
168     }
169
170     /// ChangeSection - Update streamer for a new active section.
171     ///
172     /// This is called by PopSection and SwitchSection, if the current
173     /// section changes.
174     virtual void ChangeSection(const MCSection *) = 0;
175
176     /// pushSection - Save the current and previous section on the
177     /// section stack.
178     void PushSection() {
179       SectionStack.push_back(std::make_pair(getCurrentSection(),
180                                             getPreviousSection()));
181     }
182
183     /// popSection - Restore the current and previous section from
184     /// the section stack.  Calls ChangeSection as needed.
185     ///
186     /// Returns false if the stack was empty.
187     bool PopSection() {
188       if (SectionStack.size() <= 1)
189         return false;
190       const MCSection *oldSection = SectionStack.pop_back_val().first;
191       const MCSection *curSection = SectionStack.back().first;
192
193       if (oldSection != curSection)
194         ChangeSection(curSection);
195       return true;
196     }
197
198     /// SwitchSection - Set the current section where code is being emitted to
199     /// @p Section.  This is required to update CurSection.
200     ///
201     /// This corresponds to assembler directives like .section, .text, etc.
202     void SwitchSection(const MCSection *Section) {
203       assert(Section && "Cannot switch to a null section!");
204       const MCSection *curSection = SectionStack.back().first;
205       SectionStack.back().second = curSection;
206       if (Section != curSection) {
207         SectionStack.back().first = Section;
208         ChangeSection(Section);
209       }
210     }
211
212     /// SwitchSectionNoChange - Set the current section where code is being
213     /// emitted to @p Section.  This is required to update CurSection. This
214     /// version does not call ChangeSection.
215     void SwitchSectionNoChange(const MCSection *Section) {
216       assert(Section && "Cannot switch to a null section!");
217       const MCSection *curSection = SectionStack.back().first;
218       SectionStack.back().second = curSection;
219       if (Section != curSection)
220         SectionStack.back().first = Section;
221     }
222
223     /// Initialize the streamer.
224     void InitStreamer() {
225       if (AutoInitSections)
226         InitSections();
227     }
228
229     /// Tell this MCStreamer to call InitSections upon initialization.
230     void setAutoInitSections(bool AutoInitSections) {
231       this->AutoInitSections = AutoInitSections;
232     }
233
234     /// InitSections - Create the default sections and set the initial one.
235     virtual void InitSections() = 0;
236
237     /// EmitLabel - Emit a label for @p Symbol into the current section.
238     ///
239     /// This corresponds to an assembler statement such as:
240     ///   foo:
241     ///
242     /// @param Symbol - The symbol to emit. A given symbol should only be
243     /// emitted as a label once, and symbols emitted as a label should never be
244     /// used in an assignment.
245     virtual void EmitLabel(MCSymbol *Symbol);
246
247     virtual void EmitEHSymAttributes(const MCSymbol *Symbol,
248                                      MCSymbol *EHSymbol);
249
250     /// EmitAssemblerFlag - Note in the output the specified @p Flag.
251     virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0;
252
253     /// EmitDataRegion - Note in the output the specified region @p Kind.
254     virtual void EmitDataRegion(MCDataRegionType Kind) {}
255
256     /// EmitThumbFunc - Note in the output that the specified @p Func is
257     /// a Thumb mode function (ARM target only).
258     virtual void EmitThumbFunc(MCSymbol *Func) = 0;
259
260     /// EmitAssignment - Emit an assignment of @p Value to @p Symbol.
261     ///
262     /// This corresponds to an assembler statement such as:
263     ///  symbol = value
264     ///
265     /// The assignment generates no code, but has the side effect of binding the
266     /// value in the current context. For the assembly streamer, this prints the
267     /// binding into the .s file.
268     ///
269     /// @param Symbol - The symbol being assigned to.
270     /// @param Value - The value for the symbol.
271     virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0;
272
273     /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol.
274     ///
275     /// This corresponds to an assembler statement such as:
276     ///  .weakref alias, symbol
277     ///
278     /// @param Alias - The alias that is being created.
279     /// @param Symbol - The symbol being aliased.
280     virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0;
281
282     /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol.
283     virtual void EmitSymbolAttribute(MCSymbol *Symbol,
284                                      MCSymbolAttr Attribute) = 0;
285
286     /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol.
287     ///
288     /// @param Symbol - The symbol to have its n_desc field set.
289     /// @param DescValue - The value to set into the n_desc field.
290     virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
291
292     /// BeginCOFFSymbolDef - Start emitting COFF symbol definition
293     ///
294     /// @param Symbol - The symbol to have its External & Type fields set.
295     virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0;
296
297     /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol.
298     ///
299     /// @param StorageClass - The storage class the symbol should have.
300     virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0;
301
302     /// EmitCOFFSymbolType - Emit the type of the symbol.
303     ///
304     /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
305     virtual void EmitCOFFSymbolType(int Type) = 0;
306
307     /// EndCOFFSymbolDef - Marks the end of the symbol definition.
308     virtual void EndCOFFSymbolDef() = 0;
309
310     /// EmitCOFFSecRel32 - Emits a COFF section relative relocation.
311     ///
312     /// @param Symbol - Symbol the section relative realocation should point to.
313     virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
314
315     /// EmitELFSize - Emit an ELF .size directive.
316     ///
317     /// This corresponds to an assembler statement such as:
318     ///  .size symbol, expression
319     ///
320     virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0;
321
322     /// EmitCommonSymbol - Emit a common symbol.
323     ///
324     /// @param Symbol - The common symbol to emit.
325     /// @param Size - The size of the common symbol.
326     /// @param ByteAlignment - The alignment of the symbol if
327     /// non-zero. This must be a power of 2.
328     virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
329                                   unsigned ByteAlignment) = 0;
330
331     /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
332     ///
333     /// @param Symbol - The common symbol to emit.
334     /// @param Size - The size of the common symbol.
335     /// @param ByteAlignment - The alignment of the common symbol in bytes.
336     virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
337                                        unsigned ByteAlignment) = 0;
338
339     /// EmitZerofill - Emit the zerofill section and an optional symbol.
340     ///
341     /// @param Section - The zerofill section to create and or to put the symbol
342     /// @param Symbol - The zerofill symbol to emit, if non-NULL.
343     /// @param Size - The size of the zerofill symbol.
344     /// @param ByteAlignment - The alignment of the zerofill symbol if
345     /// non-zero. This must be a power of 2 on some targets.
346     virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
347                               uint64_t Size = 0,unsigned ByteAlignment = 0) = 0;
348
349     /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol.
350     ///
351     /// @param Section - The thread local common section.
352     /// @param Symbol - The thread local common symbol to emit.
353     /// @param Size - The size of the symbol.
354     /// @param ByteAlignment - The alignment of the thread local common symbol
355     /// if non-zero.  This must be a power of 2 on some targets.
356     virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
357                                 uint64_t Size, unsigned ByteAlignment = 0) = 0;
358
359     /// @}
360     /// @name Generating Data
361     /// @{
362
363     /// EmitBytes - Emit the bytes in \p Data into the output.
364     ///
365     /// This is used to implement assembler directives such as .byte, .ascii,
366     /// etc.
367     virtual void EmitBytes(StringRef Data, unsigned AddrSpace) = 0;
368
369     /// EmitValue - Emit the expression @p Value into the output as a native
370     /// integer of the given @p Size bytes.
371     ///
372     /// This is used to implement assembler directives such as .word, .quad,
373     /// etc.
374     ///
375     /// @param Value - The value to emit.
376     /// @param Size - The size of the integer (in bytes) to emit. This must
377     /// match a native machine width.
378     virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
379                                unsigned AddrSpace) = 0;
380
381     void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0);
382
383     /// EmitIntValue - Special case of EmitValue that avoids the client having
384     /// to pass in a MCExpr for constant integers.
385     virtual void EmitIntValue(uint64_t Value, unsigned Size,
386                               unsigned AddrSpace = 0);
387
388     /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
389     /// this is done by producing
390     /// foo = value
391     /// .long foo
392     void EmitAbsValue(const MCExpr *Value, unsigned Size,
393                       unsigned AddrSpace = 0);
394
395     virtual void EmitULEB128Value(const MCExpr *Value) = 0;
396
397     virtual void EmitSLEB128Value(const MCExpr *Value) = 0;
398
399     /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
400     /// client having to pass in a MCExpr for constant integers.
401     void EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace = 0,
402                              unsigned Padding = 0);
403
404     /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
405     /// client having to pass in a MCExpr for constant integers.
406     void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0);
407
408     /// EmitSymbolValue - Special case of EmitValue that avoids the client
409     /// having to pass in a MCExpr for MCSymbols.
410     void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
411                          unsigned AddrSpace = 0);
412
413     /// EmitGPRel64Value - Emit the expression @p Value into the output as a
414     /// gprel64 (64-bit GP relative) value.
415     ///
416     /// This is used to implement assembler directives such as .gpdword on
417     /// targets that support them.
418     virtual void EmitGPRel64Value(const MCExpr *Value);
419
420     /// EmitGPRel32Value - Emit the expression @p Value into the output as a
421     /// gprel32 (32-bit GP relative) value.
422     ///
423     /// This is used to implement assembler directives such as .gprel32 on
424     /// targets that support them.
425     virtual void EmitGPRel32Value(const MCExpr *Value);
426
427     /// EmitFill - Emit NumBytes bytes worth of the value specified by
428     /// FillValue.  This implements directives such as '.space'.
429     virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
430                           unsigned AddrSpace);
431
432     /// EmitZeros - Emit NumBytes worth of zeros.  This is a convenience
433     /// function that just wraps EmitFill.
434     void EmitZeros(uint64_t NumBytes, unsigned AddrSpace) {
435       EmitFill(NumBytes, 0, AddrSpace);
436     }
437
438
439     /// EmitValueToAlignment - Emit some number of copies of @p Value until
440     /// the byte alignment @p ByteAlignment is reached.
441     ///
442     /// If the number of bytes need to emit for the alignment is not a multiple
443     /// of @p ValueSize, then the contents of the emitted fill bytes is
444     /// undefined.
445     ///
446     /// This used to implement the .align assembler directive.
447     ///
448     /// @param ByteAlignment - The alignment to reach. This must be a power of
449     /// two on some targets.
450     /// @param Value - The value to use when filling bytes.
451     /// @param ValueSize - The size of the integer (in bytes) to emit for
452     /// @p Value. This must match a native machine width.
453     /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
454     /// the alignment cannot be reached in this many bytes, no bytes are
455     /// emitted.
456     virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
457                                       unsigned ValueSize = 1,
458                                       unsigned MaxBytesToEmit = 0) = 0;
459
460     /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment
461     /// is reached.
462     ///
463     /// This used to align code where the alignment bytes may be executed.  This
464     /// can emit different bytes for different sizes to optimize execution.
465     ///
466     /// @param ByteAlignment - The alignment to reach. This must be a power of
467     /// two on some targets.
468     /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
469     /// the alignment cannot be reached in this many bytes, no bytes are
470     /// emitted.
471     virtual void EmitCodeAlignment(unsigned ByteAlignment,
472                                    unsigned MaxBytesToEmit = 0) = 0;
473
474     /// EmitValueToOffset - Emit some number of copies of @p Value until the
475     /// byte offset @p Offset is reached.
476     ///
477     /// This is used to implement assembler directives such as .org.
478     ///
479     /// @param Offset - The offset to reach. This may be an expression, but the
480     /// expression must be associated with the current section.
481     /// @param Value - The value to use when filling bytes.
482     /// @return false on success, true if the offset was invalid.
483     virtual bool EmitValueToOffset(const MCExpr *Offset,
484                                    unsigned char Value = 0) = 0;
485
486     /// @}
487
488     /// EmitFileDirective - Switch to a new logical file.  This is used to
489     /// implement the '.file "foo.c"' assembler directive.
490     virtual void EmitFileDirective(StringRef Filename) = 0;
491
492     /// EmitDwarfFileDirective - Associate a filename with a specified logical
493     /// file number.  This implements the DWARF2 '.file 4 "foo.c"' assembler
494     /// directive.
495     virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
496                                         StringRef Filename);
497
498     /// EmitDwarfLocDirective - This implements the DWARF2
499     // '.loc fileno lineno ...' assembler directive.
500     virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
501                                        unsigned Column, unsigned Flags,
502                                        unsigned Isa,
503                                        unsigned Discriminator,
504                                        StringRef FileName);
505
506     virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
507                                           const MCSymbol *LastLabel,
508                                           const MCSymbol *Label,
509                                           unsigned PointerSize) = 0;
510
511     virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
512                                            const MCSymbol *Label) {
513     }
514
515     void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
516                               int PointerSize);
517
518     virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding);
519     virtual void EmitCFISections(bool EH, bool Debug);
520     void EmitCFIStartProc();
521     void EmitCFIEndProc();
522     virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
523     virtual void EmitCFIDefCfaOffset(int64_t Offset);
524     virtual void EmitCFIDefCfaRegister(int64_t Register);
525     virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
526     virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
527     virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
528     virtual void EmitCFIRememberState();
529     virtual void EmitCFIRestoreState();
530     virtual void EmitCFISameValue(int64_t Register);
531     virtual void EmitCFIRestore(int64_t Register);
532     virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
533     virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
534     virtual void EmitCFIEscape(StringRef Values);
535     virtual void EmitCFISignalFrame();
536     virtual void EmitCFIUndefined(int64_t Register);
537     virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
538
539     virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
540     virtual void EmitWin64EHEndProc();
541     virtual void EmitWin64EHStartChained();
542     virtual void EmitWin64EHEndChained();
543     virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
544                                     bool Except);
545     virtual void EmitWin64EHHandlerData();
546     virtual void EmitWin64EHPushReg(unsigned Register);
547     virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset);
548     virtual void EmitWin64EHAllocStack(unsigned Size);
549     virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset);
550     virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset);
551     virtual void EmitWin64EHPushFrame(bool Code);
552     virtual void EmitWin64EHEndProlog();
553
554     /// EmitInstruction - Emit the given @p Instruction into the current
555     /// section.
556     virtual void EmitInstruction(const MCInst &Inst) = 0;
557
558     /// EmitRawText - If this file is backed by a assembly streamer, this dumps
559     /// the specified string in the output .s file.  This capability is
560     /// indicated by the hasRawTextSupport() predicate.  By default this aborts.
561     virtual void EmitRawText(StringRef String);
562     void EmitRawText(const Twine &String);
563
564     /// ARM-related methods.
565     /// FIXME: Eventually we should have some "target MC streamer" and move
566     /// these methods there.
567     virtual void EmitFnStart();
568     virtual void EmitFnEnd();
569     virtual void EmitCantUnwind();
570     virtual void EmitPersonality(const MCSymbol *Personality);
571     virtual void EmitHandlerData();
572     virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0);
573     virtual void EmitPad(int64_t Offset);
574     virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
575                              bool isVector);
576
577     /// PPC-related methods.
578     /// FIXME: Eventually replace it with some "target MC streamer" and move
579     /// these methods there.
580     virtual void EmitTCEntry(const MCSymbol &S);
581
582     /// FinishImpl - Streamer specific finalization.
583     virtual void FinishImpl() = 0;
584     /// Finish - Finish emission of machine code.
585     void Finish();
586   };
587
588   /// createNullStreamer - Create a dummy machine code streamer, which does
589   /// nothing. This is useful for timing the assembler front end.
590   MCStreamer *createNullStreamer(MCContext &Ctx);
591
592   /// createAsmStreamer - Create a machine code streamer which will print out
593   /// assembly for the native target, suitable for compiling with a native
594   /// assembler.
595   ///
596   /// \param InstPrint - If given, the instruction printer to use. If not given
597   /// the MCInst representation will be printed.  This method takes ownership of
598   /// InstPrint.
599   ///
600   /// \param CE - If given, a code emitter to use to show the instruction
601   /// encoding inline with the assembly. This method takes ownership of \p CE.
602   ///
603   /// \param TAB - If given, a target asm backend to use to show the fixup
604   /// information in conjunction with encoding information. This method takes
605   /// ownership of \p TAB.
606   ///
607   /// \param ShowInst - Whether to show the MCInst representation inline with
608   /// the assembly.
609   MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
610                                 bool isVerboseAsm,
611                                 bool useLoc,
612                                 bool useCFI,
613                                 bool useDwarfDirectory,
614                                 MCInstPrinter *InstPrint = 0,
615                                 MCCodeEmitter *CE = 0,
616                                 MCAsmBackend *TAB = 0,
617                                 bool ShowInst = false);
618
619   /// createMachOStreamer - Create a machine code streamer which will generate
620   /// Mach-O format object files.
621   ///
622   /// Takes ownership of \p TAB and \p CE.
623   MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
624                                   raw_ostream &OS, MCCodeEmitter *CE,
625                                   bool RelaxAll = false);
626
627   /// createWinCOFFStreamer - Create a machine code streamer which will
628   /// generate Microsoft COFF format object files.
629   ///
630   /// Takes ownership of \p TAB and \p CE.
631   MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
632                                     MCAsmBackend &TAB,
633                                     MCCodeEmitter &CE, raw_ostream &OS,
634                                     bool RelaxAll = false);
635
636   /// createELFStreamer - Create a machine code streamer which will generate
637   /// ELF format object files.
638   MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
639                                 raw_ostream &OS, MCCodeEmitter *CE,
640                                 bool RelaxAll, bool NoExecStack);
641
642   /// createPureStreamer - Create a machine code streamer which will generate
643   /// "pure" MC object files, for use with MC-JIT and testing tools.
644   ///
645   /// Takes ownership of \p TAB and \p CE.
646   MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
647                                  raw_ostream &OS, MCCodeEmitter *CE);
648
649 } // end namespace llvm
650
651 #endif