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