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