================
@@ -3226,11 +3227,31 @@ class DiagnoseHLSLAvailability : public 
DynamicRecursiveASTVisitor {
   }
 
   bool VisitCallExpr(CallExpr *CE) override {
+    DiagnoseQuadAllCall(CE);
     DiagnoseBarrierCall(CE);
     return true;
   }
 };
 
+void DiagnoseHLSLAvailability::DiagnoseQuadAllCall(CallExpr *CE) {
+  const FunctionDecl *FD = CE->getDirectCallee();
+  if (!FD || FD->getBuiltinID() != Builtin::BI__builtin_hlsl_quad_all)
+    return;
+
+  switch (GetCurrentShaderEnvironment()) {
+  case llvm::Triple::UnknownEnvironment:
+  case llvm::Triple::Pixel:
+  case llvm::Triple::Compute:
+  case llvm::Triple::Mesh:
+  case llvm::Triple::Amplification:
+    return;
+  default:
+    SemaRef.Diag(CE->getExprLoc(), diag::err_hlsl_builtin_unsupported_in_stage)
+        << FD
+        << llvm::Triple::getEnvironmentTypeName(GetCurrentShaderEnvironment());
+  }
+}
+
----------------
hekota wrote:

Is there a way to specify per-stage availability in the 
`clang/include/clang/Basic/HLSLIntrinsics.td`? If not, then maybe the intrinsic 
should be instead defined in one of the headers included from `hlsl.h` with a 
set of availability attributes specifying the allowed stages. 

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

Reply via email to