Skip to content

Commit

Permalink
[HLSL] Add WaveActiveCountBits as Langugage builtin function for HLSL
Browse files Browse the repository at this point in the history
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
  • Loading branch information
python3kgae committed Jun 2, 2022
1 parent 1882c25 commit 6bea9ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/Builtins.def
Expand Up @@ -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", "")
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/Builtins.h
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions 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);
}

0 comments on commit 6bea9ff

Please sign in to comment.