[clang] [llvm] Hlsl asuint16 function (PR #132315)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 20 18:00:45 PDT 2025
https://github.com/metkarpoonam updated https://github.com/llvm/llvm-project/pull/132315
>From 6ce249d7e4bea669480c06a935f88a21894aba67 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Wed, 19 Mar 2025 09:16:30 -0700
Subject: [PATCH 1/8] Add asuint16 intrinsic and codegen test
---
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 17 +++++++
clang/test/CodeGenHLSL/builtins/asuint16.hlsl | 48 +++++++++++++++++++
2 files changed, 65 insertions(+)
create mode 100644 clang/test/CodeGenHLSL/builtins/asuint16.hlsl
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index a48a8e998a015..4d06aa7f5e207 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -80,6 +80,23 @@ void asuint(double3, out uint3, out uint3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
void asuint(double4, out uint4, out uint4);
+//===----------------------------------------------------------------------===//
+// asuint16 builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn uint16_t asuint16(T Val)
+/// \brief Interprets the bit pattern of x as an 16-bit unsigned integer.
+/// \param Val The input value.
+#ifdef __HLSL_ENABLE_16BIT
+template <typename T, int N> constexpr vector<uint16_t, N> asuint16(vector<T, N> V) {
+ return __detail::bit_cast<uint16_t, T, N>(V);
+}
+
+template <typename T> constexpr uint16_t asuint16(T F) {
+ return __detail::bit_cast<uint16_t, T>(F);
+}
+#endif
+
//===----------------------------------------------------------------------===//
// distance builtins
//===----------------------------------------------------------------------===//
diff --git a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
new file mode 100644
index 0000000000000..7387520947efe
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
+// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+// CHECK-NOT: bitcast
+// CHECK: ret i16 [[VAL]]
+uint16_t test_int(int16_t p0)
+{
+ return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_uint{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret i16 [[VAL]]
+uint16_t test_uint(uint16_t p0)
+{
+ return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_half{{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16
+//CHECK : ret i16 [[RES]]
+uint16_t test_half(half p0)
+{
+ return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+uint16_t4 test_vector_int(int16_t4 p0)
+{
+ return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+uint16_t4 test_vector_uint(uint16_t4 p0)
+{
+ return asuint16(p0);
+}
+
+//CHECK: define {{.*}}fn{{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16>
+//CHECK: ret <4 x i16> [[RES]]
+uint16_t4 fn(half4 p1)
+{
+ return asuint16(p1);
+}
>From a912b35743a13079679b111702dbe313ec0683ee Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 11:06:29 -0700
Subject: [PATCH 2/8] Update the uint16 function call and add space in
uint16.hlsl
---
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 23 ++++++++++++++-----
clang/test/CodeGenHLSL/builtins/asuint16.hlsl | 2 ++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 4d06aa7f5e207..70cbed851f0f0 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -84,15 +84,26 @@ void asuint(double4, out uint4, out uint4);
// asuint16 builtins
//===----------------------------------------------------------------------===//
-/// \fn uint16_t asuint16(T Val)
-/// \brief Interprets the bit pattern of x as an 16-bit unsigned integer.
-/// \param Val The input value.
-#ifdef __HLSL_ENABLE_16BIT
-template <typename T, int N> constexpr vector<uint16_t, N> asuint16(vector<T, N> V) {
+/// \fn uint16_t asuint16(T X)
+/// \brief Interprets the bit pattern of \a X as an 16-bit unsigned integer.
+/// \param X The input value.
+#ifdef __HLSL_ENABLE_16_BIT
+
+template <typename T, int N>
+constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||
+ __detail::is_same<uint16_t, T>::value ||
+ __detail::is_same<half, T>::value,
+ vector<uint16_t, N>>
+asuint16(vector<T, N> V) {
return __detail::bit_cast<uint16_t, T, N>(V);
}
-template <typename T> constexpr uint16_t asuint16(T F) {
+template <typename T>
+constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||
+ __detail::is_same<uint16_t, T>::value ||
+ __detail::is_same<half, T>::value,
+ uint16_t>
+asuint16(T F) {
return __detail::bit_cast<uint16_t, T>(F);
}
#endif
diff --git a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
index 7387520947efe..49b36ee64dc8d 100644
--- a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
+
// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
// CHECK-NOT: bitcast
// CHECK: ret i16 [[VAL]]
@@ -46,3 +47,4 @@ uint16_t4 fn(half4 p1)
{
return asuint16(p1);
}
+
>From 8cabaa41bf0ed780444df21e73c6125303108dcb Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 11:53:42 -0700
Subject: [PATCH 3/8] Add sema tests to asuint16-errors.hlsl
---
.../SemaHLSL/BuiltIns/asuint16-errors.hlsl | 51 +++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
diff --git a/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
new file mode 100644
index 0000000000000..364eb828d81f4
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -verify
+
+uint16_t test_asuint16_less_argument()
+{
+ return asuint16();
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but no arguments were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'F', but no arguments were provided}}
+
+}
+
+int16_t4 test_asuint16_too_many_arg(uint16_t p0, uint16_t p1)
+{
+ return asuint16(p0, p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but 2 arguments were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'F', but 2 arguments were provided}}
+
+}
+
+int16_t test_asuint16_int(int p1)
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'int'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type'}}
+}
+
+int16_t test_asuint16_float(float p1)
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'float'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float]: no type named 'Type'}}
+}
+
+int16_t4 test_asuint16_vector_int(int4 p1)
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int, N = 4]: no type named 'Type'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int4]: no type named 'Type'}}
+}
+
+int16_t4 test_asuint16_vector_float(float4 p1)
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float, N = 4]: no type named 'Type'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float4]: no type named 'Type'}}
+}
>From 326b4d9fab3169e09f518efc14481502c02fc7b9 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 14:05:05 -0700
Subject: [PATCH 4/8] Update asuint16.ll
---
.../CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
new file mode 100644
index 0000000000000..3c9e6733c1805
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
@@ -0,0 +1,37 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK-DAG: %[[#half:]] = OpTypeFloat 16
+; CHECK-DAG: %[[#uint_16:]] = OpTypeInt 16 0
+; CHECK-DAG: %[[#v4uint_16:]] = OpTypeVector %[[#uint_16]] 4
+; CHECK-DAG: %[[#v4half:]] = OpTypeVector %[[#half]] 4
+
+define i16 @test_half(half nofpclass(nan inf) %p0) {
+entry:
+ %0 = bitcast half %p0 to i16
+ ret i16 %0
+
+ ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#half]]
+ ; CHECK: %[[#bit_cast:]] = OpBitcast %[[#uint_16]] %[[#arg0]]
+ ; CHECK: OpReturnValue %[[#bit_cast]]
+}
+
+define noundef <4 x i16> @test_vector_half(<4 x half> nofpclass(nan inf) %p1) {
+entry:
+ %0 = bitcast <4 x half> %p1 to <4 x i16>
+ ret <4 x i16> %0
+
+ ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#v4half]]
+ ; CHECK: %[[#bit_cast:]] = OpBitcast %[[#v4uint_16]] %[[#arg0]]
+ ; CHECK: OpReturnValue %[[#bit_cast]]
+}
+
+attributes #0 = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+
+!llvm.module.flags = !{!0}
+!dx.valver = !{!1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, i32 8}
+!2 = !{!"clang version 21.0.0git (https://github.com/llvm/llvm-project.git 8037234c865d98219b54a70d9d63aee1d1f2be1c)"}
>From fb46c7e7aa5acd09c82085433c651fcb6706bbfd Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 15:58:38 -0700
Subject: [PATCH 5/8] WIP on asuint16.hlsl
---
clang/test/CodeGenHLSL/builtins/asuint16.hlsl | 28 +++++++++++--------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
index 49b36ee64dc8d..80948b52739cc 100644
--- a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
-// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}test_ints
+//CHECK-SAME: {{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
// CHECK-NOT: bitcast
// CHECK: ret i16 [[VAL]]
uint16_t test_int(int16_t p0)
@@ -8,41 +9,46 @@ uint16_t test_int(int16_t p0)
return asuint16(p0);
}
-//CHECK: define {{.*}}test_uint{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}test_uint
+//CHECK-SAME: {{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
-//CHECK: ret i16 [[VAL]]
+//CHECK-NEXT: ret i16 [[VAL]]
uint16_t test_uint(uint16_t p0)
{
return asuint16(p0);
}
-//CHECK: define {{.*}}test_half{{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}test_half
+//CHECK-SAME: {{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
//CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16
-//CHECK : ret i16 [[RES]]
+//CHECK-NEXT: ret i16 [[RES]]
uint16_t test_half(half p0)
{
return asuint16(p0);
}
-//CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}test_vector_int
+//CHECK-SAME: {{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
-//CHECK: ret <4 x i16> [[VAL]]
+//CHECK-NEXT: ret <4 x i16> [[VAL]]
uint16_t4 test_vector_int(int16_t4 p0)
{
return asuint16(p0);
}
-//CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}test_vector_uint
+//CHECK-SAME: {{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
-//CHECK: ret <4 x i16> [[VAL]]
+//CHECK-NEXT: ret <4 x i16> [[VAL]]
uint16_t4 test_vector_uint(uint16_t4 p0)
{
return asuint16(p0);
}
-//CHECK: define {{.*}}fn{{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-LABEL: define {{.*}}fn
+//CHECK-SAME: {{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
//CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16>
-//CHECK: ret <4 x i16> [[RES]]
+//CHECK-NEXT: ret <4 x i16> [[RES]]
uint16_t4 fn(half4 p1)
{
return asuint16(p1);
>From 0257f04a3ef2e68f265432478dd00650420e588c Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 17:33:43 -0700
Subject: [PATCH 6/8] Update codegen asuint16.hlsl test
---
clang/test/CodeGenHLSL/builtins/asuint16.hlsl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
index 80948b52739cc..0efda5f9331a9 100644
--- a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
@@ -3,6 +3,7 @@
//CHECK-LABEL: define {{.*}}test_ints
//CHECK-SAME: {{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
// CHECK-NOT: bitcast
+//CHECK: entry:
// CHECK: ret i16 [[VAL]]
uint16_t test_int(int16_t p0)
{
@@ -12,6 +13,7 @@ uint16_t test_int(int16_t p0)
//CHECK-LABEL: define {{.*}}test_uint
//CHECK-SAME: {{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
+//CHECK: entry:
//CHECK-NEXT: ret i16 [[VAL]]
uint16_t test_uint(uint16_t p0)
{
@@ -30,6 +32,7 @@ uint16_t test_half(half p0)
//CHECK-LABEL: define {{.*}}test_vector_int
//CHECK-SAME: {{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
+//CHECK: entry:
//CHECK-NEXT: ret <4 x i16> [[VAL]]
uint16_t4 test_vector_int(int16_t4 p0)
{
@@ -39,6 +42,7 @@ uint16_t4 test_vector_int(int16_t4 p0)
//CHECK-LABEL: define {{.*}}test_vector_uint
//CHECK-SAME: {{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
//CHECK-NOT: bitcast
+//CHECK: entry:
//CHECK-NEXT: ret <4 x i16> [[VAL]]
uint16_t4 test_vector_uint(uint16_t4 p0)
{
>From 7eaedcad47233444c2d4c89e5a39c62998cd232d Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 17:53:06 -0700
Subject: [PATCH 7/8] Add new line to the asuint16-errors.hlsl
---
.../SemaHLSL/BuiltIns/asuint16-errors.hlsl | 78 +++++++++----------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
index 364eb828d81f4..3580fd639a12f 100644
--- a/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
@@ -1,51 +1,51 @@
-// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -verify
-
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -verify
+
uint16_t test_asuint16_less_argument()
{
return asuint16();
- // expected-error at -1 {{no matching function for call to 'asuint16'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but no arguments were provided}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'F', but no arguments were provided}}
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but no arguments were provided}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'F', but no arguments were provided}}
+
+}
-}
-
int16_t4 test_asuint16_too_many_arg(uint16_t p0, uint16_t p1)
-{
- return asuint16(p0, p1);
+{
+ return asuint16(p0, p1);
// expected-error at -1 {{no matching function for call to 'asuint16'}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but 2 arguments were provided}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'F', but 2 arguments were provided}}
-
-}
-
+
+}
+
int16_t test_asuint16_int(int p1)
-{
- return asuint16(p1);
- // expected-error at -1 {{no matching function for call to 'asuint16'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'int'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type'}}
-}
-
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'int'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type'}}
+}
+
int16_t test_asuint16_float(float p1)
-{
- return asuint16(p1);
- // expected-error at -1 {{no matching function for call to 'asuint16'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'float'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float]: no type named 'Type'}}
-}
-
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'float'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float]: no type named 'Type'}}
+}
+
int16_t4 test_asuint16_vector_int(int4 p1)
-{
- return asuint16(p1);
- // expected-error at -1 {{no matching function for call to 'asuint16'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int, N = 4]: no type named 'Type'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int4]: no type named 'Type'}}
-}
-
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int, N = 4]: no type named 'Type'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int4]: no type named 'Type'}}
+}
+
int16_t4 test_asuint16_vector_float(float4 p1)
-{
- return asuint16(p1);
- // expected-error at -1 {{no matching function for call to 'asuint16'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float, N = 4]: no type named 'Type'}}
- // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float4]: no type named 'Type'}}
-}
+{
+ return asuint16(p1);
+ // expected-error at -1 {{no matching function for call to 'asuint16'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float, N = 4]: no type named 'Type'}}
+ // expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float4]: no type named 'Type'}}
+}
>From b1d0f3910fad27d9c9e2ec39485c0ef302d06091 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar <poonammetkar at microsoft.com>
Date: Thu, 20 Mar 2025 18:00:25 -0700
Subject: [PATCH 8/8] Add new line to the asuint16-errors.hlsl and asuint16.ll
---
clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl | 1 +
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll | 1 +
2 files changed, 2 insertions(+)
diff --git a/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
index 3580fd639a12f..bd29f3fd23262 100644
--- a/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl
@@ -49,3 +49,4 @@ int16_t4 test_asuint16_vector_float(float4 p1)
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float, N = 4]: no type named 'Type'}}
// expected-note at hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float4]: no type named 'Type'}}
}
+
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
index 3c9e6733c1805..255f9b21f8d73 100644
--- a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
+++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asuint16.ll
@@ -35,3 +35,4 @@ attributes #0 = { alwaysinline mustprogress nofree norecurse nosync nounwind wil
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 8}
!2 = !{!"clang version 21.0.0git (https://github.com/llvm/llvm-project.git 8037234c865d98219b54a70d9d63aee1d1f2be1c)"}
+
More information about the llvm-commits
mailing list