================
@@ -160,6 +160,26 @@ 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);
+
+  CGF->CGM.Error(E->getExprLoc(),
+                 "WaveActiveBallot is not supported for this target");
+
+  return llvm::PoisonValue::get(llvm::FixedVectorType::get(I32, 4));
----------------
inbelic wrote:

I think we tend to have an llvm_unreachable when it isn't a valid triple rather 
than reporting an error.

If this error is actually reachable then we should probably update the other 
implementations here.

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