Skip to content

Implement the asint HLSL Function #99091

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
4 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 1 comment · Fixed by #110027
Closed
4 tasks
Tracked by #99235

Implement the asint HLSL Function #99091

farzonl opened this issue Jul 16, 2024 · 1 comment · Fixed by #110027
Assignees
Labels
bot:HLSL clang:headers Headers provided by Clang, e.g. for intrinsics 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: see how we did asfloat and asuint.

  • Link bitcast clang builtin for int with asint hlsl_intrinsics.h
  • Add checks for asint
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asint.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asint-errors.hlsl

DirectX

There were no DXIL opcodes found for asint.

SPIR-V

There were no SPIRV opcodes found for asint.

Test Case(s)

Example 1

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

export int4 fn(float p1) {
    return asint(p1);
}

Example 2

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

export int4 fn(uint p1) {
    return asint(p1);
}

Example 3

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

export int4 fn(int p1) {
    return asint(p1);
}

HLSL:

Interprets the bit pattern of x as an integer.

ret asint(x)

Parameters

Item Description
x
[in] The input value.

Return Value

The input interpreted as an integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, uint any
ret same as input x int 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)

@farzonl farzonl added 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
@inbelic
Copy link
Contributor

inbelic commented Sep 24, 2024

I will start working on this

inbelic added a commit to inbelic/llvm-project that referenced this issue Sep 25, 2024
Using clang's `__builtin_bit_cast`, implement the hlsl intrinsic
`asint`.

Follows implementation details of `asuint/asfloat`.

Fixes llvm#99091
inbelic added a commit to inbelic/llvm-project that referenced this issue Sep 25, 2024
Using clang's `__builtin_bit_cast`, implement the hlsl intrinsic
`asint`.

Follows implementation details of `asuint/asfloat`.

Fixes llvm#99091
inbelic added a commit that referenced this issue Sep 27, 2024
Using clang's `__builtin_bit_cast`, implement the hlsl intrinsic
`asint`.

Follows implementation details of `asuint/asfloat`.

Fixes #99091
@EugeneZelenko EugeneZelenko added the clang:headers Headers provided by Clang, e.g. for intrinsics label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:HLSL clang:headers Headers provided by Clang, e.g. for intrinsics HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants