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