-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue to collect references to a group of similar or related issues.Issue to collect references to a group of similar or related issues.
Description
- Implement
length
clang builtin, - Link
length
clang builtin withhlsl_intrinsics.h
- Add sema checks for
length
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
#101096 - Add codegen for
length
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
- Add codegen tests to
clang/test/CodeGenHLSL/builtins/length.hlsl
- Add sema tests to
clang/test/SemaHLSL/BuiltIns/length-errors.hlsl
- Create the
int_dx_length
intrinsic inIntrinsicsDirectX.td
- Create an intrinsic expansion of
int_dx_length
inllvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
- Create the
length.ll
andlength_errors.ll
tests inllvm/test/CodeGen/DirectX/
- Create the
int_spv_length
intrinsic inIntrinsicsSPIRV.td
- In SPIRVInstructionSelector.cpp create the
length
lowering and map it toint_spv_length
inSPIRVInstructionSelector::selectIntrinsic
. - Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/length.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
24 | Sqrt | 6.0 | () |
SPIR-V
Length:
Description:
Length
Result is the length of vector x, i.e., sqrt(x [0] 2 +
x [1] 2 + …).
The operand x must be a scalar or vector whose component type is
floating-point.
Result Type must be a scalar of the same type as the component type of
x.
Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
---|---|---|---|---|
66 |
<id> |
Test Case(s)
Example 1
//dxc length_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float fn(float4 p1) {
return length(p1);
}
HLSL:
Returns the length of the specified floating-point vector.
ret length(x) |
---|
Parameters
Item | Description |
---|---|
x |
The specified floating-point vector. |
Return Value
A floating-point scalar that represents the length of the x parameter.
Type Description
Name | Template Type | Component Type | Size |
---|---|---|---|
x | vector | float | any |
ret | scalar | float | 1 |
Minimum Shader Model
This function is supported in the following shader models.
Shader Model | Supported |
---|---|
Shader Model 2 (DirectX HLSL) and higher shader models | yes |
Shader Model 1 (DirectX HLSL) | yes (vs_1_1 only) |
See also
Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue to collect references to a group of similar or related issues.Issue to collect references to a group of similar or related issues.
Type
Projects
Status
No status