diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h --- a/clang/include/clang/Basic/Builtins.h +++ b/clang/include/clang/Basic/Builtins.h @@ -42,6 +42,7 @@ OCL_PIPE = 0x200, // builtin requires OpenCL pipe. OCL_DSE = 0x400, // builtin requires OpenCL device side enqueue. ALL_OCL_LANGUAGES = 0x800, // builtin for OCL languages. + HLSL_LANG = 0x1000, // builtin requires HLSL. ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode. ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode. diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -1693,6 +1693,9 @@ // CUDA/HIP LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG) +// HLSL +LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG) + // Builtins for XRay BUILTIN(__xray_customevent, "vcC*z", "") BUILTIN(__xray_typedevent, "vzcC*z", "") diff --git a/clang/test/SemaHLSL/Wave.hlsl b/clang/test/SemaHLSL/Wave.hlsl new file mode 100644 --- /dev/null +++ b/clang/test/SemaHLSL/Wave.hlsl @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -x hlsl -triple dxil--shadermodel6.7-library %s -verify + +// Make sure WaveActiveCountBits is accepted. + +// expected-no-diagnostics +unsigned foo(bool b) { + return WaveActiveCountBits(b); +}