Skip to content

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

@joaosaffran

Description

@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
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)

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbackend:DirectXclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions