Add a new MachineJumpTableInfo entry type, EK_GPRel64BlockAddress, which is
[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 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     /// 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                           unsigned AddrSpace);
462
463     /// EmitZeros - Emit NumBytes worth of zeros.  This is a convenience
464     /// function that just wraps EmitFill.
465     void EmitZeros(uint64_t NumBytes, unsigned AddrSpace) {
466       EmitFill(NumBytes, 0, AddrSpace);
467     }
468
469
470     /// EmitValueToAlignment - Emit some number of copies of @p Value until
471     /// the byte alignment @p ByteAlignment is reached.
472     ///
473     /// If the number of bytes need to emit for the alignment is not a multiple
474     /// of @p ValueSize, then the contents of the emitted fill bytes is
475     /// undefined.
476     ///
477     /// This used to implement the .align assembler directive.
478     ///
479     /// @param ByteAlignment - The alignment to reach. This must be a power of
480     /// two on some targets.
481     /// @param Value - The value to use when filling bytes.
482     /// @param ValueSize - The size of the integer (in bytes) to emit for
483     /// @p Value. This must match a native machine width.
484     /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
485     /// the alignment cannot be reached in this many bytes, no bytes are
486     /// emitted.
487     virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
488                                       unsigned ValueSize = 1,
489                                       unsigned MaxBytesToEmit = 0) = 0;
490
491     /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment
492     /// is reached.
493     ///
494     /// This used to align code where the alignment bytes may be executed.  This
495     /// can emit different bytes for different sizes to optimize execution.
496     ///
497     /// @param ByteAlignment - The alignment to reach. This must be a power of
498     /// two on some targets.
499     /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
500     /// the alignment cannot be reached in this many bytes, no bytes are
501     /// emitted.
502     virtual void EmitCodeAlignment(unsigned ByteAlignment,
503                                    unsigned MaxBytesToEmit = 0) = 0;
504
505     /// EmitValueToOffset - Emit some number of copies of @p Value until the
506     /// byte offset @p Offset is reached.
507     ///
508     /// This is used to implement assembler directives such as .org.
509     ///
510     /// @param Offset - The offset to reach. This may be an expression, but the
511     /// expression must be associated with the current section.
512     /// @param Value - The value to use when filling bytes.
513     /// @return false on success, true if the offset was invalid.
514     virtual bool EmitValueToOffset(const MCExpr *Offset,
515                                    unsigned char Value = 0) = 0;
516
517     /// @}
518
519     /// EmitFileDirective - Switch to a new logical file.  This is used to
520     /// implement the '.file "foo.c"' assembler directive.
521     virtual void EmitFileDirective(StringRef Filename) = 0;
522
523     /// EmitDwarfFileDirective - Associate a filename with a specified logical
524     /// file number.  This implements the DWARF2 '.file 4 "foo.c"' assembler
525     /// directive.
526     virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
527                                         StringRef Filename);
528
529     /// EmitDwarfLocDirective - This implements the DWARF2
530     // '.loc fileno lineno ...' assembler directive.
531     virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
532                                        unsigned Column, unsigned Flags,
533                                        unsigned Isa,
534                                        unsigned Discriminator,
535                                        StringRef FileName);
536
537     virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
538                                           const MCSymbol *LastLabel,
539                                           const MCSymbol *Label,
540                                           unsigned PointerSize) = 0;
541
542     virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
543                                            const MCSymbol *Label) {
544     }
545
546     void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
547                               int PointerSize);
548
549     virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding);
550     virtual void EmitCFISections(bool EH, bool Debug);
551     void EmitCFIStartProc();
552     void EmitCFIEndProc();
553     virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
554     virtual void EmitCFIDefCfaOffset(int64_t Offset);
555     virtual void EmitCFIDefCfaRegister(int64_t Register);
556     virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
557     virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
558     virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
559     virtual void EmitCFIRememberState();
560     virtual void EmitCFIRestoreState();
561     virtual void EmitCFISameValue(int64_t Register);
562     virtual void EmitCFIRestore(int64_t Register);
563     virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
564     virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
565     virtual void EmitCFIEscape(StringRef Values);
566     virtual void EmitCFISignalFrame();
567
568     virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
569     virtual void EmitWin64EHEndProc();
570     virtual void EmitWin64EHStartChained();
571     virtual void EmitWin64EHEndChained();
572     virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
573                                     bool Except);
574     virtual void EmitWin64EHHandlerData();
575     virtual void EmitWin64EHPushReg(unsigned Register);
576     virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset);
577     virtual void EmitWin64EHAllocStack(unsigned Size);
578     virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset);
579     virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset);
580     virtual void EmitWin64EHPushFrame(bool Code);
581     virtual void EmitWin64EHEndProlog();
582
583     /// EmitInstruction - Emit the given @p Instruction into the current
584     /// section.
585     virtual void EmitInstruction(const MCInst &Inst) = 0;
586
587     /// EmitRawText - If this file is backed by a assembly streamer, this dumps
588     /// the specified string in the output .s file.  This capability is
589     /// indicated by the hasRawTextSupport() predicate.  By default this aborts.
590     virtual void EmitRawText(StringRef String);
591     void EmitRawText(const Twine &String);
592
593     /// ARM-related methods.
594     /// FIXME: Eventually we should have some "target MC streamer" and move
595     /// these methods there.
596     virtual void EmitFnStart();
597     virtual void EmitFnEnd();
598     virtual void EmitCantUnwind();
599     virtual void EmitPersonality(const MCSymbol *Personality);
600     virtual void EmitHandlerData();
601     virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0);
602     virtual void EmitPad(int64_t Offset);
603     virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
604                              bool isVector);
605
606     /// FinishImpl - Streamer specific finalization.
607     virtual void FinishImpl() = 0;
608     /// Finish - Finish emission of machine code.
609     void Finish();
610   };
611
612   /// createNullStreamer - Create a dummy machine code streamer, which does
613   /// nothing. This is useful for timing the assembler front end.
614   MCStreamer *createNullStreamer(MCContext &Ctx);
615
616   /// createAsmStreamer - Create a machine code streamer which will print out
617   /// assembly for the native target, suitable for compiling with a native
618   /// assembler.
619   ///
620   /// \param InstPrint - If given, the instruction printer to use. If not given
621   /// the MCInst representation will be printed.  This method takes ownership of
622   /// InstPrint.
623   ///
624   /// \param CE - If given, a code emitter to use to show the instruction
625   /// encoding inline with the assembly. This method takes ownership of \arg CE.
626   ///
627   /// \param TAB - If given, a target asm backend to use to show the fixup
628   /// information in conjunction with encoding information. This method takes
629   /// ownership of \arg TAB.
630   ///
631   /// \param ShowInst - Whether to show the MCInst representation inline with
632   /// the assembly.
633   ///
634   /// \param DecodeLSDA - If true, emit comments that translates the LSDA into a
635   /// human readable format. Only usable with CFI.
636   MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
637                                 bool isVerboseAsm,
638                                 bool useLoc,
639                                 bool useCFI,
640                                 bool useDwarfDirectory,
641                                 MCInstPrinter *InstPrint = 0,
642                                 MCCodeEmitter *CE = 0,
643                                 MCAsmBackend *TAB = 0,
644                                 bool ShowInst = false);
645
646   /// createMachOStreamer - Create a machine code streamer which will generate
647   /// Mach-O format object files.
648   ///
649   /// Takes ownership of \arg TAB and \arg CE.
650   MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
651                                   raw_ostream &OS, MCCodeEmitter *CE,
652                                   bool RelaxAll = false);
653
654   /// createWinCOFFStreamer - Create a machine code streamer which will
655   /// generate Microsoft COFF format object files.
656   ///
657   /// Takes ownership of \arg TAB and \arg CE.
658   MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
659                                     MCAsmBackend &TAB,
660                                     MCCodeEmitter &CE, raw_ostream &OS,
661                                     bool RelaxAll = false);
662
663   /// createELFStreamer - Create a machine code streamer which will generate
664   /// ELF format object files.
665   MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
666                                 raw_ostream &OS, MCCodeEmitter *CE,
667                                 bool RelaxAll, bool NoExecStack);
668
669   /// createPureStreamer - Create a machine code streamer which will generate
670   /// "pure" MC object files, for use with MC-JIT and testing tools.
671   ///
672   /// Takes ownership of \arg TAB and \arg CE.
673   MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
674                                  raw_ostream &OS, MCCodeEmitter *CE);
675
676 } // end namespace llvm
677
678 #endif