-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Hlsl asuint16 function #132315
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 asuint16 function #132315
Changes from all commits
6ce249d
a912b35
8cabaa4
326b4d9
fb46c7e
0257f04
7eaedca
b1d0f39
4c0e763
3ff65ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // 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-LABEL: define {{.*}}test_ints | ||
| //CHECK-SAME: {{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}} | ||
| //CHECK-NOT: bitcast | ||
| //CHECK: entry: | ||
| //CHECK: ret i16 [[VAL]] | ||
| uint16_t test_int(int16_t p0) | ||
| { | ||
| return asuint16(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) | ||
| { | ||
| return asuint16(p0); | ||
| } | ||
|
|
||
| //CHECK-LABEL: define {{.*}}test_half | ||
| //CHECK-SAME: {{.*}}(half {{.*}} [[VAL:%.*]]){{.*}} | ||
| //CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16 | ||
| //CHECK-NEXT: ret i16 [[RES]] | ||
| uint16_t test_half(half p0) | ||
| { | ||
| return asuint16(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) | ||
| { | ||
| return asuint16(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) | ||
| { | ||
| return asuint16(p0); | ||
| } | ||
|
|
||
| //CHECK-LABEL: define {{.*}}fn | ||
| //CHECK-SAME: {{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}} | ||
| //CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16> | ||
| //CHECK-NEXT: ret <4 x i16> [[RES]] | ||
| uint16_t4 fn(half4 p1) | ||
| { | ||
| return asuint16(p1); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // 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@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but no arguments were provided}} | ||
| // expected-note@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@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'V', but 2 arguments were provided}} | ||
| // expected-note@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@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'int'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int]: no type named 'Type'}} | ||
|
Comment on lines
+25
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not an actionable item unless @farzonl has any ideas The notes here feel quite unhelpful from a user perspective. I'm guessing the error is that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a language overload resolution rule and not one we defined in sema there is not much we can do in this PR. Atleast nothing that woudn't be considered scope creep. Worth talk with Chris about though and see if there is something we can change. |
||
| } | ||
|
|
||
| int16_t test_asuint16_float(float p1) | ||
| { | ||
| return asuint16(p1); | ||
| // expected-error@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector<T, N>' against 'float'}} | ||
| // expected-note@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@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = int, N = 4]: no type named 'Type'}} | ||
| // expected-note@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@-1 {{no matching function for call to 'asuint16'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float, N = 4]: no type named 'Type'}} | ||
| // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float4]: no type named 'Type'}} | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add the Shader Model 6.2 availability macro to these two functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added suggested shader model macro.