15 #ifndef LLVM_CODEGEN_ASMPRINTER_H 16 #define LLVM_CODEGEN_ASMPRINTER_H 44 class GCMetadataPrinter;
46 class GlobalIndirectSymbol;
50 class MachineBasicBlock;
51 class MachineBlockFrequencyInfo;
52 class MachineConstantPoolValue;
53 class MachineDominatorTree;
54 class MachineFunction;
56 class MachineJumpTableInfo;
57 class MachineLoopInfo;
58 class MachineModuleInfo;
59 class MachineOptimizationRemarkEmitter;
61 class MCCFIInstruction;
67 class MCSubtargetInfo;
69 class MCTargetOptions;
72 class ProfileSummaryInfo;
76 class TargetLoweringObjectFile;
139 MCSymbol *CurExceptionSym =
nullptr;
142 void *GCMetadataPrinters =
nullptr;
162 const char *TimerName,
const char *TimerDescription,
163 const char *TimerGroupName,
const char *TimerGroupDescription)
164 : Handler(
std::move(Handler)), TimerName(TimerName),
165 TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
166 TimerGroupDescription(TimerGroupDescription) {}
183 std::unique_ptr<MachineDominatorTree> OwnedMDT;
186 std::unique_ptr<MachineLoopInfo> OwnedMLI;
190 mutable std::unique_ptr<SrcMgrDiagInfo> DiagInfo;
196 bool isCFIMoveForDebugging =
false;
274 const class Function *
Fn;
288 uint8_t Version = 0);
508 unsigned Size)
const;
518 unsigned Size,
bool IsSectionRelative =
false)
const;
523 bool IsSectionRelative =
false)
const {
535 void EmitSLEB128(int64_t Value,
const char *Desc =
nullptr)
const;
538 void EmitULEB128(uint64_t Value,
const char *Desc =
nullptr,
unsigned PadTo = 0)
const;
555 bool ForceOffset =
false)
const;
571 unsigned Encoding)
const;
594 for (
const auto &Abbrev : Abbrevs)
620 const char *
Code)
const;
655 bool IsDefinition =
true)
const;
669 mutable unsigned LastFn = 0;
670 mutable unsigned Counter = ~0U;
673 virtual void EmitFunctionHeader();
679 const MDNode *LocMDNode =
nullptr,
688 unsigned addInlineAsmDiagBuffer(
StringRef AsmStr,
689 const MDNode *LocMDNode)
const;
699 void EmitModuleIdents(
Module &M);
701 void EmitModuleCommandLines(
Module &M);
712 #endif // LLVM_CODEGEN_ASMPRINTER_H virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
void EmitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Encoding) const
Emit reference to a call site with a specified encoding.
void setDwarfVersion(uint16_t Version)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
virtual void EmitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
A parsed version of the target data layout string in and methods for querying it. ...
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
bool needsOnlyDebugCFIMoves() const
Returns false if needsCFIMoves() == CFI_M_EH for any function in the module.
bool doFinalization(Module &M) override
Shut down the asmprinter.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MCContext & OutContext
This is the context for the output file that we are streaming.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
uint16_t getDwarfVersion() const
Analysis providing profile information.
CFIMoveType needsCFIMoves() const
virtual void EmitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
Collects and handles dwarf debug information.
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...
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
void EmitAlignment(Align Alignment, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
This class implements a map that also provides access to all stored values in a deterministic order...
MachineFunction * MF
The current machine function.
SmallVector< HandlerInfo, 1 > Handlers
A vector of all debug/EH info emitters we should use.
LLVMContext::InlineAsmDiagHandlerTy DiagHandler
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
DwarfStringPoolEntry getEntry() const
Return the entire string pool entry for convenience.
const char * TimerGroupDescription
void emitRemarksSection(RemarkStreamer &RS)
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
The address of a basic block.
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual void EmitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const char * TimerDescription
Base class for the full range of assembler expressions which are needed for parsing.
SmallVector< XRayFunctionEntry, 4 > Sleds
HandlerInfo(std::unique_ptr< AsmPrinterHandler > Handler, const char *TimerName, const char *TimerDescription, const char *TimerGroupName, const char *TimerGroupDescription)
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
void emitNops(unsigned N)
Emit N NOP instructions.
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Context object for machine code objects.
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
void EmitFunctionBody()
This method emits the body and trailer for a function.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
MCSymbol * getFunctionBegin() const
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
bool isPositionIndependent() const
Protected struct HandlerInfo and Handlers permit target extended AsmPrinter adds their own handlers...
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
bool isVerbose() const
Return true if assembly output should contain comments.
Data for a string pool entry.
void EmitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Instances of this class represent a single low-level machine instruction.
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...
This class is intended to be used as a base class for asm properties and features specific to the tar...
void emitPatchableFunctionEntries()
Streaming machine code generation interface.
virtual void EmitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
MCSymbol * CurrentFnBegin
MCSymbol * CurrentFnSym
The symbol for the current function.
DenseMap< const MCSection *, unsigned > PatchableFunctionEntryID
LLVM Basic Block Representation.
const MCAsmInfo * MAI
Target Asm Printer information.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
This is an important base class in LLVM.
A structured debug information entry.
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
static Align getGVAlignment(const GlobalValue *GV, const DataLayout &DL, Align InAlign=Align::None())
Return the alignment for the specified GV.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Represent the analysis usage information of a pass.
DwarfDebug * getDwarfDebug()
static void EmitInlineAsm(LLVMContext &C, BasicBlock *BB, StringRef AsmText)
void EmitCallSiteValue(uint64_t Value, unsigned Encoding) const
Emit an integer value corresponding to the call site encoding.
const char * TimerGroupName
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...
std::unique_ptr< AsmPrinterHandler > Handler
virtual void EmitFunctionDescriptor()
void emitFrameAlloc(const MachineInstr &MI)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
Abstract base class for all machine specific constantpool value subclasses.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
const MCSymbol * Function
unsigned getFunctionNumber() const
Return a unique ID for the current function.
void emitCFIInstruction(const MachineInstr &MI)
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
void emitDwarfStringOffset(DwarfStringPoolEntry S) const
Emit the 4-byte offset of a string from the start of its section.
MCSymbol * getSymbol(const GlobalValue *GV) const
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
virtual void EmitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
DwarfDebug * getDwarfDebug() const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
const class Function * Fn
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
Emit reference to a ttype global with a specified encoding.
void emitInt32(int Value) const
Emit a long directive and value.
MCSymbol * getFunctionEnd() const
MachineDominatorTree * MDT
This is a pointer to the current MachineLoopInfo.
ConstantArray - Constant Array Declarations.
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
MCSymbol * getCurExceptionSym()
void(*)(const SMDiagnostic &, void *Context, unsigned LocCookie) InlineAsmDiagHandlerTy
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
String pool entry reference.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Representation of each machine instruction.
void emitInitialRawDwarfLocDirective(const MachineFunction &MF)
Emits inital debug location directive.
void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target...
Dwarf abbreviation, describes the organization of a debug information object.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-byte offset of a string from the start of its section.
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
void EmitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const
Emit something like ".long Label + Offset".
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
Generic base class for all target subtargets.
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
virtual void EmitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
MachineBlockFrequencyInfo * MBFI
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
void emitInt8(int Value) const
Emit a byte directive and value.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
const DataLayout & getDataLayout() const
Return information about data layout.
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
StringRef - Represent a constant reference to a string, i.e.
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
std::vector< const MDNode * > LocInfos
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
void EmitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
MCSymbol * createTempSymbol(const Twine &Name) const
virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, const char *Code) const
Print information related to the specified machine instr that is independent of the operand...
void emitStackSizeSection(const MachineFunction &MF)
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
void emitInt16(int Value) const
Emit a short directive and value.
This class contains meta information specific to a module.