LLVM 21.0.0git
MCStreamer.h
Go to the documentation of this file.
1//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the MCStreamer class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_MC_MCSTREAMER_H
14#define LLVM_MC_MCSTREAMER_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/StringRef.h"
21#include "llvm/MC/MCDwarf.h"
22#include "llvm/MC/MCFragment.h"
25#include "llvm/MC/MCWinEH.h"
26#include "llvm/Support/Error.h"
27#include "llvm/Support/MD5.h"
28#include "llvm/Support/SMLoc.h"
31#include <cassert>
32#include <cstdint>
33#include <memory>
34#include <optional>
35#include <string>
36#include <utility>
37#include <vector>
38
39namespace llvm {
40
41class APInt;
42class AssemblerConstantPools;
43class MCAsmBackend;
44class MCAssembler;
45class MCContext;
46class MCExpr;
47class MCFragment;
48class MCInst;
49class MCInstPrinter;
50class MCRegister;
51class MCSection;
52class MCStreamer;
53class MCSubtargetInfo;
54class MCSymbol;
55class MCSymbolRefExpr;
56class Triple;
57class Twine;
58class raw_ostream;
59
60namespace codeview {
61struct DefRangeRegisterRelHeader;
62struct DefRangeSubfieldRegisterHeader;
63struct DefRangeRegisterHeader;
64struct DefRangeFramePointerRelHeader;
65}
66
67using MCSectionSubPair = std::pair<MCSection *, uint32_t>;
68
69/// Target specific streamer interface. This is used so that targets can
70/// implement support for target specific assembly directives.
71///
72/// If target foo wants to use this, it should implement 3 classes:
73/// * FooTargetStreamer : public MCTargetStreamer
74/// * FooTargetAsmStreamer : public FooTargetStreamer
75/// * FooTargetELFStreamer : public FooTargetStreamer
76///
77/// FooTargetStreamer should have a pure virtual method for each directive. For
78/// example, for a ".bar symbol_name" directive, it should have
79/// virtual emitBar(const MCSymbol &Symbol) = 0;
80///
81/// The FooTargetAsmStreamer and FooTargetELFStreamer classes implement the
82/// method. The assembly streamer just prints ".bar symbol_name". The object
83/// streamer does whatever is needed to implement .bar in the object file.
84///
85/// In the assembly printer and parser the target streamer can be used by
86/// calling getTargetStreamer and casting it to FooTargetStreamer:
87///
88/// MCTargetStreamer &TS = OutStreamer.getTargetStreamer();
89/// FooTargetStreamer &ATS = static_cast<FooTargetStreamer &>(TS);
90///
91/// The base classes FooTargetAsmStreamer and FooTargetELFStreamer should
92/// *never* be treated differently. Callers should always talk to a
93/// FooTargetStreamer.
95protected:
97
98public:
101
103
104 // Allow a target to add behavior to the EmitLabel of MCStreamer.
105 virtual void emitLabel(MCSymbol *Symbol);
106 // Allow a target to add behavior to the emitAssignment of MCStreamer.
107 virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value);
108
109 virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address,
110 const MCInst &Inst, const MCSubtargetInfo &STI,
111 raw_ostream &OS);
112
114
115 /// Update streamer for a new active section.
116 ///
117 /// This is called by popSection and switchSection, if the current
118 /// section changes.
119 virtual void changeSection(const MCSection *CurSection, MCSection *Section,
120 uint32_t SubSection, raw_ostream &OS);
121
122 virtual void emitValue(const MCExpr *Value);
123
124 /// Emit the bytes in \p Data into the output.
125 ///
126 /// This is used to emit bytes in \p Data as sequence of .byte directives.
127 virtual void emitRawBytes(StringRef Data);
128
129 virtual void emitConstantPools();
130
131 virtual void finish();
132};
133
134// FIXME: declared here because it is used from
135// lib/CodeGen/AsmPrinter/ARMException.cpp.
137public:
140
141 virtual void emitFnStart();
142 virtual void emitFnEnd();
143 virtual void emitCantUnwind();
144 virtual void emitPersonality(const MCSymbol *Personality);
145 virtual void emitPersonalityIndex(unsigned Index);
146 virtual void emitHandlerData();
147 virtual void emitSetFP(MCRegister FpReg, MCRegister SpReg,
148 int64_t Offset = 0);
149 virtual void emitMovSP(MCRegister Reg, int64_t Offset = 0);
150 virtual void emitPad(int64_t Offset);
151 virtual void emitRegSave(const SmallVectorImpl<MCRegister> &RegList,
152 bool isVector);
153 virtual void emitUnwindRaw(int64_t StackOffset,
154 const SmallVectorImpl<uint8_t> &Opcodes);
155
156 virtual void switchVendor(StringRef Vendor);
157 virtual void emitAttribute(unsigned Attribute, unsigned Value);
158 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
159 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
160 StringRef StringValue = "");
161 virtual void emitFPU(ARM::FPUKind FPU);
162 virtual void emitArch(ARM::ArchKind Arch);
163 virtual void emitArchExtension(uint64_t ArchExt);
164 virtual void emitObjectArch(ARM::ArchKind Arch);
165 void emitTargetAttributes(const MCSubtargetInfo &STI);
166 virtual void finishAttributeSection();
167 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
168
169 virtual void annotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
170
171 virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
172
173 void emitConstantPools() override;
174
175 virtual void emitARMWinCFIAllocStack(unsigned Size, bool Wide);
176 virtual void emitARMWinCFISaveRegMask(unsigned Mask, bool Wide);
177 virtual void emitARMWinCFISaveSP(unsigned Reg);
178 virtual void emitARMWinCFISaveFRegs(unsigned First, unsigned Last);
179 virtual void emitARMWinCFISaveLR(unsigned Offset);
180 virtual void emitARMWinCFIPrologEnd(bool Fragment);
181 virtual void emitARMWinCFINop(bool Wide);
182 virtual void emitARMWinCFIEpilogStart(unsigned Condition);
183 virtual void emitARMWinCFIEpilogEnd();
184 virtual void emitARMWinCFICustom(unsigned Opcode);
185
186 /// Reset any state between object emissions, i.e. the equivalent of
187 /// MCStreamer's reset method.
188 virtual void reset();
189
190 /// Callback used to implement the ldr= pseudo.
191 /// Add a new entry to the constant pool for the current section and return an
192 /// MCExpr that can be used to refer to the constant pool location.
193 const MCExpr *addConstantPoolEntry(const MCExpr *, SMLoc Loc);
194
195 /// Callback used to implement the .ltorg directive.
196 /// Emit contents of constant pool for the current section.
198
199private:
200 std::unique_ptr<AssemblerConstantPools> ConstantPools;
201};
202
203/// Streaming machine code generation interface.
204///
205/// This interface is intended to provide a programmatic interface that is very
206/// similar to the level that an assembler .s file provides. It has callbacks
207/// to emit bytes, handle directives, etc. The implementation of this interface
208/// retains state to know what the current section is etc.
209///
210/// There are multiple implementations of this interface: one for writing out
211/// a .s file, and implementations that write out .o files of various formats.
212///
214 MCContext &Context;
215 std::unique_ptr<MCTargetStreamer> TargetStreamer;
216
217 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
218 // This is a pair of index into DwarfFrameInfos and the MCSection associated
219 // with the frame. Note, we use an index instead of an iterator because they
220 // can be invalidated in std::vector.
222 MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
223
224 /// Similar to DwarfFrameInfos, but for SEH unwind info. Chained frames may
225 /// refer to each other, so use std::unique_ptr to provide pointer stability.
226 std::vector<std::unique_ptr<WinEH::FrameInfo>> WinFrameInfos;
227
228 WinEH::FrameInfo *CurrentWinFrameInfo;
229 size_t CurrentProcWinFrameInfoStartIndex;
230
231 /// This is stack of current and previous section values saved by
232 /// pushSection.
234
235 /// Pointer to the parser's SMLoc if available. This is used to provide
236 /// locations for diagnostics.
237 const SMLoc *StartTokLocPtr = nullptr;
238
239 /// The next unique ID to use when creating a WinCFI-related section (.pdata
240 /// or .xdata). This ID ensures that we have a one-to-one mapping from
241 /// code section to unwind info section, which MSVC's incremental linker
242 /// requires.
243 unsigned NextWinCFIID = 0;
244
245 bool UseAssemblerInfoForParsing = true;
246
247 /// Is the assembler allowed to insert padding automatically? For
248 /// correctness reasons, we sometimes need to ensure instructions aren't
249 /// separated in unexpected ways. At the moment, this feature is only
250 /// useable from an integrated assembler, but assembly syntax is under
251 /// discussion for future inclusion.
252 bool AllowAutoPadding = false;
253
254protected:
255 // True if we are processing SEH directives in an epilogue.
256 bool InEpilogCFI = false;
257
258 // Symbol of the current epilog for which we are processing SEH directives.
260
261 MCFragment *CurFrag = nullptr;
262
263 MCStreamer(MCContext &Ctx);
264
265 /// This is called by popSection and switchSection, if the current
266 /// section changes.
267 virtual void changeSection(MCSection *, uint32_t);
268
269 virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
270 virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
271
273 return CurrentWinFrameInfo;
274 }
275
276 virtual void emitWindowsUnwindTables(WinEH::FrameInfo *Frame);
277
278 virtual void emitWindowsUnwindTables();
279
280 virtual void emitRawTextImpl(StringRef String);
281
282 /// Returns true if the .cv_loc directive is in the right section.
283 bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc);
284
285public:
286 MCStreamer(const MCStreamer &) = delete;
287 MCStreamer &operator=(const MCStreamer &) = delete;
288 virtual ~MCStreamer();
289
290 void visitUsedExpr(const MCExpr &Expr);
291 virtual void visitUsedSymbol(const MCSymbol &Sym);
292
294 TargetStreamer.reset(TS);
295 }
296
297 void setStartTokLocPtr(const SMLoc *Loc) { StartTokLocPtr = Loc; }
299 return StartTokLocPtr ? *StartTokLocPtr : SMLoc();
300 }
301
302 /// State management
303 ///
304 virtual void reset();
305
306 MCContext &getContext() const { return Context; }
307
308 // MCObjectStreamer has an MCAssembler and allows more expression folding at
309 // parse time.
310 virtual MCAssembler *getAssemblerPtr() { return nullptr; }
311
312 void setUseAssemblerInfoForParsing(bool v) { UseAssemblerInfoForParsing = v; }
313 bool getUseAssemblerInfoForParsing() { return UseAssemblerInfoForParsing; }
314
316 return TargetStreamer.get();
317 }
318
319 void setAllowAutoPadding(bool v) { AllowAutoPadding = v; }
320 bool getAllowAutoPadding() const { return AllowAutoPadding; }
321
323
324 /// When emitting an object file, create and emit a real label. When emitting
325 /// textual assembly, this should do nothing to avoid polluting our output.
326 virtual MCSymbol *emitCFILabel();
327
328 /// Retrieve the current frame info if one is available and it is not yet
329 /// closed. Otherwise, issue an error and return null.
331
332 unsigned getNumFrameInfos();
334
336
337 unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
339 return WinFrameInfos;
340 }
341
343
344 bool isInEpilogCFI() const { return InEpilogCFI; }
345
347
348 /// \name Assembly File Formatting.
349 /// @{
350
351 /// Return true if this streamer supports verbose assembly and if it is
352 /// enabled.
353 virtual bool isVerboseAsm() const { return false; }
354
355 /// Return true if this asm streamer supports emitting unformatted text
356 /// to the .s file with EmitRawText.
357 virtual bool hasRawTextSupport() const { return false; }
358
359 /// Is the integrated assembler required for this streamer to function
360 /// correctly?
361 virtual bool isIntegratedAssemblerRequired() const { return false; }
362
363 /// Add a textual comment.
364 ///
365 /// Typically for comments that can be emitted to the generated .s
366 /// file if applicable as a QoI issue to make the output of the compiler
367 /// more readable. This only affects the MCAsmStreamer, and only when
368 /// verbose assembly output is enabled.
369 ///
370 /// If the comment includes embedded \n's, they will each get the comment
371 /// prefix as appropriate. The added comment should not end with a \n.
372 /// By default, each comment is terminated with an end of line, i.e. the
373 /// EOL param is set to true by default. If one prefers not to end the
374 /// comment with a new line then the EOL param should be passed
375 /// with a false value.
376 virtual void AddComment(const Twine &T, bool EOL = true) {}
377
378 /// Return a raw_ostream that comments can be written to. Unlike
379 /// AddComment, you are required to terminate comments with \n if you use this
380 /// method.
381 virtual raw_ostream &getCommentOS();
382
383 /// Print T and prefix it with the comment string (normally #) and
384 /// optionally a tab. This prints the comment immediately, not at the end of
385 /// the current line. It is basically a safe version of EmitRawText: since it
386 /// only prints comments, the object streamer ignores it instead of asserting.
387 virtual void emitRawComment(const Twine &T, bool TabPrefix = true);
388
389 /// Add explicit comment T. T is required to be a valid
390 /// comment in the output and does not need to be escaped.
391 virtual void addExplicitComment(const Twine &T);
392
393 /// Emit added explicit comments.
394 virtual void emitExplicitComments();
395
396 /// Emit a blank line to a .s file to pretty it up.
397 virtual void addBlankLine() {}
398
399 /// @}
400
401 /// \name Symbol & Section Management
402 /// @{
403
404 /// Return the current section that the streamer is emitting code to.
406 if (!SectionStack.empty())
407 return SectionStack.back().first;
408 return MCSectionSubPair();
409 }
411 return CurFrag->getParent();
412 }
413
414 /// Return the previous section that the streamer is emitting code to.
416 if (!SectionStack.empty())
417 return SectionStack.back().second;
418 return MCSectionSubPair();
419 }
420
422 assert(!getCurrentSection().first ||
423 CurFrag->getParent() == getCurrentSection().first);
424 return CurFrag;
425 }
426
427 /// Save the current and previous section on the section stack.
428 void pushSection() {
429 SectionStack.push_back(
430 std::make_pair(getCurrentSection(), getPreviousSection()));
431 }
432
433 /// Restore the current and previous section from the section stack.
434 /// Calls changeSection as needed.
435 ///
436 /// Returns false if the stack was empty.
437 virtual bool popSection();
438
439 /// Set the current section where code is being emitted to \p Section. This
440 /// is required to update CurSection.
441 ///
442 /// This corresponds to assembler directives like .section, .text, etc.
443 virtual void switchSection(MCSection *Section, uint32_t Subsec = 0);
444 bool switchSection(MCSection *Section, const MCExpr *);
445
446 /// Similar to switchSection, but does not print the section directive.
447 virtual void switchSectionNoPrint(MCSection *Section);
448
449 /// Create the default sections and set the initial one.
450 virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI);
451
452 MCSymbol *endSection(MCSection *Section);
453
454 /// Returns the mnemonic for \p MI, if the streamer has access to a
455 /// instruction printer and returns an empty string otherwise.
456 virtual StringRef getMnemonic(const MCInst &MI) const { return ""; }
457
458 /// Emit a label for \p Symbol into the current section.
459 ///
460 /// This corresponds to an assembler statement such as:
461 /// foo:
462 ///
463 /// \param Symbol - The symbol to emit. A given symbol should only be
464 /// emitted as a label once, and symbols emitted as a label should never be
465 /// used in an assignment.
466 // FIXME: These emission are non-const because we mutate the symbol to
467 // add the section we're emitting it to later.
468 virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc());
469
470 virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
471
472 /// Note in the output the specified \p Flag.
473 virtual void emitAssemblerFlag(MCAssemblerFlag Flag);
474
475 /// Emit the given list \p Options of strings as linker
476 /// options into the output.
478
479 /// Note in the output the specified region \p Kind.
480 virtual void emitDataRegion(MCDataRegionType Kind) {}
481
482 /// Specify the Mach-O minimum deployment target version.
483 virtual void emitVersionMin(MCVersionMinType Type, unsigned Major,
484 unsigned Minor, unsigned Update,
485 VersionTuple SDKVersion) {}
486
487 /// Emit/Specify Mach-O build version command.
488 /// \p Platform should be one of MachO::PlatformType.
489 virtual void emitBuildVersion(unsigned Platform, unsigned Major,
490 unsigned Minor, unsigned Update,
491 VersionTuple SDKVersion) {}
492
493 virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform,
494 unsigned Major,
495 unsigned Minor,
496 unsigned Update,
497 VersionTuple SDKVersion) {}
498
500 const VersionTuple &SDKVersion,
501 const Triple *DarwinTargetVariantTriple,
502 const VersionTuple &DarwinTargetVariantSDKVersion);
503
504 /// Note in the output that the specified \p Func is a Thumb mode
505 /// function (ARM target only).
506 virtual void emitThumbFunc(MCSymbol *Func);
507
508 /// Emit an assignment of \p Value to \p Symbol.
509 ///
510 /// This corresponds to an assembler statement such as:
511 /// symbol = value
512 ///
513 /// The assignment generates no code, but has the side effect of binding the
514 /// value in the current context. For the assembly streamer, this prints the
515 /// binding into the .s file.
516 ///
517 /// \param Symbol - The symbol being assigned to.
518 /// \param Value - The value for the symbol.
519 virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value);
520
521 /// Emit an assignment of \p Value to \p Symbol, but only if \p Value is also
522 /// emitted.
523 virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value);
524
525 /// Emit an weak reference from \p Alias to \p Symbol.
526 ///
527 /// This corresponds to an assembler statement such as:
528 /// .weakref alias, symbol
529 ///
530 /// \param Alias - The alias that is being created.
531 /// \param Symbol - The symbol being aliased.
532 virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
533
534 /// Add the given \p Attribute to \p Symbol.
535 virtual bool emitSymbolAttribute(MCSymbol *Symbol,
537
538 /// Set the \p DescValue for the \p Symbol.
539 ///
540 /// \param Symbol - The symbol to have its n_desc field set.
541 /// \param DescValue - The value to set into the n_desc field.
542 virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
543
544 /// Start emitting COFF symbol definition
545 ///
546 /// \param Symbol - The symbol to have its External & Type fields set.
547 virtual void beginCOFFSymbolDef(const MCSymbol *Symbol);
548
549 /// Emit the storage class of the symbol.
550 ///
551 /// \param StorageClass - The storage class the symbol should have.
553
554 /// Emit the type of the symbol.
555 ///
556 /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
557 virtual void emitCOFFSymbolType(int Type);
558
559 /// Marks the end of the symbol definition.
560 virtual void endCOFFSymbolDef();
561
562 virtual void emitCOFFSafeSEH(MCSymbol const *Symbol);
563
564 /// Emits the symbol table index of a Symbol into the current section.
565 virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol);
566
567 /// Emits a COFF section index.
568 ///
569 /// \param Symbol - Symbol the section number relocation should point to.
570 virtual void emitCOFFSectionIndex(MCSymbol const *Symbol);
571
572 /// Emits a COFF section relative relocation.
573 ///
574 /// \param Symbol - Symbol the section relative relocation should point to.
575 virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset);
576
577 /// Emits a COFF image relative relocation.
578 ///
579 /// \param Symbol - Symbol the image relative relocation should point to.
580 virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset);
581
582 /// Emits the physical number of the section containing the given symbol as
583 /// assigned during object writing (i.e., this is not a runtime relocation).
584 virtual void emitCOFFSecNumber(MCSymbol const *Symbol);
585
586 /// Emits the offset of the symbol from the beginning of the section during
587 /// object writing (i.e., this is not a runtime relocation).
588 virtual void emitCOFFSecOffset(MCSymbol const *Symbol);
589
590 /// Emits an lcomm directive with XCOFF csect information.
591 ///
592 /// \param LabelSym - Label on the block of storage.
593 /// \param Size - The size of the block of storage.
594 /// \param CsectSym - Csect name for the block of storage.
595 /// \param Alignment - The alignment of the symbol in bytes.
596 virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size,
597 MCSymbol *CsectSym, Align Alignment);
598
599 /// Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
600 ///
601 /// \param Symbol - The symbol to emit.
602 /// \param Linkage - The linkage of the symbol to emit.
603 /// \param Visibility - The visibility of the symbol to emit or MCSA_Invalid
604 /// if the symbol does not have an explicit visibility.
607 MCSymbolAttr Visibility);
608
609 /// Emit a XCOFF .rename directive which creates a synonym for an illegal or
610 /// undesirable name.
611 ///
612 /// \param Name - The name used internally in the assembly for references to
613 /// the symbol.
614 /// \param Rename - The value to which the Name parameter is
615 /// changed at the end of assembly.
616 virtual void emitXCOFFRenameDirective(const MCSymbol *Name, StringRef Rename);
617
618 /// Emit an XCOFF .except directive which adds information about
619 /// a trap instruction to the object file exception section
620 ///
621 /// \param Symbol - The function containing the trap.
622 /// \param Lang - The language code for the exception entry.
623 /// \param Reason - The reason code for the exception entry.
624 virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol,
625 const MCSymbol *Trap,
626 unsigned Lang, unsigned Reason,
627 unsigned FunctionSize, bool hasDebug);
628
629 /// Emit a XCOFF .ref directive which creates R_REF type entry in the
630 /// relocation table for one or more symbols.
631 ///
632 /// \param Sym - The symbol on the .ref directive.
633 virtual void emitXCOFFRefDirective(const MCSymbol *Symbol);
634
635 /// Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
636 ///
637 /// \param Name - The embedded metadata name
638 /// \param Metadata - The embedded metadata
640
641 /// Emit an ELF .size directive.
642 ///
643 /// This corresponds to an assembler statement such as:
644 /// .size symbol, expression
645 virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value);
646
647 /// Emit an ELF .symver directive.
648 ///
649 /// This corresponds to an assembler statement such as:
650 /// .symver _start, foo@@SOME_VERSION
651 virtual void emitELFSymverDirective(const MCSymbol *OriginalSym,
652 StringRef Name, bool KeepOriginalSym);
653
654 /// Emit a Linker Optimization Hint (LOH) directive.
655 /// \param Args - Arguments of the LOH.
656 virtual void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {}
657
658 /// Emit a .gnu_attribute directive.
659 virtual void emitGNUAttribute(unsigned Tag, unsigned Value) {}
660
661 /// Emit a common symbol.
662 ///
663 /// \param Symbol - The common symbol to emit.
664 /// \param Size - The size of the common symbol.
665 /// \param ByteAlignment - The alignment of the symbol.
666 virtual void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
667 Align ByteAlignment) = 0;
668
669 /// Emit a local common (.lcomm) symbol.
670 ///
671 /// \param Symbol - The common symbol to emit.
672 /// \param Size - The size of the common symbol.
673 /// \param ByteAlignment - The alignment of the common symbol in bytes.
674 virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
675 Align ByteAlignment);
676
677 /// Emit the zerofill section and an optional symbol.
678 ///
679 /// \param Section - The zerofill section to create and or to put the symbol
680 /// \param Symbol - The zerofill symbol to emit, if non-NULL.
681 /// \param Size - The size of the zerofill symbol.
682 /// \param ByteAlignment - The alignment of the zerofill symbol.
683 virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
684 uint64_t Size = 0, Align ByteAlignment = Align(1),
685 SMLoc Loc = SMLoc()) = 0;
686
687 /// Emit a thread local bss (.tbss) symbol.
688 ///
689 /// \param Section - The thread local common section.
690 /// \param Symbol - The thread local common symbol to emit.
691 /// \param Size - The size of the symbol.
692 /// \param ByteAlignment - The alignment of the thread local common symbol.
693 virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
694 uint64_t Size, Align ByteAlignment = Align(1));
695
696 /// @}
697 /// \name Generating Data
698 /// @{
699
700 /// Emit the bytes in \p Data into the output.
701 ///
702 /// This is used to implement assembler directives such as .byte, .ascii,
703 /// etc.
704 virtual void emitBytes(StringRef Data);
705
706 /// Functionally identical to EmitBytes. When emitting textual assembly, this
707 /// method uses .byte directives instead of .ascii or .asciz for readability.
708 virtual void emitBinaryData(StringRef Data);
709
710 /// Emit the expression \p Value into the output as a native
711 /// integer of the given \p Size bytes.
712 ///
713 /// This is used to implement assembler directives such as .word, .quad,
714 /// etc.
715 ///
716 /// \param Value - The value to emit.
717 /// \param Size - The size of the integer (in bytes) to emit. This must
718 /// match a native machine width.
719 /// \param Loc - The location of the expression for error reporting.
720 virtual void emitValueImpl(const MCExpr *Value, unsigned Size,
721 SMLoc Loc = SMLoc());
722
723 void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc());
724
725 /// Special case of EmitValue that avoids the client having
726 /// to pass in a MCExpr for constant integers.
727 virtual void emitIntValue(uint64_t Value, unsigned Size);
728 virtual void emitIntValue(const APInt &Value);
729
730 /// Special case of EmitValue that avoids the client having to pass
731 /// in a MCExpr for constant integers & prints in Hex format for certain
732 /// modes.
733 virtual void emitIntValueInHex(uint64_t Value, unsigned Size) {
735 }
736
741
742 /// Special case of EmitValue that avoids the client having to pass
743 /// in a MCExpr for constant integers & prints in Hex format for certain
744 /// modes, pads the field with leading zeros to Size width
747 }
748
749 virtual void emitULEB128Value(const MCExpr *Value);
750
751 virtual void emitSLEB128Value(const MCExpr *Value);
752
753 /// Special case of EmitULEB128Value that avoids the client having to
754 /// pass in a MCExpr for constant integers.
755 unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo = 0);
756
757 /// Special case of EmitSLEB128Value that avoids the client having to
758 /// pass in a MCExpr for constant integers.
759 unsigned emitSLEB128IntValue(int64_t Value);
760
761 /// Special case of EmitValue that avoids the client having to pass in
762 /// a MCExpr for MCSymbols.
763 void emitSymbolValue(const MCSymbol *Sym, unsigned Size,
764 bool IsSectionRelative = false);
765
766 /// Emit the expression \p Value into the output as a dtprel
767 /// (64-bit DTP relative) value.
768 ///
769 /// This is used to implement assembler directives such as .dtpreldword on
770 /// targets that support them.
771 virtual void emitDTPRel64Value(const MCExpr *Value);
772
773 /// Emit the expression \p Value into the output as a dtprel
774 /// (32-bit DTP relative) value.
775 ///
776 /// This is used to implement assembler directives such as .dtprelword on
777 /// targets that support them.
778 virtual void emitDTPRel32Value(const MCExpr *Value);
779
780 /// Emit the expression \p Value into the output as a tprel
781 /// (64-bit TP relative) value.
782 ///
783 /// This is used to implement assembler directives such as .tpreldword on
784 /// targets that support them.
785 virtual void emitTPRel64Value(const MCExpr *Value);
786
787 /// Emit the expression \p Value into the output as a tprel
788 /// (32-bit TP relative) value.
789 ///
790 /// This is used to implement assembler directives such as .tprelword on
791 /// targets that support them.
792 virtual void emitTPRel32Value(const MCExpr *Value);
793
794 /// Emit the expression \p Value into the output as a gprel64 (64-bit
795 /// GP relative) value.
796 ///
797 /// This is used to implement assembler directives such as .gpdword on
798 /// targets that support them.
799 virtual void emitGPRel64Value(const MCExpr *Value);
800
801 /// Emit the expression \p Value into the output as a gprel32 (32-bit
802 /// GP relative) value.
803 ///
804 /// This is used to implement assembler directives such as .gprel32 on
805 /// targets that support them.
806 virtual void emitGPRel32Value(const MCExpr *Value);
807
808 /// Emit NumBytes bytes worth of the value specified by FillValue.
809 /// This implements directives such as '.space'.
810 void emitFill(uint64_t NumBytes, uint8_t FillValue);
811
812 /// Emit \p Size bytes worth of the value specified by \p FillValue.
813 ///
814 /// This is used to implement assembler directives such as .space or .skip.
815 ///
816 /// \param NumBytes - The number of bytes to emit.
817 /// \param FillValue - The value to use when filling bytes.
818 /// \param Loc - The location of the expression for error reporting.
819 virtual void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
820 SMLoc Loc = SMLoc());
821
822 /// Emit \p NumValues copies of \p Size bytes. Each \p Size bytes is
823 /// taken from the lowest order 4 bytes of \p Expr expression.
824 ///
825 /// This is used to implement assembler directives such as .fill.
826 ///
827 /// \param NumValues - The number of copies of \p Size bytes to emit.
828 /// \param Size - The size (in bytes) of each repeated value.
829 /// \param Expr - The expression from which \p Size bytes are used.
830 virtual void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
831 SMLoc Loc = SMLoc());
832
833 virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength,
834 SMLoc Loc, const MCSubtargetInfo& STI);
835
836 /// Emit NumBytes worth of zeros.
837 /// This function properly handles data in virtual sections.
838 void emitZeros(uint64_t NumBytes);
839
840 /// Emit some number of copies of \p Value until the byte alignment \p
841 /// ByteAlignment is reached.
842 ///
843 /// If the number of bytes need to emit for the alignment is not a multiple
844 /// of \p ValueSize, then the contents of the emitted fill bytes is
845 /// undefined.
846 ///
847 /// This used to implement the .align assembler directive.
848 ///
849 /// \param Alignment - The alignment to reach.
850 /// \param Value - The value to use when filling bytes.
851 /// \param ValueSize - The size of the integer (in bytes) to emit for
852 /// \p Value. This must match a native machine width.
853 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
854 /// the alignment cannot be reached in this many bytes, no bytes are
855 /// emitted.
856 virtual void emitValueToAlignment(Align Alignment, int64_t Value = 0,
857 unsigned ValueSize = 1,
858 unsigned MaxBytesToEmit = 0);
859
860 /// Emit nops until the byte alignment \p ByteAlignment is reached.
861 ///
862 /// This used to align code where the alignment bytes may be executed. This
863 /// can emit different bytes for different sizes to optimize execution.
864 ///
865 /// \param Alignment - The alignment to reach.
866 /// \param STI - The MCSubtargetInfo in operation when padding is emitted.
867 /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
868 /// the alignment cannot be reached in this many bytes, no bytes are
869 /// emitted.
870 virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI,
871 unsigned MaxBytesToEmit = 0);
872
873 /// Emit some number of copies of \p Value until the byte offset \p
874 /// Offset is reached.
875 ///
876 /// This is used to implement assembler directives such as .org.
877 ///
878 /// \param Offset - The offset to reach. This may be an expression, but the
879 /// expression must be associated with the current section.
880 /// \param Value - The value to use when filling bytes.
881 virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value,
882 SMLoc Loc);
883
884 /// @}
885
886 /// Switch to a new logical file. This is used to implement the '.file
887 /// "foo.c"' assembler directive.
888 virtual void emitFileDirective(StringRef Filename);
889
890 /// Emit ".file assembler diretive with additioal info.
891 virtual void emitFileDirective(StringRef Filename, StringRef CompilerVersion,
892 StringRef TimeStamp, StringRef Description);
893
894 /// Emit the "identifiers" directive. This implements the
895 /// '.ident "version foo"' assembler directive.
896 virtual void emitIdent(StringRef IdentString) {}
897
898 /// Associate a filename with a specified logical file number. This
899 /// implements the DWARF2 '.file 4 "foo.c"' assembler directive.
901 unsigned FileNo, StringRef Directory, StringRef Filename,
902 std::optional<MD5::MD5Result> Checksum = std::nullopt,
903 std::optional<StringRef> Source = std::nullopt, unsigned CUID = 0) {
904 return cantFail(
905 tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum,
906 Source, CUID));
907 }
908
909 /// Associate a filename with a specified logical file number.
910 /// Also associate a directory, optional checksum, and optional source
911 /// text with the logical file. This implements the DWARF2
912 /// '.file 4 "dir/foo.c"' assembler directive, and the DWARF5
913 /// '.file 4 "dir/foo.c" md5 "..." source "..."' assembler directive.
915 unsigned FileNo, StringRef Directory, StringRef Filename,
916 std::optional<MD5::MD5Result> Checksum = std::nullopt,
917 std::optional<StringRef> Source = std::nullopt, unsigned CUID = 0);
918
919 /// Specify the "root" file of the compilation, using the ".file 0" extension.
920 virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
921 std::optional<MD5::MD5Result> Checksum,
922 std::optional<StringRef> Source,
923 unsigned CUID = 0);
924
925 virtual void emitCFIBKeyFrame();
926 virtual void emitCFIMTETaggedFrame();
927
928 /// This implements the DWARF2 '.loc fileno lineno ...' assembler
929 /// directive.
930 virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line,
931 unsigned Column, unsigned Flags,
932 unsigned Isa, unsigned Discriminator,
933 StringRef FileName);
934
935 /// This implements the '.loc_label Name' directive.
937
938 /// Associate a filename with a specified logical file number, and also
939 /// specify that file's checksum information. This implements the '.cv_file 4
940 /// "foo.c"' assembler directive. Returns true on success.
941 virtual bool emitCVFileDirective(unsigned FileNo, StringRef Filename,
942 ArrayRef<uint8_t> Checksum,
943 unsigned ChecksumKind);
944
945 /// Introduces a function id for use with .cv_loc.
946 virtual bool emitCVFuncIdDirective(unsigned FunctionId);
947
948 /// Introduces an inline call site id for use with .cv_loc. Includes
949 /// extra information for inline line table generation.
950 virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc,
951 unsigned IAFile, unsigned IALine,
952 unsigned IACol, SMLoc Loc);
953
954 /// This implements the CodeView '.cv_loc' assembler directive.
955 virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
956 unsigned Line, unsigned Column,
957 bool PrologueEnd, bool IsStmt,
958 StringRef FileName, SMLoc Loc);
959
960 /// This implements the CodeView '.cv_linetable' assembler directive.
961 virtual void emitCVLinetableDirective(unsigned FunctionId,
962 const MCSymbol *FnStart,
963 const MCSymbol *FnEnd);
964
965 /// This implements the CodeView '.cv_inline_linetable' assembler
966 /// directive.
967 virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
968 unsigned SourceFileId,
969 unsigned SourceLineNum,
970 const MCSymbol *FnStartSym,
971 const MCSymbol *FnEndSym);
972
973 /// This implements the CodeView '.cv_def_range' assembler
974 /// directive.
975 virtual void emitCVDefRangeDirective(
976 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
977 StringRef FixedSizePortion);
978
979 virtual void emitCVDefRangeDirective(
980 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
982
983 virtual void emitCVDefRangeDirective(
984 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
986
987 virtual void emitCVDefRangeDirective(
988 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
990
991 virtual void emitCVDefRangeDirective(
992 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
994
995 /// This implements the CodeView '.cv_stringtable' assembler directive.
997
998 /// This implements the CodeView '.cv_filechecksums' assembler directive.
1000
1001 /// This implements the CodeView '.cv_filechecksumoffset' assembler
1002 /// directive.
1003 virtual void emitCVFileChecksumOffsetDirective(unsigned FileNo) {}
1004
1005 /// This implements the CodeView '.cv_fpo_data' assembler directive.
1006 virtual void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc = {}) {}
1007
1008 /// Emit the absolute difference between two symbols.
1009 ///
1010 /// \pre Offset of \c Hi is greater than the offset \c Lo.
1011 virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
1012 unsigned Size);
1013
1014 /// Emit the absolute difference between two symbols encoded with ULEB128.
1015 virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
1016 const MCSymbol *Lo);
1017
1018 virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
1019 virtual void emitCFISections(bool EH, bool Debug);
1020 void emitCFIStartProc(bool IsSimple, SMLoc Loc = SMLoc());
1021 void emitCFIEndProc();
1022 virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc = {});
1023 virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc = {});
1024 virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc = {});
1025 virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset,
1026 int64_t AddressSpace, SMLoc Loc = {});
1027 virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc = {});
1028 virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
1029 virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding);
1030 virtual void emitCFIRememberState(SMLoc Loc);
1031 virtual void emitCFIRestoreState(SMLoc Loc);
1032 virtual void emitCFISameValue(int64_t Register, SMLoc Loc = {});
1033 virtual void emitCFIRestore(int64_t Register, SMLoc Loc = {});
1034 virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc);
1035 virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc = {});
1036 virtual void emitCFIEscape(StringRef Values, SMLoc Loc = {});
1037 virtual void emitCFIReturnColumn(int64_t Register);
1038 virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc = {});
1039 virtual void emitCFISignalFrame();
1040 virtual void emitCFIUndefined(int64_t Register, SMLoc Loc = {});
1041 virtual void emitCFIRegister(int64_t Register1, int64_t Register2,
1042 SMLoc Loc = {});
1043 virtual void emitCFIWindowSave(SMLoc Loc = {});
1044 virtual void emitCFINegateRAState(SMLoc Loc = {});
1045 virtual void emitCFINegateRAStateWithPC(SMLoc Loc = {});
1046 virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name);
1047 virtual void emitCFIValOffset(int64_t Register, int64_t Offset,
1048 SMLoc Loc = {});
1049
1050 virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc = SMLoc());
1051 virtual void emitWinCFIEndProc(SMLoc Loc = SMLoc());
1052 /// This is used on platforms, such as Windows on ARM64, that require function
1053 /// or funclet sizes to be emitted in .xdata before the End marker is emitted
1054 /// for the frame. We cannot use the End marker, as it is not set at the
1055 /// point of emitting .xdata, in order to indicate that the frame is active.
1056 virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc = SMLoc());
1057 virtual void emitWinCFIStartChained(SMLoc Loc = SMLoc());
1058 virtual void emitWinCFIEndChained(SMLoc Loc = SMLoc());
1059 virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc = SMLoc());
1060 virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset,
1061 SMLoc Loc = SMLoc());
1062 virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc = SMLoc());
1063 virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset,
1064 SMLoc Loc = SMLoc());
1065 virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset,
1066 SMLoc Loc = SMLoc());
1067 virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc = SMLoc());
1068 virtual void emitWinCFIEndProlog(SMLoc Loc = SMLoc());
1069 virtual void emitWinCFIBeginEpilogue(SMLoc Loc = SMLoc());
1070 virtual void emitWinCFIEndEpilogue(SMLoc Loc = SMLoc());
1071 virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
1072 SMLoc Loc = SMLoc());
1073 virtual void emitWinEHHandlerData(SMLoc Loc = SMLoc());
1074
1075 virtual void emitCGProfileEntry(const MCSymbolRefExpr *From,
1076 const MCSymbolRefExpr *To, uint64_t Count);
1077
1078 /// Get the .pdata section used for the given section. Typically the given
1079 /// section is either the main .text section or some other COMDAT .text
1080 /// section, but it may be any section containing code.
1081 MCSection *getAssociatedPDataSection(const MCSection *TextSec);
1082
1083 /// Get the .xdata section used for the given section.
1084 MCSection *getAssociatedXDataSection(const MCSection *TextSec);
1085
1086 virtual void emitSyntaxDirective();
1087
1088 /// Record a relocation described by the .reloc directive. Return std::nullopt
1089 /// if succeeded. Otherwise, return a pair (Name is invalid, error message).
1090 virtual std::optional<std::pair<bool, std::string>>
1092 SMLoc Loc, const MCSubtargetInfo &STI) {
1093 return std::nullopt;
1094 }
1095
1096 virtual void emitAddrsig() {}
1097 virtual void emitAddrsigSym(const MCSymbol *Sym) {}
1098
1099 /// Emit the given \p Instruction into the current section.
1100 virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
1101
1102 /// Emit the a pseudo probe into the current section.
1104 uint64_t Attr, uint64_t Discriminator,
1105 const MCPseudoProbeInlineStack &InlineStack,
1106 MCSymbol *FnSym);
1107
1108 /// Set the bundle alignment mode from now on in the section.
1109 /// The value 1 means turn the bundle alignment off.
1110 virtual void emitBundleAlignMode(Align Alignment);
1111
1112 /// The following instructions are a bundle-locked group.
1113 ///
1114 /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
1115 /// the end of a bundle.
1116 virtual void emitBundleLock(bool AlignToEnd);
1117
1118 /// Ends a bundle-locked group.
1119 virtual void emitBundleUnlock();
1120
1121 /// If this file is backed by a assembly streamer, this dumps the
1122 /// specified string in the output .s file. This capability is indicated by
1123 /// the hasRawTextSupport() predicate. By default this aborts.
1124 void emitRawText(const Twine &String);
1125
1126 /// Streamer specific finalization.
1127 virtual void finishImpl();
1128 /// Finish emission of machine code.
1129 void finish(SMLoc EndLoc = SMLoc());
1130
1131 virtual bool mayHaveInstructions(MCSection &Sec) const { return true; }
1132
1133 /// Emit a special value of 0xffffffff if producing 64-bit debugging info.
1134 void maybeEmitDwarf64Mark();
1135
1136 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
1137 /// according to the settings.
1138 virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment);
1139
1140 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
1141 /// according to the settings.
1142 /// Return the end symbol generated inside, the caller needs to emit it.
1143 virtual MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
1144 const Twine &Comment);
1145
1146 /// Emit the debug line start label.
1147 virtual void emitDwarfLineStartLabel(MCSymbol *StartSym);
1148
1149 /// Emit the debug line end entry.
1150 virtual void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
1151 MCSymbol *EndLabel = nullptr) {}
1152
1153 /// If targets does not support representing debug line section by .loc/.file
1154 /// directives in assembly output, we need to populate debug line section with
1155 /// raw debug line contents.
1156 virtual void emitDwarfAdvanceLineAddr(int64_t LineDelta,
1157 const MCSymbol *LastLabel,
1158 const MCSymbol *Label,
1159 unsigned PointerSize) {}
1160};
1161
1162/// Create a dummy machine code streamer, which does nothing. This is useful for
1163/// timing the assembler front end.
1164MCStreamer *createNullStreamer(MCContext &Ctx);
1165
1166} // end namespace llvm
1167
1168#endif // LLVM_MC_MCSTREAMER_H
BlockVerifier::State From
DXIL Finalize Linkage
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
Definition: Debug.cpp:108
This file defines the DenseMap class.
std::string Name
uint32_t Index
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
IRTranslator LLVM IR MI
unsigned Reg
Profile::FuncID FuncId
Definition: Profile.cpp:321
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallVector class.
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Class for arbitrary precision integers.
Definition: APInt.h:78
virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl< uint8_t > &Opcodes)
~ARMTargetStreamer() override
void emitTargetAttributes(const MCSubtargetInfo &STI)
Emit the build attributes that only depend on the hardware that we expect.
virtual void reset()
Reset any state between object emissions, i.e.
virtual void emitSetFP(MCRegister FpReg, MCRegister SpReg, int64_t Offset=0)
virtual void annotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE)
virtual void finishAttributeSection()
virtual void emitMovSP(MCRegister Reg, int64_t Offset=0)
virtual void emitARMWinCFISaveSP(unsigned Reg)
virtual void emitPersonalityIndex(unsigned Index)
virtual void emitInst(uint32_t Inst, char Suffix='\0')
virtual void emitARMWinCFISaveLR(unsigned Offset)
virtual void emitArchExtension(uint64_t ArchExt)
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
virtual void emitARMWinCFIAllocStack(unsigned Size, bool Wide)
virtual void emitARMWinCFICustom(unsigned Opcode)
virtual void emitARMWinCFISaveRegMask(unsigned Mask, bool Wide)
virtual void emitRegSave(const SmallVectorImpl< MCRegister > &RegList, bool isVector)
virtual void emitARMWinCFIEpilogEnd()
virtual void emitARMWinCFIPrologEnd(bool Fragment)
virtual void switchVendor(StringRef Vendor)
virtual void emitPersonality(const MCSymbol *Personality)
virtual void emitObjectArch(ARM::ArchKind Arch)
const MCExpr * addConstantPoolEntry(const MCExpr *, SMLoc Loc)
Callback used to implement the ldr= pseudo.
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue="")
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value)
virtual void emitFPU(ARM::FPUKind FPU)
virtual void emitARMWinCFISaveFRegs(unsigned First, unsigned Last)
virtual void emitARMWinCFIEpilogStart(unsigned Condition)
virtual void emitPad(int64_t Offset)
void emitCurrentConstantPool()
Callback used to implement the .ltorg directive.
virtual void emitAttribute(unsigned Attribute, unsigned Value)
virtual void emitARMWinCFINop(bool Wide)
void emitConstantPools() override
virtual void emitArch(ARM::ArchKind Arch)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Tagged union holding either a T or a Error.
Definition: Error.h:481
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCSection * getParent() const
Definition: MCFragment.h:99
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Streaming machine code generation interface.
Definition: MCStreamer.h:213
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
Definition: MCStreamer.cpp:648
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
Definition: MCStreamer.cpp:225
virtual void emitAddrsig()
Definition: MCStreamer.h:1096
MCSymbol * emitLineTableLabel()
Definition: MCStreamer.cpp:486
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void switchSectionNoPrint(MCSection *Section)
Similar to switchSection, but does not print the section directive.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:506
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
Definition: MCStreamer.h:397
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:444
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:307
virtual void finishImpl()
Streamer specific finalization.
virtual void emitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
Definition: MCStreamer.cpp:194
virtual void emitCFIBKeyFrame()
Definition: MCStreamer.cpp:248
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
Definition: MCStreamer.cpp:125
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
Definition: MCStreamer.h:415
virtual void beginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void emitSyntaxDirective()
Definition: MCStreamer.cpp:903
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:909
virtual void emitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI)
Create the default sections and set the initial one.
Definition: MCStreamer.cpp:416
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
Definition: MCStreamer.cpp:500
virtual void emitWindowsUnwindTables()
MCStreamer(const MCStreamer &)=delete
virtual void emitGNUAttribute(unsigned Tag, unsigned Value)
Emit a .gnu_attribute directive.
Definition: MCStreamer.h:659
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
Definition: MCStreamer.cpp:110
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:828
virtual void emitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
Definition: MCStreamer.cpp:891
unsigned getNumWinFrameInfos()
Definition: MCStreamer.h:337
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
Definition: MCStreamer.cpp:270
bool hasUnfinishedDwarfFrameInfo()
Definition: MCStreamer.cpp:286
virtual ~MCStreamer()
void setStartTokLocPtr(const SMLoc *Loc)
Definition: MCStreamer.h:297
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
MCFragment * getCurrentFragment() const
Definition: MCStreamer.h:421
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
Definition: MCStreamer.cpp:705
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
Definition: MCStreamer.cpp:210
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:618
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual bool emitCVFileDirective(unsigned FileNo, StringRef Filename, ArrayRef< uint8_t > Checksum, unsigned ChecksumKind)
Associate a filename with a specified logical file number, and also specify that file's checksum info...
Definition: MCStreamer.cpp:300
virtual void emitCFIReturnColumn(int64_t Register)
Definition: MCStreamer.cpp:715
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:580
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
Definition: MCStreamer.cpp:686
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
virtual void emitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
Definition: MCStreamer.h:996
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
Definition: MCStreamer.h:357
virtual void emitIntValueInHex(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
Definition: MCStreamer.h:733
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Definition: MCStreamer.cpp:262
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
Definition: MCStreamer.h:353
virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset)
Emits a COFF image relative relocation.
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
unsigned emitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.h:900
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:992
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:845
virtual void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)=0
Emit a common symbol.
virtual MCAssembler * getAssemblerPtr()
Definition: MCStreamer.h:310
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:665
void setTargetStreamer(MCTargetStreamer *TS)
Definition: MCStreamer.h:293
virtual bool isIntegratedAssemblerRequired() const
Is the integrated assembler required for this streamer to function correctly?
Definition: MCStreamer.h:361
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:977
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
Definition: MCStreamer.cpp:469
virtual void emitCVFileChecksumOffsetDirective(unsigned FileNo)
This implements the CodeView '.cv_filechecksumoffset' assembler directive.
Definition: MCStreamer.h:1003
bool getUseAssemblerInfoForParsing()
Definition: MCStreamer.h:313
virtual void emitCOFFSecNumber(MCSymbol const *Symbol)
Emits the physical number of the section containing the given symbol as assigned during object writin...
virtual void emitCFINegateRAState(SMLoc Loc={})
Definition: MCStreamer.cpp:695
virtual void emitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
Definition: MCStreamer.cpp:214
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:589
MCContext & getContext() const
Definition: MCStreamer.h:306
SMLoc getStartTokLoc() const
Definition: MCStreamer.h:298
virtual void emitBundleUnlock()
Ends a bundle-locked group.
virtual Expected< unsigned > tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
Definition: MCStreamer.cpp:231
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
Definition: MCStreamer.cpp:122
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
Definition: MCStreamer.h:376
virtual void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
Definition: MCStreamer.h:1006
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, MCSymbol *CsectSym, Align Alignment)
Emits an lcomm directive with XCOFF csect information.
virtual void emitCFIMTETaggedFrame()
Definition: MCStreamer.cpp:255
virtual void emitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
Definition: MCStreamer.cpp:206
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
Definition: MCStreamer.cpp:897
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
Definition: MCStreamer.cpp:120
virtual std::optional< std::pair< bool, std::string > > emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc, const MCSubtargetInfo &STI)
Record a relocation described by the .reloc directive.
Definition: MCStreamer.h:1091
MCSymbol * getCurrentEpilog() const
Definition: MCStreamer.h:342
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:754
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:179
void emitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
Definition: MCStreamer.cpp:183
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:330
virtual void emitIdent(StringRef IdentString)
Emit the "identifiers" directive.
Definition: MCStreamer.h:896
virtual StringRef getMnemonic(const MCInst &MI) const
Returns the mnemonic for MI, if the streamer has access to a instruction printer and returns an empty...
Definition: MCStreamer.h:456
virtual void emitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
Definition: MCStreamer.h:999
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
Definition: MCStreamer.cpp:638
MCSymbol * CurrentEpilog
Definition: MCStreamer.h:259
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap, unsigned Lang, unsigned Reason, unsigned FunctionSize, bool hasDebug)
Emit an XCOFF .except directive which adds information about a trap instruction to the object file ex...
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:420
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
void setAllowAutoPadding(bool v)
Definition: MCStreamer.h:319
virtual void emitCFIRememberState(SMLoc Loc)
Definition: MCStreamer.cpp:597
virtual void reset()
State management.
Definition: MCStreamer.cpp:101
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
Definition: MCStreamer.cpp:722
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:352
virtual void emitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
Definition: MCStreamer.cpp:202
virtual void emitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:442
virtual void emitCOFFSecOffset(MCSymbol const *Symbol)
Emits the offset of the symbol from the beginning of the section during object writing (i....
MCTargetStreamer * getTargetStreamer()
Definition: MCStreamer.h:315
virtual void emitIntValueInHexWithPadding(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
Definition: MCStreamer.h:745
MCFragment * CurFrag
Definition: MCStreamer.h:261
virtual void emitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Definition: MCStreamer.h:493
virtual bool mayHaveInstructions(MCSection &Sec) const
Definition: MCStreamer.h:1131
virtual void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
Definition: MCStreamer.cpp:133
unsigned getNumFrameInfos()
Definition: MCStreamer.cpp:115
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:960
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:814
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
bool isInEpilogCFI() const
Definition: MCStreamer.h:344
virtual void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
If targets does not support representing debug line section by .loc/.file directives in assembly outp...
Definition: MCStreamer.h:1156
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:772
void emitInt16(uint64_t Value)
Definition: MCStreamer.h:738
void emitVersionForTarget(const Triple &Target, const VersionTuple &SDKVersion, const Triple *DarwinTargetVariantTriple, const VersionTuple &DarwinTargetVariantSDKVersion)
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:480
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:537
virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:276
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
Definition: MCStreamer.cpp:675
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
Definition: MCStreamer.cpp:790
virtual void emitXCOFFRenameDirective(const MCSymbol *Name, StringRef Rename)
Emit a XCOFF .rename directive which creates a synonym for an illegal or undesirable name.
void pushSection()
Save the current and previous section on the section stack.
Definition: MCStreamer.h:428
virtual void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, uint64_t Discriminator, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
void setUseAssemblerInfoForParsing(bool v)
Definition: MCStreamer.h:312
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
Definition: MCStreamer.cpp:853
virtual void emitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
Definition: MCStreamer.h:480
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
Definition: MCStreamer.cpp:527
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:161
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
Definition: MCStreamer.cpp:116
bool getAllowAutoPadding() const
Definition: MCStreamer.h:320
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
Definition: MCStreamer.cpp:570
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
Definition: MCStreamer.h:477
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
void emitInt64(uint64_t Value)
Definition: MCStreamer.h:740
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
Definition: MCStreamer.cpp:123
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
Definition: MCStreamer.cpp:739
virtual void emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
virtual void emitCFIRestoreState(SMLoc Loc)
Definition: MCStreamer.cpp:607
virtual void emitXCOFFRefDirective(const MCSymbol *Symbol)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
Definition: MCStreamer.cpp:412
virtual void emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
Definition: MCStreamer.cpp:374
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:739
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:560
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:921
ArrayRef< std::unique_ptr< WinEH::FrameInfo > > getWinFrameInfos() const
Definition: MCStreamer.h:338
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
Definition: MCStreamer.cpp:198
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:517
virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, Align ByteAlignment=Align(1), SMLoc Loc=SMLoc())=0
Emit the zerofill section and an optional symbol.
virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
Definition: MCStreamer.cpp:325
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition: MCStreamer.h:405
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:943
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
Definition: MCStreamer.cpp:729
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata)
Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:410
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
MCStreamer & operator=(const MCStreamer &)=delete
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:229
virtual void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel, MCSymbol *EndLabel=nullptr)
Emit the debug line end entry.
Definition: MCStreamer.h:1150
virtual void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
Definition: MCStreamer.h:656
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:171
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
Definition: MCStreamer.cpp:311
virtual void emitCFISignalFrame()
Definition: MCStreamer.cpp:658
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition: MCStreamer.h:483
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
WinEH::FrameInfo * getCurrentWinFrameInfo()
Definition: MCStreamer.h:272
virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol, but only if Value is also emitted.
Definition: MCStreamer.cpp:439
void emitInt8(uint64_t Value)
Definition: MCStreamer.h:737
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:801
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCFIRestore(int64_t Register, SMLoc Loc={})
Definition: MCStreamer.cpp:628
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp:356
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:220
virtual void emitBundleAlignMode(Align Alignment)
Set the bundle alignment mode from now on in the section.
virtual void emitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
virtual void emitAddrsigSym(const MCSymbol *Sym)
Definition: MCStreamer.h:1097
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void visitUsedExpr(const MCExpr &Expr)
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID=0)
Specify the "root" file of the compilation, using the ".file 0" extension.
Definition: MCStreamer.cpp:239
virtual void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
Definition: MCStreamer.h:489
virtual void changeSection(MCSection *, uint32_t)
This is called by popSection and switchSection, if the current section changes.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
Definition: MCStreamer.cpp:548
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Target specific streamer interface.
Definition: MCStreamer.h:94
virtual void emitDwarfFileDirective(StringRef Directive)
Definition: MCStreamer.cpp:67
virtual void emitValue(const MCExpr *Value)
Definition: MCStreamer.cpp:71
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
virtual void finish()
Definition: MCStreamer.cpp:55
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Definition: MCStreamer.cpp:91
MCStreamer & getStreamer()
Definition: MCStreamer.h:102
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:79
MCStreamer & Streamer
Definition: MCStreamer.h:96
virtual void changeSection(const MCSection *CurSection, MCSection *Section, uint32_t SubSection, raw_ostream &OS)
Update streamer for a new active section.
Definition: MCStreamer.cpp:59
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:53
virtual void emitConstantPools()
Definition: MCStreamer.cpp:57
Root of the metadata hierarchy.
Definition: Metadata.h:62
Represents a location in source code.
Definition: SMLoc.h:23
bool empty() const
Definition: SmallVector.h:81
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:33
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This class represents a function that is read from a sample profile.
Definition: FunctionId.h:36
StorageClass
Definition: XCOFF.h:170
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Length
Definition: DWP.cpp:480
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
MCDataRegionType
Definition: MCDirectives.h:61
std::pair< MCSection *, uint32_t > MCSectionSubPair
Definition: MCStreamer.h:67
MCVersionMinType
Definition: MCDirectives.h:69
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
MCAssemblerFlag
Definition: MCDirectives.h:53
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:756
MCLOHType
Linker Optimization Hint Type.
MCSymbolAttr
Definition: MCDirectives.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39