Skip to content

Implement the dot2add HLSL Function #99221

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

Closed
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 2 comments · Fixed by #131237
Closed
12 tasks
Tracked by #99235

Implement the dot2add HLSL Function #99221

farzonl opened this issue Jul 16, 2024 · 2 comments · Fixed by #131237
Assignees
Labels
bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • 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

@farzonl farzonl added backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Planning to Ready in HLSL Support Jan 21, 2025
@sumitsays
Copy link
Contributor

Will start working on this.

@damyanp damyanp moved this from Ready to Active in HLSL Support Feb 6, 2025
@V-FEXrt V-FEXrt moved this from Active to Needs Review in HLSL Support Apr 3, 2025
@V-FEXrt V-FEXrt closed this as completed in 996cf5d Apr 3, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Closed in HLSL Support Apr 3, 2025
@EugeneZelenko EugeneZelenko added clang:codegen IR generation bugs: mangling, exceptions, etc. and removed backend:DirectX backend:SPIR-V labels Apr 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2025

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (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.

<table style="width:100%;">
<colgroup>
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
</colgroup>
<thead>
<tr>
<th>Word Count</th>
<th>Opcode</th>
<th>Results</th>
<th>Operands</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p>5</p></td>
<td class="tableblock halign-left valign-top"><p>148</p></td>
<td
class="tableblock halign-left valign-top"><p><em>&lt;id&gt;</em><br />
<em>Result Type</em></p></td>
<td class="tableblock halign-left valign-top"><p><a
href="#ResultId"><em>Result &lt;id&gt;</em></a></p></td>
<td
class="tableblock halign-left valign-top"><p><em>&lt;id&gt;</em><br />
<em>Vector 1</em></p></td>
<td
class="tableblock halign-left valign-top"><p><em>&lt;id&gt;</em><br />
<em>Vector 2</em></p></td>
</tr>
</tbody>
</table>

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&lt;2&gt; a, float16_t&lt;2&gt; 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

4 participants