16 #ifndef LLVM_CODEGEN_ASMPRINTER_H 17 #define LLVM_CODEGEN_ASMPRINTER_H 36 class AsmPrinterHandler;
45 class GCMetadataPrinter;
47 class GlobalIndirectSymbol;
51 class MachineBasicBlock;
52 class MachineConstantPoolValue;
53 class MachineDominatorTree;
54 class MachineFunction;
56 class MachineJumpTableInfo;
57 class MachineLoopInfo;
58 class MachineModuleInfo;
59 class MachineOptimizationRemarkEmitter;
61 class MCCFIInstruction;
62 struct MCCodePaddingContext;
68 class MCSubtargetInfo;
70 class MCTargetOptions;
75 class TargetLoweringObjectFile;
131 MCSymbol *CurExceptionSym =
nullptr;
134 void *GCMetadataPrinters =
nullptr;
152 const char *TimerDescription,
const char *TimerGroupName,
153 const char *TimerGroupDescription)
154 : Handler(Handler), TimerName(TimerName),
155 TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
156 TimerGroupDescription(TimerGroupDescription) {}
173 std::unique_ptr<MachineDominatorTree> OwnedMDT;
176 std::unique_ptr<MachineLoopInfo> OwnedMLI;
180 mutable std::unique_ptr<SrcMgrDiagInfo> DiagInfo;
186 bool isCFIMoveForDebugging =
false;
261 const class Function *
Fn;
275 uint8_t Version = 0);
484 unsigned Size)
const;
494 unsigned Size,
bool IsSectionRelative =
false)
const;
499 bool IsSectionRelative =
false)
const {
511 void EmitSLEB128(int64_t Value,
const char *Desc =
nullptr)
const;
514 void EmitULEB128(uint64_t Value,
const char *Desc =
nullptr)
const;
531 bool ForceOffset =
false)
const;
564 for (
const auto &Abbrev : Abbrevs)
590 const char *
Code)
const;
596 unsigned AsmVariant,
const char *ExtraCode,
604 unsigned AsmVariant,
const char *ExtraCode,
624 mutable unsigned LastFn = 0;
625 mutable unsigned Counter = ~0U;
628 virtual void EmitFunctionHeader();
634 const MDNode *LocMDNode =
nullptr,
643 unsigned addInlineAsmDiagBuffer(
StringRef AsmStr,
644 const MDNode *LocMDNode)
const;
653 bool IsDefinition =
true)
const;
661 void EmitModuleIdents(
Module &M);
663 void EmitModuleCommandLines(
Module &M);
676 #endif // LLVM_CODEGEN_ASMPRINTER_H virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
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.
MCContext & OutContext
This is the context for the output file that we are streaming.
bool EnablePrintSchedInfo
Enable print [latency:throughput] in output.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
uint16_t getDwarfVersion() const
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 AsmPrinter objects required to build debug or EH information.
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...
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.
ELFYAML::ELF_STV Visibility
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
The address of a basic block.
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
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
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
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...
Streaming machine code generation interface.
virtual void EmitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
MCSymbol * CurrentFnSym
The symbol for the current function.
LLVM Basic Block Representation.
const MCAsmInfo * MAI
Target Asm Printer information.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
This is an important base class in LLVM.
A structured debug information entry.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
void EmitAlignment(unsigned NumBits, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
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)
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...
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.
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.
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.
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.
AsmPrinterHandler * Handler
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 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 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.
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.
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".
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
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 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.
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.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr) const
Emit the specified unsigned leb128 value.
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.
HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName, const char *TimerDescription, const char *TimerGroupName, const char *TimerGroupDescription)
std::vector< const MDNode * > LocInfos
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
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.