45#define DEBUG_TYPE "asm-printer"
54 std::unique_ptr<MCStreamer> Streamer)
55 :
AsmPrinter(TM, std::move(Streamer),
ID), ModuleSectionsEmitted(
false),
56 ST(
nullptr),
TII(
nullptr), MAI(
nullptr) {}
58 bool ModuleSectionsEmitted;
62 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
67 void outputMCInst(
MCInst &Inst);
70 void outputGlobalRequirements();
71 void outputEntryPoints();
72 void outputDebugSourceAndStrings(
const Module &M);
73 void outputOpExtInstImports(
const Module &M);
74 void outputOpMemoryModel();
75 void outputOpFunctionEnd();
76 void outputExtFuncDecls();
78 SPIRV::ExecutionMode::ExecutionMode EM,
79 unsigned ExpectMDOps, int64_t DefVal);
80 void outputExecutionModeFromNumthreadsAttribute(
82 SPIRV::ExecutionMode::ExecutionMode EM);
83 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
85 void outputExecutionMode(
const Module &M);
86 void outputAnnotations(
const Module &M);
87 void outputModuleSections();
88 void outputFPFastMathDefaultInfo();
90 return MF->getFunction()
96 void emitFunctionEntryLabel()
override {}
97 void emitFunctionHeader()
override;
98 void emitFunctionBodyStart()
override {}
99 void emitFunctionBodyEnd()
override;
104 void emitEndOfAsmFile(
Module &M)
override;
105 bool doInitialization(
Module &M)
override;
115 std::unique_ptr<SPIRVAuxDataHandler> AuxDataHandler;
122void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
129void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
130 if (!ModuleSectionsEmitted) {
131 outputModuleSections();
132 ModuleSectionsEmitted =
true;
135 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
143 uint32_t Major = SPIRVVersion.
getMajor();
144 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
147 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
148 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
149 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
150 .setBuildVersion(Major, Minor, Bound);
157void SPIRVAsmPrinter::cleanUp(
Module &M) {
159 for (StringRef GVName :
160 {
"llvm.global_ctors",
"llvm.global_dtors",
"llvm.used"}) {
161 if (GlobalVariable *GV =
M.getNamedGlobal(GVName))
166void SPIRVAsmPrinter::emitFunctionHeader() {
167 if (!ModuleSectionsEmitted) {
168 outputModuleSections();
169 ModuleSectionsEmitted =
true;
172 ST = &MF->getSubtarget<SPIRVSubtarget>();
176 if (isVerbose() && !isHidden()) {
177 OutStreamer->getCommentOS()
178 <<
"-- Begin function "
182 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
183 MF->setSection(Section);
189 for (
auto &Handler : Handlers) {
190 Handler->beginFunction(MF);
191 Handler->beginBasicBlockSection(MF->front());
195void SPIRVAsmPrinter::outputOpFunctionEnd() {
196 MCInst FunctionEndInst;
197 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
198 outputMCInst(FunctionEndInst);
201void SPIRVAsmPrinter::emitFunctionBodyEnd() {
203 outputOpFunctionEnd();
206void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
214 outputMCInst(LabelInst);
219void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
227 for (
const MachineInstr &
MI :
MBB)
228 if (
MI.getOpcode() == SPIRV::OpFunction)
236void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
238 const MachineOperand &MO =
MI->getOperand(OpNum);
278bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
279 const char *ExtraCode, raw_ostream &O) {
280 if (ExtraCode && ExtraCode[0])
289 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
290 MI->getOpcode() == SPIRV::OpFunctionParameter;
293void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
294 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
297void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
298 SPIRVMCInstLower MCInstLowering;
300 MCInstLowering.
lower(
MI, TmpInst, MAI);
301 outputMCInst(TmpInst);
304void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
305 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
306 getSubtargetInfo().getFeatureBits());
308 if (!MAI->getSkipEmission(
MI))
309 outputInstruction(
MI);
312 const MachineInstr *NextMI =
MI->getNextNode();
315 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
316 "OpFunction is not in the front MBB of MF");
317 emitOpLabel(*
MI->getParent());
321void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
322 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
323 outputInstruction(
MI);
326void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
328 for (
auto &Str : MAI->SrcExt) {
330 Inst.
setOpcode(SPIRV::OpSourceExtension);
335 outputModuleSection(SPIRV::MB_DebugStrings);
351 AuxDataHandler->emitAuxDataStrings(*MAI);
354void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
355 for (
auto &CU : MAI->ExtInstSetMap) {
356 unsigned Set = CU.first;
357 MCRegister
Reg = CU.second;
362 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
368void SPIRVAsmPrinter::outputOpMemoryModel() {
380void SPIRVAsmPrinter::outputEntryPoints() {
382 DenseSet<MCRegister> InterfaceIDs;
383 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
384 assert(
MI->getOpcode() == SPIRV::OpVariable);
385 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
392 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
393 const MachineFunction *MF =
MI->getMF();
394 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
400 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
401 SPIRVMCInstLower MCInstLowering;
403 MCInstLowering.
lower(
MI, TmpInst, MAI);
404 for (MCRegister
Reg : InterfaceIDs) {
408 outputMCInst(TmpInst);
413void SPIRVAsmPrinter::outputGlobalRequirements() {
415 MAI->Reqs.checkSatisfiable(*ST);
417 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
425 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
429 SPIRV::OperandCategory::ExtensionOperand, Ext),
436void SPIRVAsmPrinter::outputExtFuncDecls() {
438 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
439 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
440 for (;
I !=
E; ++
I) {
441 outputInstruction(*
I);
442 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
443 outputOpFunctionEnd();
453 if (Ty->isDoubleTy())
456 switch (IntTy->getIntegerBitWidth()) {
470 Type *EleTy = VecTy->getElementType();
471 unsigned Size = VecTy->getNumElements();
493void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
494 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
495 unsigned ExpectMDOps, int64_t DefVal) {
503 unsigned NodeSz =
Node->getNumOperands();
504 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
505 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
510void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
512 SPIRV::ExecutionMode::ExecutionMode EM) {
513 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
522 assert(NumThreads.size() == 3 &&
"invalid numthreads");
523 for (uint32_t i = 0; i < 3; ++i) {
525 [[maybe_unused]]
bool Result = NumThreads[i].getAsInteger(10, V);
526 assert(!Result &&
"Failed to parse numthreads");
533void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
534 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
535 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
536 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
542 static_cast<unsigned>(SPIRV::ExecutionMode::MaximallyReconvergesKHR);
547void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
548 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
550 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
557 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
562 if (
ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
563 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
564 EM == SPIRV::ExecutionMode::ContractionOff ||
565 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
574 outputFPFastMathDefaultInfo();
576 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
582 MCRegister FReg = MAI->getGlobalObjReg(&
F);
595 static_cast<unsigned>(SPIRV::ExecutionMode::OriginUpperLeft);
600 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
601 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
604 outputExecutionModeFromNumthreadsAttribute(
605 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
606 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
608 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
610 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
611 outputExecutionModeFromMDNode(FReg, Node,
612 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
613 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
614 outputExecutionModeFromMDNode(FReg, Node,
615 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
616 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
617 outputExecutionModeFromMDNode(FReg, Node,
618 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
619 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
620 if (
ST->canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
621 outputExecutionModeFromMDNode(
622 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
624 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
628 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
637 SPIRV::Capability::PoisonFreezeKHR)) {
642 static_cast<unsigned>(SPIRV::ExecutionMode::ArithmeticPoisonKHR);
646 if (
ST->isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
647 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT")) {
648 if (
ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
665 std::vector<const MachineInstr *> SPIRVFloatTypes;
666 const MachineInstr *ConstZeroInt32 =
nullptr;
667 for (
const MachineInstr *
MI :
668 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
672 if (OpCode == SPIRV::OpTypeFloat) {
674 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
675 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
676 OpTypeFloatSize != 64) {
679 SPIRVFloatTypes.push_back(
MI);
683 if (OpCode == SPIRV::OpConstantNull) {
685 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
686 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
687 bool IsInt32Ty = TypeMI &&
688 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
701 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
703 Inst.
setOpcode(SPIRV::OpExecutionModeId);
706 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
708 const MachineFunction *MF =
MI->getMF();
710 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
712 assert(ConstZeroInt32 &&
"There should be a constant zero.");
713 MCRegister ConstReg = MAI->getRegisterAlias(
723 static_cast<unsigned>(SPIRV::ExecutionMode::ContractionOff);
731void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
732 outputModuleSection(SPIRV::MB_Annotations);
734 for (
auto F =
M.global_begin(),
E =
M.global_end();
F !=
E; ++
F) {
735 if ((*F).getName() !=
"llvm.global.annotations")
737 const GlobalVariable *
V = &(*F);
745 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
748 raw_string_ostream OS(DiagMsg);
749 AnnotatedVar->
print(OS);
750 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
758 StringRef AnnotationString;
759 [[maybe_unused]]
bool Success =
765 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
773void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
776 std::vector<const MachineInstr *> SPIRVFloatTypes;
778 std::unordered_map<int, const MachineInstr *>
ConstMap;
779 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
782 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
783 OpCode != SPIRV::OpConstantNull)
787 if (OpCode == SPIRV::OpTypeFloat) {
788 SPIRVFloatTypes.push_back(
MI);
791 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
792 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
793 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
797 if (OpCode == SPIRV::OpConstantI)
804 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
805 MAI->FPFastMathDefaultInfoMap) {
806 if (FPFastMathDefaultInfoVec.empty())
809 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
810 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
813 assert(Index < FPFastMathDefaultInfoVec.size() &&
814 "Index out of bounds for FPFastMathDefaultInfoVec");
815 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
816 assert(FPFastMathDefaultInfo.Ty &&
817 "Expected target type for FPFastMathDefaultInfo");
818 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
820 "Mismatched float type size");
822 Inst.
setOpcode(SPIRV::OpExecutionModeId);
823 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
829 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
831 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
832 if (FPFastMathDefaultInfo.ContractionOff &&
833 (Flags & SPIRV::FPFastMathMode::AllowContract))
835 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
837 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
839 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
840 SPIRV::FPFastMathMode::NSZ))) {
841 if (FPFastMathDefaultInfo.FPFastMathDefault)
843 "SignedZeroInfNanPreserve but at least one of "
844 "NotNaN/NotInf/NSZ is enabled.");
848 if (Flags == SPIRV::FPFastMathMode::None &&
849 !FPFastMathDefaultInfo.ContractionOff &&
850 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
851 !FPFastMathDefaultInfo.FPFastMathDefault)
858 "Mode operand of FPFastMathDefault execution mode.");
859 const MachineInstr *ConstMI = It->second;
860 MCRegister ConstReg = MAI->getRegisterAlias(
868void SPIRVAsmPrinter::outputModuleSections() {
869 const Module *
M = MMI->getModule();
871 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
872 TII =
ST->getInstrInfo();
873 MAI = &getAnalysis<SPIRVModuleAnalysis>().MAI;
874 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
876 if (!AuxDataHandler) {
877 auto Handler = std::make_unique<SPIRVAuxDataHandler>(*
this, *M);
878 if (Handler->hasWork())
879 AuxDataHandler = std::move(Handler);
887 AuxDataHandler->prepareModuleOutput(*ST, *MAI);
892 outputGlobalRequirements();
894 outputOpExtInstImports(*M);
896 outputOpMemoryModel();
901 outputExecutionMode(*M);
904 outputDebugSourceAndStrings(*M);
906 outputModuleSection(SPIRV::MB_DebugNames);
908 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
911 outputModuleSection(SPIRV::MB_AliasingInsts);
913 outputAnnotations(*M);
918 outputModuleSection(SPIRV::MB_TypeConstVars);
925 AuxDataHandler->emitAuxData(*MAI);
927 outputExtFuncDecls();
932bool SPIRVAsmPrinter::doInitialization(
Module &M) {
933 ModuleSectionsEmitted =
false;
934 if (!
M.getModuleInlineAsm().empty()) {
935 M.getContext().emitError(
936 "SPIR-V does not support module-level inline assembly");
937 M.setModuleInlineAsm(
"");
942 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
943 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
944 NSDebugHandler = Handler.get();
945 addAsmPrinterHandler(std::move(Handler));
951char SPIRVAsmPrinter::ID = 0;
958LLVMInitializeSPIRVAsmPrinter() {
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)