Description
- Implement
firstbithigh
clang builtin,Linkfirstbithigh
clang builtin withhlsl_intrinsics.h
Add sema checks forfirstbithigh
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen forfirstbithigh
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/firstbithigh.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/firstbithigh-errors.hlsl
Create theint_dx_firstbithigh
intrinsic inIntrinsicsDirectX.td
Create theDXILOpMapping
ofint_dx_firstbithigh
to34
inDXIL.td
Create thefirstbithigh.ll
andfirstbithigh_errors.ll
tests inllvm/test/CodeGen/DirectX/
Create theint_spv_firstbithigh
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create thefirstbithigh
lowering and map it toint_spv_firstbithigh
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/firstbithigh.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
34 | FirstbitSHi | 6.0 | () |
SPIR-V
FindSMsb:
Description:
FindSMsb
Signed-integer most-significant bit, with Value interpreted as a
signed integer.
For positive numbers, the result will be the bit number of the most
significant 1-bit. For negative numbers, the result will be the bit
number of the most significant 0-bit. For a Value of 0 or -1, 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.
This instruction is currently limited to 32-bit width components.
Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
---|---|---|---|---|
74 |
<id> |
Test Case(s)
Example 1
//dxc firstbithigh_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(int4 p1) {
return firstbithigh(p1);
}
HLSL:
Gets the location of the first set bit starting from the highest order bit and working downward, per component.
Syntax
int firstbithigh(
in int value
);
Parameters
-
value [in]
-
Type: int
The input value.
Return value
Type: int
The location of the first set bit.
Remarks
For a signed integer, the first significant bit is zero for a negative number.
The following overloaded versions are also available:
int2 firstbithigh(int2 value);
int3 firstbithigh(int3 value);
int4 firstbithigh(int4 value);
uint firstbithigh(uint value);
uint2 firstbithigh(uint2 value);
uint3 firstbithigh(uint3 value);
uint4 firstbithigh(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
Labels
Type
Projects
Status
Activity
spall commentedon Sep 11, 2024
looking at this
7 remaining items