-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[HLSL] Add "or" intrinsic #128979
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 "or" intrinsic #128979
Changes from 9 commits
08e1912
eae4c9f
aa69604
659f2fc
39ebc00
a770cbf
cc26694
d99e734
b72a197
584548f
6c93c16
69fb22e
c07e61e
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 |
|---|---|---|
|
|
@@ -2305,6 +2305,24 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { | |
| TheCall->setType(ArgTyA); | ||
| break; | ||
| } | ||
| case Builtin::BI__builtin_hlsl_or: { | ||
| if (SemaRef.checkArgCount(TheCall, 2)) | ||
|
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. we are doing the same sema checks for the and intrinsic. Delete this whole block and merge the and an or builtins as fall through cases.
Contributor
Author
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. Code updated with suggested changes. |
||
| return true; | ||
| if (CheckVectorElementCallArgs(&SemaRef, TheCall)) | ||
| return true; | ||
|
|
||
| // Ensure input expr type is a scalar/vector of type Boolty | ||
| if (CheckScalarOrVector(&SemaRef, TheCall, getASTContext().BoolTy, 0)) | ||
| return true; | ||
|
|
||
| ExprResult A = TheCall->getArg(0); | ||
| QualType ArgTyA = A.get()->getType(); | ||
|
|
||
| // return type is the same as the input type | ||
| TheCall->setType(ArgTyA); | ||
|
|
||
| break; | ||
| } | ||
| case Builtin::BI__builtin_hlsl_all: | ||
| case Builtin::BI__builtin_hlsl_any: { | ||
| if (SemaRef.checkArgCount(TheCall, 1)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||
| // RUN: %clang_cc1 -finclude-default-header -triple \ | ||||||||
| // RUN: dxil-pc-shadermodel6.3-library %s \ | ||||||||
| // RUN: -emit-llvm -O1 -o - | FileCheck %s | ||||||||
|
||||||||
|
|
||||||||
| //CHECK-LABEL: define noundef i1 @_Z12test_or_boolbb( | ||||||||
| //CHECK-SAME: i1 noundef [[X:%.*]], i1 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||||||||
| //CHECK-NEXT: [[ENTRY:.*:]] | ||||||||
| //CHECK-NEXT: [[HLSL_OR:%.*]] = or i1 [[x]], [[y]] | ||||||||
| //CHECK-NEXT: ret i1 [[HLSL_OR]] | ||||||||
| //CHECK_NEXT: } | ||||||||
| bool test_and_scalar(bool x, bool y) | ||||||||
|
||||||||
| bool test_and_scalar(bool x, bool y) | |
| bool test_or_scalar(bool x, bool y) | |
Outdated
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.
Can this line have a stricter match? If not, does it make since to just delete it? .* is such a broad match that it doesn't provide much value imo
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||
| // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify -DTEST_FUNC=__builtin_hlsl_or | ||||||||
| // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -verify -DTEST_FUNC=__builtin_hlsl_and | ||||||||
damyanp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
|
|
||||||||
V-FEXrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| bool test_too_few_arg(bool a) | ||||||||
| { | ||||||||
| return TEST_FUNC(a); | ||||||||
| // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} | ||||||||
| } | ||||||||
|
|
||||||||
| bool test_too_many_arg(bool a) | ||||||||
| { | ||||||||
| return TEST_FUNC(a, a, a); | ||||||||
| // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} | ||||||||
| } | ||||||||
|
|
||||||||
| bool2 test_mismatched_args(bool2 a, bool3 b) | ||||||||
| { | ||||||||
| return TEST_FUNC(a, b); | ||||||||
| // expected-error@-1 {{all arguments to}}{{.*}}{{must have the same type}} | ||||||||
|
||||||||
| // expected-error@-1 {{all arguments to}}{{.*}}{{must have the same type}} | |
| // expected-error@-1 {{all arguments to}}{{and|or}}{{must have the same 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.
It should actually be _builtin_hlsl_or and _builtin_hlsl_and but the idea is correct.
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.