[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsics (PR #110739)

Finn Plummer via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 1 14:00:12 PDT 2024


================
@@ -2653,6 +2653,21 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
         .addUse(GR.getSPIRVTypeID(ResType))
         .addUse(GR.getOrCreateConstInt(3, I, IntTy, TII));
   }
+  case Intrinsic::spv_wave_read_lane_at: {
+    assert(I.getNumOperands() == 4);
+    assert(I.getOperand(2).isReg());
+    assert(I.getOperand(3).isReg());
+
+    // Defines the execution scope currently 2 for group, see scope table
+    SPIRVType *IntTy = GR.getOrCreateSPIRVIntegerType(32, I, TII);
+    return BuildMI(BB, I, I.getDebugLoc(),
+                   TII.get(SPIRV::OpGroupNonUniformShuffle))
+        .addDef(ResVReg)
+        .addUse(GR.getSPIRVTypeID(ResType))
+        .addUse(I.getOperand(2).getReg())
+        .addUse(I.getOperand(3).getReg())
+        .addUse(GR.getOrCreateConstInt(2, I, IntTy, TII));
----------------
inbelic wrote:

IIUC, an HLSL `wave` corresponds to the SPIR-V workgroup scope, which is denoted as 2.

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


More information about the cfe-commits mailing list