-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[HLSL] Implement the lit
intrinsic
#134171
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d878048
finished lit implementation, added codegen and sema tests
kmpeng 282dd49
rename variables
kmpeng 9905d25
WIP accept double/int inputs and downcast to floats
kmpeng d9d1731
WIP double/int overloads
kmpeng 9064f10
WIP fix double/int overloads
kmpeng 6026d8f
finished double/int overloads and overload tests
kmpeng 0f6d9bf
address PR comments - formatting changes
kmpeng 409fd4c
address PR comments - turn clang-format off for `or` line in `lit_impl`
kmpeng 199e9b1
allow bool overload, add bool test
kmpeng 3f8e6a5
template specialization
kmpeng 321e54e
add >= hlsl202y primary template definition, add hlsl202y sema tests
kmpeng df05a3d
remove compat overloads and corresponding tests, remove templates in …
kmpeng 584df9e
remove `-O1` from `lit.hlsl` run command, remove `lit-errors.hlsl`
kmpeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s | ||
|
||
// CHECK-LABEL: test_lit_half | ||
// CHECK-SAME: half noundef nofpclass(nan inf) [[NDOTL:%.*]], half noundef nofpclass(nan inf) [[NDOTH:%.*]], half noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTL]], 0xH0000 | ||
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.maxnum.f16(half [[NDOTL]], half 0xH0000) | ||
// CHECK-NEXT: [[VECINIT2_I:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half 0xH3C00>, half [[HLSL_SELECT_I]], i64 1 | ||
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTH]], 0xH0000 | ||
// CHECK-NEXT: [[HLSL_OR_I:%.*]] = or i1 [[CMP_I]], [[CMP4_I]] | ||
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.log.f16(half [[NDOTH]]) | ||
// CHECK-NEXT: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[ELT_LOG_I]], [[M]] | ||
// CHECK-NEXT: [[ELT_EXP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.exp.f16(half [[MUL_I]]) | ||
// CHECK-NEXT: [[HLSL_SELECT7_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[HLSL_OR_I]], half 0xH0000, half [[ELT_EXP_I]] | ||
// CHECK-NEXT: [[VECINS_I:%.*]] = insertelement <4 x half> [[VECINIT2_I]], half [[HLSL_SELECT7_I]], i64 2 | ||
// CHECK-NEXT: ret <4 x half> [[VECINS_I]] | ||
half4 test_lit_half(half NDotL, half NDotH, half M) { return lit(NDotL, NDotH, M); } | ||
|
||
// CHECK-LABEL: test_lit_float | ||
// CHECK-SAME: float noundef nofpclass(nan inf) [[NDOTL:%.*]], float noundef nofpclass(nan inf) [[NDOTH:%.*]], float noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[NDOTL]], 0.000000e+00 | ||
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.maxnum.f32(float [[NDOTL]], float 0.000000e+00) | ||
// CHECK-NEXT: [[VECINIT2_I:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float 1.000000e+00>, float [[HLSL_SELECT_I]], i64 1 | ||
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[NDOTH]], 0.000000e+00 | ||
// CHECK-NEXT: [[HLSL_OR_I:%.*]] = or i1 [[CMP_I]], [[CMP4_I]] | ||
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.log.f32(float [[NDOTH]]) | ||
// CHECK-NEXT: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[ELT_LOG_I]], [[M]] | ||
// CHECK-NEXT: [[ELT_EXP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.exp.f32(float [[MUL_I]]) | ||
// CHECK-NEXT: [[HLSL_SELECT7_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[HLSL_OR_I]], float 0.000000e+00, float [[ELT_EXP_I]] | ||
// CHECK-NEXT: [[VECINS_I:%.*]] = insertelement <4 x float> [[VECINIT2_I]], float [[HLSL_SELECT7_I]], i64 2 | ||
// CHECK-NEXT: ret <4 x float> [[VECINS_I]] | ||
float4 test_lit_float(float NDotL, float NDotH, float M) { return lit(NDotL, NDotH, M); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected=note | ||
|
||
float4 test_double_inputs(double p0, double p1, double p2) { | ||
return lit(p0, p1, p2); | ||
kmpeng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// expected-error@-1 {{call to 'lit' is ambiguous}} | ||
} | ||
|
||
float4 test_int_inputs(int p0, int p1, int p2) { | ||
return lit(p0, p1, p2); | ||
// expected-error@-1 {{call to 'lit' is ambiguous}} | ||
} | ||
|
||
float4 test_bool_inputs(bool p0, bool p1, bool p2) { | ||
return lit(p0, p1, p2); | ||
// expected-error@-1 {{call to 'lit' is ambiguous}} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't do -01 here. Drop the check-next and just check for the instructions you are expecting like
select, or, exp, log, and select again
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.
Just for future reference, when do we want to use
-O1
and/or-disable-llvm-passes
in tests? I haven't been able to figure out a consistent rule looking through the other codegen tests.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.
Generally you should prefer
-disable-llvm-passes
since it makes the test run faster