LLVM 24.0.0git
AsmPrinter.h
Go to the documentation of this file.
1//===- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework ---------*- 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 contains a class to be used as the base class for target specific
10// asm writers. This class primarily handles common functionality used by
11// all asm writers.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_ASMPRINTER_H
16#define LLVM_CODEGEN_ASMPRINTER_H
17
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/MapVector.h"
20#include "llvm/ADT/SetVector.h"
29#include "llvm/IR/InlineAsm.h"
32#include <cstdint>
33#include <memory>
34#include <utility>
35#include <vector>
36
37namespace llvm {
38
39class AddrLabelMap;
41class BasicBlock;
43class BlockAddress;
44class Constant;
45class ConstantArray;
46class ConstantPtrAuth;
47class DataLayout;
49class DIE;
50class DIEAbbrev;
51class DwarfDebug;
53class GCStrategy;
54class GlobalAlias;
55class GlobalObject;
56class GlobalValue;
57class GlobalVariable;
64class MachineFunction;
65class MachineInstr;
67class MachineLoopInfo;
70class MCAsmInfo;
72class MCContext;
73class MCExpr;
74class MCInst;
75class MCSection;
76class MCStreamer;
77class MCSubtargetInfo;
78class MCSymbol;
79class MCTargetOptions;
80class MDNode;
81class Module;
83class raw_ostream;
84class StringRef;
86class TargetMachine;
87class Twine;
88
89namespace remarks {
90class RemarkStreamer;
91}
92
93/// This class is intended to be used as a driving class for all asm writers.
95public:
96 /// Target machine description.
98
99 /// Target Asm Printer information.
101
102 /// This is the context for the output file that we are streaming. This owns
103 /// all of the global MC-related objects for the generated translation unit.
105
106 /// This is the MCStreamer object for the file we are generating. This
107 /// contains the transient state for the current translation unit that we are
108 /// generating (such as the current section etc).
109 std::unique_ptr<MCStreamer> OutStreamer;
110
111 /// The current machine function.
112 MachineFunction *MF = nullptr;
113
114 /// This is a pointer to the current MachineModuleInfo.
116
117 /// The pointer size in bytes for the default address space
118 unsigned PointerSize = 0;
119
120 /// This is a pointer to the current MachineDominatorTree.
122
123 /// This is a pointer to the current MachineLoopInfo.
125
126 /// Optimization remark emitter.
128
129 /// The symbol for the entry in __patchable_function_entires.
131
132 /// The symbol for the current function. This is recalculated at the beginning
133 /// of each call to runOnMachineFunction().
135
136 /// The symbol for the current function descriptor on AIX. This is created
137 /// at the beginning of each call to SetupMachineFunction().
139
140 /// The symbol used to represent the start of the current function for the
141 /// purpose of calculating its size (e.g. using the .size directive). By
142 /// default, this is equal to CurrentFnSym.
144
145 /// Vector of symbols marking the end of the callsites in the current
146 /// function, keyed by their containing basic block.
147 /// The callsite symbols of each block are stored in the order they appear
148 /// in that block.
151
152 /// Provides the profile information for constants.
153 const StaticDataProfileInfo *SDPI = nullptr;
154
155 /// The profile summary information.
156 const ProfileSummaryInfo *PSI = nullptr;
157
158 /// Map a basic block section ID to the begin and end symbols of that section
159 /// which determine the section's range.
163
165
166 /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
167 /// its number of uses by other globals.
168 using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
170
171 // Flags representing which CFI section is required for a function/module.
172 enum class CFISection : unsigned {
173 None = 0, ///< Do not emit either .eh_frame or .debug_frame
174 EH = 1, ///< Emit .eh_frame
175 Debug = 2 ///< Emit .debug_frame
176 };
177
178 // Callbacks to get analyses to allow portability between the new and
179 // legacy pass managers.
180 // TODO(boomanaiden154): Remove these and use a more native solution once
181 // we drop support for the legacy PM.
182 std::function<MachineModuleInfo *()> GetMMI;
189 /// Returns the basic block sections profile reader if available, nullptr
190 /// otherwise.
192 std::function<void(Module &)> BeginGCAssembly;
193 std::function<void(Module &)> FinishGCAssembly;
194 std::function<void(Module &)> EmitStackMaps;
195 std::function<void()> AssertDebugEHFinalized;
196
197private:
198 MCSymbol *CurrentFnEnd = nullptr;
199
200 /// Map a basic block section ID to the exception symbol associated with that
201 /// section. Map entries are assigned and looked up via
202 /// AsmPrinter::getMBBExceptionSym.
203 DenseMap<MBBSectionID, MCSymbol *> MBBSectionExceptionSyms;
204
205 // The symbol used to represent the start of the current BB section of the
206 // function. This is used to calculate the size of the BB section.
207 MCSymbol *CurrentSectionBeginSym = nullptr;
208
209 /// This map keeps track of which symbol is being used for the specified basic
210 /// block's address of label.
211 std::unique_ptr<AddrLabelMap> AddrLabelSymbols;
212
213 /// The garbage collection metadata printer table.
215
216 /// Emit comments in assembly output if this is true.
217 bool VerboseAsm;
218
219 /// Store symbols and type identifiers used to create callgraph section
220 /// entries related to a function.
221 struct FunctionCallGraphInfo {
222 /// Numeric type identifier used in callgraph section for indirect calls
223 /// and targets.
224 using CGTypeId = uint64_t;
225
226 /// Unique target type IDs.
227 SmallSetVector<CGTypeId, 4> IndirectCalleeTypeIDs;
228 /// Unique direct callees.
229 SmallSetVector<MCSymbol *, 4> DirectCallees;
230 };
231
232 enum CallGraphSectionFormatVersion : uint8_t {
233 V_0 = 0,
234 };
235
236 /// Output stream for the stack usage file (i.e., .su file).
237 std::unique_ptr<raw_fd_ostream> StackUsageStream;
238
239 /// List of symbols to be inserted into PC sections.
240 MapVector<const MDNode *, SmallVector<const MCSymbol *>> PCSectionsSymbols;
241
242 static char ID;
243
244protected:
246
247 /// For dso_local functions, the current $local alias for the function.
249
250 /// A handle to the EH info emitter (if present).
252
253 // A vector of all Debuginfo emitters we should use. Protected so that
254 // targets can add their own. This vector maintains ownership of the
255 // emitters.
257 size_t NumUserHandlers = 0;
258
260
261private:
262 /// If generated on the fly this own the instance.
263 std::unique_ptr<MachineDominatorTree> OwnedMDT;
264
265 /// If generated on the fly this own the instance.
266 std::unique_ptr<MachineLoopInfo> OwnedMLI;
267
268 /// If the target supports dwarf debug info, this pointer is non-null.
269 DwarfDebug *DD = nullptr;
270
271 /// A handler that supports pseudo probe emission with embedded inline
272 /// context.
273 std::unique_ptr<PseudoProbeHandler> PP;
274
275 /// CFISection type the module needs i.e. either .eh_frame or .debug_frame.
276 CFISection ModuleCFISection = CFISection::None;
277
278 /// The exception model for the current module.
279 ExceptionHandling ModuleExceptionModel = ExceptionHandling::None;
280
281 /// True if the module contains split-stack functions. This is used to
282 /// emit .note.GNU-split-stack section as required by the linker for
283 /// special handling split-stack function calling no-split-stack function.
284 bool HasSplitStack = false;
285
286 /// True if the module contains no-split-stack functions. This is used to emit
287 /// .note.GNU-no-split-stack section when it also contains functions without a
288 /// split stack prologue.
289 bool HasNoSplitStack = false;
290
291 /// True if debugging information is available in this module.
292 bool DbgInfoAvailable = false;
293
294protected:
295 /// The attribute used for a pointer type's DWARF address space. Targets that
296 /// describe address spaces with a target-specific attribute set this in their
297 /// constructor.
298 dwarf::Attribute TypeAddressSpaceAttribute = dwarf::DW_AT_address_class;
299
300 AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer,
301 char &ID = AsmPrinter::ID);
302
303 /// Create the DwarfDebug handler. Targets can override this to provide
304 /// custom debug information handling.
305 virtual DwarfDebug *createDwarfDebug();
306
307public:
311
312 ~AsmPrinter() override;
313
314 DwarfDebug *getDwarfDebug() { return DD; }
315 DwarfDebug *getDwarfDebug() const { return DD; }
316
318 void setDwarfVersion(uint16_t Version);
319
320 bool isDwarf64() const;
321
322 /// Returns 4 for DWARF32 and 8 for DWARF64.
323 unsigned int getDwarfOffsetByteSize() const;
324
325 /// Returns 4 for DWARF32 and 12 for DWARF64.
326 unsigned int getUnitLengthFieldByteSize() const;
327
328 /// Returns information about the byte size of DW_FORM values.
329 dwarf::FormParams getDwarfFormParams() const;
330
331 bool isPositionIndependent() const;
332
333 /// Return true if assembly output should contain comments.
334 bool isVerbose() const { return VerboseAsm; }
335
336 /// Return a unique ID for the current function.
337 unsigned getFunctionNumber() const;
338
339 /// Return symbol for the function pseudo stack if the stack frame is not a
340 /// register based.
341 virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
342
344 MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
345
346 // Return the exception symbol associated with the MBB section containing a
347 // given basic block.
348 MCSymbol *getMBBExceptionSym(const MachineBasicBlock &MBB);
349
350 /// Return the symbol to be used for the specified basic block when its
351 /// address is taken. This cannot be its normal LBB label because the block
352 /// may be accessed outside its containing function.
354 return getAddrLabelSymbolToEmit(BB).front();
355 }
356
357 /// Return the symbol to be used for the specified basic block when its
358 /// address is taken. If other blocks were RAUW'd to this one, we may have
359 /// to emit them as well, return the whole set.
360 ArrayRef<MCSymbol *> getAddrLabelSymbolToEmit(const BasicBlock *BB);
361
362 /// Creates a new symbol to be used for the end of a callsite at the specified
363 /// basic block.
364 MCSymbol *createCallsiteEndSymbol(const MachineBasicBlock &MBB);
365
366 /// If the specified function has had any references to address-taken blocks
367 /// generated, but the block got deleted, return the symbol now so we can
368 /// emit it. This prevents emitting a reference to a symbol that has no
369 /// definition.
370 void takeDeletedSymbolsForFunction(const Function *F,
371 std::vector<MCSymbol *> &Result);
372
373 /// Return information about object file lowering.
374 const TargetLoweringObjectFile &getObjFileLowering() const;
375
376 /// Return information about data layout.
377 const DataLayout &getDataLayout() const;
378
379 /// Return the pointer size in bytes from the target triple.
380 unsigned getPointerSize() const { return PointerSize; }
381
382 /// Return information about subtarget.
383 const MCSubtargetInfo &getSubtargetInfo() const;
384
385 void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
386
387 /// Return the current section we are emitting to.
388 const MCSection *getCurrentSection() const;
389
390 void getNameWithPrefix(SmallVectorImpl<char> &Name,
391 const GlobalValue *GV) const;
392
393 MCSymbol *getSymbol(const GlobalValue *GV) const;
394
395 /// Similar to getSymbol() but preferred for references. On ELF, this uses a
396 /// local symbol if a reference to GV is guaranteed to be resolved to the
397 /// definition in the same module.
398 MCSymbol *getSymbolPreferLocal(const GlobalValue &GV) const;
399
401 return DwarfUsesRelocationsAcrossSections;
402 }
403
405 DwarfUsesRelocationsAcrossSections = Enable;
406 }
407
408 /// Returns a section suffix (hot or unlikely) for the constant if profiles
409 /// are available. Returns empty string otherwise.
410 StringRef getConstantSectionSuffix(const Constant *C) const;
411
412 /// If MI is an indirect call, add expected type IDs to indirect type ids
413 /// list. If MI is a direct call add the callee symbol to direct callsites
414 /// list of FuncCGInfo.
415 void handleCallsiteForCallgraph(
416 FunctionCallGraphInfo &FuncCGInfo,
417 const MachineFunction::CallSiteInfoMap &CallSitesInfoMap,
418 const MachineInstr &MI);
419
420 //===------------------------------------------------------------------===//
421 // XRay instrumentation implementation.
422 //===------------------------------------------------------------------===//
423public:
424 // This describes the kind of sled we're storing in the XRay table.
433
434 // The table will contain these structs that point to the sled, the function
435 // containing the sled, and what kind of sled (and whether they should always
436 // be instrumented). We also use a version identifier that the runtime can use
437 // to decide what to do with the sled, depending on the version of the sled.
443 const class Function *Fn;
445
446 LLVM_ABI void emit(int, MCStreamer *) const;
447 };
448
449 // All the sleds to be emitted.
451
452 // Helper function to record a given XRay sled.
453 void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
454 uint8_t Version = 0);
455
456 /// Emit a table with all XRay instrumentation points.
457 void emitXRayTable();
458
460
461 //===------------------------------------------------------------------===//
462 // MachineFunctionPass Implementation.
463 //===------------------------------------------------------------------===//
464
465 /// Record analysis usage.
466 void getAnalysisUsage(AnalysisUsage &AU) const override;
467
468 /// Set up the AsmPrinter when we are working on a new module. If your pass
469 /// overrides this, it must make sure to explicitly call this implementation.
470 bool doInitialization(Module &M) override;
471
472 /// Shut down the asmprinter. If you override this in your pass, you must make
473 /// sure to call it explicitly.
474 bool doFinalization(Module &M) override;
475
476 /// Emit the specified function out to the OutStreamer.
480 return false;
481 }
482
483 //===------------------------------------------------------------------===//
484 // Coarse grained IR lowering routines.
485 //===------------------------------------------------------------------===//
486
487 /// This should be called when a new MachineFunction is being processed from
488 /// runOnMachineFunction.
489 virtual void SetupMachineFunction(MachineFunction &MF);
490
491 /// This method emits the body and trailer for a function.
492 void emitFunctionBody();
493
494 void emitCFIInstruction(const MachineInstr &MI);
495
496 void emitFrameAlloc(const MachineInstr &MI);
497
498 void emitStackSizeSection(const MachineFunction &MF);
499
500 void emitStackUsage(const MachineFunction &MF);
501
502 void emitBBAddrMapSection(const MachineFunction &MF);
503
504 void emitKCFITrapEntry(const MachineFunction &MF, const MCSymbol *Symbol);
505 virtual void emitKCFITypeId(const MachineFunction &MF);
506
507 void emitCallGraphSection(const MachineFunction &MF,
508 FunctionCallGraphInfo &FuncCGInfo);
509
510 /// Helper to emit a symbol for the prefetch target associated with the given
511 /// BBID and callsite index. The symbol is emitted as a label and its linkage
512 /// is set based on the function's linkage.
513 void emitPrefetchTargetSymbol(const UniqueBBID &BBID, unsigned CallsiteIndex);
514
515 /// Emit prefetch targets that were not mapped to any basic block. These
516 /// targets are emitted at the beginning of the function body.
517 void emitDanglingPrefetchTargets();
518
519 void emitPseudoProbe(const MachineInstr &MI);
520
521 void emitRemarksSection(remarks::RemarkStreamer &RS);
522
523 /// Emits a label as reference for PC sections.
524 void emitPCSectionsLabel(const MachineFunction &MF, const MDNode &MD);
525
526 /// Emits the PC sections collected from instructions.
527 void emitPCSections(const MachineFunction &MF);
528
529 /// Get the CFISection type for a function.
530 CFISection getFunctionCFISectionType(const Function &F) const;
531
532 /// Get the CFISection type for a function.
533 CFISection getFunctionCFISectionType(const MachineFunction &MF) const;
534
535 /// Get the CFISection type for the module.
536 CFISection getModuleCFISectionType() const { return ModuleCFISection; }
537
538 /// Get the exception model resolved for the current module.
540 return ModuleExceptionModel;
541 }
542
543 /// Returns true if valid debug info is present.
544 bool hasDebugInfo() const { return DbgInfoAvailable; }
545
546 virtual bool hasExplicitWinCFIRanges() const { return false; }
547
548 /// Since emitting CFI unwind information is entangled with supporting the
549 /// exceptions, this returns true for platforms which use CFI unwind
550 /// information for other purposes (debugging, sanitizers, ...) when the
551 /// module's exception model is `ExceptionHandling::None`.
552 bool usesCFIWithoutEH() const;
553
554 /// Print to the current output stream assembly representations of the
555 /// constants in the constant pool MCP. This is used to print out constants
556 /// which have been "spilled to memory" by the code generator.
557 virtual void emitConstantPool();
558
559 /// Print assembly representations of the jump tables used by the current
560 /// function to the current output stream.
561 virtual void emitJumpTableInfo();
562
563 /// Emit the specified global variable to the .s file.
564 virtual void emitGlobalVariable(const GlobalVariable *GV);
565
566 /// Emit the specified global variable to the .s file, with an explicit
567 /// alignment granule applied to both address and size.
568 virtual void emitGlobalVariable(const GlobalVariable *GV,
569 MaybeAlign AlignmentGranule);
570
571 /// Check to see if the specified global is a special global used by LLVM. If
572 /// so, emit it and return true, otherwise do nothing and return false.
573 bool emitSpecialLLVMGlobal(const GlobalVariable *GV);
574
575 /// `llvm.global_ctors` and `llvm.global_dtors` are arrays of Structor
576 /// structs.
577 ///
578 /// Priority - init priority
579 /// Func - global initialization or global clean-up function
580 /// ComdatKey - associated data
581 struct Structor {
582 int Priority = 0;
583 Constant *Func = nullptr;
585
586 Structor() = default;
587 };
588
589 /// This method gathers an array of Structors and then sorts them out by
590 /// Priority.
591 /// @param List The initializer of `llvm.global_ctors` or `llvm.global_dtors`
592 /// array.
593 /// @param[out] Structors Sorted Structor structs by Priority.
595 SmallVector<Structor, 8> &Structors);
596
597 /// This method emits `llvm.global_ctors` or `llvm.global_dtors` list.
598 virtual void emitXXStructorList(const DataLayout &DL, const Constant *List,
599 bool IsCtor);
600
601 /// Emit an alignment directive to the specified power of two boundary. If a
602 /// global value is specified, and if that global has an explicit alignment
603 /// requested, it will override the alignment request if required for
604 /// correctness. Returns the effective alignment that was emitted (which may
605 /// exceed \p Alignment when \p GV has a stricter explicit alignment).
606 Align emitAlignment(Align Alignment, const GlobalObject *GV = nullptr,
607 unsigned MaxBytesToEmit = 0) const;
608
609 /// Lower the specified LLVM Constant to an MCExpr.
610 /// When BaseCV is present, we are lowering the element at BaseCV plus Offset.
611 virtual const MCExpr *lowerConstant(const Constant *CV,
612 const Constant *BaseCV = nullptr,
613 uint64_t Offset = 0);
614
615 /// Print a general LLVM constant to the .s file.
616 /// On AIX, when an alias refers to a sub-element of a global variable, the
617 /// label of that alias needs to be emitted before the corresponding element.
619 void emitGlobalConstant(const DataLayout &DL, const Constant *CV,
620 AliasMapTy *AliasList = nullptr);
621
622 /// Unnamed constant global variables solely contaning a pointer to
623 /// another globals variable act like a global variable "proxy", or GOT
624 /// equivalents, i.e., it's only used to hold the address of the latter. One
625 /// optimization is to replace accesses to these proxies by using the GOT
626 /// entry for the final global instead. Hence, we select GOT equivalent
627 /// candidates among all the module global variables, avoid emitting them
628 /// unnecessarily and finally replace references to them by pc relative
629 /// accesses to GOT entries.
631
632 /// Constant expressions using GOT equivalent globals may not be
633 /// eligible for PC relative GOT entry conversion, in such cases we need to
634 /// emit the proxies we previously omitted in EmitGlobalVariable.
635 void emitGlobalGOTEquivs();
636
637 //===------------------------------------------------------------------===//
638 // Overridable Hooks
639 //===------------------------------------------------------------------===//
640
641 void addAsmPrinterHandler(std::unique_ptr<AsmPrinterHandler> Handler);
642
643 // Targets can, or in the case of EmitInstruction, must implement these to
644 // customize output.
645
646 /// This virtual method can be overridden by targets that want to emit
647 /// something at the start of their file.
648 virtual void emitStartOfAsmFile(Module &) {}
649
650 /// This virtual method can be overridden by targets that want to emit
651 /// something at the end of their file.
652 virtual void emitEndOfAsmFile(Module &) {}
653
654 /// Targets can override this to emit stuff before the first basic block in
655 /// the function.
656 virtual void emitFunctionBodyStart() {}
657
658 /// Targets can override this to emit stuff after the last basic block in the
659 /// function.
660 virtual void emitFunctionBodyEnd() {}
661
662 /// Targets can override this to emit stuff at the start of a basic block.
663 /// By default, this method prints the label for the specified
664 /// MachineBasicBlock, an alignment (if present) and a comment describing it
665 /// if appropriate.
666 virtual void emitBasicBlockStart(const MachineBasicBlock &MBB);
667
668 /// Targets can override this to emit stuff at the end of a basic block.
669 virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB);
670
671 /// Targets should implement this to emit instructions.
672 virtual void emitInstruction(const MachineInstr *) {
673 llvm_unreachable("EmitInstruction not implemented");
674 }
675
676 /// Return the symbol for the specified constant pool entry.
677 virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
678
679 virtual void emitFunctionEntryLabel();
680
681 virtual void emitFunctionDescriptor() {
682 llvm_unreachable("Function descriptor is target-specific.");
683 }
684
685 virtual void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
686
687 /// Targets can override this to change how global constants that are part of
688 /// a C++ static/global constructor list are emitted.
689 virtual void emitXXStructor(const DataLayout &DL, const Constant *CV) {
691 }
692
693 virtual const MCExpr *lowerConstantPtrAuth(const ConstantPtrAuth &CPA) {
694 reportFatalUsageError("ptrauth constant lowering not implemented");
695 }
696
697 /// Lower the specified BlockAddress to an MCExpr.
698 virtual const MCExpr *lowerBlockAddressConstant(const BlockAddress &BA);
699
700 /// Return true if the basic block has exactly one predecessor and the control
701 /// transfer mechanism between the predecessor and this block is a
702 /// fall-through.
703 virtual bool
704 isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const;
705
706 /// Targets can override this to customize the output of IMPLICIT_DEF
707 /// instructions in verbose mode.
708 virtual void emitImplicitDef(const MachineInstr *MI) const;
709
710 /// getSubtargetInfo() cannot be used where this is needed because we don't
711 /// have a MachineFunction when we're lowering a GlobalIFunc, and
712 /// getSubtargetInfo requires one. Override the implementation in targets
713 /// that support the Mach-O IFunc lowering.
715 return nullptr;
716 }
717
718 virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,
719 MCSymbol *LazyPointer) {
721 "Mach-O IFunc lowering is not yet supported on this target");
722 }
723
725 MCSymbol *LazyPointer) {
727 "Mach-O IFunc lowering is not yet supported on this target");
728 }
729
730 /// Emit N NOP instructions.
731 void emitNops(unsigned N);
732
733 //===------------------------------------------------------------------===//
734 // Symbol Lowering Routines.
735 //===------------------------------------------------------------------===//
736
737 MCSymbol *createTempSymbol(const Twine &Name) const;
738
739 /// Return the MCSymbol for a private symbol with global value name as its
740 /// base, with the specified suffix.
741 MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
742 StringRef Suffix) const;
743
744 /// Return the MCSymbol for the specified ExternalSymbol.
745 MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const;
746
747 /// Return the symbol for the specified jump table entry.
748 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
749
750 /// Return the symbol for the specified jump table .set
751 /// FIXME: privatize to AsmPrinter.
752 MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
753
754 /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
755 /// basic block.
756 MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
757 MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
758
759 //===------------------------------------------------------------------===//
760 // Emission Helper Routines.
761 //===------------------------------------------------------------------===//
762
763 /// This is just convenient handler for printing offsets.
764 void printOffset(int64_t Offset, raw_ostream &OS) const;
765
766 /// Emit a byte directive and value.
767 void emitInt8(int Value) const;
768
769 /// Emit a short directive and value.
770 void emitInt16(int Value) const;
771
772 /// Emit a long directive and value.
773 void emitInt32(int Value) const;
774
775 /// Emit a long long directive and value.
776 void emitInt64(uint64_t Value) const;
777
778 /// Emit the specified signed leb128 value.
779 void emitSLEB128(int64_t Value, const char *Desc = nullptr) const;
780
781 /// Emit the specified unsigned leb128 value.
782 void emitULEB128(uint64_t Value, const char *Desc = nullptr,
783 unsigned PadTo = 0) const;
784
785 /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
786 /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
787 /// .set if it is available.
788 void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
789 unsigned Size) const;
790
791 /// Emit something like ".uleb128 Hi-Lo".
792 void emitLabelDifferenceAsULEB128(const MCSymbol *Hi,
793 const MCSymbol *Lo) const;
794
795 /// Emit something like ".long Label+Offset" where the size in bytes of the
796 /// directive is specified by Size and Label specifies the label. This
797 /// implicitly uses .set if it is available.
798 void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
799 unsigned Size, bool IsSectionRelative = false) const;
800
801 /// Emit something like ".long Label" where the size in bytes of the directive
802 /// is specified by Size and Label specifies the label.
803 void emitLabelReference(const MCSymbol *Label, unsigned Size,
804 bool IsSectionRelative = false) const {
805 emitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
806 }
807
808 //===------------------------------------------------------------------===//
809 // Dwarf Emission Helper Routines
810 //===------------------------------------------------------------------===//
811
812 /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
813 /// assembly output is enabled, we output comments describing the encoding.
814 /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
815 void emitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
816
817 /// Return the size of the encoding in bytes.
818 unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
819
820 /// Emit reference to a ttype global with a specified encoding.
821 virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding);
822
823 /// Emit a reference to a symbol for use in dwarf. Different object formats
824 /// represent this in different ways. Some use a relocation others encode
825 /// the label offset in its section.
826 void emitDwarfSymbolReference(const MCSymbol *Label,
827 bool ForceOffset = false) const;
828
829 /// Emit the 4- or 8-byte offset of a string from the start of its section.
830 ///
831 /// When possible, emit a DwarfStringPool section offset without any
832 /// relocations, and without using the symbol. Otherwise, defers to \a
833 /// emitDwarfSymbolReference().
834 ///
835 /// The length of the emitted value depends on the DWARF format.
836 void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
837
838 /// Emit the 4-or 8-byte offset of a string from the start of its section.
842
843 /// Emit something like ".long Label + Offset" or ".quad Label + Offset"
844 /// depending on the DWARF format.
845 void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const;
846
847 /// Emit 32- or 64-bit value depending on the DWARF format.
848 void emitDwarfLengthOrOffset(uint64_t Value) const;
849
850 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
851 /// according to the settings.
852 void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const;
853
854 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
855 /// according to the settings.
856 /// Return the end symbol generated inside, the caller needs to emit it.
857 MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
858 const Twine &Comment) const;
859
860 /// Emit reference to a call site with a specified encoding
861 void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
862 unsigned Encoding) const;
863 /// Emit an integer value corresponding to the call site encoding
864 void emitCallSiteValue(uint64_t Value, unsigned Encoding) const;
865
866 /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
867 virtual unsigned getISAEncoding() { return 0; }
868
869 /// Emit the directive and value for debug thread local expression
870 ///
871 /// \p Value - The value to emit.
872 /// \p Size - The size of the integer (in bytes) to emit.
873 virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const;
874
875 //===------------------------------------------------------------------===//
876 // Dwarf Lowering Routines
877 //===------------------------------------------------------------------===//
878
879 /// Emit frame instruction to describe the layout of the frame.
880 void emitCFIInstruction(const MCCFIInstruction &Inst) const;
881
882 /// Emit Dwarf abbreviation table.
883 template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
884 // For each abbreviation.
885 for (const auto &Abbrev : Abbrevs)
886 emitDwarfAbbrev(*Abbrev);
887
888 // Mark end of abbreviations.
889 emitULEB128(0, "EOM(3)");
890 }
891
892 void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
893
894 /// Recursively emit Dwarf DIE tree.
895 void emitDwarfDIE(const DIE &Die) const;
896
897 //===------------------------------------------------------------------===//
898 // CodeView Helper Routines
899 //===------------------------------------------------------------------===//
900
901 /// Gets information required to create a CodeView debug symbol for a jump
902 /// table.
903 /// Return value is <Base Address, Base Offset, Branch Address, Entry Size>
904 virtual std::tuple<const MCSymbol *, uint64_t, const MCSymbol *,
906 getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr,
907 const MCSymbol *BranchLabel) const;
908
909 //===------------------------------------------------------------------===//
910 // COFF Helper Routines
911 //===------------------------------------------------------------------===//
912
913 /// Emits symbols and data to allow functions marked with the
914 /// loader-replaceable attribute to be replaceable.
915 void emitCOFFReplaceableFunctionData(Module &M);
916
917 /// Emits the @feat.00 symbol indicating the features enabled in this module.
918 void emitCOFFFeatureSymbol(Module &M);
919
920 //===------------------------------------------------------------------===//
921 // Inline Asm Support
922 //===------------------------------------------------------------------===//
923
924 // These are hooks that targets can override to implement inline asm
925 // support. These should probably be moved out of AsmPrinter someday.
926
927 /// Print information related to the specified machine instr that is
928 /// independent of the operand, and may be independent of the instr itself.
929 /// This can be useful for portably encoding the comment character or other
930 /// bits of target-specific knowledge into the asmstrings. The syntax used is
931 /// ${:comment}. Targets can override this to add support for their own
932 /// strange codes.
933 virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
934 StringRef Code) const;
935
936 /// Print the MachineOperand as a symbol. Targets with complex handling of
937 /// symbol references should override the base implementation.
938 virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS);
939
940 /// Print the specified operand of MI, an INLINEASM instruction, using the
941 /// specified assembler variant. Targets should override this to format as
942 /// appropriate. This method can return true if the operand is erroneous.
943 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
944 const char *ExtraCode, raw_ostream &OS);
945
946 /// Print the specified operand of MI, an INLINEASM instruction, using the
947 /// specified assembler variant as an address. Targets should override this to
948 /// format as appropriate. This method can return true if the operand is
949 /// erroneous.
950 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
951 const char *ExtraCode, raw_ostream &OS);
952
953 /// Let the target do anything it needs to do before emitting inlineasm.
954 /// \p StartInfo - the subtarget info before parsing inline asm
955 virtual void emitInlineAsmStart() const;
956
957 /// Let the target do anything it needs to do after emitting inlineasm.
958 /// This callback can be used restore the original mode in case the
959 /// inlineasm contains directives to switch modes.
960 /// \p StartInfo - the original subtarget info before inline asm
961 /// \p EndInfo - the final subtarget info after parsing the inline asm,
962 /// or NULL if the value is unknown.
963 virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
964 const MCSubtargetInfo *EndInfo,
965 const MachineInstr *MI);
966
967 /// Emit necessary directives to allow use of instructions that are permitted
968 /// by target features enabled by STI, but are not permitted by target
969 /// features enabled by the global subtarget (TM.getSubTargetInfo()).
970 /// Returns whether anything was emitted.
971 virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI) {
972 return false;
973 }
974
975 /// Emit necessary directives to restore target feature state.
976 /// The \p DidPush argument is the result of the prior emitTargetFeaturePush()
977 /// call.
978 virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush) {}
979
980 /// This emits visibility information about symbol, if this is supported by
981 /// the target.
982 void emitVisibility(MCSymbol *Sym, unsigned Visibility,
983 bool IsDefinition = true) const;
984
985 /// This emits linkage information about \p GVSym based on \p GV, if this is
986 /// supported by the target.
987 virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
988
989 /// Return the alignment for the specified \p GV.
990 static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL,
991 Align InAlign = Align(1));
992
993private:
994 /// Private state for PrintSpecial()
995 // Assign a unique ID to this machine instruction.
996 mutable const MachineInstr *LastMI = nullptr;
997 mutable unsigned LastFn = 0;
998 mutable unsigned Counter = ~0U;
999
1000 bool DwarfUsesRelocationsAcrossSections = false;
1001
1002 /// This method emits the header for the current function.
1003 virtual void emitFunctionHeader();
1004
1005 /// This method emits a comment next to header for the current function.
1006 virtual void emitFunctionHeaderComment();
1007
1008 /// This method emits prefix-like data before the current function.
1009 void emitFunctionPrefix(ArrayRef<const Constant *> Prefix);
1010
1011 /// Emit a blob of inline asm to the output streamer.
1012 virtual void
1013 emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
1014 const MCTargetOptions &MCOptions,
1015 const MDNode *LocMDNode = nullptr,
1017 const MachineInstr *MI = nullptr);
1018
1019 /// This method formats and emits the specified machine instruction that is an
1020 /// inline asm.
1021 void emitInlineAsm(const MachineInstr *MI);
1022
1023 /// Add inline assembly info to the diagnostics machinery, so we can
1024 /// emit file and position info. Returns SrcMgr memory buffer position.
1025 unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
1026 const MDNode *LocMDNode) const;
1027
1028 //===------------------------------------------------------------------===//
1029 // Internal Implementation Details
1030 //===------------------------------------------------------------------===//
1031
1032 virtual void emitJumpTableImpl(const MachineJumpTableInfo &MJTI,
1033 ArrayRef<unsigned> JumpTableIndices);
1034
1035 void emitJumpTableSizesSection(const MachineJumpTableInfo &MJTI,
1036 const Function &F) const;
1037
1038 void emitLLVMUsedList(const ConstantArray *InitList);
1039 /// Emit llvm.ident metadata in an '.ident' directive.
1040 void emitModuleIdents(Module &M);
1041 /// Emit bytes for llvm.commandline metadata.
1042 virtual void emitModuleCommandLines(Module &M);
1043
1044 GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S);
1045 virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI);
1046
1047 /// This method decides whether the specified basic block requires a label.
1048 bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
1049
1050protected:
1051 virtual void emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
1052 const MachineBasicBlock *MBB,
1053 unsigned uid) const;
1054 virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA);
1056 return false;
1057 }
1058
1059 /// Returns a optional minimum alignment that applies to both the address and
1060 /// the allocation size of the global. This is used for systems like CHERI and
1061 /// MTE that impose a minimum alignment, and require globals to be padded to
1062 /// that alignment.
1063 virtual MaybeAlign
1065 return std::nullopt;
1066 };
1067};
1068
1070 AsmPrinter &AsmPrinter);
1071
1072LLVM_ABI void
1074 MachineFunction &MF, AsmPrinter &AsmPrinter);
1075
1076} // end namespace llvm
1077
1078#endif // LLVM_CODEGEN_ASMPRINTER_H
uint64_t uint64_t
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static unsigned getDwarfVersion(const MachineFunction &MF)
Resolve the DWARF version the way DwarfDebug does.
Definition Analysis.cpp:598
#define LLVM_ABI
Definition Compiler.h:211
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
IRTranslator LLVM IR MI
static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)
Definition MCDwarf.cpp:1420
#define F(x, y, z)
Definition MD5.cpp:54
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
static void emitInlineAsm(LLVMContext &C, BasicBlock *BB, StringRef AsmText)
#define T
ModuleAnalysisManager MAM
static SDValue lowerConstant(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget)
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
std::unique_ptr< MCStreamer > && Streamer
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Collects and handles AsmPrinter objects required to build debug or EH information.
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:94
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition AsmPrinter.h:672
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
SmallVector< XRayFunctionEntry, 4 > Sleds
Definition AsmPrinter.h:450
MapVector< MBBSectionID, MBBSectionRange > MBBSectionRanges
Definition AsmPrinter.h:164
CFISection getModuleCFISectionType() const
Get the CFISection type for the module.
Definition AsmPrinter.h:536
MCSymbol * CurrentFnBegin
Definition AsmPrinter.h:245
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Definition AsmPrinter.h:124
DwarfDebug * getDwarfDebug()
Definition AsmPrinter.h:314
std::function< MachineOptimizationRemarkEmitter *(MachineFunction &)> GetORE
Definition AsmPrinter.h:183
virtual const MCExpr * lowerConstantPtrAuth(const ConstantPtrAuth &CPA)
Definition AsmPrinter.h:693
dwarf::Attribute getTypeAddressSpaceAttribute() const
Definition AsmPrinter.h:308
dwarf::Attribute TypeAddressSpaceAttribute
The attribute used for a pointer type's DWARF address space.
Definition AsmPrinter.h:298
void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
unsigned getPointerSize() const
Return the pointer size in bytes from the target triple.
Definition AsmPrinter.h:380
virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI)
Emit necessary directives to allow use of instructions that are permitted by target features enabled ...
Definition AsmPrinter.h:971
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:97
void emitXRayTable()
Emit a table with all XRay instrumentation points.
DenseMap< const MachineBasicBlock *, SmallVector< MCSymbol *, 1 > > CurrentFnCallsiteEndSymbols
Vector of symbols marking the end of the callsites in the current function, keyed by their containing...
Definition AsmPrinter.h:150
Align emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
DwarfDebug * getDwarfDebug() const
Definition AsmPrinter.h:315
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
Definition AsmPrinter.h:138
MCSymbol * CurrentFnBeginLocal
For dso_local functions, the current $local alias for the function.
Definition AsmPrinter.h:248
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
Definition AsmPrinter.h:169
void emitDwarfStringOffset(DwarfStringPoolEntry S) const
Emit the 4- or 8-byte offset of a string from the start of its section.
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
MCSymbol * getFunctionBegin() const
Definition AsmPrinter.h:343
virtual void emitMachOIFuncStubHelperBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition AsmPrinter.h:724
std::function< void(Module &)> EmitStackMaps
Definition AsmPrinter.h:194
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
Definition AsmPrinter.h:353
virtual DwarfDebug * createDwarfDebug()
Create the DwarfDebug handler.
std::function< BasicBlockSectionsProfileReader *(MachineFunction &)> GetBBSPR
Returns the basic block sections profile reader if available, nullptr otherwise.
Definition AsmPrinter.h:191
SmallVector< std::unique_ptr< AsmPrinterHandler >, 2 > Handlers
Definition AsmPrinter.h:256
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:112
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
void emitFunctionBody()
This method emits the body and trailer for a function.
MachineDominatorTree * MDT
This is a pointer to the current MachineDominatorTree.
Definition AsmPrinter.h:121
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Definition AsmPrinter.h:648
unsigned PointerSize
The pointer size in bytes for the default address space.
Definition AsmPrinter.h:118
std::function< void(Module &)> FinishGCAssembly
Definition AsmPrinter.h:193
bool hasDebugInfo() const
Returns true if valid debug info is present.
Definition AsmPrinter.h:544
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition AsmPrinter.h:656
ExceptionHandling getModuleExceptionModel() const
Get the exception model resolved for the current module.
Definition AsmPrinter.h:539
std::function< MachineDominatorTree *(MachineFunction &)> GetMDT
Definition AsmPrinter.h:184
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
Definition AsmPrinter.h:168
void emitPatchableFunctionEntries()
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
virtual void emitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
Definition AsmPrinter.h:652
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition AsmPrinter.h:718
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
Definition AsmPrinter.h:127
DenseMap< uint64_t, SmallVector< const GlobalAlias *, 1 > > AliasMapTy
Print a general LLVM constant to the .s file.
Definition AsmPrinter.h:618
virtual bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const
std::function< MachineBlockHashInfoResult *(MachineFunction &)> GetMBHI
Definition AsmPrinter.h:188
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
void emitGlobalConstant(const DataLayout &DL, const Constant *CV, AliasMapTy *AliasList=nullptr)
EmitGlobalConstant - Print a general LLVM constant to the .s file.
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
Definition AsmPrinter.h:341
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
Definition AsmPrinter.h:839
std::function< void(Module &)> BeginGCAssembly
Definition AsmPrinter.h:192
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition AsmPrinter.h:134
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition AsmPrinter.h:115
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
Definition AsmPrinter.h:883
std::function< MachineBlockFrequencyInfo *(MachineFunction &)> GetMBFI
Definition AsmPrinter.h:187
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition AsmPrinter.h:104
const StaticDataProfileInfo * SDPI
Provides the profile information for constants.
Definition AsmPrinter.h:153
bool doFinalization(Module &M) override
Shut down the asmprinter.
virtual const MCSubtargetInfo * getIFuncMCSubtargetInfo() const
getSubtargetInfo() cannot be used where this is needed because we don't have a MachineFunction when w...
Definition AsmPrinter.h:714
virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush)
Emit necessary directives to restore target feature state.
Definition AsmPrinter.h:978
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
Definition AsmPrinter.h:130
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition AsmPrinter.h:477
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
void setDwarfUsesRelocationsAcrossSections(bool Enable)
Definition AsmPrinter.h:404
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:109
const ProfileSummaryInfo * PSI
The profile summary information.
Definition AsmPrinter.h:156
const MCAsmInfo & MAI
Target Asm Printer information.
Definition AsmPrinter.h:100
std::function< void()> AssertDebugEHFinalized
Definition AsmPrinter.h:195
void emitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
Definition AsmPrinter.h:803
virtual void emitFunctionDescriptor()
Definition AsmPrinter.h:681
size_t NumUserHandlers
Definition AsmPrinter.h:257
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
Definition AsmPrinter.h:143
std::function< MachineLoopInfo *(MachineFunction &)> GetMLI
Definition AsmPrinter.h:185
std::function< MachineModuleInfo *()> GetMMI
Definition AsmPrinter.h:182
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition AsmPrinter.h:867
bool isVerbose() const
Return true if assembly output should contain comments.
Definition AsmPrinter.h:334
MCSymbol * getFunctionEnd() const
Definition AsmPrinter.h:344
virtual void emitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
Definition AsmPrinter.h:689
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
SmallVector< std::unique_ptr< AsmPrinterHandler >, 1 > EHHandlers
A handle to the EH info emitter (if present).
Definition AsmPrinter.h:251
virtual MaybeAlign getRequiredGlobalAlignmentGranule(const GlobalVariable &GV)
Returns a optional minimum alignment that applies to both the address and the allocation size of the ...
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
Definition AsmPrinter.h:660
bool doesDwarfUseRelocationsAcrossSections() const
Definition AsmPrinter.h:400
@ None
Do not emit either .eh_frame or .debug_frame.
Definition AsmPrinter.h:173
@ Debug
Emit .debug_frame.
Definition AsmPrinter.h:175
std::function< MachineBranchProbabilityInfo *(MachineFunction &)> GetMBPI
Definition AsmPrinter.h:186
void addAsmPrinterHandler(std::unique_ptr< AsmPrinterHandler > Handler)
virtual bool hasExplicitWinCFIRanges() const
Definition AsmPrinter.h:546
LLVM Basic Block Representation.
Definition BasicBlock.h:62
The address of a basic block.
Definition Constants.h:1088
ConstantArray - Constant Array Declarations.
Definition Constants.h:590
A signed pointer, in the ptrauth sense.
Definition Constants.h:1223
This is an important base class in LLVM.
Definition Constant.h:44
Dwarf abbreviation, describes the organization of a debug information object.
Definition DIE.h:80
A structured debug information entry.
Definition DIE.h:835
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Base class for debug information backends.
Collects and handles dwarf debug information.
Definition DwarfDebug.h:352
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
const DwarfStringPoolEntry & getEntry() const
GCMetadataPrinter - Emits GC metadata as assembly code.
GCStrategy describes a garbage collector algorithm's code generation requirements,...
Definition GCStrategy.h:64
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
Context object for machine code objects.
Definition MCContext.h:84
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Metadata node.
Definition Metadata.h:1087
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
Result object for MachineBlockHashInfo.
Abstract base class for all machine specific constantpool value subclasses.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
DenseMap< const MachineInstr *, CallSiteInfo > CallSiteInfoMap
Representation of each machine instruction.
This class contains meta information specific to a module.
MachineOperand class - Representation of each machine instruction operand.
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:39
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Analysis providing profile information.
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:346
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A class that holds the constants that represent static data and their profile information and provide...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Attribute
Attributes.
Definition Dwarf.h:125
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Length
Definition DWP.cpp:577
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
Op::Description Desc
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
ExceptionHandling
Definition CodeGen.h:54
@ None
No exception support.
Definition CodeGen.h:56
LLVM_ABI void setupMachineFunctionAsmPrinter(MachineFunctionAnalysisManager &MFAM, MachineFunction &MF, AsmPrinter &AsmPrinter)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
@ Enable
Enable colors.
Definition WithColor.h:47
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Map a basic block section ID to the begin and end symbols of that section which determine the section...
Definition AsmPrinter.h:160
LLVM_ABI void emit(int, MCStreamer *) const
Data for a string pool entry.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:111
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1221