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