Skip to content

Implement the asdouble HLSL Function #99081

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
9 tasks
Tracked by #99235 ...
farzonl opened this issue Jul 16, 2024 · 2 comments · Fixed by #114847
Closed
9 tasks
Tracked by #99235 ...

Implement the asdouble HLSL Function #99081

farzonl opened this issue Jul 16, 2024 · 2 comments · Fixed by #114847
Assignees
Labels
backend:DirectX bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" 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

NOTE: asdouble is special: there are questions around what the right design is for this. If 64-bit integers are supported then we don't need a specific DXIL operation to do this. We also need to consider what the right thing is for the SPIR-V backend.

  • Implement asdouble clang builtin,
  • Link asdouble clang builtin with hlsl_intrinsics.h
  • Add sema checks for asdouble to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asdouble to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asdouble-errors.hlsl
  • Create the int_dx_asdouble intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_asdouble to 101 in DXIL.td
  • Create the asdouble.ll and asdouble_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
101 MakeDouble 6.0 ()

SPIR-V

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

Test Case(s)

Example 1

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

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

HLSL:

Reinterprets a cast value (two 32-bit values) into a double.

Syntax

double asdouble(
  in uint lowbits,
  in uint highbits
);

Parameters

lowbits [in]

Type: uint

The low 32-bit pattern of the input value.

highbits [in]

Type: uint

The high 32-bit pattern of the input value.

Return value

Type: double

The input (two 32-bit values) recast as a double.

Remarks

The following overloaded version is also available:

double2 asdouble(uint2 lowbits, uint2 highbits);

If the input value is two 32-bit components, the return type will contain one double. If the input value is four 32-bit components, the return type will contain two doubles. If the input value is a 64-bit type, the returned value will have the same number of components as the input 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

Intrinsic Functions

Shader Model 5

@farzonl farzonl added backend:DirectX bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
This was referenced Jul 16, 2024
Closed
@damyanp damyanp moved this to Ready in HLSL Support Oct 9, 2024
@inbelic inbelic self-assigned this Oct 28, 2024
@damyanp damyanp moved this from Ready to Active in HLSL Support Oct 29, 2024
@inbelic inbelic moved this from Active to Needs Review in HLSL Support Nov 4, 2024
@inbelic inbelic moved this from Needs Review to Active in HLSL Support Nov 14, 2024
@damyanp damyanp moved this from Active to Needs Review in HLSL Support Nov 18, 2024
@github-project-automation github-project-automation bot moved this from Needs Review to Closed in HLSL Support Nov 22, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. labels Nov 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)

> NOTE: asdouble is special: there are questions around what the right design is for this. If 64-bit integers are supported then we don't need a specific DXIL operation to do this. We also need to consider what the right thing is for the SPIR-V backend.
  • Implement asdouble clang builtin,
  • Link asdouble clang builtin with hlsl_intrinsics.h
  • Add sema checks for asdouble to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asdouble to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asdouble-errors.hlsl
  • Create the int_dx_asdouble intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_asdouble to 101 in DXIL.td
  • Create the asdouble.ll and asdouble_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
101 MakeDouble 6.0 ()

SPIR-V

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

Test Case(s)

Example 1

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

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

HLSL:

Reinterprets a cast value (two 32-bit values) into a double.

Syntax

double asdouble(
  in uint lowbits,
  in uint highbits
);

Parameters

<dl> <dt>

lowbits [in]
</dt> <dd>

Type: uint

The low 32-bit pattern of the input value.

</dd> <dt>

highbits [in]
</dt> <dd>

Type: uint

The high 32-bit pattern of the input value.

</dd> </dl>

Return value

Type: double

The input (two 32-bit values) recast as a double.

Remarks

The following overloaded version is also available:

double2 asdouble(uint2 lowbits, uint2 highbits);

If the input value is two 32-bit components, the return type will contain one double. If the input value is four 32-bit components, the return type will contain two doubles. If the input value is a 64-bit type, the returned value will have the same number of components as the input 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

<dl> <dt>

Intrinsic Functions
</dt> <dt>

Shader Model 5
</dt> </dl>

@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/issue-subscribers-clang-frontend

Author: Farzon Lotfi (farzonl)

> NOTE: asdouble is special: there are questions around what the right design is for this. If 64-bit integers are supported then we don't need a specific DXIL operation to do this. We also need to consider what the right thing is for the SPIR-V backend.
  • Implement asdouble clang builtin,
  • Link asdouble clang builtin with hlsl_intrinsics.h
  • Add sema checks for asdouble to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asdouble to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asdouble-errors.hlsl
  • Create the int_dx_asdouble intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_asdouble to 101 in DXIL.td
  • Create the asdouble.ll and asdouble_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
101 MakeDouble 6.0 ()

SPIR-V

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

Test Case(s)

Example 1

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

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

HLSL:

Reinterprets a cast value (two 32-bit values) into a double.

Syntax

double asdouble(
  in uint lowbits,
  in uint highbits
);

Parameters

<dl> <dt>

lowbits [in]
</dt> <dd>

Type: uint

The low 32-bit pattern of the input value.

</dd> <dt>

highbits [in]
</dt> <dd>

Type: uint

The high 32-bit pattern of the input value.

</dd> </dl>

Return value

Type: double

The input (two 32-bit values) recast as a double.

Remarks

The following overloaded version is also available:

double2 asdouble(uint2 lowbits, uint2 highbits);

If the input value is two 32-bit components, the return type will contain one double. If the input value is four 32-bit components, the return type will contain two doubles. If the input value is a 64-bit type, the returned value will have the same number of components as the input 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

<dl> <dt>

Intrinsic Functions
</dt> <dt>

Shader Model 5
</dt> </dl>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" 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