[llvm] [DXIL] Add GroupMemoryBarrierWithGroupSync intrinsic (PR #111884)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 06:53:35 PDT 2024


================
@@ -477,6 +500,11 @@ class OpLowerer {
     HasErrors |= replaceFunctionWithOp(F, OpCode);                             \
     break;
 #include "DXILOperation.inc"
+      case Intrinsic::dx_group_memory_barrier_with_group_sync:
----------------
bogner wrote:

I don't really like this pattern of defining extra llvm intrinsics just for a lowering phase.

As far as I can tell there are a few ways to design the intrinsics for barriers:
1. Have one llvm intrinsic with arguments for the barrier mode. This would either need to match DXIL's mask (which means we need to expose the `BarrierMode` enum in `DXILABI.h`) or we'd still need custom lowering to translate it
2. Have the LLVM intrinsics map to the HLSL operations and figure out the mask for the DXIL operation later.
3. 3 Have both of these representations and thus potentially have to handle them both throughout the compiler

I prefer (2), as (1) makes lowering to SPIR-V a bit messier in that it needs to be aware of random DXIL enums. (3) really just means we have to deal with both, which seems worse to me.

So if that's the case then the question is can we avoid needing custom lowering in DXILOpLowering to map the intrinsic to the barrier masks? Can we enhance DXIL.td to embed this information so the generic lowering can take care of this? Or can make replaceFunctionWithOp more modular and have a way to pass it extra arguments to pass on?

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


More information about the llvm-commits mailing list