Description
- Implement
firstbitlow
clang builtin,Linkfirstbitlow
clang builtin withhlsl_intrinsics.h
Add sema checks forfirstbitlow
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen forfirstbitlow
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/firstbitlow.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/firstbitlow-errors.hlsl
Create theint_dx_firstbitlow
intrinsic inIntrinsicsDirectX.td
Create theDXILOpMapping
ofint_dx_firstbitlow
to32
inDXIL.td
Create thefirstbitlow.ll
andfirstbitlow_errors.ll
tests inllvm/test/CodeGen/DirectX/
Create theint_spv_firstbitlow
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create thefirstbitlow
lowering and map it toint_spv_firstbitlow
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/firstbitlow.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
32 | FirstbitLo | 6.0 | () |
SPIR-V
FindILsb:
Description:
FindILsb
Integer least-significant bit.
Results in the bit number of the least-significant 1-bit in the binary
representation of Value. If Value is 0, the result is -1.
Result Type and the type of Value must both be integer scalar or
integer vector types. Result Type and operand types must have the same
number of components with the same component width. Results are computed
per component.
Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
---|---|---|---|---|
73 |
<id> |
Test Case(s)
Example 1
//dxc firstbitlow_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(int4 p1) {
return firstbitlow(p1);
}
HLSL:
Returns the location of the first set bit starting from the lowest order bit and working upward, per component.
Syntax
int firstbitlow(
in int value
);
Parameters
-
value [in]
-
Type: int
The input value.
Return value
Type: int
The location of the first set bit.
Remarks
The following overloaded versions are also available:
uint2 firstbitlow(uint2 value);
uint3 firstbitlow(uint3 value);
uint4 firstbitlow(uint4 value);
Minimum Shader Model
This function is supported in the following shader models.
Shader Model | Supported |
---|---|
Shader Model 5 and higher shader models | yes |
This function is supported in the following types of shaders:
Vertex | Hull | Domain | Geometry | Pixel | Compute |
---|---|---|---|---|---|
x | x | x | x | x | x |
See also
Metadata
Metadata
Assignees
Type
Projects
Status
Activity
spall commentedon Sep 11, 2024
looking at this
damyanp commentedon Sep 11, 2024
As discussed with @spall - keeping this around as a good starter issue.
15 remaining items