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/MCDirectives.h"
20 #include "llvm/MC/MCDwarf.h"
21 #include "llvm/MC/MCLinkerOptimizationHint.h"
22 #include "llvm/MC/MCWinEH.h"
23 #include "llvm/Support/DataTypes.h"
24 #include "llvm/Support/SMLoc.h"
38 class MCSymbolRefExpr;
39 class MCSubtargetInfo;
43 class formatted_raw_ostream;
44 class AssemblerConstantPools;
46 typedef std::pair<MCSection *, const MCExpr *> MCSectionSubPair;
48 /// Target specific streamer interface. This is used so that targets can
49 /// implement support for target specific assembly directives.
51 /// If target foo wants to use this, it should implement 3 classes:
52 /// * FooTargetStreamer : public MCTargetStreamer
53 /// * FooTargetAsmStreamer : public FooTargetStreamer
54 /// * FooTargetELFStreamer : public FooTargetStreamer
56 /// FooTargetStreamer should have a pure virtual method for each directive. For
57 /// example, for a ".bar symbol_name" directive, it should have
58 /// virtual emitBar(const MCSymbol &Symbol) = 0;
60 /// The FooTargetAsmStreamer and FooTargetELFStreamer classes implement the
61 /// method. The assembly streamer just prints ".bar symbol_name". The object
62 /// streamer does whatever is needed to implement .bar in the object file.
64 /// In the assembly printer and parser the target streamer can be used by
65 /// calling getTargetStreamer and casting it to FooTargetStreamer:
67 /// MCTargetStreamer &TS = OutStreamer.getTargetStreamer();
68 /// FooTargetStreamer &ATS = static_cast<FooTargetStreamer &>(TS);
70 /// The base classes FooTargetAsmStreamer and FooTargetELFStreamer should
71 /// *never* be treated differently. Callers should always talk to a
72 /// FooTargetStreamer.
73 class MCTargetStreamer {
78 MCTargetStreamer(MCStreamer &S);
79 virtual ~MCTargetStreamer();
81 const MCStreamer &getStreamer() { return Streamer; }
83 // Allow a target to add behavior to the EmitLabel of MCStreamer.
84 virtual void emitLabel(MCSymbol *Symbol);
85 // Allow a target to add behavior to the emitAssignment of MCStreamer.
86 virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value);
88 virtual void finish();
91 // FIXME: declared here because it is used from
92 // lib/CodeGen/AsmPrinter/ARMException.cpp.
93 class ARMTargetStreamer : public MCTargetStreamer {
95 ARMTargetStreamer(MCStreamer &S);
96 ~ARMTargetStreamer() override;
98 virtual void emitFnStart();
99 virtual void emitFnEnd();
100 virtual void emitCantUnwind();
101 virtual void emitPersonality(const MCSymbol *Personality);
102 virtual void emitPersonalityIndex(unsigned Index);
103 virtual void emitHandlerData();
104 virtual void emitSetFP(unsigned FpReg, unsigned SpReg,
106 virtual void emitMovSP(unsigned Reg, int64_t Offset = 0);
107 virtual void emitPad(int64_t Offset);
108 virtual void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
110 virtual void emitUnwindRaw(int64_t StackOffset,
111 const SmallVectorImpl<uint8_t> &Opcodes);
113 virtual void switchVendor(StringRef Vendor);
114 virtual void emitAttribute(unsigned Attribute, unsigned Value);
115 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
116 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
117 StringRef StringValue = "");
118 virtual void emitFPU(unsigned FPU);
119 virtual void emitArch(unsigned Arch);
120 virtual void emitArchExtension(unsigned ArchExt);
121 virtual void emitObjectArch(unsigned Arch);
122 virtual void finishAttributeSection();
123 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
125 virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
127 virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
129 void finish() override;
131 /// Callback used to implement the ldr= pseudo.
132 /// Add a new entry to the constant pool for the current section and return an
133 /// MCExpr that can be used to refer to the constant pool location.
134 const MCExpr *addConstantPoolEntry(const MCExpr *);
136 /// Callback used to implemnt the .ltorg directive.
137 /// Emit contents of constant pool for the current section.
138 void emitCurrentConstantPool();
141 std::unique_ptr<AssemblerConstantPools> ConstantPools;
144 /// \brief Streaming machine code generation interface.
146 /// This interface is intended to provide a programatic interface that is very
147 /// similar to the level that an assembler .s file provides. It has callbacks
148 /// to emit bytes, handle directives, etc. The implementation of this interface
149 /// retains state to know what the current section is etc.
151 /// There are multiple implementations of this interface: one for writing out
152 /// a .s file, and implementations that write out .o files of various formats.
156 std::unique_ptr<MCTargetStreamer> TargetStreamer;
158 MCStreamer(const MCStreamer &) = delete;
159 MCStreamer &operator=(const MCStreamer &) = delete;
161 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
162 MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
163 void EnsureValidDwarfFrame();
165 MCSymbol *EmitCFICommon();
167 std::vector<WinEH::FrameInfo *> WinFrameInfos;
168 WinEH::FrameInfo *CurrentWinFrameInfo;
169 void EnsureValidWinFrameInfo();
171 /// \brief Tracks an index to represent the order a symbol was emitted in.
172 /// Zero means we did not emit that symbol.
173 DenseMap<const MCSymbol *, unsigned> SymbolOrdering;
175 /// \brief This is stack of current and previous section values saved by
177 SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
180 MCStreamer(MCContext &Ctx);
182 virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
183 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
185 WinEH::FrameInfo *getCurrentWinFrameInfo() {
186 return CurrentWinFrameInfo;
189 virtual void EmitWindowsUnwindTables();
191 virtual void EmitRawTextImpl(StringRef String);
194 virtual ~MCStreamer();
196 void visitUsedExpr(const MCExpr &Expr);
197 virtual void visitUsedSymbol(const MCSymbol &Sym);
199 void setTargetStreamer(MCTargetStreamer *TS) {
200 TargetStreamer.reset(TS);
205 virtual void reset();
207 MCContext &getContext() const { return Context; }
209 MCTargetStreamer *getTargetStreamer() {
210 return TargetStreamer.get();
213 unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); }
214 ArrayRef<MCDwarfFrameInfo> getDwarfFrameInfos() const {
215 return DwarfFrameInfos;
218 unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
219 ArrayRef<WinEH::FrameInfo *> getWinFrameInfos() const {
220 return WinFrameInfos;
223 void generateCompactUnwindEncodings(MCAsmBackend *MAB);
225 /// \name Assembly File Formatting.
228 /// \brief Return true if this streamer supports verbose assembly and if it is
230 virtual bool isVerboseAsm() const { return false; }
232 /// \brief Return true if this asm streamer supports emitting unformatted text
233 /// to the .s file with EmitRawText.
234 virtual bool hasRawTextSupport() const { return false; }
236 /// \brief Is the integrated assembler required for this streamer to function
238 virtual bool isIntegratedAssemblerRequired() const { return false; }
240 /// \brief Add a textual command.
242 /// Typically for comments that can be emitted to the generated .s
243 /// file if applicable as a QoI issue to make the output of the compiler
244 /// more readable. This only affects the MCAsmStreamer, and only when
245 /// verbose assembly output is enabled.
247 /// If the comment includes embedded \n's, they will each get the comment
248 /// prefix as appropriate. The added comment should not end with a \n.
249 virtual void AddComment(const Twine &T) {}
251 /// \brief Return a raw_ostream that comments can be written to. Unlike
252 /// AddComment, you are required to terminate comments with \n if you use this
254 virtual raw_ostream &GetCommentOS();
256 /// \brief Print T and prefix it with the comment string (normally #) and
257 /// optionally a tab. This prints the comment immediately, not at the end of
258 /// the current line. It is basically a safe version of EmitRawText: since it
259 /// only prints comments, the object streamer ignores it instead of asserting.
260 virtual void emitRawComment(const Twine &T, bool TabPrefix = true);
262 /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
263 virtual void AddBlankLine() {}
267 /// \name Symbol & Section Management
270 /// \brief Return the current section that the streamer is emitting code to.
271 MCSectionSubPair getCurrentSection() const {
272 if (!SectionStack.empty())
273 return SectionStack.back().first;
274 return MCSectionSubPair();
276 MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
278 /// \brief Return the previous section that the streamer is emitting code to.
279 MCSectionSubPair getPreviousSection() const {
280 if (!SectionStack.empty())
281 return SectionStack.back().second;
282 return MCSectionSubPair();
285 /// \brief Returns an index to represent the order a symbol was emitted in.
286 /// (zero if we did not emit that symbol)
287 unsigned GetSymbolOrder(const MCSymbol *Sym) const {
288 return SymbolOrdering.lookup(Sym);
291 /// \brief Update streamer for a new active section.
293 /// This is called by PopSection and SwitchSection, if the current
295 virtual void ChangeSection(MCSection *, const MCExpr *);
297 /// \brief Save the current and previous section on the section stack.
299 SectionStack.push_back(
300 std::make_pair(getCurrentSection(), getPreviousSection()));
303 /// \brief Restore the current and previous section from the section stack.
304 /// Calls ChangeSection as needed.
306 /// Returns false if the stack was empty.
308 if (SectionStack.size() <= 1)
310 auto I = SectionStack.end();
312 MCSectionSubPair OldSection = I->first;
314 MCSectionSubPair NewSection = I->first;
316 if (OldSection != NewSection)
317 ChangeSection(NewSection.first, NewSection.second);
318 SectionStack.pop_back();
322 bool SubSection(const MCExpr *Subsection) {
323 if (SectionStack.empty())
326 SwitchSection(SectionStack.back().first.first, Subsection);
330 /// Set the current section where code is being emitted to \p Section. This
331 /// is required to update CurSection.
333 /// This corresponds to assembler directives like .section, .text, etc.
334 virtual void SwitchSection(MCSection *Section,
335 const MCExpr *Subsection = nullptr);
337 /// \brief Set the current section where code is being emitted to \p Section.
338 /// This is required to update CurSection. This version does not call
340 void SwitchSectionNoChange(MCSection *Section,
341 const MCExpr *Subsection = nullptr) {
342 assert(Section && "Cannot switch to a null section!");
343 MCSectionSubPair curSection = SectionStack.back().first;
344 SectionStack.back().second = curSection;
345 if (MCSectionSubPair(Section, Subsection) != curSection)
346 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
349 /// \brief Create the default sections and set the initial one.
350 virtual void InitSections(bool NoExecStack);
352 MCSymbol *endSection(MCSection *Section);
354 /// \brief Sets the symbol's section.
356 /// Each emitted symbol will be tracked in the ordering table,
357 /// so we can sort on them later.
358 void AssignSection(MCSymbol *Symbol, MCSection *Section);
360 /// \brief Emit a label for \p Symbol into the current section.
362 /// This corresponds to an assembler statement such as:
365 /// \param Symbol - The symbol to emit. A given symbol should only be
366 /// emitted as a label once, and symbols emitted as a label should never be
367 /// used in an assignment.
368 // FIXME: These emission are non-const because we mutate the symbol to
369 // add the section we're emitting it to later.
370 virtual void EmitLabel(MCSymbol *Symbol);
372 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
374 /// \brief Note in the output the specified \p Flag.
375 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
377 /// \brief Emit the given list \p Options of strings as linker
378 /// options into the output.
379 virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {}
381 /// \brief Note in the output the specified region \p Kind.
382 virtual void EmitDataRegion(MCDataRegionType Kind) {}
384 /// \brief Specify the MachO minimum deployment target version.
385 virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor,
388 /// \brief Note in the output that the specified \p Func is a Thumb mode
389 /// function (ARM target only).
390 virtual void EmitThumbFunc(MCSymbol *Func);
392 /// \brief Emit an assignment of \p Value to \p Symbol.
394 /// This corresponds to an assembler statement such as:
397 /// The assignment generates no code, but has the side effect of binding the
398 /// value in the current context. For the assembly streamer, this prints the
399 /// binding into the .s file.
401 /// \param Symbol - The symbol being assigned to.
402 /// \param Value - The value for the symbol.
403 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
405 /// \brief Emit an weak reference from \p Alias to \p Symbol.
407 /// This corresponds to an assembler statement such as:
408 /// .weakref alias, symbol
410 /// \param Alias - The alias that is being created.
411 /// \param Symbol - The symbol being aliased.
412 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
414 /// \brief Add the given \p Attribute to \p Symbol.
415 virtual bool EmitSymbolAttribute(MCSymbol *Symbol,
416 MCSymbolAttr Attribute) = 0;
418 /// \brief Set the \p DescValue for the \p Symbol.
420 /// \param Symbol - The symbol to have its n_desc field set.
421 /// \param DescValue - The value to set into the n_desc field.
422 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
424 /// \brief Start emitting COFF symbol definition
426 /// \param Symbol - The symbol to have its External & Type fields set.
427 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
429 /// \brief Emit the storage class of the symbol.
431 /// \param StorageClass - The storage class the symbol should have.
432 virtual void EmitCOFFSymbolStorageClass(int StorageClass);
434 /// \brief Emit the type of the symbol.
436 /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
437 virtual void EmitCOFFSymbolType(int Type);
439 /// \brief Marks the end of the symbol definition.
440 virtual void EndCOFFSymbolDef();
442 virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
444 /// \brief Emits a COFF section index.
446 /// \param Symbol - Symbol the section number relocation should point to.
447 virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol);
449 /// \brief Emits a COFF section relative relocation.
451 /// \param Symbol - Symbol the section relative relocation should point to.
452 virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
454 /// \brief Emit an ELF .size directive.
456 /// This corresponds to an assembler statement such as:
457 /// .size symbol, expression
458 virtual void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value);
460 /// \brief Emit a Linker Optimization Hint (LOH) directive.
461 /// \param Args - Arguments of the LOH.
462 virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
464 /// \brief Emit a common symbol.
466 /// \param Symbol - The common symbol to emit.
467 /// \param Size - The size of the common symbol.
468 /// \param ByteAlignment - The alignment of the symbol if
469 /// non-zero. This must be a power of 2.
470 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
471 unsigned ByteAlignment) = 0;
473 /// \brief Emit a local common (.lcomm) symbol.
475 /// \param Symbol - The common symbol to emit.
476 /// \param Size - The size of the common symbol.
477 /// \param ByteAlignment - The alignment of the common symbol in bytes.
478 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
479 unsigned ByteAlignment);
481 /// \brief Emit the zerofill section and an optional symbol.
483 /// \param Section - The zerofill section to create and or to put the symbol
484 /// \param Symbol - The zerofill symbol to emit, if non-NULL.
485 /// \param Size - The size of the zerofill symbol.
486 /// \param ByteAlignment - The alignment of the zerofill symbol if
487 /// non-zero. This must be a power of 2 on some targets.
488 virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
489 uint64_t Size = 0, unsigned ByteAlignment = 0) = 0;
491 /// \brief Emit a thread local bss (.tbss) symbol.
493 /// \param Section - The thread local common section.
494 /// \param Symbol - The thread local common symbol to emit.
495 /// \param Size - The size of the symbol.
496 /// \param ByteAlignment - The alignment of the thread local common symbol
497 /// if non-zero. This must be a power of 2 on some targets.
498 virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
499 uint64_t Size, unsigned ByteAlignment = 0);
502 /// \name Generating Data
505 /// \brief Emit the bytes in \p Data into the output.
507 /// This is used to implement assembler directives such as .byte, .ascii,
509 virtual void EmitBytes(StringRef Data);
511 /// \brief Emit the expression \p Value into the output as a native
512 /// integer of the given \p Size bytes.
514 /// This is used to implement assembler directives such as .word, .quad,
517 /// \param Value - The value to emit.
518 /// \param Size - The size of the integer (in bytes) to emit. This must
519 /// match a native machine width.
520 /// \param Loc - The location of the expression for error reporting.
521 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
522 const SMLoc &Loc = SMLoc());
524 void EmitValue(const MCExpr *Value, unsigned Size,
525 const SMLoc &Loc = SMLoc());
527 /// \brief Special case of EmitValue that avoids the client having
528 /// to pass in a MCExpr for constant integers.
529 virtual void EmitIntValue(uint64_t Value, unsigned Size);
531 virtual void EmitULEB128Value(const MCExpr *Value);
533 virtual void EmitSLEB128Value(const MCExpr *Value);
535 /// \brief Special case of EmitULEB128Value that avoids the client having to
536 /// pass in a MCExpr for constant integers.
537 void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
539 /// \brief Special case of EmitSLEB128Value that avoids the client having to
540 /// pass in a MCExpr for constant integers.
541 void EmitSLEB128IntValue(int64_t Value);
543 /// \brief Special case of EmitValue that avoids the client having to pass in
544 /// a MCExpr for MCSymbols.
545 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
546 bool IsSectionRelative = false);
548 /// \brief Emit the expression \p Value into the output as a gprel64 (64-bit
549 /// GP relative) value.
551 /// This is used to implement assembler directives such as .gpdword on
552 /// targets that support them.
553 virtual void EmitGPRel64Value(const MCExpr *Value);
555 /// \brief Emit the expression \p Value into the output as a gprel32 (32-bit
556 /// GP relative) value.
558 /// This is used to implement assembler directives such as .gprel32 on
559 /// targets that support them.
560 virtual void EmitGPRel32Value(const MCExpr *Value);
562 /// \brief Emit NumBytes bytes worth of the value specified by FillValue.
563 /// This implements directives such as '.space'.
564 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
566 /// \brief Emit NumBytes worth of zeros.
567 /// This function properly handles data in virtual sections.
568 virtual void EmitZeros(uint64_t NumBytes);
570 /// \brief Emit some number of copies of \p Value until the byte alignment \p
571 /// ByteAlignment is reached.
573 /// If the number of bytes need to emit for the alignment is not a multiple
574 /// of \p ValueSize, then the contents of the emitted fill bytes is
577 /// This used to implement the .align assembler directive.
579 /// \param ByteAlignment - The alignment to reach. This must be a power of
580 /// two on some targets.
581 /// \param Value - The value to use when filling bytes.
582 /// \param ValueSize - The size of the integer (in bytes) to emit for
583 /// \p Value. This must match a native machine width.
584 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
585 /// the alignment cannot be reached in this many bytes, no bytes are
587 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
588 unsigned ValueSize = 1,
589 unsigned MaxBytesToEmit = 0);
591 /// \brief Emit nops until the byte alignment \p ByteAlignment is reached.
593 /// This used to align code where the alignment bytes may be executed. This
594 /// can emit different bytes for different sizes to optimize execution.
596 /// \param ByteAlignment - The alignment to reach. This must be a power of
597 /// two on some targets.
598 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
599 /// the alignment cannot be reached in this many bytes, no bytes are
601 virtual void EmitCodeAlignment(unsigned ByteAlignment,
602 unsigned MaxBytesToEmit = 0);
604 /// \brief Emit some number of copies of \p Value until the byte offset \p
605 /// Offset is reached.
607 /// This is used to implement assembler directives such as .org.
609 /// \param Offset - The offset to reach. This may be an expression, but the
610 /// expression must be associated with the current section.
611 /// \param Value - The value to use when filling bytes.
612 /// \return false on success, true if the offset was invalid.
613 virtual bool EmitValueToOffset(const MCExpr *Offset,
614 unsigned char Value = 0);
618 /// \brief Switch to a new logical file. This is used to implement the '.file
619 /// "foo.c"' assembler directive.
620 virtual void EmitFileDirective(StringRef Filename);
622 /// \brief Emit the "identifiers" directive. This implements the
623 /// '.ident "version foo"' assembler directive.
624 virtual void EmitIdent(StringRef IdentString) {}
626 /// \brief Associate a filename with a specified logical file number. This
627 /// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
628 virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
632 /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler
634 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
635 unsigned Column, unsigned Flags,
636 unsigned Isa, unsigned Discriminator,
639 /// Emit the absolute difference between two symbols.
641 /// \pre Offset of \c Hi is greater than the offset \c Lo.
642 /// \return true on success.
643 virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
646 virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
647 virtual void EmitCFISections(bool EH, bool Debug);
648 void EmitCFIStartProc(bool IsSimple);
649 void EmitCFIEndProc();
650 virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
651 virtual void EmitCFIDefCfaOffset(int64_t Offset);
652 virtual void EmitCFIDefCfaRegister(int64_t Register);
653 virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
654 virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
655 virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
656 virtual void EmitCFIRememberState();
657 virtual void EmitCFIRestoreState();
658 virtual void EmitCFISameValue(int64_t Register);
659 virtual void EmitCFIRestore(int64_t Register);
660 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
661 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
662 virtual void EmitCFIEscape(StringRef Values);
663 virtual void EmitCFISignalFrame();
664 virtual void EmitCFIUndefined(int64_t Register);
665 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
666 virtual void EmitCFIWindowSave();
668 virtual void EmitWinCFIStartProc(const MCSymbol *Symbol);
669 virtual void EmitWinCFIEndProc();
670 virtual void EmitWinCFIStartChained();
671 virtual void EmitWinCFIEndChained();
672 virtual void EmitWinCFIPushReg(unsigned Register);
673 virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset);
674 virtual void EmitWinCFIAllocStack(unsigned Size);
675 virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset);
676 virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset);
677 virtual void EmitWinCFIPushFrame(bool Code);
678 virtual void EmitWinCFIEndProlog();
680 virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
681 virtual void EmitWinEHHandlerData();
683 /// \brief Emit the given \p Instruction into the current section.
684 virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
686 /// \brief Set the bundle alignment mode from now on in the section.
687 /// The argument is the power of 2 to which the alignment is set. The
688 /// value 0 means turn the bundle alignment off.
689 virtual void EmitBundleAlignMode(unsigned AlignPow2);
691 /// \brief The following instructions are a bundle-locked group.
693 /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
694 /// the end of a bundle.
695 virtual void EmitBundleLock(bool AlignToEnd);
697 /// \brief Ends a bundle-locked group.
698 virtual void EmitBundleUnlock();
700 /// \brief If this file is backed by a assembly streamer, this dumps the
701 /// specified string in the output .s file. This capability is indicated by
702 /// the hasRawTextSupport() predicate. By default this aborts.
703 void EmitRawText(const Twine &String);
705 /// \brief Causes any cached state to be written out.
706 virtual void Flush() {}
708 /// \brief Streamer specific finalization.
709 virtual void FinishImpl();
710 /// \brief Finish emission of machine code.
713 virtual bool mayHaveInstructions(MCSection &Sec) const { return true; }
716 /// Create a dummy machine code streamer, which does nothing. This is useful for
717 /// timing the assembler front end.
718 MCStreamer *createNullStreamer(MCContext &Ctx);
720 /// Create a machine code streamer which will print out assembly for the native
721 /// target, suitable for compiling with a native assembler.
723 /// \param InstPrint - If given, the instruction printer to use. If not given
724 /// the MCInst representation will be printed. This method takes ownership of
727 /// \param CE - If given, a code emitter to use to show the instruction
728 /// encoding inline with the assembly. This method takes ownership of \p CE.
730 /// \param TAB - If given, a target asm backend to use to show the fixup
731 /// information in conjunction with encoding information. This method takes
732 /// ownership of \p TAB.
734 /// \param ShowInst - Whether to show the MCInst representation inline with
736 MCStreamer *createAsmStreamer(MCContext &Ctx,
737 std::unique_ptr<formatted_raw_ostream> OS,
738 bool isVerboseAsm, bool useDwarfDirectory,
739 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
740 MCAsmBackend *TAB, bool ShowInst);
741 } // end namespace llvm