[llvm] [SPIRV] Add reads from image buffer for shaders. (PR #115178)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 12 07:23:07 PST 2024


================
@@ -1126,6 +1131,24 @@ SPIRVGlobalRegistry::getScalarOrVectorComponentCount(SPIRVType *Type) const {
              : 1;
 }
 
+SPIRVType *
+SPIRVGlobalRegistry::getScalarOrVectorComponentType(Register VReg) const {
+  return getScalarOrVectorComponentType(getSPIRVTypeForVReg(VReg));
+}
+
+SPIRVType *
+SPIRVGlobalRegistry::getScalarOrVectorComponentType(SPIRVType *Type) const {
+  if (!Type)
+    return nullptr;
+  Register ScalarReg = Type->getOpcode() == SPIRV::OpTypeVector
+                           ? Type->getOperand(1).getReg()
+                           : Type->getOperand(0).getReg();
+  SPIRVType *ScalarType = getSPIRVTypeForVReg(ScalarReg);
+  assert(isScalarOrVectorOfType(Type->getOperand(0).getReg(),
+                                ScalarType->getOpcode()));
+  return getSPIRVTypeForVReg(ScalarReg);
----------------
s-perron wrote:

Silly mistake when adding the assert. Thanks for catching it.

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


More information about the llvm-commits mailing list