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

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 04:31:32 PST 2024


================
@@ -2803,6 +2816,83 @@ void SPIRVInstructionSelector::selectHandleFromBinding(Register &ResVReg,
       .addUse(VarReg);
 }
 
+void SPIRVInstructionSelector::selectReadImageIntrinsic(
+    Register &ResVReg, const SPIRVType *ResType, MachineInstr &I) const {
+
+  // If the load of the image is in a different basic block, then
+  // this will generate invalid code. A proper solution is to move
+  // the OpLoad from selectHandleFromBinding here. However, to do
+  // that we will need to change the return type of the intrinsic.
+  // We will do that when we can, but for now trying to move forward with other
+  // issues.
+  Register ImageReg = I.getOperand(2).getReg();
----------------
Keenuts wrote:

Can we assert the defining register of this reg has the same parent (BB) as the instruction we add? This way we crash when we generate invalid code, and know something has to be fixed.

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


More information about the llvm-commits mailing list