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