[llvm] [SPIRV] Implement handle_fromBinding intrinsic. (PR #111052)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 08:50:37 PDT 2024


================
@@ -713,6 +713,29 @@ Register SPIRVGlobalRegistry::buildGlobalVariable(
   return Reg;
 }
 
+Register SPIRVGlobalRegistry::getOrCreateGlobalVariableWithBinding(
+    const SPIRVType *VarType, uint32_t Set, uint32_t Binding,
+    MachineIRBuilder &MIRBuilder) {
+  SPIRVType *VarPointerTypeReg = getOrCreateSPIRVPointerType(
+      VarType, MIRBuilder, SPIRV::StorageClass::UniformConstant);
+  Register VarReg =
+      MIRBuilder.getMRI()->createVirtualRegister(&SPIRV::iIDRegClass);
+
+  // TODO: The name should come from the llvm-ir, but how that name will be
+  // passed from the HLSL to the backend has not been decided. Using this place
+  // holder for now. We use the result register of the type in the name.
+  std::string name = ("__resource_" + Twine(VarType->getOperand(0).getReg()) +
----------------
s-perron wrote:

Right. I was able to get a case that failed. I fixed it up by building a string for the type based on the operands of the OpType* instruction. It currently only handled the type that could show up in an image. Let me know what you think.

https://github.com/llvm/llvm-project/pull/111052


More information about the llvm-commits mailing list