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] Add new int overloads for math builtins #133162

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions clang/lib/Headers/hlsl/hlsl_compat_overloads.h

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions clang/test/CodeGenHLSL/builtins/acos-overloads.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK

// CHECK-LABEL: test_acos_double
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_double ( double p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_double2 ( double2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_double3 ( double3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_double4 ( double4 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_int ( int p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_int2 ( int2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_int3 ( int3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_int4 ( int4 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_uint ( uint p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_uint2 ( uint2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_uint3 ( uint3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_uint4 ( uint4 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int64_t
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_int64_t ( int64_t p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int64_t2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_int64_t2 ( int64_t2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int64_t3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_int64_t3 ( int64_t3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_int64_t4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_int64_t4 ( int64_t4 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint64_t
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_uint64_t ( uint64_t p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint64_t2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_uint64_t2 ( uint64_t2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint64_t3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_uint64_t3 ( uint64_t3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_uint64_t4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_uint64_t4 ( uint64_t4 p0 ) {
return acos ( p0 );
}
24 changes: 0 additions & 24 deletions clang/test/CodeGenHLSL/builtins/acos.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,3 @@ float3 test_acos_float3 ( float3 p0 ) {
float4 test_acos_float4 ( float4 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
float test_acos_double ( double p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
float2 test_acos_double2 ( double2 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
float3 test_acos_double3 ( double3 p0 ) {
return acos ( p0 );
}

// CHECK-LABEL: test_acos_double4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
float4 test_acos_double4 ( double4 p0 ) {
return acos ( p0 );
}
123 changes: 123 additions & 0 deletions clang/test/CodeGenHLSL/builtins/asin-overloads.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
// RUN: -o - | FileCheck %s --check-prefixes=CHECK

// CHECK-LABEL: test_asin_double
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_double ( double p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_double2 ( double2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_double3 ( double3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_double4 ( double4 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_int ( int p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_int2 ( int2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_int3 ( int3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_int4 ( int4 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_uint ( uint p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_uint2 ( uint2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_uint3 ( uint3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_uint4 ( uint4 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int64_t
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_int64_t ( int64_t p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int64_t2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_int64_t2 ( int64_t2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int64_t3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_int64_t3 ( int64_t3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_int64_t4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_int64_t4 ( int64_t4 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint64_t
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_uint64_t ( uint64_t p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint64_t2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_uint64_t2 ( uint64_t2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint64_t3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_uint64_t3 ( uint64_t3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_uint64_t4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_uint64_t4 ( uint64_t4 p0 ) {
return asin ( p0 );
}
24 changes: 0 additions & 24 deletions clang/test/CodeGenHLSL/builtins/asin.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,3 @@ float3 test_asin_float3 ( float3 p0 ) {
float4 test_asin_float4 ( float4 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
float test_asin_double ( double p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double2
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
float2 test_asin_double2 ( double2 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double3
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
float3 test_asin_double3 ( double3 p0 ) {
return asin ( p0 );
}

// CHECK-LABEL: test_asin_double4
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
float4 test_asin_double4 ( double4 p0 ) {
return asin ( p0 );
}
Loading
Loading