[clang] 6bea9ff - [HLSL] Add WaveActiveCountBits as Langugage builtin function for HLSL
Xiang Li via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 2 13:06:08 PDT 2022
Author: Xiang Li
Date: 2022-06-02T13:06:01-07:00
New Revision: 6bea9ff91378571b3bedcdc12fac7bb916371871
URL: https://github.com/llvm/llvm-project/commit/6bea9ff91378571b3bedcdc12fac7bb916371871
DIFF: https://github.com/llvm/llvm-project/commit/6bea9ff91378571b3bedcdc12fac7bb916371871.diff
LOG: [HLSL] Add WaveActiveCountBits as Langugage builtin function for HLSL
One clang builtins are introduced
uint WaveActiveCountBits( bool bBit ) as Langugage builtin function for HLSL.
The detail for WaveActiveCountBits is at
https://github.com/microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics#uint-waveactivecountbits-bool-bbit-
This is only clang part change to make WaveActiveCountBits into AST.
llvm intrinsic for WaveActiveCountBits will be add in separate PR.
Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D126857
Added:
clang/test/SemaHLSL/Wave.hlsl
Modified:
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index e9b8ac6c602a4..6fb6d955557d2 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1693,6 +1693,9 @@ BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
// 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/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
index f7348f2b2a7c9..2761f5d282ac0 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -42,6 +42,7 @@ enum LanguageID {
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/test/SemaHLSL/Wave.hlsl b/clang/test/SemaHLSL/Wave.hlsl
new file mode 100644
index 0000000000000..ed64d1a5a55ba
--- /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);
+}
More information about the cfe-commits
mailing list