-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Implement the countbits
HLSL Function
#99094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
looking at this |
@llvm/issue-subscribers-clang-frontend Author: Farzon Lotfi (farzonl)
> Note The SPIRV Work is completed https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L481C3-L482C63
> We just need to add the test case.
DirectX
SPIR-VOpBitCount:Description:Count the number of set bits in an object. Results are computed per component. Result Type must be a scalar or vector of integer type. Base must be a scalar or vector of integer type. It must The result is the unsigned value that is the number of bits in Base <table> Test Case(s)Example 1//dxc countbits_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(int4 p1) {
return countbits(p1);
} HLSL:Counts the number of bits (per component) set in the input integer. Syntaxuint countbits(
in uint value
); Parameters<dl> <dt> value [in] Type: uint The input value. </dd> </dl> Return valueType: uint The number of bits. RemarksThe following overloaded versions are also available: uint count_bits(uint value);
uint2 count_bits(uint2 value);
uint3 count_bits(uint3 value);
uint4 count_bits(uint4 value); Minimum Shader ModelThis function is supported in the following shader models.
This function is supported in the following types of shaders:
See also<dl> <dt> Intrinsic Functions Shader Model 5 |
@llvm/issue-subscribers-clang-codegen Author: Farzon Lotfi (farzonl)
> Note The SPIRV Work is completed https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L481C3-L482C63
> We just need to add the test case.
DirectX
SPIR-VOpBitCount:Description:Count the number of set bits in an object. Results are computed per component. Result Type must be a scalar or vector of integer type. Base must be a scalar or vector of integer type. It must The result is the unsigned value that is the number of bits in Base <table> Test Case(s)Example 1//dxc countbits_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(int4 p1) {
return countbits(p1);
} HLSL:Counts the number of bits (per component) set in the input integer. Syntaxuint countbits(
in uint value
); Parameters<dl> <dt> value [in] Type: uint The input value. </dd> </dl> Return valueType: uint The number of bits. RemarksThe following overloaded versions are also available: uint count_bits(uint value);
uint2 count_bits(uint2 value);
uint3 count_bits(uint3 value);
uint4 count_bits(uint4 value); Minimum Shader ModelThis function is supported in the following shader models.
This function is supported in the following types of shaders:
See also<dl> <dt> Intrinsic Functions Shader Model 5 |
Add new elementwise popcount builtin to support HLSL function 'countbits'. elementwise popcount only accepts integer types. Add hlsl intrinsic 'countbits' Closes llvm#99094
Uh oh!
There was an error while loading. Please reload this page.
countbits
clang builtin,countbits
clang builtin withhlsl_intrinsics.h
countbits
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
countbits
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/countbits.hlsl
clang/test/SemaHLSL/BuiltIns/countbits-errors.hlsl
DXILOpMapping
ofint_ctpop
to31
inDXIL.td
countbits.ll
andcountbits_errors.ll
tests inllvm/test/CodeGen/DirectX/
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/countbits.ll
DirectX
SPIR-V
OpBitCount:
Description:
Count the number of set bits in an object.
Results are computed per component.
Result Type must be a scalar or vector of integer type.
The components must be wide enough to hold the unsigned Width of
Base as an unsigned value. That is, no sign bit is needed or counted
when checking for a wide enough result width.
Base must be a scalar or vector of integer type. It must
have the same number of components as Result Type.
The result is the unsigned value that is the number of bits in Base
that are 1.
4
205
<id>
Result Type
Result <id>
<id>
Base
Test Case(s)
Example 1
HLSL:
Counts the number of bits (per component) set in the input integer.
Syntax
Parameters
value [in]
Type: uint
The input value.
Return value
Type: uint
The number of bits.
Remarks
The following overloaded versions are also available:
Minimum Shader Model
This function is supported in the following shader models.
This function is supported in the following types of shaders:
See also
Intrinsic Functions
Shader Model 5
The text was updated successfully, but these errors were encountered: