Lines Matching +full:ext +full:- +full:regs

1 //===- SPIRVModuleAnalysis.cpp - analysis of global instrs & regs - C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
31 #define DEBUG_TYPE "spirv-module-analysis"
34 SPVDumpDeps("spv-dump-deps",
35 cl::desc("Dump MIR with SPIR-V dependencies info"),
39 AvoidCapabilities("avoid-spirv-capabilities",
40 cl::desc("SPIR-V capabilities to avoid if there are "
44 "SPIR-V Shader capability")));
66 if (MdNode && OpIndex < MdNode->getNumOperands()) {
67 const auto &Op = MdNode->getOperand(OpIndex);
68 return mdconst::extract<ConstantInt>(Op)->getZExtValue();
100 // By SPIR-V specification: "If an instruction, enumerant, or other
112 if (i == Sz - 1 || !AvoidCaps.S.contains(Cap))
120 if (llvm::all_of(ReqExts, [&ST](const SPIRV::Extension::Extension &Ext) {
121 return ST.canUseExtension(Ext);
146 auto MemMD = MemModel->getOperand(0);
153 MAI.Mem = ST->isOpenCLEnv() ? SPIRV::MemoryModel::OpenCL
156 unsigned PtrSize = ST->getPointerSize();
169 // Construct version literal in accordance with SPIRV-LLVM-Translator.
171 assert(VerNode->getNumOperands() > 0 && "Invalid SPIR");
172 auto VersionMD = VerNode->getOperand(0);
182 // run-times with Unknown/0.0 version output. For a reference, LLVM-SPIRV
183 // Translator avoids potential issues with run-times in a similar manner.
184 if (ST->isOpenCLEnv()) {
194 for (unsigned I = 0, E = ExtNode->getNumOperands(); I != E; ++I) {
195 MDNode *MD = ExtNode->getOperand(I);
196 if (!MD || MD->getNumOperands() == 0)
198 for (unsigned J = 0, N = MD->getNumOperands(); J != N; ++J)
199 MAI.SrcExt.insert(cast<MDString>(MD->getOperand(J))->getString());
212 if (ST->isOpenCLEnv()) {
225 assert(MAI->hasRegisterAlias(MF, Reg) && "Cannot find register alias");
226 MachineInstr *MI = MF->getRegInfo().getUniqueVRegDef(Reg);
228 MAI->setSkipEmission(MI);
230 MAI->MS[MSType].push_back(MI);
249 // Traversing deps graph in post-order allows us to get rid of
251 // But pre-order is required for correct processing of function
254 for (auto *S : E->getDeps())
263 if (!MF->getRegInfo().getUniqueVRegDef(Reg))
267 if (E->getIsGV())
268 MAI.GlobalVarList.push_back(MF->getRegInfo().getUniqueVRegDef(Reg));
272 for (auto *S : E->getDeps())
286 GR->buildDepsGraph(DepsGraph, SPVDumpDeps ? MMI : nullptr);
290 [](const SPIRV::DTSortableEntry *E) { return !E->getIsFunc(); });
293 MachineFunction *MF = MMI->getMachineFunction(*F);
301 auto Ext = SPIRV::Extension::Extension(MI.getOperand(0).getImm());
302 MAI.Reqs.addExtension(Ext);
315 [](const SPIRV::DTSortableEntry *E) { return E->getIsFunc(); }, true);
328 auto Lnk = MI.getOperand(MI.getNumOperands() - 1).getImm();
332 F->getParent()->getFunction(getStringImm(MI, 2));
339 Register Reg = MI.defs().begin()->getReg();
352 if (MI->getOpcode() == SPIRV::OpConstantFunctionPointerINTEL)
357 const MachineOperand *FunUse = &MI->getOperand(2);
358 if (const MachineOperand *FunDef = GR->getFunctionDefinitionByUse(FunUse)) {
359 const MachineInstr *FunDefMI = FunDef->getParent();
360 assert(FunDefMI->getOpcode() == SPIRV::OpFunction &&
362 Register FunDefReg = FunDef->getReg();
364 MAI.getRegisterAlias(FunDefMI->getMF(), FunDefReg);
367 Register FunPtrReg = FunUse->getReg();
368 MAI.setRegisterAlias(MI->getMF(), FunPtrReg, GlobalFunDefReg);
416 // Some global instructions make reference to function-local ID regs, so cannot
423 MachineFunction *MF = MMI->getMachineFunction(*F);
434 } else if (TII->isDecorationInstr(MI)) {
437 } else if (TII->isConstantInstr(MI)) {
457 MachineFunction *MF = MMI->getMachineFunction(*F);
500 if (!IsNewlyInserted) // Don't re-add if it's already been declared.
512 report_fatal_error("Adding SPIR-V requirements this target can't satisfy.");
523 report_fatal_error("Adding SPIR-V requirements that can't be satisfied.");
534 report_fatal_error("Adding SPIR-V requirements that can't be satisfied.");
550 dbgs() << "Target SPIR-V version too high for required features\n"
557 LLVM_DEBUG(dbgs() << "Target SPIR-V version too low for required features\n"
567 << "Required SPIR-V min version: " << MinVersion
568 << " required SPIR-V max version " << MaxVersion << "\n");
582 for (auto Ext : AllExtensions) {
583 if (ST.canUseExtension(Ext))
587 OperandCategory::ExtensionOperand, Ext)
593 report_fatal_error("Unable to meet SPIR-V requirements for this target.");
624 report_fatal_error("Unimplemented environment for SPIR-V generation.");
629 // Add the min requirements for different OpenCL and SPIR-V versions.
701 int64_t LinkageOp = MI.getOperand(MI.getNumOperands() - 1).getImm();
774 "The atomic float instruction requires the following SPIR-V " \
782 SPIRVType *TypeDef = MI.getMF()->getRegInfo().getVRegDef(TypeReg);
783 if (TypeDef->getOpcode() != SPIRV::OpTypeFloat)
785 "floating-point type scalar");
787 unsigned BitWidth = TypeDef->getOperand(1).getImm();
809 "Unexpected floating-point type width in atomic float instruction");
828 "Unexpected floating-point type width in atomic float instruction");
895 const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
897 if (TypeDef->getOpcode() == SPIRV::OpTypeFloat &&
898 TypeDef->getOperand(1).getImm() == 16)
970 const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
977 assert(InstrPtr->getOperand(1).isReg() && "Unexpected operand in atomic");
978 Register TypeReg = InstrPtr->getOperand(1).getReg();
980 if (TypeDef->getOpcode() == SPIRV::OpTypeInt) {
981 unsigned BitWidth = TypeDef->getOperand(1).getImm();
1109 "following SPIR-V extension: SPV_KHR_subgroup_rotate",
1132 "following SPIR-V extension: SPV_KHR_shader_clock",
1175 "following SPIR-V extension: SPV_KHR_cooperative_matrix",
1195 MachineFunction *MF = MMI->getMachineFunction(*F);
1208 for (unsigned i = 0; i < Node->getNumOperands(); i++) {
1209 MDNode *MDN = cast<MDNode>(Node->getOperand(i));
1210 const MDOperand &MDOp = MDN->getOperand(1);
1212 Constant *C = CMeta->getValue();
1214 auto EM = Const->getZExtValue();
1316 MachineFunction *MF = MMI->getMachineFunction(*F);
1336 GR = ST->getSPIRVGlobalRegistry();
1337 TII = ST->getInstrInfo();
1355 if (GR->hasConstFunPtr())
1366 GR->setBound(MAI.MaxID);