Skip to content

Implement the dot2add HLSL Function #99221

@farzonl

Description

@farzonl
  • Implement dot2add clang builtin,
  • Link dot2add clang builtin with hlsl_intrinsics.h
  • Add sema checks for dot2add to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for dot2add to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/dot2add.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
  • Create the int_dx_dot2add intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_dot2add to 162 in DXIL.td
  • Create the dot2add.ll and dot2add_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_dot2add intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the dot2add lowering and map it to int_spv_dot2add in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/dot2add.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
162 Dot2AddHalf 6.4 ()

SPIR-V

OpDot:

Description:

Dot product of Vector 1 and Vector 2.

Result Type must be a floating-point type scalar.

Vector 1 and Vector 2 must be vectors of the same type, and their
component type must be Result Type.

Word Count Opcode Results Operands

5

148

<id>
Result Type

Result <id>

<id>
Vector 1

<id>
Vector 2

Test Case(s)

Example 1

//dxc dot2add_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export float fn(half2 p1, half2 p2, float p3) {
    return dot2add(p1, p2, p3);
}

HLSL:

Syntax

float dot2add(float16_t<2> a, float16_t<2> b, float c);

Type Description

Name Template Type Component Type Size
ret scalar float 1
a vector half 2
b vector half 2
c scalar float 1

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 6.4 and higher shader models yes

Shader Stages

See also

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.metaissueIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions