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 /// The attribute used for a pointer type's DWARF address space. Targets that
294 /// describe address spaces with a target-specific attribute set this in their
295 /// constructor.
296 dwarf::Attribute TypeAddressSpaceAttribute = dwarf::DW_AT_address_class;
297
298 AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer,
299 char &ID = AsmPrinter::ID);
300
301 /// Create the DwarfDebug handler. Targets can override this to provide
302 /// custom debug information handling.
303 virtual DwarfDebug *createDwarfDebug();
304
305public:
309
310 ~AsmPrinter() override;
311
312 DwarfDebug *getDwarfDebug() { return DD; }
313 DwarfDebug *getDwarfDebug() const { return DD; }
314
316 void setDwarfVersion(uint16_t Version);
317
318 bool isDwarf64() const;
319
320 /// Returns 4 for DWARF32 and 8 for DWARF64.
321 unsigned int getDwarfOffsetByteSize() const;
322
323 /// Returns 4 for DWARF32 and 12 for DWARF64.
324 unsigned int getUnitLengthFieldByteSize() const;
325
326 /// Returns information about the byte size of DW_FORM values.
327 dwarf::FormParams getDwarfFormParams() const;
328
329 bool isPositionIndependent() const;
330
331 /// Return true if assembly output should contain comments.
332 bool isVerbose() const { return VerboseAsm; }
333
334 /// Return a unique ID for the current function.
335 unsigned getFunctionNumber() const;
336
337 /// Return symbol for the function pseudo stack if the stack frame is not a
338 /// register based.
339 virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
340
342 MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
343
344 // Return the exception symbol associated with the MBB section containing a
345 // given basic block.
346 MCSymbol *getMBBExceptionSym(const MachineBasicBlock &MBB);
347
348 /// Return the symbol to be used for the specified basic block when its
349 /// address is taken. This cannot be its normal LBB label because the block
350 /// may be accessed outside its containing function.
352 return getAddrLabelSymbolToEmit(BB).front();
353 }
354
355 /// Return the symbol to be used for the specified basic block when its
356 /// address is taken. If other blocks were RAUW'd to this one, we may have
357 /// to emit them as well, return the whole set.
358 ArrayRef<MCSymbol *> getAddrLabelSymbolToEmit(const BasicBlock *BB);
359
360 /// Creates a new symbol to be used for the end of a callsite at the specified
361 /// basic block.
362 MCSymbol *createCallsiteEndSymbol(const MachineBasicBlock &MBB);
363
364 /// If the specified function has had any references to address-taken blocks
365 /// generated, but the block got deleted, return the symbol now so we can
366 /// emit it. This prevents emitting a reference to a symbol that has no
367 /// definition.
368 void takeDeletedSymbolsForFunction(const Function *F,
369 std::vector<MCSymbol *> &Result);
370
371 /// Return information about object file lowering.
372 const TargetLoweringObjectFile &getObjFileLowering() const;
373
374 /// Return information about data layout.
375 const DataLayout &getDataLayout() const;
376
377 /// Return the pointer size in bytes from the target triple.
378 unsigned getPointerSize() const { return PointerSize; }
379
380 /// Return information about subtarget.
381 const MCSubtargetInfo &getSubtargetInfo() const;
382
383 void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
384
385 /// Return the current section we are emitting to.
386 const MCSection *getCurrentSection() const;
387
388 void getNameWithPrefix(SmallVectorImpl<char> &Name,
389 const GlobalValue *GV) const;
390
391 MCSymbol *getSymbol(const GlobalValue *GV) const;
392
393 /// Similar to getSymbol() but preferred for references. On ELF, this uses a
394 /// local symbol if a reference to GV is guaranteed to be resolved to the
395 /// definition in the same module.
396 MCSymbol *getSymbolPreferLocal(const GlobalValue &GV) const;
397
399 return DwarfUsesRelocationsAcrossSections;
400 }
401
403 DwarfUsesRelocationsAcrossSections = Enable;
404 }
405
406 /// Returns a section suffix (hot or unlikely) for the constant if profiles
407 /// are available. Returns empty string otherwise.
408 StringRef getConstantSectionSuffix(const Constant *C) const;
409
410 /// If MI is an indirect call, add expected type IDs to indirect type ids
411 /// list. If MI is a direct call add the callee symbol to direct callsites
412 /// list of FuncCGInfo.
413 void handleCallsiteForCallgraph(
414 FunctionCallGraphInfo &FuncCGInfo,
415 const MachineFunction::CallSiteInfoMap &CallSitesInfoMap,
416 const MachineInstr &MI);
417
418 //===------------------------------------------------------------------===//
419 // XRay instrumentation implementation.
420 //===------------------------------------------------------------------===//
421public:
422 // This describes the kind of sled we're storing in the XRay table.
431
432 // The table will contain these structs that point to the sled, the function
433 // containing the sled, and what kind of sled (and whether they should always
434 // be instrumented). We also use a version identifier that the runtime can use
435 // to decide what to do with the sled, depending on the version of the sled.
441 const class Function *Fn;
443
444 LLVM_ABI void emit(int, MCStreamer *) const;
445 };
446
447 // All the sleds to be emitted.
449
450 // Helper function to record a given XRay sled.
451 void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
452 uint8_t Version = 0);
453
454 /// Emit a table with all XRay instrumentation points.
455 void emitXRayTable();
456
458
459 //===------------------------------------------------------------------===//
460 // MachineFunctionPass Implementation.
461 //===------------------------------------------------------------------===//
462
463 /// Record analysis usage.
464 void getAnalysisUsage(AnalysisUsage &AU) const override;
465
466 /// Set up the AsmPrinter when we are working on a new module. If your pass
467 /// overrides this, it must make sure to explicitly call this implementation.
468 bool doInitialization(Module &M) override;
469
470 /// Shut down the asmprinter. If you override this in your pass, you must make
471 /// sure to call it explicitly.
472 bool doFinalization(Module &M) override;
473
474 /// Emit the specified function out to the OutStreamer.
478 return false;
479 }
480
481 //===------------------------------------------------------------------===//
482 // Coarse grained IR lowering routines.
483 //===------------------------------------------------------------------===//
484
485 /// This should be called when a new MachineFunction is being processed from
486 /// runOnMachineFunction.
487 virtual void SetupMachineFunction(MachineFunction &MF);
488
489 /// This method emits the body and trailer for a function.
490 void emitFunctionBody();
491
492 void emitCFIInstruction(const MachineInstr &MI);
493
494 void emitFrameAlloc(const MachineInstr &MI);
495
496 void emitStackSizeSection(const MachineFunction &MF);
497
498 void emitStackUsage(const MachineFunction &MF);
499
500 void emitBBAddrMapSection(const MachineFunction &MF);
501
502 void emitKCFITrapEntry(const MachineFunction &MF, const MCSymbol *Symbol);
503 virtual void emitKCFITypeId(const MachineFunction &MF);
504
505 void emitCallGraphSection(const MachineFunction &MF,
506 FunctionCallGraphInfo &FuncCGInfo);
507
508 /// Helper to emit a symbol for the prefetch target associated with the given
509 /// BBID and callsite index. The symbol is emitted as a label and its linkage
510 /// is set based on the function's linkage.
511 void emitPrefetchTargetSymbol(const UniqueBBID &BBID, unsigned CallsiteIndex);
512
513 /// Emit prefetch targets that were not mapped to any basic block. These
514 /// targets are emitted at the beginning of the function body.
515 void emitDanglingPrefetchTargets();
516
517 void emitPseudoProbe(const MachineInstr &MI);
518
519 void emitRemarksSection(remarks::RemarkStreamer &RS);
520
521 /// Emits a label as reference for PC sections.
522 void emitPCSectionsLabel(const MachineFunction &MF, const MDNode &MD);
523
524 /// Emits the PC sections collected from instructions.
525 void emitPCSections(const MachineFunction &MF);
526
527 /// Get the CFISection type for a function.
528 CFISection getFunctionCFISectionType(const Function &F) const;
529
530 /// Get the CFISection type for a function.
531 CFISection getFunctionCFISectionType(const MachineFunction &MF) const;
532
533 /// Get the CFISection type for the module.
534 CFISection getModuleCFISectionType() const { return ModuleCFISection; }
535
536 /// Returns true if valid debug info is present.
537 bool hasDebugInfo() const { return DbgInfoAvailable; }
538
539 /// Since emitting CFI unwind information is entangled with supporting the
540 /// exceptions, this returns true for platforms which use CFI unwind
541 /// information for other purposes (debugging, sanitizers, ...) when
542 /// `MCAsmInfo::ExceptionsType == ExceptionHandling::None`.
543 bool usesCFIWithoutEH() const;
544
545 /// Print to the current output stream assembly representations of the
546 /// constants in the constant pool MCP. This is used to print out constants
547 /// which have been "spilled to memory" by the code generator.
548 virtual void emitConstantPool();
549
550 /// Print assembly representations of the jump tables used by the current
551 /// function to the current output stream.
552 virtual void emitJumpTableInfo();
553
554 /// Emit the specified global variable to the .s file.
555 virtual void emitGlobalVariable(const GlobalVariable *GV);
556
557 /// Emit the specified global variable to the .s file, with an explicit
558 /// alignment granule applied to both address and size.
559 virtual void emitGlobalVariable(const GlobalVariable *GV,
560 MaybeAlign AlignmentGranule);
561
562 /// Check to see if the specified global is a special global used by LLVM. If
563 /// so, emit it and return true, otherwise do nothing and return false.
564 bool emitSpecialLLVMGlobal(const GlobalVariable *GV);
565
566 /// `llvm.global_ctors` and `llvm.global_dtors` are arrays of Structor
567 /// structs.
568 ///
569 /// Priority - init priority
570 /// Func - global initialization or global clean-up function
571 /// ComdatKey - associated data
572 struct Structor {
573 int Priority = 0;
574 Constant *Func = nullptr;
576
577 Structor() = default;
578 };
579
580 /// This method gathers an array of Structors and then sorts them out by
581 /// Priority.
582 /// @param List The initializer of `llvm.global_ctors` or `llvm.global_dtors`
583 /// array.
584 /// @param[out] Structors Sorted Structor structs by Priority.
586 SmallVector<Structor, 8> &Structors);
587
588 /// This method emits `llvm.global_ctors` or `llvm.global_dtors` list.
589 virtual void emitXXStructorList(const DataLayout &DL, const Constant *List,
590 bool IsCtor);
591
592 /// Emit an alignment directive to the specified power of two boundary. If a
593 /// global value is specified, and if that global has an explicit alignment
594 /// requested, it will override the alignment request if required for
595 /// correctness. Returns the effective alignment that was emitted (which may
596 /// exceed \p Alignment when \p GV has a stricter explicit alignment).
597 Align emitAlignment(Align Alignment, const GlobalObject *GV = nullptr,
598 unsigned MaxBytesToEmit = 0) const;
599
600 /// Lower the specified LLVM Constant to an MCExpr.
601 /// When BaseCV is present, we are lowering the element at BaseCV plus Offset.
602 virtual const MCExpr *lowerConstant(const Constant *CV,
603 const Constant *BaseCV = nullptr,
604 uint64_t Offset = 0);
605
606 /// Print a general LLVM constant to the .s file.
607 /// On AIX, when an alias refers to a sub-element of a global variable, the
608 /// label of that alias needs to be emitted before the corresponding element.
610 void emitGlobalConstant(const DataLayout &DL, const Constant *CV,
611 AliasMapTy *AliasList = nullptr);
612
613 /// Unnamed constant global variables solely contaning a pointer to
614 /// another globals variable act like a global variable "proxy", or GOT
615 /// equivalents, i.e., it's only used to hold the address of the latter. One
616 /// optimization is to replace accesses to these proxies by using the GOT
617 /// entry for the final global instead. Hence, we select GOT equivalent
618 /// candidates among all the module global variables, avoid emitting them
619 /// unnecessarily and finally replace references to them by pc relative
620 /// accesses to GOT entries.
622
623 /// Constant expressions using GOT equivalent globals may not be
624 /// eligible for PC relative GOT entry conversion, in such cases we need to
625 /// emit the proxies we previously omitted in EmitGlobalVariable.
626 void emitGlobalGOTEquivs();
627
628 //===------------------------------------------------------------------===//
629 // Overridable Hooks
630 //===------------------------------------------------------------------===//
631
632 void addAsmPrinterHandler(std::unique_ptr<AsmPrinterHandler> Handler);
633
634 // Targets can, or in the case of EmitInstruction, must implement these to
635 // customize output.
636
637 /// This virtual method can be overridden by targets that want to emit
638 /// something at the start of their file.
639 virtual void emitStartOfAsmFile(Module &) {}
640
641 /// This virtual method can be overridden by targets that want to emit
642 /// something at the end of their file.
643 virtual void emitEndOfAsmFile(Module &) {}
644
645 /// Targets can override this to emit stuff before the first basic block in
646 /// the function.
647 virtual void emitFunctionBodyStart() {}
648
649 /// Targets can override this to emit stuff after the last basic block in the
650 /// function.
651 virtual void emitFunctionBodyEnd() {}
652
653 /// Targets can override this to emit stuff at the start of a basic block.
654 /// By default, this method prints the label for the specified
655 /// MachineBasicBlock, an alignment (if present) and a comment describing it
656 /// if appropriate.
657 virtual void emitBasicBlockStart(const MachineBasicBlock &MBB);
658
659 /// Targets can override this to emit stuff at the end of a basic block.
660 virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB);
661
662 /// Targets should implement this to emit instructions.
663 virtual void emitInstruction(const MachineInstr *) {
664 llvm_unreachable("EmitInstruction not implemented");
665 }
666
667 /// Return the symbol for the specified constant pool entry.
668 virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
669
670 virtual void emitFunctionEntryLabel();
671
672 virtual void emitFunctionDescriptor() {
673 llvm_unreachable("Function descriptor is target-specific.");
674 }
675
676 virtual void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
677
678 /// Targets can override this to change how global constants that are part of
679 /// a C++ static/global constructor list are emitted.
680 virtual void emitXXStructor(const DataLayout &DL, const Constant *CV) {
682 }
683
684 virtual const MCExpr *lowerConstantPtrAuth(const ConstantPtrAuth &CPA) {
685 reportFatalUsageError("ptrauth constant lowering not implemented");
686 }
687
688 /// Lower the specified BlockAddress to an MCExpr.
689 virtual const MCExpr *lowerBlockAddressConstant(const BlockAddress &BA);
690
691 /// Return true if the basic block has exactly one predecessor and the control
692 /// transfer mechanism between the predecessor and this block is a
693 /// fall-through.
694 virtual bool
695 isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const;
696
697 /// Targets can override this to customize the output of IMPLICIT_DEF
698 /// instructions in verbose mode.
699 virtual void emitImplicitDef(const MachineInstr *MI) const;
700
701 /// getSubtargetInfo() cannot be used where this is needed because we don't
702 /// have a MachineFunction when we're lowering a GlobalIFunc, and
703 /// getSubtargetInfo requires one. Override the implementation in targets
704 /// that support the Mach-O IFunc lowering.
706 return nullptr;
707 }
708
709 virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,
710 MCSymbol *LazyPointer) {
712 "Mach-O IFunc lowering is not yet supported on this target");
713 }
714
716 MCSymbol *LazyPointer) {
718 "Mach-O IFunc lowering is not yet supported on this target");
719 }
720
721 /// Emit N NOP instructions.
722 void emitNops(unsigned N);
723
724 //===------------------------------------------------------------------===//
725 // Symbol Lowering Routines.
726 //===------------------------------------------------------------------===//
727
728 MCSymbol *createTempSymbol(const Twine &Name) const;
729
730 /// Return the MCSymbol for a private symbol with global value name as its
731 /// base, with the specified suffix.
732 MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
733 StringRef Suffix) const;
734
735 /// Return the MCSymbol for the specified ExternalSymbol.
736 MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const;
737
738 /// Return the symbol for the specified jump table entry.
739 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
740
741 /// Return the symbol for the specified jump table .set
742 /// FIXME: privatize to AsmPrinter.
743 MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
744
745 /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
746 /// basic block.
747 MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
748 MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
749
750 //===------------------------------------------------------------------===//
751 // Emission Helper Routines.
752 //===------------------------------------------------------------------===//
753
754 /// This is just convenient handler for printing offsets.
755 void printOffset(int64_t Offset, raw_ostream &OS) const;
756
757 /// Emit a byte directive and value.
758 void emitInt8(int Value) const;
759
760 /// Emit a short directive and value.
761 void emitInt16(int Value) const;
762
763 /// Emit a long directive and value.
764 void emitInt32(int Value) const;
765
766 /// Emit a long long directive and value.
767 void emitInt64(uint64_t Value) const;
768
769 /// Emit the specified signed leb128 value.
770 void emitSLEB128(int64_t Value, const char *Desc = nullptr) const;
771
772 /// Emit the specified unsigned leb128 value.
773 void emitULEB128(uint64_t Value, const char *Desc = nullptr,
774 unsigned PadTo = 0) const;
775
776 /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
777 /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
778 /// .set if it is available.
779 void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
780 unsigned Size) const;
781
782 /// Emit something like ".uleb128 Hi-Lo".
783 void emitLabelDifferenceAsULEB128(const MCSymbol *Hi,
784 const MCSymbol *Lo) const;
785
786 /// Emit something like ".long Label+Offset" where the size in bytes of the
787 /// directive is specified by Size and Label specifies the label. This
788 /// implicitly uses .set if it is available.
789 void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
790 unsigned Size, bool IsSectionRelative = false) const;
791
792 /// Emit something like ".long Label" where the size in bytes of the directive
793 /// is specified by Size and Label specifies the label.
794 void emitLabelReference(const MCSymbol *Label, unsigned Size,
795 bool IsSectionRelative = false) const {
796 emitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
797 }
798
799 //===------------------------------------------------------------------===//
800 // Dwarf Emission Helper Routines
801 //===------------------------------------------------------------------===//
802
803 /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
804 /// assembly output is enabled, we output comments describing the encoding.
805 /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
806 void emitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
807
808 /// Return the size of the encoding in bytes.
809 unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
810
811 /// Emit reference to a ttype global with a specified encoding.
812 virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding);
813
814 /// Emit a reference to a symbol for use in dwarf. Different object formats
815 /// represent this in different ways. Some use a relocation others encode
816 /// the label offset in its section.
817 void emitDwarfSymbolReference(const MCSymbol *Label,
818 bool ForceOffset = false) const;
819
820 /// Emit the 4- or 8-byte offset of a string from the start of its section.
821 ///
822 /// When possible, emit a DwarfStringPool section offset without any
823 /// relocations, and without using the symbol. Otherwise, defers to \a
824 /// emitDwarfSymbolReference().
825 ///
826 /// The length of the emitted value depends on the DWARF format.
827 void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
828
829 /// Emit the 4-or 8-byte offset of a string from the start of its section.
833
834 /// Emit something like ".long Label + Offset" or ".quad Label + Offset"
835 /// depending on the DWARF format.
836 void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const;
837
838 /// Emit 32- or 64-bit value depending on the DWARF format.
839 void emitDwarfLengthOrOffset(uint64_t Value) const;
840
841 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
842 /// according to the settings.
843 void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const;
844
845 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
846 /// according to the settings.
847 /// Return the end symbol generated inside, the caller needs to emit it.
848 MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
849 const Twine &Comment) const;
850
851 /// Emit reference to a call site with a specified encoding
852 void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
853 unsigned Encoding) const;
854 /// Emit an integer value corresponding to the call site encoding
855 void emitCallSiteValue(uint64_t Value, unsigned Encoding) const;
856
857 /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
858 virtual unsigned getISAEncoding() { return 0; }
859
860 /// Emit the directive and value for debug thread local expression
861 ///
862 /// \p Value - The value to emit.
863 /// \p Size - The size of the integer (in bytes) to emit.
864 virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const;
865
866 //===------------------------------------------------------------------===//
867 // Dwarf Lowering Routines
868 //===------------------------------------------------------------------===//
869
870 /// Emit frame instruction to describe the layout of the frame.
871 void emitCFIInstruction(const MCCFIInstruction &Inst) const;
872
873 /// Emit Dwarf abbreviation table.
874 template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
875 // For each abbreviation.
876 for (const auto &Abbrev : Abbrevs)
877 emitDwarfAbbrev(*Abbrev);
878
879 // Mark end of abbreviations.
880 emitULEB128(0, "EOM(3)");
881 }
882
883 void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
884
885 /// Recursively emit Dwarf DIE tree.
886 void emitDwarfDIE(const DIE &Die) const;
887
888 //===------------------------------------------------------------------===//
889 // CodeView Helper Routines
890 //===------------------------------------------------------------------===//
891
892 /// Gets information required to create a CodeView debug symbol for a jump
893 /// table.
894 /// Return value is <Base Address, Base Offset, Branch Address, Entry Size>
895 virtual std::tuple<const MCSymbol *, uint64_t, const MCSymbol *,
897 getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr,
898 const MCSymbol *BranchLabel) const;
899
900 //===------------------------------------------------------------------===//
901 // COFF Helper Routines
902 //===------------------------------------------------------------------===//
903
904 /// Emits symbols and data to allow functions marked with the
905 /// loader-replaceable attribute to be replaceable.
906 void emitCOFFReplaceableFunctionData(Module &M);
907
908 /// Emits the @feat.00 symbol indicating the features enabled in this module.
909 void emitCOFFFeatureSymbol(Module &M);
910
911 //===------------------------------------------------------------------===//
912 // Inline Asm Support
913 //===------------------------------------------------------------------===//
914
915 // These are hooks that targets can override to implement inline asm
916 // support. These should probably be moved out of AsmPrinter someday.
917
918 /// Print information related to the specified machine instr that is
919 /// independent of the operand, and may be independent of the instr itself.
920 /// This can be useful for portably encoding the comment character or other
921 /// bits of target-specific knowledge into the asmstrings. The syntax used is
922 /// ${:comment}. Targets can override this to add support for their own
923 /// strange codes.
924 virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
925 StringRef Code) const;
926
927 /// Print the MachineOperand as a symbol. Targets with complex handling of
928 /// symbol references should override the base implementation.
929 virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS);
930
931 /// Print the specified operand of MI, an INLINEASM instruction, using the
932 /// specified assembler variant. Targets should override this to format as
933 /// appropriate. This method can return true if the operand is erroneous.
934 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
935 const char *ExtraCode, raw_ostream &OS);
936
937 /// Print the specified operand of MI, an INLINEASM instruction, using the
938 /// specified assembler variant as an address. Targets should override this to
939 /// format as appropriate. This method can return true if the operand is
940 /// erroneous.
941 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
942 const char *ExtraCode, raw_ostream &OS);
943
944 /// Let the target do anything it needs to do before emitting inlineasm.
945 /// \p StartInfo - the subtarget info before parsing inline asm
946 virtual void emitInlineAsmStart() const;
947
948 /// Let the target do anything it needs to do after emitting inlineasm.
949 /// This callback can be used restore the original mode in case the
950 /// inlineasm contains directives to switch modes.
951 /// \p StartInfo - the original subtarget info before inline asm
952 /// \p EndInfo - the final subtarget info after parsing the inline asm,
953 /// or NULL if the value is unknown.
954 virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
955 const MCSubtargetInfo *EndInfo,
956 const MachineInstr *MI);
957
958 /// Emit necessary directives to allow use of instructions that are permitted
959 /// by target features enabled by STI, but are not permitted by target
960 /// features enabled by the global subtarget (TM.getSubTargetInfo()).
961 /// Returns whether anything was emitted.
962 virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI) {
963 return false;
964 }
965
966 /// Emit necessary directives to restore target feature state.
967 /// The \p DidPush argument is the result of the prior emitTargetFeaturePush()
968 /// call.
969 virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush) {}
970
971 /// This emits visibility information about symbol, if this is supported by
972 /// the target.
973 void emitVisibility(MCSymbol *Sym, unsigned Visibility,
974 bool IsDefinition = true) const;
975
976 /// This emits linkage information about \p GVSym based on \p GV, if this is
977 /// supported by the target.
978 virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
979
980 /// Return the alignment for the specified \p GV.
981 static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL,
982 Align InAlign = Align(1));
983
984private:
985 /// Private state for PrintSpecial()
986 // Assign a unique ID to this machine instruction.
987 mutable const MachineInstr *LastMI = nullptr;
988 mutable unsigned LastFn = 0;
989 mutable unsigned Counter = ~0U;
990
991 bool DwarfUsesRelocationsAcrossSections = false;
992
993 /// This method emits the header for the current function.
994 virtual void emitFunctionHeader();
995
996 /// This method emits a comment next to header for the current function.
997 virtual void emitFunctionHeaderComment();
998
999 /// This method emits prefix-like data before the current function.
1000 void emitFunctionPrefix(ArrayRef<const Constant *> Prefix);
1001
1002 /// Emit a blob of inline asm to the output streamer.
1003 virtual void
1004 emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
1005 const MCTargetOptions &MCOptions,
1006 const MDNode *LocMDNode = nullptr,
1008 const MachineInstr *MI = nullptr);
1009
1010 /// This method formats and emits the specified machine instruction that is an
1011 /// inline asm.
1012 void emitInlineAsm(const MachineInstr *MI);
1013
1014 /// Add inline assembly info to the diagnostics machinery, so we can
1015 /// emit file and position info. Returns SrcMgr memory buffer position.
1016 unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
1017 const MDNode *LocMDNode) const;
1018
1019 //===------------------------------------------------------------------===//
1020 // Internal Implementation Details
1021 //===------------------------------------------------------------------===//
1022
1023 virtual void emitJumpTableImpl(const MachineJumpTableInfo &MJTI,
1024 ArrayRef<unsigned> JumpTableIndices);
1025
1026 void emitJumpTableSizesSection(const MachineJumpTableInfo &MJTI,
1027 const Function &F) const;
1028
1029 void emitLLVMUsedList(const ConstantArray *InitList);
1030 /// Emit llvm.ident metadata in an '.ident' directive.
1031 void emitModuleIdents(Module &M);
1032 /// Emit bytes for llvm.commandline metadata.
1033 virtual void emitModuleCommandLines(Module &M);
1034
1035 GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S);
1036 virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI);
1037
1038 /// This method decides whether the specified basic block requires a label.
1039 bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
1040
1041protected:
1042 virtual void emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
1043 const MachineBasicBlock *MBB,
1044 unsigned uid) const;
1045 virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA);
1047 return false;
1048 }
1049
1050 /// Returns a optional minimum alignment that applies to both the address and
1051 /// the allocation size of the global. This is used for systems like CHERI and
1052 /// MTE that impose a minimum alignment, and require globals to be padded to
1053 /// that alignment.
1054 virtual MaybeAlign
1056 return std::nullopt;
1057 };
1058};
1059
1061 AsmPrinter &AsmPrinter);
1062
1063LLVM_ABI void
1065 MachineFunction &MF, AsmPrinter &AsmPrinter);
1066
1067} // end namespace llvm
1068
1069#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.
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:95
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition AsmPrinter.h:663
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:448
MapVector< MBBSectionID, MBBSectionRange > MBBSectionRanges
Definition AsmPrinter.h:165
CFISection getModuleCFISectionType() const
Get the CFISection type for the module.
Definition AsmPrinter.h:534
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:312
std::function< MachineOptimizationRemarkEmitter *(MachineFunction &)> GetORE
Definition AsmPrinter.h:184
virtual const MCExpr * lowerConstantPtrAuth(const ConstantPtrAuth &CPA)
Definition AsmPrinter.h:684
dwarf::Attribute getTypeAddressSpaceAttribute() const
Definition AsmPrinter.h:306
dwarf::Attribute TypeAddressSpaceAttribute
The attribute used for a pointer type's DWARF address space.
Definition AsmPrinter.h:296
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:378
virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI)
Emit necessary directives to allow use of instructions that are permitted by target features enabled ...
Definition AsmPrinter.h:962
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:313
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:341
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:715
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:351
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:639
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:537
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition AsmPrinter.h:647
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:643
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:709
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:609
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:339
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
Definition AsmPrinter.h:830
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:874
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:705
virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush)
Emit necessary directives to restore target feature state.
Definition AsmPrinter.h:969
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:475
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
void setDwarfUsesRelocationsAcrossSections(bool Enable)
Definition AsmPrinter.h:402
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:794
virtual void emitFunctionDescriptor()
Definition AsmPrinter.h:672
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:858
bool isVerbose() const
Return true if assembly output should contain comments.
Definition AsmPrinter.h:332
MCSymbol * getFunctionEnd() const
Definition AsmPrinter.h:342
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:680
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:651
bool doesDwarfUseRelocationsAcrossSections() const
Definition AsmPrinter.h:398
@ 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.
Attribute
Attributes.
Definition Dwarf.h:125
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Length
Definition DWP.cpp:577
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
Op::Description Desc
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
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