44#define DEBUG_TYPE "asm-printer"
53 std::unique_ptr<MCStreamer> Streamer)
54 :
AsmPrinter(TM, std::move(Streamer),
ID), ModuleSectionsEmitted(
false),
55 ST(
nullptr),
TII(
nullptr), MAI(
nullptr) {}
57 bool ModuleSectionsEmitted;
61 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
66 void outputMCInst(
MCInst &Inst);
69 void outputGlobalRequirements();
70 void outputEntryPoints();
71 void outputDebugSourceAndStrings(
const Module &M);
72 void outputOpExtInstImports(
const Module &M);
73 void outputOpMemoryModel();
74 void outputOpFunctionEnd();
75 void outputExtFuncDecls();
77 SPIRV::ExecutionMode::ExecutionMode EM,
78 unsigned ExpectMDOps, int64_t DefVal);
79 void outputExecutionModeFromNumthreadsAttribute(
81 SPIRV::ExecutionMode::ExecutionMode EM);
82 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
84 void outputExecutionMode(
const Module &M);
85 void outputAnnotations(
const Module &M);
86 void outputModuleSections();
87 void outputFPFastMathDefaultInfo();
89 return MF->getFunction()
95 void emitFunctionEntryLabel()
override {}
96 void emitFunctionHeader()
override;
97 void emitFunctionBodyStart()
override {}
98 void emitFunctionBodyEnd()
override;
103 void emitEndOfAsmFile(
Module &M)
override;
104 bool doInitialization(
Module &M)
override;
119void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
126void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
127 if (!ModuleSectionsEmitted) {
128 outputModuleSections();
129 ModuleSectionsEmitted =
true;
132 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
140 uint32_t Major = SPIRVVersion.
getMajor();
141 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
144 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
145 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
146 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
147 .setBuildVersion(Major, Minor, Bound);
154void SPIRVAsmPrinter::cleanUp(
Module &M) {
156 for (StringRef GVName :
157 {
"llvm.global_ctors",
"llvm.global_dtors",
"llvm.used"}) {
158 if (GlobalVariable *GV =
M.getNamedGlobal(GVName))
163void SPIRVAsmPrinter::emitFunctionHeader() {
164 if (!ModuleSectionsEmitted) {
165 outputModuleSections();
166 ModuleSectionsEmitted =
true;
169 ST = &MF->getSubtarget<SPIRVSubtarget>();
173 if (isVerbose() && !isHidden()) {
174 OutStreamer->getCommentOS()
175 <<
"-- Begin function "
179 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
180 MF->setSection(Section);
186 for (
auto &Handler : Handlers) {
187 Handler->beginFunction(MF);
188 Handler->beginBasicBlockSection(MF->front());
192void SPIRVAsmPrinter::outputOpFunctionEnd() {
193 MCInst FunctionEndInst;
194 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
195 outputMCInst(FunctionEndInst);
198void SPIRVAsmPrinter::emitFunctionBodyEnd() {
200 outputOpFunctionEnd();
203void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
211 outputMCInst(LabelInst);
216void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
224 for (
const MachineInstr &
MI :
MBB)
225 if (
MI.getOpcode() == SPIRV::OpFunction)
233void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
235 const MachineOperand &MO =
MI->getOperand(OpNum);
275bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
276 const char *ExtraCode, raw_ostream &O) {
277 if (ExtraCode && ExtraCode[0])
286 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
287 MI->getOpcode() == SPIRV::OpFunctionParameter;
290void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
291 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
294void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
295 SPIRVMCInstLower MCInstLowering;
297 MCInstLowering.
lower(
MI, TmpInst, MAI);
298 outputMCInst(TmpInst);
301void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
302 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
303 getSubtargetInfo().getFeatureBits());
305 if (!MAI->getSkipEmission(
MI))
306 outputInstruction(
MI);
309 const MachineInstr *NextMI =
MI->getNextNode();
312 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
313 "OpFunction is not in the front MBB of MF");
314 emitOpLabel(*
MI->getParent());
318void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
319 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
320 outputInstruction(
MI);
323void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
325 for (
auto &Str : MAI->SrcExt) {
327 Inst.
setOpcode(SPIRV::OpSourceExtension);
332 outputModuleSection(SPIRV::MB_DebugStrings);
349void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
350 for (
auto &CU : MAI->ExtInstSetMap) {
351 unsigned Set = CU.first;
352 MCRegister
Reg = CU.second;
357 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
363void SPIRVAsmPrinter::outputOpMemoryModel() {
375void SPIRVAsmPrinter::outputEntryPoints() {
377 DenseSet<MCRegister> InterfaceIDs;
378 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
379 assert(
MI->getOpcode() == SPIRV::OpVariable);
380 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
387 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
388 const MachineFunction *MF =
MI->getMF();
389 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
395 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
396 SPIRVMCInstLower MCInstLowering;
398 MCInstLowering.
lower(
MI, TmpInst, MAI);
399 for (MCRegister
Reg : InterfaceIDs) {
403 outputMCInst(TmpInst);
408void SPIRVAsmPrinter::outputGlobalRequirements() {
410 MAI->Reqs.checkSatisfiable(*ST);
412 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
420 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
424 SPIRV::OperandCategory::ExtensionOperand, Ext),
431void SPIRVAsmPrinter::outputExtFuncDecls() {
433 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
434 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
435 for (;
I !=
E; ++
I) {
436 outputInstruction(*
I);
437 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
438 outputOpFunctionEnd();
448 if (Ty->isDoubleTy())
451 switch (IntTy->getIntegerBitWidth()) {
465 Type *EleTy = VecTy->getElementType();
466 unsigned Size = VecTy->getNumElements();
488void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
489 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
490 unsigned ExpectMDOps, int64_t DefVal) {
498 unsigned NodeSz =
Node->getNumOperands();
499 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
500 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
505void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
507 SPIRV::ExecutionMode::ExecutionMode EM) {
508 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
517 assert(NumThreads.size() == 3 &&
"invalid numthreads");
518 for (uint32_t i = 0; i < 3; ++i) {
520 [[maybe_unused]]
bool Result = NumThreads[i].getAsInteger(10, V);
521 assert(!Result &&
"Failed to parse numthreads");
528void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
529 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
530 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
531 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
537 static_cast<unsigned>(SPIRV::ExecutionMode::MaximallyReconvergesKHR);
542void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
543 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
545 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
552 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
557 if (
ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
558 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
559 EM == SPIRV::ExecutionMode::ContractionOff ||
560 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
569 outputFPFastMathDefaultInfo();
571 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
577 MCRegister FReg = MAI->getGlobalObjReg(&
F);
590 static_cast<unsigned>(SPIRV::ExecutionMode::OriginUpperLeft);
595 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
596 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
599 outputExecutionModeFromNumthreadsAttribute(
600 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
601 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
603 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
605 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
606 outputExecutionModeFromMDNode(FReg, Node,
607 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
608 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
609 outputExecutionModeFromMDNode(FReg, Node,
610 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
611 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
612 outputExecutionModeFromMDNode(FReg, Node,
613 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
614 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
615 if (
ST->canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
616 outputExecutionModeFromMDNode(
617 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
619 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
623 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
632 SPIRV::Capability::PoisonFreezeKHR)) {
637 static_cast<unsigned>(SPIRV::ExecutionMode::ArithmeticPoisonKHR);
641 if (
ST->isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
642 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT")) {
643 if (
ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
660 std::vector<const MachineInstr *> SPIRVFloatTypes;
661 const MachineInstr *ConstZeroInt32 =
nullptr;
662 for (
const MachineInstr *
MI :
663 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
667 if (OpCode == SPIRV::OpTypeFloat) {
669 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
670 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
671 OpTypeFloatSize != 64) {
674 SPIRVFloatTypes.push_back(
MI);
678 if (OpCode == SPIRV::OpConstantNull) {
680 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
681 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
682 bool IsInt32Ty = TypeMI &&
683 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
696 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
698 Inst.
setOpcode(SPIRV::OpExecutionModeId);
701 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
703 const MachineFunction *MF =
MI->getMF();
705 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
707 assert(ConstZeroInt32 &&
"There should be a constant zero.");
708 MCRegister ConstReg = MAI->getRegisterAlias(
718 static_cast<unsigned>(SPIRV::ExecutionMode::ContractionOff);
726void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
727 outputModuleSection(SPIRV::MB_Annotations);
729 for (
auto F =
M.global_begin(),
E =
M.global_end();
F !=
E; ++
F) {
730 if ((*F).getName() !=
"llvm.global.annotations")
732 const GlobalVariable *
V = &(*F);
740 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
743 raw_string_ostream OS(DiagMsg);
744 AnnotatedVar->
print(OS);
745 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
753 StringRef AnnotationString;
754 [[maybe_unused]]
bool Success =
760 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
768void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
771 std::vector<const MachineInstr *> SPIRVFloatTypes;
773 std::unordered_map<int, const MachineInstr *>
ConstMap;
774 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
777 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
778 OpCode != SPIRV::OpConstantNull)
782 if (OpCode == SPIRV::OpTypeFloat) {
783 SPIRVFloatTypes.push_back(
MI);
786 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
787 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
788 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
792 if (OpCode == SPIRV::OpConstantI)
799 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
800 MAI->FPFastMathDefaultInfoMap) {
801 if (FPFastMathDefaultInfoVec.empty())
804 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
805 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
808 assert(Index < FPFastMathDefaultInfoVec.size() &&
809 "Index out of bounds for FPFastMathDefaultInfoVec");
810 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
811 assert(FPFastMathDefaultInfo.Ty &&
812 "Expected target type for FPFastMathDefaultInfo");
813 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
815 "Mismatched float type size");
817 Inst.
setOpcode(SPIRV::OpExecutionModeId);
818 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
824 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
826 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
827 if (FPFastMathDefaultInfo.ContractionOff &&
828 (Flags & SPIRV::FPFastMathMode::AllowContract))
830 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
832 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
834 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
835 SPIRV::FPFastMathMode::NSZ))) {
836 if (FPFastMathDefaultInfo.FPFastMathDefault)
838 "SignedZeroInfNanPreserve but at least one of "
839 "NotNaN/NotInf/NSZ is enabled.");
843 if (Flags == SPIRV::FPFastMathMode::None &&
844 !FPFastMathDefaultInfo.ContractionOff &&
845 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
846 !FPFastMathDefaultInfo.FPFastMathDefault)
853 "Mode operand of FPFastMathDefault execution mode.");
854 const MachineInstr *ConstMI = It->second;
855 MCRegister ConstReg = MAI->getRegisterAlias(
863void SPIRVAsmPrinter::outputModuleSections() {
864 const Module *
M = MMI->getModule();
866 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
867 TII =
ST->getInstrInfo();
868 MAI = &getAnalysis<SPIRVModuleAnalysis>().MAI;
869 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
879 outputGlobalRequirements();
881 outputOpExtInstImports(*M);
883 outputOpMemoryModel();
888 outputExecutionMode(*M);
891 outputDebugSourceAndStrings(*M);
893 outputModuleSection(SPIRV::MB_DebugNames);
895 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
898 outputModuleSection(SPIRV::MB_AliasingInsts);
900 outputAnnotations(*M);
905 outputModuleSection(SPIRV::MB_TypeConstVars);
912 outputExtFuncDecls();
917bool SPIRVAsmPrinter::doInitialization(
Module &M) {
918 ModuleSectionsEmitted =
false;
921 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
922 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
923 NSDebugHandler = Handler.get();
924 addAsmPrinterHandler(std::move(Handler));
930char SPIRVAsmPrinter::ID = 0;
937LLVMInitializeSPIRVAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
This file defines the DenseMap class.
const HexagonInstrInfo * TII
static Value * getOpcode(Value &V, Type &Ty, InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB)
Machine Check Debug Module
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void addOpsFromMDNode(MDNode *MDN, MCInst &Inst, SPIRV::ModuleAnalysisInfo *MAI)
static bool isFuncOrHeaderInstr(const MachineInstr *MI, const SPIRVInstrInfo *TII)
static unsigned encodeVecTypeHint(Type *Ty)
#define SPIRV_BACKEND_SERVICE_FUN_NAME
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
This class is intended to be used as a driving class for all asm writers.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
iterator find(const_arg_type_t< KeyT > Val)
Class to represent fixed width SIMD vectors.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Class to represent integer types.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
StringRef getName() const
getName - Get the symbol name.
ArrayRef< MDOperand > operands() const
Tracking metadata reference owned by Metadata.
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const MachineOperand & getOperand(unsigned i) const
const GlobalValue * getGlobal() const
MachineBasicBlock * getMBB() const
const BlockAddress * getBlockAddress() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
@ MO_FPImmediate
Floating-point immediate operand.
LLVM_ABI MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
A Module instance is used to store all the information related to an LLVM module.
constexpr bool isValid() const
void setBound(unsigned V)
static const char * getRegisterName(MCRegister Reg)
void lower(const MachineInstr *MI, MCInst &OutMI, SPIRV::ModuleAnalysisInfo *MAI) const
AsmPrinter handler that emits NonSemantic.Shader.DebugInfo.100 (NSDI) instructions for the SPIR-V bac...
void emitNonSemanticDebugStrings(SPIRV::ModuleAnalysisInfo &MAI)
Emit OpString instructions for all NSDI file paths and basic type names into the debug section (secti...
void emitNonSemanticGlobalDebugInfo(SPIRV::ModuleAnalysisInfo &MAI)
Emit module-scope NSDI instructions (DebugSource, DebugCompilationUnit, DebugTypeBasic,...
void prepareModuleOutput(const SPIRVSubtarget &ST, SPIRV::ModuleAnalysisInfo &MAI)
Add SPV_KHR_non_semantic_info extension and NonSemantic.Shader.DebugInfo.100 ext inst set entry to MA...
const SPIRVInstrInfo * getInstrInfo() const override
bool isAtLeastSPIRVVer(VersionTuple VerToCompareTo) const
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
VersionTuple getSPIRVVersion() const
unsigned getBound() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Primary interface to the complete machine description for the target machine.
The instances of the Type class are immutable: once they are created, they are never changed.
Value * getOperand(unsigned i) const
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
std::pair< iterator, bool > insert(const ValueT &V)
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Target & getTheSPIRV32Target()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
DenseMap< Value *, Constant * > ConstMap
LLVM_ABI bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
std::string getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category, int32_t Value)
bool isEntryPoint(const Function &F)
Target & getTheSPIRV64Target()
Target & getTheSPIRVLogicalTarget()
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Type * getMDOperandAsType(const MDNode *N, unsigned I)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void addStringImm(const StringRef &Str, MCInst &Inst)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
static size_t computeFPFastMathDefaultInfoVecIndex(size_t BitWidth)
MCRegister getGlobalObjReg(const GlobalObject *GO)