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 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 prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS,
89 const MCInst &Inst, const MCSubtargetInfo &STI);
91 virtual void finish();
94 // FIXME: declared here because it is used from
95 // lib/CodeGen/AsmPrinter/ARMException.cpp.
96 class ARMTargetStreamer : public MCTargetStreamer {
98 ARMTargetStreamer(MCStreamer &S);
99 ~ARMTargetStreamer() override;
101 virtual void emitFnStart();
102 virtual void emitFnEnd();
103 virtual void emitCantUnwind();
104 virtual void emitPersonality(const MCSymbol *Personality);
105 virtual void emitPersonalityIndex(unsigned Index);
106 virtual void emitHandlerData();
107 virtual void emitSetFP(unsigned FpReg, unsigned SpReg,
109 virtual void emitMovSP(unsigned Reg, int64_t Offset = 0);
110 virtual void emitPad(int64_t Offset);
111 virtual void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
113 virtual void emitUnwindRaw(int64_t StackOffset,
114 const SmallVectorImpl<uint8_t> &Opcodes);
116 virtual void switchVendor(StringRef Vendor);
117 virtual void emitAttribute(unsigned Attribute, unsigned Value);
118 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
119 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
120 StringRef StringValue = "");
121 virtual void emitFPU(unsigned FPU);
122 virtual void emitArch(unsigned Arch);
123 virtual void emitArchExtension(unsigned ArchExt);
124 virtual void emitObjectArch(unsigned Arch);
125 virtual void finishAttributeSection();
126 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
128 virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
130 virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
132 void finish() override;
134 /// Callback used to implement the ldr= pseudo.
135 /// Add a new entry to the constant pool for the current section and return an
136 /// MCExpr that can be used to refer to the constant pool location.
137 const MCExpr *addConstantPoolEntry(const MCExpr *);
139 /// Callback used to implemnt the .ltorg directive.
140 /// Emit contents of constant pool for the current section.
141 void emitCurrentConstantPool();
144 std::unique_ptr<AssemblerConstantPools> ConstantPools;
147 /// \brief Streaming machine code generation interface.
149 /// This interface is intended to provide a programatic interface that is very
150 /// similar to the level that an assembler .s file provides. It has callbacks
151 /// to emit bytes, handle directives, etc. The implementation of this interface
152 /// retains state to know what the current section is etc.
154 /// There are multiple implementations of this interface: one for writing out
155 /// a .s file, and implementations that write out .o files of various formats.
159 std::unique_ptr<MCTargetStreamer> TargetStreamer;
161 MCStreamer(const MCStreamer &) = delete;
162 MCStreamer &operator=(const MCStreamer &) = delete;
164 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
165 MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
166 void EnsureValidDwarfFrame();
168 MCSymbol *EmitCFICommon();
170 std::vector<WinEH::FrameInfo *> WinFrameInfos;
171 WinEH::FrameInfo *CurrentWinFrameInfo;
172 void EnsureValidWinFrameInfo();
174 /// \brief Tracks an index to represent the order a symbol was emitted in.
175 /// Zero means we did not emit that symbol.
176 DenseMap<const MCSymbol *, unsigned> SymbolOrdering;
178 /// \brief This is stack of current and previous section values saved by
180 SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
183 MCStreamer(MCContext &Ctx);
185 virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
186 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
188 WinEH::FrameInfo *getCurrentWinFrameInfo() {
189 return CurrentWinFrameInfo;
192 virtual void EmitWindowsUnwindTables();
194 virtual void EmitRawTextImpl(StringRef String);
197 virtual ~MCStreamer();
199 void visitUsedExpr(const MCExpr &Expr);
200 virtual void visitUsedSymbol(const MCSymbol &Sym);
202 void setTargetStreamer(MCTargetStreamer *TS) {
203 TargetStreamer.reset(TS);
208 virtual void reset();
210 MCContext &getContext() const { return Context; }
212 MCTargetStreamer *getTargetStreamer() {
213 return TargetStreamer.get();
216 unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); }
217 ArrayRef<MCDwarfFrameInfo> getDwarfFrameInfos() const {
218 return DwarfFrameInfos;
221 unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
222 ArrayRef<WinEH::FrameInfo *> getWinFrameInfos() const {
223 return WinFrameInfos;
226 void generateCompactUnwindEncodings(MCAsmBackend *MAB);
228 /// \name Assembly File Formatting.
231 /// \brief Return true if this streamer supports verbose assembly and if it is
233 virtual bool isVerboseAsm() const { return false; }
235 /// \brief Return true if this asm streamer supports emitting unformatted text
236 /// to the .s file with EmitRawText.
237 virtual bool hasRawTextSupport() const { return false; }
239 /// \brief Is the integrated assembler required for this streamer to function
241 virtual bool isIntegratedAssemblerRequired() const { return false; }
243 /// \brief Add a textual command.
245 /// Typically for comments that can be emitted to the generated .s
246 /// file if applicable as a QoI issue to make the output of the compiler
247 /// more readable. This only affects the MCAsmStreamer, and only when
248 /// verbose assembly output is enabled.
250 /// If the comment includes embedded \n's, they will each get the comment
251 /// prefix as appropriate. The added comment should not end with a \n.
252 virtual void AddComment(const Twine &T) {}
254 /// \brief Return a raw_ostream that comments can be written to. Unlike
255 /// AddComment, you are required to terminate comments with \n if you use this
257 virtual raw_ostream &GetCommentOS();
259 /// \brief Print T and prefix it with the comment string (normally #) and
260 /// optionally a tab. This prints the comment immediately, not at the end of
261 /// the current line. It is basically a safe version of EmitRawText: since it
262 /// only prints comments, the object streamer ignores it instead of asserting.
263 virtual void emitRawComment(const Twine &T, bool TabPrefix = true);
265 /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
266 virtual void AddBlankLine() {}
270 /// \name Symbol & Section Management
273 /// \brief Return the current section that the streamer is emitting code to.
274 MCSectionSubPair getCurrentSection() const {
275 if (!SectionStack.empty())
276 return SectionStack.back().first;
277 return MCSectionSubPair();
279 MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
281 /// \brief Return the previous section that the streamer is emitting code to.
282 MCSectionSubPair getPreviousSection() const {
283 if (!SectionStack.empty())
284 return SectionStack.back().second;
285 return MCSectionSubPair();
288 /// \brief Returns an index to represent the order a symbol was emitted in.
289 /// (zero if we did not emit that symbol)
290 unsigned GetSymbolOrder(const MCSymbol *Sym) const {
291 return SymbolOrdering.lookup(Sym);
294 /// \brief Update streamer for a new active section.
296 /// This is called by PopSection and SwitchSection, if the current
298 virtual void ChangeSection(MCSection *, const MCExpr *);
300 /// \brief Save the current and previous section on the section stack.
302 SectionStack.push_back(
303 std::make_pair(getCurrentSection(), getPreviousSection()));
306 /// \brief Restore the current and previous section from the section stack.
307 /// Calls ChangeSection as needed.
309 /// Returns false if the stack was empty.
311 if (SectionStack.size() <= 1)
313 auto I = SectionStack.end();
315 MCSectionSubPair OldSection = I->first;
317 MCSectionSubPair NewSection = I->first;
319 if (OldSection != NewSection)
320 ChangeSection(NewSection.first, NewSection.second);
321 SectionStack.pop_back();
325 bool SubSection(const MCExpr *Subsection) {
326 if (SectionStack.empty())
329 SwitchSection(SectionStack.back().first.first, Subsection);
333 /// Set the current section where code is being emitted to \p Section. This
334 /// is required to update CurSection.
336 /// This corresponds to assembler directives like .section, .text, etc.
337 virtual void SwitchSection(MCSection *Section,
338 const MCExpr *Subsection = nullptr);
340 /// \brief Set the current section where code is being emitted to \p Section.
341 /// This is required to update CurSection. This version does not call
343 void SwitchSectionNoChange(MCSection *Section,
344 const MCExpr *Subsection = nullptr) {
345 assert(Section && "Cannot switch to a null section!");
346 MCSectionSubPair curSection = SectionStack.back().first;
347 SectionStack.back().second = curSection;
348 if (MCSectionSubPair(Section, Subsection) != curSection)
349 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
352 /// \brief Create the default sections and set the initial one.
353 virtual void InitSections(bool NoExecStack);
355 MCSymbol *endSection(MCSection *Section);
357 /// \brief Sets the symbol's section.
359 /// Each emitted symbol will be tracked in the ordering table,
360 /// so we can sort on them later.
361 void AssignSection(MCSymbol *Symbol, MCSection *Section);
363 /// \brief Emit a label for \p Symbol into the current section.
365 /// This corresponds to an assembler statement such as:
368 /// \param Symbol - The symbol to emit. A given symbol should only be
369 /// emitted as a label once, and symbols emitted as a label should never be
370 /// used in an assignment.
371 // FIXME: These emission are non-const because we mutate the symbol to
372 // add the section we're emitting it to later.
373 virtual void EmitLabel(MCSymbol *Symbol);
375 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
377 /// \brief Note in the output the specified \p Flag.
378 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
380 /// \brief Emit the given list \p Options of strings as linker
381 /// options into the output.
382 virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {}
384 /// \brief Note in the output the specified region \p Kind.
385 virtual void EmitDataRegion(MCDataRegionType Kind) {}
387 /// \brief Specify the MachO minimum deployment target version.
388 virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor,
391 /// \brief Note in the output that the specified \p Func is a Thumb mode
392 /// function (ARM target only).
393 virtual void EmitThumbFunc(MCSymbol *Func);
395 /// \brief Emit an assignment of \p Value to \p Symbol.
397 /// This corresponds to an assembler statement such as:
400 /// The assignment generates no code, but has the side effect of binding the
401 /// value in the current context. For the assembly streamer, this prints the
402 /// binding into the .s file.
404 /// \param Symbol - The symbol being assigned to.
405 /// \param Value - The value for the symbol.
406 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
408 /// \brief Emit an weak reference from \p Alias to \p Symbol.
410 /// This corresponds to an assembler statement such as:
411 /// .weakref alias, symbol
413 /// \param Alias - The alias that is being created.
414 /// \param Symbol - The symbol being aliased.
415 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
417 /// \brief Add the given \p Attribute to \p Symbol.
418 virtual bool EmitSymbolAttribute(MCSymbol *Symbol,
419 MCSymbolAttr Attribute) = 0;
421 /// \brief Set the \p DescValue for the \p Symbol.
423 /// \param Symbol - The symbol to have its n_desc field set.
424 /// \param DescValue - The value to set into the n_desc field.
425 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
427 /// \brief Start emitting COFF symbol definition
429 /// \param Symbol - The symbol to have its External & Type fields set.
430 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
432 /// \brief Emit the storage class of the symbol.
434 /// \param StorageClass - The storage class the symbol should have.
435 virtual void EmitCOFFSymbolStorageClass(int StorageClass);
437 /// \brief Emit the type of the symbol.
439 /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
440 virtual void EmitCOFFSymbolType(int Type);
442 /// \brief Marks the end of the symbol definition.
443 virtual void EndCOFFSymbolDef();
445 virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
447 /// \brief Emits a COFF section index.
449 /// \param Symbol - Symbol the section number relocation should point to.
450 virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol);
452 /// \brief Emits a COFF section relative relocation.
454 /// \param Symbol - Symbol the section relative relocation should point to.
455 virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
457 /// \brief Emit an ELF .size directive.
459 /// This corresponds to an assembler statement such as:
460 /// .size symbol, expression
461 virtual void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value);
463 /// \brief Emit a Linker Optimization Hint (LOH) directive.
464 /// \param Args - Arguments of the LOH.
465 virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
467 /// \brief Emit a common symbol.
469 /// \param Symbol - The common symbol to emit.
470 /// \param Size - The size of the common symbol.
471 /// \param ByteAlignment - The alignment of the symbol if
472 /// non-zero. This must be a power of 2.
473 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
474 unsigned ByteAlignment) = 0;
476 /// \brief Emit a local common (.lcomm) symbol.
478 /// \param Symbol - The common symbol to emit.
479 /// \param Size - The size of the common symbol.
480 /// \param ByteAlignment - The alignment of the common symbol in bytes.
481 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
482 unsigned ByteAlignment);
484 /// \brief Emit the zerofill section and an optional symbol.
486 /// \param Section - The zerofill section to create and or to put the symbol
487 /// \param Symbol - The zerofill symbol to emit, if non-NULL.
488 /// \param Size - The size of the zerofill symbol.
489 /// \param ByteAlignment - The alignment of the zerofill symbol if
490 /// non-zero. This must be a power of 2 on some targets.
491 virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
492 uint64_t Size = 0, unsigned ByteAlignment = 0) = 0;
494 /// \brief Emit a thread local bss (.tbss) symbol.
496 /// \param Section - The thread local common section.
497 /// \param Symbol - The thread local common symbol to emit.
498 /// \param Size - The size of the symbol.
499 /// \param ByteAlignment - The alignment of the thread local common symbol
500 /// if non-zero. This must be a power of 2 on some targets.
501 virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
502 uint64_t Size, unsigned ByteAlignment = 0);
505 /// \name Generating Data
508 /// \brief Emit the bytes in \p Data into the output.
510 /// This is used to implement assembler directives such as .byte, .ascii,
512 virtual void EmitBytes(StringRef Data);
514 /// \brief Emit the expression \p Value into the output as a native
515 /// integer of the given \p Size bytes.
517 /// This is used to implement assembler directives such as .word, .quad,
520 /// \param Value - The value to emit.
521 /// \param Size - The size of the integer (in bytes) to emit. This must
522 /// match a native machine width.
523 /// \param Loc - The location of the expression for error reporting.
524 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
525 const SMLoc &Loc = SMLoc());
527 void EmitValue(const MCExpr *Value, unsigned Size,
528 const SMLoc &Loc = SMLoc());
530 /// \brief Special case of EmitValue that avoids the client having
531 /// to pass in a MCExpr for constant integers.
532 virtual void EmitIntValue(uint64_t Value, unsigned Size);
534 virtual void EmitULEB128Value(const MCExpr *Value);
536 virtual void EmitSLEB128Value(const MCExpr *Value);
538 /// \brief Special case of EmitULEB128Value that avoids the client having to
539 /// pass in a MCExpr for constant integers.
540 void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
542 /// \brief Special case of EmitSLEB128Value that avoids the client having to
543 /// pass in a MCExpr for constant integers.
544 void EmitSLEB128IntValue(int64_t Value);
546 /// \brief Special case of EmitValue that avoids the client having to pass in
547 /// a MCExpr for MCSymbols.
548 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
549 bool IsSectionRelative = false);
551 /// \brief Emit the expression \p Value into the output as a gprel64 (64-bit
552 /// GP relative) value.
554 /// This is used to implement assembler directives such as .gpdword on
555 /// targets that support them.
556 virtual void EmitGPRel64Value(const MCExpr *Value);
558 /// \brief Emit the expression \p Value into the output as a gprel32 (32-bit
559 /// GP relative) value.
561 /// This is used to implement assembler directives such as .gprel32 on
562 /// targets that support them.
563 virtual void EmitGPRel32Value(const MCExpr *Value);
565 /// \brief Emit NumBytes bytes worth of the value specified by FillValue.
566 /// This implements directives such as '.space'.
567 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
569 /// \brief Emit NumBytes worth of zeros.
570 /// This function properly handles data in virtual sections.
571 virtual void EmitZeros(uint64_t NumBytes);
573 /// \brief Emit some number of copies of \p Value until the byte alignment \p
574 /// ByteAlignment is reached.
576 /// If the number of bytes need to emit for the alignment is not a multiple
577 /// of \p ValueSize, then the contents of the emitted fill bytes is
580 /// This used to implement the .align assembler directive.
582 /// \param ByteAlignment - The alignment to reach. This must be a power of
583 /// two on some targets.
584 /// \param Value - The value to use when filling bytes.
585 /// \param ValueSize - The size of the integer (in bytes) to emit for
586 /// \p Value. This must match a native machine width.
587 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
588 /// the alignment cannot be reached in this many bytes, no bytes are
590 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
591 unsigned ValueSize = 1,
592 unsigned MaxBytesToEmit = 0);
594 /// \brief Emit nops until the byte alignment \p ByteAlignment is reached.
596 /// This used to align code where the alignment bytes may be executed. This
597 /// can emit different bytes for different sizes to optimize execution.
599 /// \param ByteAlignment - The alignment to reach. This must be a power of
600 /// two on some targets.
601 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
602 /// the alignment cannot be reached in this many bytes, no bytes are
604 virtual void EmitCodeAlignment(unsigned ByteAlignment,
605 unsigned MaxBytesToEmit = 0);
607 /// \brief Emit some number of copies of \p Value until the byte offset \p
608 /// Offset is reached.
610 /// This is used to implement assembler directives such as .org.
612 /// \param Offset - The offset to reach. This may be an expression, but the
613 /// expression must be associated with the current section.
614 /// \param Value - The value to use when filling bytes.
615 /// \return false on success, true if the offset was invalid.
616 virtual bool EmitValueToOffset(const MCExpr *Offset,
617 unsigned char Value = 0);
621 /// \brief Switch to a new logical file. This is used to implement the '.file
622 /// "foo.c"' assembler directive.
623 virtual void EmitFileDirective(StringRef Filename);
625 /// \brief Emit the "identifiers" directive. This implements the
626 /// '.ident "version foo"' assembler directive.
627 virtual void EmitIdent(StringRef IdentString) {}
629 /// \brief Associate a filename with a specified logical file number. This
630 /// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
631 virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
635 /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler
637 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
638 unsigned Column, unsigned Flags,
639 unsigned Isa, unsigned Discriminator,
642 /// Emit the absolute difference between two symbols.
644 /// \pre Offset of \c Hi is greater than the offset \c Lo.
645 virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
648 virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
649 virtual void EmitCFISections(bool EH, bool Debug);
650 void EmitCFIStartProc(bool IsSimple);
651 void EmitCFIEndProc();
652 virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
653 virtual void EmitCFIDefCfaOffset(int64_t Offset);
654 virtual void EmitCFIDefCfaRegister(int64_t Register);
655 virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
656 virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
657 virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
658 virtual void EmitCFIRememberState();
659 virtual void EmitCFIRestoreState();
660 virtual void EmitCFISameValue(int64_t Register);
661 virtual void EmitCFIRestore(int64_t Register);
662 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
663 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
664 virtual void EmitCFIEscape(StringRef Values);
665 virtual void EmitCFISignalFrame();
666 virtual void EmitCFIUndefined(int64_t Register);
667 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
668 virtual void EmitCFIWindowSave();
670 virtual void EmitWinCFIStartProc(const MCSymbol *Symbol);
671 virtual void EmitWinCFIEndProc();
672 virtual void EmitWinCFIStartChained();
673 virtual void EmitWinCFIEndChained();
674 virtual void EmitWinCFIPushReg(unsigned Register);
675 virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset);
676 virtual void EmitWinCFIAllocStack(unsigned Size);
677 virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset);
678 virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset);
679 virtual void EmitWinCFIPushFrame(bool Code);
680 virtual void EmitWinCFIEndProlog();
682 virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
683 virtual void EmitWinEHHandlerData();
685 /// \brief Emit the given \p Instruction into the current section.
686 virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
688 /// \brief Set the bundle alignment mode from now on in the section.
689 /// The argument is the power of 2 to which the alignment is set. The
690 /// value 0 means turn the bundle alignment off.
691 virtual void EmitBundleAlignMode(unsigned AlignPow2);
693 /// \brief The following instructions are a bundle-locked group.
695 /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
696 /// the end of a bundle.
697 virtual void EmitBundleLock(bool AlignToEnd);
699 /// \brief Ends a bundle-locked group.
700 virtual void EmitBundleUnlock();
702 /// \brief If this file is backed by a assembly streamer, this dumps the
703 /// specified string in the output .s file. This capability is indicated by
704 /// the hasRawTextSupport() predicate. By default this aborts.
705 void EmitRawText(const Twine &String);
707 /// \brief Causes any cached state to be written out.
708 virtual void Flush() {}
710 /// \brief Streamer specific finalization.
711 virtual void FinishImpl();
712 /// \brief Finish emission of machine code.
715 virtual bool mayHaveInstructions(MCSection &Sec) const { return true; }
718 /// Create a dummy machine code streamer, which does nothing. This is useful for
719 /// timing the assembler front end.
720 MCStreamer *createNullStreamer(MCContext &Ctx);
722 /// Create a machine code streamer which will print out assembly for the native
723 /// target, suitable for compiling with a native assembler.
725 /// \param InstPrint - If given, the instruction printer to use. If not given
726 /// the MCInst representation will be printed. This method takes ownership of
729 /// \param CE - If given, a code emitter to use to show the instruction
730 /// encoding inline with the assembly. This method takes ownership of \p CE.
732 /// \param TAB - If given, a target asm backend to use to show the fixup
733 /// information in conjunction with encoding information. This method takes
734 /// ownership of \p TAB.
736 /// \param ShowInst - Whether to show the MCInst representation inline with
738 MCStreamer *createAsmStreamer(MCContext &Ctx,
739 std::unique_ptr<formatted_raw_ostream> OS,
740 bool isVerboseAsm, bool useDwarfDirectory,
741 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
742 MCAsmBackend *TAB, bool ShowInst);
743 } // end namespace llvm