16 #ifndef LLVM_CODEGEN_ASMPRINTER_H
17 #define LLVM_CODEGEN_ASMPRINTER_H
24 #include "llvm/Support/DataTypes.h"
28 class AsmPrinterHandler;
36 class GCMetadataPrinter;
37 class GlobalIndirectSymbol;
40 class MachineBasicBlock;
41 class MachineFunction;
43 class MachineLocation;
44 class MachineLoopInfo;
46 class MachineConstantPoolValue;
47 class MachineJumpTableInfo;
48 class MachineModuleInfo;
50 class MCCFIInstruction;
56 class MCSubtargetInfo;
58 class MCTargetOptions;
62 class TargetLoweringObjectFile;
113 void *GCMetadataPrinters;
125 const char *TimerName;
126 const char *TimerDescription;
127 const char *TimerGroupName;
128 const char *TimerGroupDescription;
130 const char *TimerDescription,
const char *TimerGroupName,
131 const char *TimerGroupDescription)
132 : Handler(Handler), TimerName(TimerName),
133 TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
134 TimerGroupDescription(TimerGroupDescription) {}
144 bool isCFIMoveForDebugging;
219 std::vector<XRayFunctionEntry>
Sleds;
430 unsigned Size)
const;
436 unsigned Size,
bool IsSectionRelative =
false)
const;
441 bool IsSectionRelative =
false)
const {
454 unsigned PadTo = 0)
const;
471 bool ForceOffset =
false)
const;
499 for (
const auto &Abbrev : Abbrevs)
525 const char *
Code)
const;
531 unsigned AsmVariant,
const char *ExtraCode,
539 unsigned AsmVariant,
const char *ExtraCode,
559 mutable unsigned LastFn;
563 virtual void EmitFunctionHeader();
569 const MDNode *LocMDNode =
nullptr,
583 bool IsDefinition =
true)
const;
591 void EmitModuleIdents(
Module &M);
596 void emitGlobalIndirectSymbol(
Module &M,
std::vector< XRayFunctionEntry > Sleds
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
void setDwarfVersion(uint16_t Version)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
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 * getSymbol(const GlobalValue *GV) const
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
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. ...
const DataLayout & getDataLayout() const
Return information about data layout.
bool doFinalization(Module &M) override
Shut down the asmprinter.
void EmitInt8(int Value) const
Emit a byte directive and value.
MCContext & OutContext
This is the context for the output file that we are streaming.
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...
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
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 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...
const MachineFunction * MF
The current machine function.
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
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...
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
This class implements a map that also provides access to all stored values in a deterministic order...
unsigned getFunctionNumber() const
Return a unique ID for the current function.
void EmitInt32(int Value) const
Emit a long directive and value.
ELFYAML::ELF_STV Visibility
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 emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
The address of a basic block.
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...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
String pool entry reference.
Base class for the full range of assembler expressions which are needed for parsing.
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...
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
uint16_t getDwarfVersion() const
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
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.
bool needsOnlyDebugCFIMoves() const
Returns false if needsCFIMoves() == CFI_M_EH for any function in the module.
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
void EmitInt16(int Value) const
Emit a short directive and value.
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...
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode...
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.
This class is intended to be used as a base class for asm properties and features specific to the tar...
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
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)
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
This is an important base class in LLVM.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind)
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...
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
Represent the analysis usage information of a pass.
DwarfDebug * getDwarfDebug()
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
void emitFrameAlloc(const MachineInstr &MI)
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
Abstract base class for all machine specific constantpool value subclasses.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
const MCSymbol * Function
void EmitAlignment(unsigned NumBits, const GlobalObject *GO=nullptr) const
Emit an alignment directive to the specified power of two boundary.
void emitCFIInstruction(const MachineInstr &MI)
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
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.
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.
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
const class Function * Fn
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
Emit reference to a ttype global with a specified encoding.
MCSymbol * createTempSymbol(const Twine &Name) const
bool isPositionIndependent() const
DwarfDebug * getDwarfDebug() const
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void emit(int, MCStreamer *, const MCSymbol *) const
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
ConstantArray - Constant Array Declarations.
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
MCSymbol * getCurExceptionSym()
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
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.
MCSymbol * getFunctionBegin() const
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
MCSubtargetInfo - Generic base class for all target subtargets.
MCSymbol * getFunctionEnd() const
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
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.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
CFIMoveType needsCFIMoves()
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-byte offset of a string from the start of its section.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
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...
StringRef - Represent a constant reference to a string, i.e.
bool isVerbose() const
Return true if assembly output should contain comments.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
This class contains meta information specific to a module.