[clang] [llvm] [HLSL] Add QuadAll Emulation support (PR #240645)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 13 00:18:58 PST 2026
================
@@ -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
More information about the cfe-commits
mailing list