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