Skip to content
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

[HLSL] Implement _split double_ scenario for asuint in HLSL #108901

Closed
6 tasks done
Tracked by #99235 ...
joaosaffran opened this issue Sep 17, 2024 · 2 comments · Fixed by #109331
Closed
6 tasks done
Tracked by #99235 ...

[HLSL] Implement _split double_ scenario for asuint in HLSL #108901

joaosaffran opened this issue Sep 17, 2024 · 2 comments · Fixed by #109331
Assignees
Labels
backend:DirectX clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@joaosaffran
Copy link
Contributor

joaosaffran commented Sep 17, 2024

Implement asuint clang builtin,splitdouble,

  • Link asuint clang builtin with hlsl_intrinsics.h
  • Add sema checks for asuint to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asuint to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Use HLSL bit_cast to implement the SPIRV code gen
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asuint-splitdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asuint-splitdouble-errors.hlsl

This will implement the missing DXIL requirements for #70097

DXIL

Opcode DXIL OpName Shader Model Shader Stages Description
102 SplitDouble 6.0 () splits a double into low and high parts

SPIR-V

There is no support for asuint when targeting SPIR-V.

asuint

Interprets the bit pattern of x as an unsigned integer.

ret asuint(x)

Test Case(s)

Example 1

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

export uint4 fn(double4 p1, uint4 p2, uint4 p3) {
    asuint(p1, p2, p3);
    return p3;
}

Parameters

Item Description
x
[in] The input value.

Return Value

The input interpreted as an unsigned integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, int any
ret same as input x uint same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

See also

Intrinsic Functions (DirectX HLSL)

@EugeneZelenko EugeneZelenko added HLSL HLSL Language Support and removed new issue labels Sep 17, 2024
@pow2clk pow2clk moved this to Active in HLSL Support Sep 23, 2024
@damyanp damyanp moved this from Active to Needs Review in HLSL Support Oct 17, 2024
joaosaffran added a commit that referenced this issue Oct 28, 2024
- Adding hlsl `splitdouble` intrinsics
- Adding DXIL lowering
- Adding SPIRV lowering
- Adding test

Fixes: #108901

---------

Co-authored-by: Joao Saffran <jderezende@microsoft.com>
@github-project-automation github-project-automation bot moved this from Needs Review to Closed in HLSL Support Oct 28, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen labels Oct 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2024

@llvm/issue-subscribers-clang-codegen

Author: None (joaosaffran)

Implement `asuint` clang builtin,`splitdouble`,
  • Link asuint clang builtin with hlsl_intrinsics.h
  • Add sema checks for asuint to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asuint to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Use HLSL bit_cast to implement the SPIRV code gen
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asuint-splitdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asuint-splitdouble-errors.hlsl

This will implement the missing DXIL requirements for #70097

DXIL

Opcode DXIL OpName Shader Model Shader Stages Description
102 SplitDouble 6.0 () splits a double into low and high parts

SPIR-V

There is no support for asuint when targeting SPIR-V.

asuint

Interprets the bit pattern of x as an unsigned integer.

ret asuint(x)

Test Case(s)

Example 1

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

export uint4 fn(double4 p1, uint4 p2, uint4 p3) {
    asuint(p1, p2, p3);
    return p3;
}

Parameters

Item Description
<span id="x"></span><span id="X"></span>x<br/> [in] The input value.<br/>

Return Value

The input interpreted as an unsigned integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, int any
ret same as input x uint same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

See also

<dl> <dt>

Intrinsic Functions (DirectX HLSL)
</dt> </dl>

@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (joaosaffran)

Implement `asuint` clang builtin,`splitdouble`,
  • Link asuint clang builtin with hlsl_intrinsics.h
  • Add sema checks for asuint to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asuint to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Use HLSL bit_cast to implement the SPIRV code gen
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asuint-splitdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asuint-splitdouble-errors.hlsl

This will implement the missing DXIL requirements for #70097

DXIL

Opcode DXIL OpName Shader Model Shader Stages Description
102 SplitDouble 6.0 () splits a double into low and high parts

SPIR-V

There is no support for asuint when targeting SPIR-V.

asuint

Interprets the bit pattern of x as an unsigned integer.

ret asuint(x)

Test Case(s)

Example 1

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

export uint4 fn(double4 p1, uint4 p2, uint4 p3) {
    asuint(p1, p2, p3);
    return p3;
}

Parameters

Item Description
<span id="x"></span><span id="X"></span>x<br/> [in] The input value.<br/>

Return Value

The input interpreted as an unsigned integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, int any
ret same as input x uint same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

See also

<dl> <dt>

Intrinsic Functions (DirectX HLSL)
</dt> </dl>

NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this issue Nov 4, 2024
- Adding hlsl `splitdouble` intrinsics
- Adding DXIL lowering
- Adding SPIRV lowering
- Adding test

Fixes: llvm#108901

---------

Co-authored-by: Joao Saffran <jderezende@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX clang:codegen clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants