1 //===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the MCStreamer class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSTREAMER_H
15 #define LLVM_MC_MCSTREAMER_H
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"
38 class formatted_raw_ostream;
40 typedef std::pair<const MCSection *, const MCExpr *> MCSectionSubPair;
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.
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.
54 MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION;
55 MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION;
60 std::vector<MCDwarfFrameInfo> FrameInfos;
61 MCDwarfFrameInfo *getCurrentFrameInfo();
62 MCSymbol *EmitCFICommon();
63 void EnsureValidFrame();
65 std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos;
66 MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
67 void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
68 void EnsureValidW64UnwindInfo();
72 // SymbolOrdering - Tracks an index to represent the order
73 // a symbol was emitted in. Zero means we did not emit that symbol.
74 DenseMap<const MCSymbol *, unsigned> SymbolOrdering;
76 /// SectionStack - This is stack of current and previous section
77 /// values saved by PushSection.
78 SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
80 bool AutoInitSections;
83 MCStreamer(MCContext &Ctx);
85 const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
88 const MCExpr *ForceExpAbs(const MCExpr *Expr);
90 void RecordProcStart(MCDwarfFrameInfo &Frame);
91 virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
92 void RecordProcEnd(MCDwarfFrameInfo &Frame);
93 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
94 void EmitFrames(MCAsmBackend *MAB, bool usingCFI);
96 MCWin64EHUnwindInfo *getCurrentW64UnwindInfo() {
97 return CurrentW64UnwindInfo;
102 virtual ~MCStreamer();
106 virtual void reset();
108 MCContext &getContext() const { return Context; }
110 unsigned getNumFrameInfos() { return FrameInfos.size(); }
112 const MCDwarfFrameInfo &getFrameInfo(unsigned i) { return FrameInfos[i]; }
114 ArrayRef<MCDwarfFrameInfo> getFrameInfos() const { return FrameInfos; }
116 unsigned getNumW64UnwindInfos() { return W64UnwindInfos.size(); }
118 MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) {
119 return *W64UnwindInfos[i];
122 void generateCompactUnwindEncodings(MCAsmBackend *MAB);
124 /// @name Assembly File Formatting.
127 /// isVerboseAsm - Return true if this streamer supports verbose assembly
128 /// and if it is enabled.
129 virtual bool isVerboseAsm() const { return false; }
131 /// hasRawTextSupport - Return true if this asm streamer supports emitting
132 /// unformatted text to the .s file with EmitRawText.
133 virtual bool hasRawTextSupport() const { return false; }
135 /// AddComment - Add a comment that can be emitted to the generated .s
136 /// file if applicable as a QoI issue to make the output of the compiler
137 /// more readable. This only affects the MCAsmStreamer, and only when
138 /// verbose assembly output is enabled.
140 /// If the comment includes embedded \n's, they will each get the comment
141 /// prefix as appropriate. The added comment should not end with a \n.
142 virtual void AddComment(const Twine &T) {}
144 /// GetCommentOS - Return a raw_ostream that comments can be written to.
145 /// Unlike AddComment, you are required to terminate comments with \n if you
147 virtual raw_ostream &GetCommentOS();
149 /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
150 virtual void AddBlankLine() {}
154 /// @name Symbol & Section Management
157 /// getCurrentSection - Return the current section that the streamer is
158 /// emitting code to.
159 MCSectionSubPair getCurrentSection() const {
160 if (!SectionStack.empty())
161 return SectionStack.back().first;
162 return MCSectionSubPair();
165 /// getPreviousSection - Return the previous section that the streamer is
166 /// emitting code to.
167 MCSectionSubPair getPreviousSection() const {
168 if (!SectionStack.empty())
169 return SectionStack.back().second;
170 return MCSectionSubPair();
173 /// GetSymbolOrder - Returns an index to represent the order
174 /// a symbol was emitted in. (zero if we did not emit that symbol)
175 unsigned GetSymbolOrder(const MCSymbol *Sym) const {
176 return SymbolOrdering.lookup(Sym);
179 /// ChangeSection - Update streamer for a new active section.
181 /// This is called by PopSection and SwitchSection, if the current
183 virtual void ChangeSection(const MCSection *, const MCExpr *) = 0;
185 /// pushSection - Save the current and previous section on the
188 SectionStack.push_back(
189 std::make_pair(getCurrentSection(), getPreviousSection()));
192 /// popSection - Restore the current and previous section from
193 /// the section stack. Calls ChangeSection as needed.
195 /// Returns false if the stack was empty.
197 if (SectionStack.size() <= 1)
199 MCSectionSubPair oldSection = SectionStack.pop_back_val().first;
200 MCSectionSubPair curSection = SectionStack.back().first;
202 if (oldSection != curSection)
203 ChangeSection(curSection.first, curSection.second);
207 bool SubSection(const MCExpr *Subsection) {
208 if (SectionStack.empty())
211 SwitchSection(SectionStack.back().first.first, Subsection);
215 /// SwitchSection - Set the current section where code is being emitted to
216 /// @p Section. This is required to update CurSection.
218 /// This corresponds to assembler directives like .section, .text, etc.
219 void SwitchSection(const MCSection *Section, const MCExpr *Subsection = 0) {
220 assert(Section && "Cannot switch to a null section!");
221 MCSectionSubPair curSection = SectionStack.back().first;
222 SectionStack.back().second = curSection;
223 if (MCSectionSubPair(Section, Subsection) != curSection) {
224 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
225 ChangeSection(Section, Subsection);
229 /// SwitchSectionNoChange - Set the current section where code is being
230 /// emitted to @p Section. This is required to update CurSection. This
231 /// version does not call ChangeSection.
232 void SwitchSectionNoChange(const MCSection *Section,
233 const MCExpr *Subsection = 0) {
234 assert(Section && "Cannot switch to a null section!");
235 MCSectionSubPair curSection = SectionStack.back().first;
236 SectionStack.back().second = curSection;
237 if (MCSectionSubPair(Section, Subsection) != curSection)
238 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
241 /// Initialize the streamer.
242 void InitStreamer() {
243 if (AutoInitSections)
247 /// Tell this MCStreamer to call InitSections upon initialization.
248 void setAutoInitSections(bool AutoInitSections) {
249 this->AutoInitSections = AutoInitSections;
252 /// InitSections - Create the default sections and set the initial one.
253 virtual void InitSections() = 0;
255 /// InitToTextSection - Create a text section and switch the streamer to it.
256 virtual void InitToTextSection() = 0;
258 /// AssignSection - Sets the symbol's section.
260 /// Each emitted symbol will be tracked in the ordering table,
261 /// so we can sort on them later.
262 void AssignSection(MCSymbol *Symbol, const MCSection *Section);
264 /// EmitLabel - Emit a label for @p Symbol into the current section.
266 /// This corresponds to an assembler statement such as:
269 /// @param Symbol - The symbol to emit. A given symbol should only be
270 /// emitted as a label once, and symbols emitted as a label should never be
271 /// used in an assignment.
272 virtual void EmitLabel(MCSymbol *Symbol);
274 virtual void EmitDebugLabel(MCSymbol *Symbol);
276 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
278 /// EmitAssemblerFlag - Note in the output the specified @p Flag.
279 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0;
281 /// EmitLinkerOptions - Emit the given list @p Options of strings as linker
282 /// options into the output.
283 virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {}
285 /// EmitDataRegion - Note in the output the specified region @p Kind.
286 virtual void EmitDataRegion(MCDataRegionType Kind) {}
288 /// EmitThumbFunc - Note in the output that the specified @p Func is
289 /// a Thumb mode function (ARM target only).
290 virtual void EmitThumbFunc(MCSymbol *Func) = 0;
292 /// getOrCreateSymbolData - Get symbol data for given symbol.
293 virtual MCSymbolData &getOrCreateSymbolData(MCSymbol *Symbol);
295 /// EmitAssignment - Emit an assignment of @p Value to @p Symbol.
297 /// This corresponds to an assembler statement such as:
300 /// The assignment generates no code, but has the side effect of binding the
301 /// value in the current context. For the assembly streamer, this prints the
302 /// binding into the .s file.
304 /// @param Symbol - The symbol being assigned to.
305 /// @param Value - The value for the symbol.
306 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0;
308 /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol.
310 /// This corresponds to an assembler statement such as:
311 /// .weakref alias, symbol
313 /// @param Alias - The alias that is being created.
314 /// @param Symbol - The symbol being aliased.
315 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0;
317 /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol.
318 virtual bool EmitSymbolAttribute(MCSymbol *Symbol,
319 MCSymbolAttr Attribute) = 0;
321 /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol.
323 /// @param Symbol - The symbol to have its n_desc field set.
324 /// @param DescValue - The value to set into the n_desc field.
325 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
327 /// BeginCOFFSymbolDef - Start emitting COFF symbol definition
329 /// @param Symbol - The symbol to have its External & Type fields set.
330 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0;
332 /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol.
334 /// @param StorageClass - The storage class the symbol should have.
335 virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0;
337 /// EmitCOFFSymbolType - Emit the type of the symbol.
339 /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
340 virtual void EmitCOFFSymbolType(int Type) = 0;
342 /// EndCOFFSymbolDef - Marks the end of the symbol definition.
343 virtual void EndCOFFSymbolDef() = 0;
345 /// EmitCOFFSecRel32 - Emits a COFF section relative relocation.
347 /// @param Symbol - Symbol the section relative realocation should point to.
348 virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
350 /// EmitELFSize - Emit an ELF .size directive.
352 /// This corresponds to an assembler statement such as:
353 /// .size symbol, expression
355 virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0;
357 /// EmitCommonSymbol - Emit a common symbol.
359 /// @param Symbol - The common symbol to emit.
360 /// @param Size - The size of the common symbol.
361 /// @param ByteAlignment - The alignment of the symbol if
362 /// non-zero. This must be a power of 2.
363 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
364 unsigned ByteAlignment) = 0;
366 /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
368 /// @param Symbol - The common symbol to emit.
369 /// @param Size - The size of the common symbol.
370 /// @param ByteAlignment - The alignment of the common symbol in bytes.
371 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
372 unsigned ByteAlignment) = 0;
374 /// EmitZerofill - Emit the zerofill section and an optional symbol.
376 /// @param Section - The zerofill section to create and or to put the symbol
377 /// @param Symbol - The zerofill symbol to emit, if non-NULL.
378 /// @param Size - The size of the zerofill symbol.
379 /// @param ByteAlignment - The alignment of the zerofill symbol if
380 /// non-zero. This must be a power of 2 on some targets.
381 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
382 uint64_t Size = 0, unsigned ByteAlignment = 0) = 0;
384 /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol.
386 /// @param Section - The thread local common section.
387 /// @param Symbol - The thread local common symbol to emit.
388 /// @param Size - The size of the symbol.
389 /// @param ByteAlignment - The alignment of the thread local common symbol
390 /// if non-zero. This must be a power of 2 on some targets.
391 virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
392 uint64_t Size, unsigned ByteAlignment = 0) = 0;
395 /// @name Generating Data
398 /// EmitBytes - Emit the bytes in \p Data into the output.
400 /// This is used to implement assembler directives such as .byte, .ascii,
402 virtual void EmitBytes(StringRef Data) = 0;
404 /// EmitValue - Emit the expression @p Value into the output as a native
405 /// integer of the given @p Size bytes.
407 /// This is used to implement assembler directives such as .word, .quad,
410 /// @param Value - The value to emit.
411 /// @param Size - The size of the integer (in bytes) to emit. This must
412 /// match a native machine width.
413 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) = 0;
415 void EmitValue(const MCExpr *Value, unsigned Size);
417 /// EmitIntValue - Special case of EmitValue that avoids the client having
418 /// to pass in a MCExpr for constant integers.
419 virtual void EmitIntValue(uint64_t Value, unsigned Size);
421 /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
422 /// this is done by producing
425 void EmitAbsValue(const MCExpr *Value, unsigned Size);
427 virtual void EmitULEB128Value(const MCExpr *Value) = 0;
429 virtual void EmitSLEB128Value(const MCExpr *Value) = 0;
431 /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
432 /// client having to pass in a MCExpr for constant integers.
433 void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
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);
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);
443 /// EmitGPRel64Value - Emit the expression @p Value into the output as a
444 /// gprel64 (64-bit GP relative) value.
446 /// This is used to implement assembler directives such as .gpdword on
447 /// targets that support them.
448 virtual void EmitGPRel64Value(const MCExpr *Value);
450 /// EmitGPRel32Value - Emit the expression @p Value into the output as a
451 /// gprel32 (32-bit GP relative) value.
453 /// This is used to implement assembler directives such as .gprel32 on
454 /// targets that support them.
455 virtual void EmitGPRel32Value(const MCExpr *Value);
457 /// EmitFill - Emit NumBytes bytes worth of the value specified by
458 /// FillValue. This implements directives such as '.space'.
459 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
461 /// \brief Emit NumBytes worth of zeros.
462 /// This function properly handles data in virtual sections.
463 virtual void EmitZeros(uint64_t NumBytes);
465 /// EmitValueToAlignment - Emit some number of copies of @p Value until
466 /// the byte alignment @p ByteAlignment is reached.
468 /// If the number of bytes need to emit for the alignment is not a multiple
469 /// of @p ValueSize, then the contents of the emitted fill bytes is
472 /// This used to implement the .align assembler directive.
474 /// @param ByteAlignment - The alignment to reach. This must be a power of
475 /// two on some targets.
476 /// @param Value - The value to use when filling bytes.
477 /// @param ValueSize - The size of the integer (in bytes) to emit for
478 /// @p Value. This must match a native machine width.
479 /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
480 /// the alignment cannot be reached in this many bytes, no bytes are
482 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
483 unsigned ValueSize = 1,
484 unsigned MaxBytesToEmit = 0) = 0;
486 /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment
489 /// This used to align code where the alignment bytes may be executed. This
490 /// can emit different bytes for different sizes to optimize execution.
492 /// @param ByteAlignment - The alignment to reach. This must be a power of
493 /// two on some targets.
494 /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
495 /// the alignment cannot be reached in this many bytes, no bytes are
497 virtual void EmitCodeAlignment(unsigned ByteAlignment,
498 unsigned MaxBytesToEmit = 0) = 0;
500 /// EmitValueToOffset - Emit some number of copies of @p Value until the
501 /// byte offset @p Offset is reached.
503 /// This is used to implement assembler directives such as .org.
505 /// @param Offset - The offset to reach. This may be an expression, but the
506 /// expression must be associated with the current section.
507 /// @param Value - The value to use when filling bytes.
508 /// @return false on success, true if the offset was invalid.
509 virtual bool EmitValueToOffset(const MCExpr *Offset,
510 unsigned char Value = 0) = 0;
514 /// EmitFileDirective - Switch to a new logical file. This is used to
515 /// implement the '.file "foo.c"' assembler directive.
516 virtual void EmitFileDirective(StringRef Filename) = 0;
518 /// EmitDwarfFileDirective - Associate a filename with a specified logical
519 /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
521 virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
522 StringRef Filename, unsigned CUID = 0);
524 /// EmitDwarfLocDirective - This implements the DWARF2
525 // '.loc fileno lineno ...' assembler directive.
526 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
527 unsigned Column, unsigned Flags,
528 unsigned Isa, unsigned Discriminator,
531 virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
532 const MCSymbol *LastLabel,
533 const MCSymbol *Label,
534 unsigned PointerSize) = 0;
536 virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
537 const MCSymbol *Label) {}
539 void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
542 virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding);
543 virtual void EmitCFISections(bool EH, bool Debug);
544 void EmitCFIStartProc();
545 void EmitCFIEndProc();
546 virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
547 virtual void EmitCFIDefCfaOffset(int64_t Offset);
548 virtual void EmitCFIDefCfaRegister(int64_t Register);
549 virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
550 virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
551 virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
552 virtual void EmitCFIRememberState();
553 virtual void EmitCFIRestoreState();
554 virtual void EmitCFISameValue(int64_t Register);
555 virtual void EmitCFIRestore(int64_t Register);
556 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
557 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
558 virtual void EmitCFIEscape(StringRef Values);
559 virtual void EmitCFISignalFrame();
560 virtual void EmitCFIUndefined(int64_t Register);
561 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
562 virtual void EmitCFIWindowSave();
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,
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();
579 /// EmitInstruction - Emit the given @p Instruction into the current
581 virtual void EmitInstruction(const MCInst &Inst) = 0;
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;
588 /// \brief The following instructions are a bundle-locked group.
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;
594 /// \brief Ends a bundle-locked group.
595 virtual void EmitBundleUnlock() = 0;
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);
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,
616 /// Mips-related methods.
617 virtual void emitMipsHackELFFlags(unsigned Flags);
618 virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val);
620 /// PPC-related methods.
621 /// FIXME: Eventually replace it with some "target MC streamer" and move
622 /// these methods there.
623 virtual void EmitTCEntry(const MCSymbol &S);
625 /// Flush - Causes any cached state to be written out.
626 virtual void Flush() {}
628 /// FinishImpl - Streamer specific finalization.
629 virtual void FinishImpl() = 0;
630 /// Finish - Finish emission of machine code.
634 /// createNullStreamer - Create a dummy machine code streamer, which does
635 /// nothing. This is useful for timing the assembler front end.
636 MCStreamer *createNullStreamer(MCContext &Ctx);
638 /// createAsmStreamer - Create a machine code streamer which will print out
639 /// assembly for the native target, suitable for compiling with a native
642 /// \param InstPrint - If given, the instruction printer to use. If not given
643 /// the MCInst representation will be printed. This method takes ownership of
646 /// \param CE - If given, a code emitter to use to show the instruction
647 /// encoding inline with the assembly. This method takes ownership of \p CE.
649 /// \param TAB - If given, a target asm backend to use to show the fixup
650 /// information in conjunction with encoding information. This method takes
651 /// ownership of \p TAB.
653 /// \param ShowInst - Whether to show the MCInst representation inline with
655 MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
656 bool isVerboseAsm, bool useLoc, bool useCFI,
657 bool useDwarfDirectory,
658 MCInstPrinter *InstPrint = 0,
659 MCCodeEmitter *CE = 0, MCAsmBackend *TAB = 0,
660 bool ShowInst = false);
662 /// createMachOStreamer - Create a machine code streamer which will generate
663 /// Mach-O format object files.
665 /// Takes ownership of \p TAB and \p CE.
666 MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
667 raw_ostream &OS, MCCodeEmitter *CE,
668 bool RelaxAll = false);
670 /// createWinCOFFStreamer - Create a machine code streamer which will
671 /// generate Microsoft COFF format object files.
673 /// Takes ownership of \p TAB and \p CE.
674 MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
675 MCCodeEmitter &CE, raw_ostream &OS,
676 bool RelaxAll = false);
678 /// createELFStreamer - Create a machine code streamer which will generate
679 /// ELF format object files.
680 MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
681 raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll,
684 /// createPureStreamer - Create a machine code streamer which will generate
685 /// "pure" MC object files, for use with MC-JIT and testing tools.
687 /// Takes ownership of \p TAB and \p CE.
688 MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
689 raw_ostream &OS, MCCodeEmitter *CE);
691 } // end namespace llvm