Skip to content

Implement the asuint HLSL Function #70097

Closed
@llvm-beanz

Description

@llvm-beanz
  • Implement asuint clang builtin,
  • 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
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asuint.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asuint-errors.hlsl

DirectX

There were no DXIL opcodes found for most asuint cases. There is an opcode for the three arg case:

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.

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;
}

Example 2

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

export uint4 fn(float p1) {
    return asuint(p1);
}

Example 3

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

export uint4 fn(uint p1) {
    return asuint(p1);
}

Example 4

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

export uint4 fn(int p1) {
    return asuint(p1);
}

HLSL:

Interprets the bit pattern of x as an unsigned integer.

ret asuint(x)

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 Support

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions