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 MCSectionSubPair oldSection = SectionStack.pop_back_val().first;
311 MCSectionSubPair curSection = SectionStack.back().first;
313 if (oldSection != curSection)
314 ChangeSection(curSection.first, curSection.second);
318 bool SubSection(const MCExpr *Subsection) {
319 if (SectionStack.empty())
322 SwitchSection(SectionStack.back().first.first, Subsection);
326 /// Set the current section where code is being emitted to \p Section. This
327 /// is required to update CurSection.
329 /// This corresponds to assembler directives like .section, .text, etc.
330 virtual void SwitchSection(MCSection *Section,
331 const MCExpr *Subsection = nullptr);
333 /// \brief Set the current section where code is being emitted to \p Section.
334 /// This is required to update CurSection. This version does not call
336 void SwitchSectionNoChange(MCSection *Section,
337 const MCExpr *Subsection = nullptr) {
338 assert(Section && "Cannot switch to a null section!");
339 MCSectionSubPair curSection = SectionStack.back().first;
340 SectionStack.back().second = curSection;
341 if (MCSectionSubPair(Section, Subsection) != curSection)
342 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
345 /// \brief Create the default sections and set the initial one.
346 virtual void InitSections(bool NoExecStack);
348 MCSymbol *endSection(MCSection *Section);
350 /// \brief Sets the symbol's section.
352 /// Each emitted symbol will be tracked in the ordering table,
353 /// so we can sort on them later.
354 void AssignSection(MCSymbol *Symbol, MCSection *Section);
356 /// \brief Emit a label for \p Symbol into the current section.
358 /// This corresponds to an assembler statement such as:
361 /// \param Symbol - The symbol to emit. A given symbol should only be
362 /// emitted as a label once, and symbols emitted as a label should never be
363 /// used in an assignment.
364 // FIXME: These emission are non-const because we mutate the symbol to
365 // add the section we're emitting it to later.
366 virtual void EmitLabel(MCSymbol *Symbol);
368 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
370 /// \brief Note in the output the specified \p Flag.
371 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
373 /// \brief Emit the given list \p Options of strings as linker
374 /// options into the output.
375 virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {}
377 /// \brief Note in the output the specified region \p Kind.
378 virtual void EmitDataRegion(MCDataRegionType Kind) {}
380 /// \brief Specify the MachO minimum deployment target version.
381 virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor,
384 /// \brief Note in the output that the specified \p Func is a Thumb mode
385 /// function (ARM target only).
386 virtual void EmitThumbFunc(MCSymbol *Func);
388 /// \brief Emit an assignment of \p Value to \p Symbol.
390 /// This corresponds to an assembler statement such as:
393 /// The assignment generates no code, but has the side effect of binding the
394 /// value in the current context. For the assembly streamer, this prints the
395 /// binding into the .s file.
397 /// \param Symbol - The symbol being assigned to.
398 /// \param Value - The value for the symbol.
399 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
401 /// \brief Emit an weak reference from \p Alias to \p Symbol.
403 /// This corresponds to an assembler statement such as:
404 /// .weakref alias, symbol
406 /// \param Alias - The alias that is being created.
407 /// \param Symbol - The symbol being aliased.
408 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
410 /// \brief Add the given \p Attribute to \p Symbol.
411 virtual bool EmitSymbolAttribute(MCSymbol *Symbol,
412 MCSymbolAttr Attribute) = 0;
414 /// \brief Set the \p DescValue for the \p Symbol.
416 /// \param Symbol - The symbol to have its n_desc field set.
417 /// \param DescValue - The value to set into the n_desc field.
418 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
420 /// \brief Start emitting COFF symbol definition
422 /// \param Symbol - The symbol to have its External & Type fields set.
423 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
425 /// \brief Emit the storage class of the symbol.
427 /// \param StorageClass - The storage class the symbol should have.
428 virtual void EmitCOFFSymbolStorageClass(int StorageClass);
430 /// \brief Emit the type of the symbol.
432 /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
433 virtual void EmitCOFFSymbolType(int Type);
435 /// \brief Marks the end of the symbol definition.
436 virtual void EndCOFFSymbolDef();
438 virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
440 /// \brief Emits a COFF section index.
442 /// \param Symbol - Symbol the section number relocation should point to.
443 virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol);
445 /// \brief Emits a COFF section relative relocation.
447 /// \param Symbol - Symbol the section relative relocation should point to.
448 virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
450 /// \brief Emit an ELF .size directive.
452 /// This corresponds to an assembler statement such as:
453 /// .size symbol, expression
454 virtual void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value);
456 /// \brief Emit a Linker Optimization Hint (LOH) directive.
457 /// \param Args - Arguments of the LOH.
458 virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
460 /// \brief Emit a common symbol.
462 /// \param Symbol - The common symbol to emit.
463 /// \param Size - The size of the common symbol.
464 /// \param ByteAlignment - The alignment of the symbol if
465 /// non-zero. This must be a power of 2.
466 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
467 unsigned ByteAlignment) = 0;
469 /// \brief Emit a local common (.lcomm) symbol.
471 /// \param Symbol - The common symbol to emit.
472 /// \param Size - The size of the common symbol.
473 /// \param ByteAlignment - The alignment of the common symbol in bytes.
474 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
475 unsigned ByteAlignment);
477 /// \brief Emit the zerofill section and an optional symbol.
479 /// \param Section - The zerofill section to create and or to put the symbol
480 /// \param Symbol - The zerofill symbol to emit, if non-NULL.
481 /// \param Size - The size of the zerofill symbol.
482 /// \param ByteAlignment - The alignment of the zerofill symbol if
483 /// non-zero. This must be a power of 2 on some targets.
484 virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
485 uint64_t Size = 0, unsigned ByteAlignment = 0) = 0;
487 /// \brief Emit a thread local bss (.tbss) symbol.
489 /// \param Section - The thread local common section.
490 /// \param Symbol - The thread local common symbol to emit.
491 /// \param Size - The size of the symbol.
492 /// \param ByteAlignment - The alignment of the thread local common symbol
493 /// if non-zero. This must be a power of 2 on some targets.
494 virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
495 uint64_t Size, unsigned ByteAlignment = 0);
498 /// \name Generating Data
501 /// \brief Emit the bytes in \p Data into the output.
503 /// This is used to implement assembler directives such as .byte, .ascii,
505 virtual void EmitBytes(StringRef Data);
507 /// \brief Emit the expression \p Value into the output as a native
508 /// integer of the given \p Size bytes.
510 /// This is used to implement assembler directives such as .word, .quad,
513 /// \param Value - The value to emit.
514 /// \param Size - The size of the integer (in bytes) to emit. This must
515 /// match a native machine width.
516 /// \param Loc - The location of the expression for error reporting.
517 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
518 const SMLoc &Loc = SMLoc());
520 void EmitValue(const MCExpr *Value, unsigned Size,
521 const SMLoc &Loc = SMLoc());
523 /// \brief Special case of EmitValue that avoids the client having
524 /// to pass in a MCExpr for constant integers.
525 virtual void EmitIntValue(uint64_t Value, unsigned Size);
527 virtual void EmitULEB128Value(const MCExpr *Value);
529 virtual void EmitSLEB128Value(const MCExpr *Value);
531 /// \brief Special case of EmitULEB128Value that avoids the client having to
532 /// pass in a MCExpr for constant integers.
533 void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
535 /// \brief Special case of EmitSLEB128Value that avoids the client having to
536 /// pass in a MCExpr for constant integers.
537 void EmitSLEB128IntValue(int64_t Value);
539 /// \brief Special case of EmitValue that avoids the client having to pass in
540 /// a MCExpr for MCSymbols.
541 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
542 bool IsSectionRelative = false);
544 /// \brief Emit the expression \p Value into the output as a gprel64 (64-bit
545 /// GP relative) value.
547 /// This is used to implement assembler directives such as .gpdword on
548 /// targets that support them.
549 virtual void EmitGPRel64Value(const MCExpr *Value);
551 /// \brief Emit the expression \p Value into the output as a gprel32 (32-bit
552 /// GP relative) value.
554 /// This is used to implement assembler directives such as .gprel32 on
555 /// targets that support them.
556 virtual void EmitGPRel32Value(const MCExpr *Value);
558 /// \brief Emit NumBytes bytes worth of the value specified by FillValue.
559 /// This implements directives such as '.space'.
560 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
562 /// \brief Emit NumBytes worth of zeros.
563 /// This function properly handles data in virtual sections.
564 virtual void EmitZeros(uint64_t NumBytes);
566 /// \brief Emit some number of copies of \p Value until the byte alignment \p
567 /// ByteAlignment is reached.
569 /// If the number of bytes need to emit for the alignment is not a multiple
570 /// of \p ValueSize, then the contents of the emitted fill bytes is
573 /// This used to implement the .align assembler directive.
575 /// \param ByteAlignment - The alignment to reach. This must be a power of
576 /// two on some targets.
577 /// \param Value - The value to use when filling bytes.
578 /// \param ValueSize - The size of the integer (in bytes) to emit for
579 /// \p Value. This must match a native machine width.
580 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
581 /// the alignment cannot be reached in this many bytes, no bytes are
583 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
584 unsigned ValueSize = 1,
585 unsigned MaxBytesToEmit = 0);
587 /// \brief Emit nops until the byte alignment \p ByteAlignment is reached.
589 /// This used to align code where the alignment bytes may be executed. This
590 /// can emit different bytes for different sizes to optimize execution.
592 /// \param ByteAlignment - The alignment to reach. This must be a power of
593 /// two on some targets.
594 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
595 /// the alignment cannot be reached in this many bytes, no bytes are
597 virtual void EmitCodeAlignment(unsigned ByteAlignment,
598 unsigned MaxBytesToEmit = 0);
600 /// \brief Emit some number of copies of \p Value until the byte offset \p
601 /// Offset is reached.
603 /// This is used to implement assembler directives such as .org.
605 /// \param Offset - The offset to reach. This may be an expression, but the
606 /// expression must be associated with the current section.
607 /// \param Value - The value to use when filling bytes.
608 /// \return false on success, true if the offset was invalid.
609 virtual bool EmitValueToOffset(const MCExpr *Offset,
610 unsigned char Value = 0);
614 /// \brief Switch to a new logical file. This is used to implement the '.file
615 /// "foo.c"' assembler directive.
616 virtual void EmitFileDirective(StringRef Filename);
618 /// \brief Emit the "identifiers" directive. This implements the
619 /// '.ident "version foo"' assembler directive.
620 virtual void EmitIdent(StringRef IdentString) {}
622 /// \brief Associate a filename with a specified logical file number. This
623 /// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
624 virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
628 /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler
630 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
631 unsigned Column, unsigned Flags,
632 unsigned Isa, unsigned Discriminator,
635 /// Emit the absolute difference between two symbols if possible.
637 /// \pre Offset of \c Hi is greater than the offset \c Lo.
638 /// \return true on success.
639 virtual bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
644 virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
645 virtual void EmitCFISections(bool EH, bool Debug);
646 void EmitCFIStartProc(bool IsSimple);
647 void EmitCFIEndProc();
648 virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
649 virtual void EmitCFIDefCfaOffset(int64_t Offset);
650 virtual void EmitCFIDefCfaRegister(int64_t Register);
651 virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
652 virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
653 virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
654 virtual void EmitCFIRememberState();
655 virtual void EmitCFIRestoreState();
656 virtual void EmitCFISameValue(int64_t Register);
657 virtual void EmitCFIRestore(int64_t Register);
658 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
659 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
660 virtual void EmitCFIEscape(StringRef Values);
661 virtual void EmitCFISignalFrame();
662 virtual void EmitCFIUndefined(int64_t Register);
663 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
664 virtual void EmitCFIWindowSave();
666 virtual void EmitWinCFIStartProc(const MCSymbol *Symbol);
667 virtual void EmitWinCFIEndProc();
668 virtual void EmitWinCFIStartChained();
669 virtual void EmitWinCFIEndChained();
670 virtual void EmitWinCFIPushReg(unsigned Register);
671 virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset);
672 virtual void EmitWinCFIAllocStack(unsigned Size);
673 virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset);
674 virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset);
675 virtual void EmitWinCFIPushFrame(bool Code);
676 virtual void EmitWinCFIEndProlog();
678 virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
679 virtual void EmitWinEHHandlerData();
681 /// \brief Emit the given \p Instruction into the current section.
682 virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
684 /// \brief Set the bundle alignment mode from now on in the section.
685 /// The argument is the power of 2 to which the alignment is set. The
686 /// value 0 means turn the bundle alignment off.
687 virtual void EmitBundleAlignMode(unsigned AlignPow2);
689 /// \brief The following instructions are a bundle-locked group.
691 /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
692 /// the end of a bundle.
693 virtual void EmitBundleLock(bool AlignToEnd);
695 /// \brief Ends a bundle-locked group.
696 virtual void EmitBundleUnlock();
698 /// \brief If this file is backed by a assembly streamer, this dumps the
699 /// specified string in the output .s file. This capability is indicated by
700 /// the hasRawTextSupport() predicate. By default this aborts.
701 void EmitRawText(const Twine &String);
703 /// \brief Causes any cached state to be written out.
704 virtual void Flush() {}
706 /// \brief Streamer specific finalization.
707 virtual void FinishImpl();
708 /// \brief Finish emission of machine code.
711 virtual bool mayHaveInstructions(MCSection &Sec) const { return true; }
714 /// Create a dummy machine code streamer, which does nothing. This is useful for
715 /// timing the assembler front end.
716 MCStreamer *createNullStreamer(MCContext &Ctx);
718 /// Create a machine code streamer which will print out assembly for the native
719 /// target, suitable for compiling with a native assembler.
721 /// \param InstPrint - If given, the instruction printer to use. If not given
722 /// the MCInst representation will be printed. This method takes ownership of
725 /// \param CE - If given, a code emitter to use to show the instruction
726 /// encoding inline with the assembly. This method takes ownership of \p CE.
728 /// \param TAB - If given, a target asm backend to use to show the fixup
729 /// information in conjunction with encoding information. This method takes
730 /// ownership of \p TAB.
732 /// \param ShowInst - Whether to show the MCInst representation inline with
734 MCStreamer *createAsmStreamer(MCContext &Ctx,
735 std::unique_ptr<formatted_raw_ostream> OS,
736 bool isVerboseAsm, bool useDwarfDirectory,
737 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
738 MCAsmBackend *TAB, bool ShowInst);
739 } // end namespace llvm