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