[PATCH] D126857: [HLSL] Add WaveActiveCountBits as Langugage builtin function for HLSL
Xiang Li via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 2 00:28:19 PDT 2022
python3kgae created this revision.
python3kgae added reviewers: Anastasia, svenvh, jdoerfert, azabaznov, beanz, tra, yaxunl, pow2clk.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126857
Files:
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/test/SemaHLSL/Wave.hlsl
Index: clang/test/SemaHLSL/Wave.hlsl
===================================================================
--- /dev/null
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x hlsl -triple dxil--shadermodel6.7-library -ast-dump %s -o - -finclude-default-header | FileCheck %s
+
+// Make sure WaveActiveCountBits is used in AST.
+// CHECK: BuiltinFnToFnPtr>
+// CHECK-NEXT:-DeclRefExpr 0x{{.*}} <col:12> '<builtin fn type>' Function 0x{{.*}} 'WaveActiveCountBits' 'unsigned int (bool)
+uint foo(bool b) {
+ return WaveActiveCountBits(b);
+}
\ No newline at end of file
Index: clang/include/clang/Basic/Builtins.h
===================================================================
--- clang/include/clang/Basic/Builtins.h
+++ 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.
Index: clang/include/clang/Basic/Builtins.def
===================================================================
--- clang/include/clang/Basic/Builtins.def
+++ 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", "")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126857.433671.patch
Type: text/x-patch
Size: 1789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220602/9bab2e7a/attachment.bin>
More information about the cfe-commits
mailing list