15#ifndef LLVM_CODEGEN_ASMPRINTER_H
16#define LLVM_CODEGEN_ASMPRINTER_H
207 MCSymbol *CurrentSectionBeginSym =
nullptr;
211 std::unique_ptr<AddrLabelMap> AddrLabelSymbols;
221 struct FunctionCallGraphInfo {
232 enum CallGraphSectionFormatVersion :
uint8_t {
237 std::unique_ptr<raw_fd_ostream> StackUsageStream;
240 MapVector<const MDNode *, SmallVector<const MCSymbol *>> PCSectionsSymbols;
263 std::unique_ptr<MachineDominatorTree> OwnedMDT;
266 std::unique_ptr<MachineLoopInfo> OwnedMLI;
273 std::unique_ptr<PseudoProbeHandler> PP;
284 bool HasSplitStack =
false;
289 bool HasNoSplitStack =
false;
292 bool DbgInfoAvailable =
false;
301 char &ID = AsmPrinter::ID);
320 bool isDwarf64()
const;
323 unsigned int getDwarfOffsetByteSize()
const;
326 unsigned int getUnitLengthFieldByteSize()
const;
331 bool isPositionIndependent()
const;
337 unsigned getFunctionNumber()
const;
370 void takeDeletedSymbolsForFunction(
const Function *
F,
371 std::vector<MCSymbol *> &Result);
388 const MCSection *getCurrentSection()
const;
401 return DwarfUsesRelocationsAcrossSections;
405 DwarfUsesRelocationsAcrossSections =
Enable;
415 void handleCallsiteForCallgraph(
416 FunctionCallGraphInfo &FuncCGInfo,
492 void emitFunctionBody();
508 FunctionCallGraphInfo &FuncCGInfo);
517 void emitDanglingPrefetchTargets();
530 CFISection getFunctionCFISectionType(
const Function &
F)
const;
540 return ModuleExceptionModel;
550 bool usesCFIWithoutEH()
const;
559 virtual void emitJumpTableInfo();
605 unsigned MaxBytesToEmit = 0)
const;
675 virtual MCSymbol *GetCPISymbol(
unsigned CPID)
const;
677 virtual void emitFunctionEntryLabel();
719 "Mach-O IFunc lowering is not yet supported on this target");
725 "Mach-O IFunc lowering is not yet supported on this target");
729 void emitNops(
unsigned N);
746 MCSymbol *GetJTISymbol(
unsigned JTID,
bool isLinkerPrivate =
false)
const;
750 MCSymbol *GetJTSetSymbol(
unsigned UID,
unsigned MBBID)
const;
765 void emitInt8(
int Value)
const;
768 void emitInt16(
int Value)
const;
771 void emitInt32(
int Value)
const;
777 void emitSLEB128(int64_t
Value,
const char *
Desc =
nullptr)
const;
781 unsigned PadTo = 0)
const;
787 unsigned Size)
const;
790 void emitLabelDifferenceAsULEB128(
const MCSymbol *
Hi,
797 unsigned Size,
bool IsSectionRelative =
false)
const;
802 bool IsSectionRelative =
false)
const {
816 unsigned GetSizeOfEncodedValue(
unsigned Encoding)
const;
819 virtual void emitTTypeReference(
const GlobalValue *GV,
unsigned Encoding);
824 void emitDwarfSymbolReference(
const MCSymbol *Label,
825 bool ForceOffset =
false)
const;
856 const Twine &Comment)
const;
860 unsigned Encoding)
const;
862 void emitCallSiteValue(
uint64_t Value,
unsigned Encoding)
const;
883 for (
const auto &Abbrev : Abbrevs)
890 void emitDwarfAbbrev(
const DIEAbbrev &Abbrev)
const;
893 void emitDwarfDIE(
const DIE &Die)
const;
904 getCodeViewJumpTableInfo(
int JTI,
const MachineInstr *BranchInstr,
913 void emitCOFFReplaceableFunctionData(
Module &M);
916 void emitCOFFFeatureSymbol(
Module &M);
941 virtual bool PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
948 virtual bool PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
953 virtual void emitInlineAsmStart()
const;
980 void emitVisibility(
MCSymbol *Sym,
unsigned Visibility,
981 bool IsDefinition =
true)
const;
995 mutable unsigned LastFn = 0;
996 mutable unsigned Counter = ~0U;
998 bool DwarfUsesRelocationsAcrossSections =
false;
1001 virtual void emitFunctionHeader();
1004 virtual void emitFunctionHeaderComment();
1013 const MDNode *LocMDNode =
nullptr,
1023 unsigned addInlineAsmDiagBuffer(
StringRef AsmStr,
1024 const MDNode *LocMDNode)
const;
1038 void emitModuleIdents(
Module &M);
1040 virtual void emitModuleCommandLines(
Module &M);
1051 unsigned uid)
const;
1063 return std::nullopt;
1068 AsmPrinter &AsmPrinter);
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.
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.
static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
static void emitInlineAsm(LLVMContext &C, BasicBlock *BB, StringRef AsmText)
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),...
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.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
SmallVector< XRayFunctionEntry, 4 > Sleds
MapVector< MBBSectionID, MBBSectionRange > MBBSectionRanges
CFISection getModuleCFISectionType() const
Get the CFISection type for the module.
MCSymbol * CurrentFnBegin
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
DwarfDebug * getDwarfDebug()
std::function< MachineOptimizationRemarkEmitter *(MachineFunction &)> GetORE
virtual const MCExpr * lowerConstantPtrAuth(const ConstantPtrAuth &CPA)
dwarf::Attribute getTypeAddressSpaceAttribute() const
dwarf::Attribute TypeAddressSpaceAttribute
The attribute used for a pointer type's DWARF address space.
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.
virtual bool emitTargetFeaturePush(const MCSubtargetInfo &STI)
Emit necessary directives to allow use of instructions that are permitted by target features enabled ...
TargetMachine & TM
Target machine description.
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...
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
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
MCSymbol * CurrentFnBeginLocal
For dso_local functions, the current $local alias for the function.
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
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
virtual void emitMachOIFuncStubHelperBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
std::function< void(Module &)> EmitStackMaps
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
virtual DwarfDebug * createDwarfDebug()
Create the DwarfDebug handler.
std::function< BasicBlockSectionsProfileReader *(MachineFunction &)> GetBBSPR
Returns the basic block sections profile reader if available, nullptr otherwise.
SmallVector< std::unique_ptr< AsmPrinterHandler >, 2 > Handlers
MachineFunction * MF
The current machine function.
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.
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
unsigned PointerSize
The pointer size in bytes for the default address space.
std::function< void(Module &)> FinishGCAssembly
bool hasDebugInfo() const
Returns true if valid debug info is present.
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
ExceptionHandling getModuleExceptionModel() const
Get the exception model resolved for the current module.
std::function< MachineDominatorTree *(MachineFunction &)> GetMDT
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
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...
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)
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
DenseMap< uint64_t, SmallVector< const GlobalAlias *, 1 > > AliasMapTy
Print a general LLVM constant to the .s file.
virtual bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const
std::function< MachineBlockHashInfoResult *(MachineFunction &)> GetMBHI
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.
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
std::function< void(Module &)> BeginGCAssembly
MCSymbol * CurrentFnSym
The symbol for the current function.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
std::function< MachineBlockFrequencyInfo *(MachineFunction &)> GetMBFI
MCContext & OutContext
This is the context for the output file that we are streaming.
const StaticDataProfileInfo * SDPI
Provides the profile information for constants.
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...
virtual void emitTargetFeaturePop(const MCSubtargetInfo &STI, bool DidPush)
Emit necessary directives to restore target feature state.
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.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
void setDwarfUsesRelocationsAcrossSections(bool Enable)
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
const ProfileSummaryInfo * PSI
The profile summary information.
const MCAsmInfo & MAI
Target Asm Printer information.
std::function< void()> AssertDebugEHFinalized
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...
virtual void emitFunctionDescriptor()
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
std::function< MachineLoopInfo *(MachineFunction &)> GetMLI
std::function< MachineModuleInfo *()> GetMMI
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
bool isVerbose() const
Return true if assembly output should contain comments.
MCSymbol * getFunctionEnd() const
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...
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
SmallVector< std::unique_ptr< AsmPrinterHandler >, 1 > EHHandlers
A handle to the EH info emitter (if present).
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.
bool doesDwarfUseRelocationsAcrossSections() const
@ None
Do not emit either .eh_frame or .debug_frame.
@ Debug
Emit .debug_frame.
std::function< MachineBranchProbabilityInfo *(MachineFunction &)> GetMBPI
void addAsmPrinterHandler(std::unique_ptr< AsmPrinterHandler > Handler)
LLVM Basic Block Representation.
The address of a basic block.
ConstantArray - Constant Array Declarations.
A signed pointer, in the ptrauth sense.
This is an important base class in LLVM.
Dwarf abbreviation, describes the organization of a debug information object.
A structured debug information entry.
A parsed version of the target data layout string in and methods for querying it.
Base class for debug information backends.
Collects and handles dwarf debug information.
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
const DwarfStringPoolEntry & getEntry() const
GCStrategy describes a garbage collector algorithm's code generation requirements,...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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...
MachineFunctionPass(char &ID)
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.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
A SetVector that performs no allocations if smaller than a certain size.
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.
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#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.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
@ None
No exception support.
LLVM_ABI void setupMachineFunctionAsmPrinter(MachineFunctionAnalysisManager &MFAM, MachineFunction &MF, AsmPrinter &AsmPrinter)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Map a basic block section ID to the begin and end symbols of that section which determine the section...
const MCSymbol * Function
const class Function * Fn
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.