================
@@ -160,6 +160,24 @@ static Value *handleHlslSplitdouble(const CallExpr *E, 
CodeGenFunction *CGF) {
   return LastInst;
 }
 
+static Value *handleHlslWaveActiveBallot(const CallExpr *E,
+                                         CodeGenFunction *CGF) {
+  Value *Cond = CGF->EmitScalarExpr(E->getArg(0));
+  llvm::Type *I32 = CGF->Int32Ty;
+
+  if (CGF->CGM.getTarget().getTriple().isDXIL()) {
+    return CGF->EmitRuntimeCall(
+        CGF->CGM.getIntrinsic(Intrinsic::dx_wave_ballot, {I32}), Cond);
+  }
+
+  if (CGF->CGM.getTarget().getTriple().isSPIRV())
+    return CGF->EmitRuntimeCall(
+        CGF->CGM.getIntrinsic(Intrinsic::spv_wave_ballot), Cond);
----------------
farzonl wrote:

I have some concerns with these intrinsics being the same name and having 
different return types. 

Further I'm pretty sure this is going to break in the HLSL header when we call 
the `WaveActiveBallot` api because the return types are different but we are 
doing nothing in codegen to uniform them.

I think we should rename `spv_wave_ballot` to `spirv_subgroup_ballot`. Wave is 
not a concept in spirv and now that the intrinsics in DirectX and SPIRV no 
longer match we don't have to force a standard naming convention since we 
aren't using the intrinsic toggling helpers.


https://github.com/llvm/llvm-project/pull/175105
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to