-
Notifications
You must be signed in to change notification settings - Fork 883
This is really a reference #5473
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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
55 changes: 55 additions & 0 deletions
55
tools/clang/test/HLSLFileCheck/hlsl/classes/template_base_this.hlsl
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,55 @@ | ||
| // RUN: %dxc -T lib_6_4 -HV 2021 %s -ast-dump | FileCheck %s -check-prefix=AST | ||
| // RUN: %dxc -T lib_6_4 -HV 2021 %s -fcgl | FileCheck %s | ||
|
|
||
| // This test verifies two things. First it verifies that the AST instantiates a | ||
| // correct AST where the `CXXThisExpr` is an lvalue of type array_ext<float, 3> | ||
| // rather than a pointer (as C++ would have). | ||
|
|
||
| // Secondarily it verifies that the code geneariton for the `this` reference | ||
| // correctly resolves to the base pointer and indexes off the base class member. | ||
|
|
||
| // AST: ClassTemplateDecl {{.*}} array_ext | ||
| // AST-NEXT: TemplateTypeParmDecl {{.*}} referenced typename T | ||
| // AST-NEXT: NonTypeTemplateParmDecl {{.*}} referenced 'uint32_t':'unsigned int' N | ||
| // AST-NEXT: CXXRecordDecl {{.*}} class array_ext definition | ||
| // AST-NEXT: public 'array<T, N>' | ||
|
|
||
| // AST: ClassTemplateSpecializationDecl {{.*}} class array_ext definition | ||
| // AST: TemplateArgument type 'float' | ||
| // AST-NEXT: TemplateArgument integral 3 | ||
| // AST-NEXT: CXXRecordDecl {{.*}} implicit class array_ext | ||
| // AST-NEXT: CXXMethodDecl {{.*}} used test 'float ()' | ||
| // AST-NEXT: CompoundStmt | ||
| // AST-NEXT: ReturnStmt | ||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'float':'float' <LValueToRValue> | ||
| // AST-NEXT: ArraySubscriptExpr {{.*}} 'float':'float' lvalue | ||
|
|
||
| // Note: the implicit LValueToRvalue casts below are nonsensical as noted by them | ||
| // producing lvalues. This test verifies them only to ensure the correct ASTs | ||
| // around the casts. The casts themselves might be removed or changed in a | ||
| // future change. | ||
|
|
||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'float [3]' <LValueToRValue> | ||
| // AST-NEXT: MemberExpr {{.*}} 'float [3]' lvalue .mArr | ||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'array<float, 3U>':'array<float, 3>' lvalue <UncheckedDerivedToBase (array)> | ||
| // AST-NEXT: CXXThisExpr {{.* }}'array_ext<float, 3>' lvalue this | ||
| // AST-NEXT: IntegerLiteral {{.*}} 'literal int' 0 | ||
|
|
||
| template <typename T, uint32_t N> class array { T mArr[N]; }; | ||
|
|
||
| template <typename T, uint32_t N> class array_ext : array<T, N> { | ||
| float test() { return array<T, N>::mArr[0]; } | ||
| }; | ||
|
|
||
| // CHECK: define linkonce_odr float @"\01?test@?$array_ext@{{.*}}"(%"class.array_ext<float, 3>"* [[this:%.+]]) | ||
| // CHECK: [[basePtr:%[0-9]+]] = bitcast %"class.array_ext<float, 3>"* [[this]] to %"class.array<float, 3>"* | ||
| // CHECK: [[mArr:%.+]] = getelementptr inbounds %"class.array<float, 3>", %"class.array<float, 3>"* [[basePtr]], i32 0, i32 0 | ||
| // CHECK: [[elemPtr:%.+]] = getelementptr inbounds [3 x float], [3 x float]* [[mArr]], i32 0, i32 0 | ||
| // CHECK: [[Val:%.+]] = load float, float* [[elemPtr]] | ||
| // CHECK: ret float [[Val]] | ||
|
|
||
| // This function only exists to force instantiation of the template. | ||
| float fn() { | ||
| array_ext<float, 3> arr1; | ||
| return arr1.test(); | ||
| } | ||
54 changes: 54 additions & 0 deletions
54
tools/clang/test/HLSLFileCheck/hlsl/classes/this_reference_2018.hlsl
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,54 @@ | ||
| // RUN: %dxc -T lib_6_6 %s -HV 2018 -ast-dump | FileCheck %s -check-prefix=AST | ||
| // RUN: %dxc -T lib_6_6 %s -HV 2018 -fcgl | FileCheck %s | ||
| // RUN: %dxc -T lib_6_6 %s -HV 2021 -ast-dump | FileCheck %s -check-prefix=AST | ||
| // RUN: %dxc -T lib_6_6 %s -HV 2021 -fcgl | FileCheck %s | ||
|
|
||
| // This test verifies two things, and it verifies them each under both HLSL 2018 | ||
| // and HLSL 2021 language modes. The behavior between the two modes should not | ||
| // differ. | ||
|
|
||
| // The first thing this verifies is that the AST formulation for | ||
| // `array_ext::test` uses the `this` reference as an lvalue of type `array_ext` | ||
| // rather than a pointer (as C++ would). | ||
|
|
||
| // The second part of this test is to verify the code generation to verify that | ||
| // the base class address is resolved and that the member is indexed off the | ||
| // base class as expected. | ||
|
|
||
| // AST: CXXRecordDecl {{.*}} referenced class array definition | ||
| // AST-NEXT: CXXRecordDecl {{.*}} implicit class array | ||
| // AST-NEXT: FieldDecl {{.*}} referenced mArr 'float [4]' | ||
| // AST-NEXT: CXXRecordDecl {{.*}} class array_ext definition | ||
| // AST-NEXT: public 'array' | ||
| // AST-NEXT: CXXRecordDecl {{.*}} implicit class array_ext | ||
| // AST-NEXT: CXXMethodDecl {{.*}} test 'float ()' | ||
| // AST-NEXT: CompoundStmt | ||
| // AST-NEXT: ReturnStmt | ||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'float' <LValueToRValue> | ||
| // AST-NEXT: ArraySubscriptExpr {{.*}} 'float' lvalue | ||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'float [4]' <LValueToRValue> | ||
| // AST-NEXT: MemberExpr {{.*}} 'float [4]' lvalue .mArr | ||
| // AST-NEXT: ImplicitCastExpr {{.*}} 'array' lvalue <UncheckedDerivedToBase (array)> | ||
| // AST-NEXT: CXXThisExpr {{.*}} 'array_ext' lvalue this | ||
| // AST-NEXT: IntegerLiteral {{.*}} 'literal int' 0 | ||
|
|
||
| class array { | ||
| float mArr[4]; | ||
| }; | ||
|
|
||
| class array_ext : array { | ||
| float test() { return array::mArr[0]; } | ||
| }; | ||
|
|
||
| // CHECK: define linkonce_odr float @"\01?test@array_ext@{{.*}}"(%class.array_ext* [[this:%.+]]) | ||
| // CHECK: [[basePtr:%[0-9]+]] = bitcast %class.array_ext* [[this]] to %class.array* | ||
| // CHECK: [[mArr:%.+]] = getelementptr inbounds %class.array, %class.array* [[basePtr]], i32 0, i32 0 | ||
| // CHECK: [[elemPtr:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[mArr]], i32 0, i32 0 | ||
| // CHECK: [[Val:%.+]] = load float, float* [[elemPtr]] | ||
| // CHECK: ret float [[Val]] | ||
|
|
||
| // This function only exists to force generation of the internal methods | ||
| float fn() { | ||
| array_ext arr1; | ||
| return arr1.test(); | ||
| } |
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.
I would appreciate a comment at the top of both of these tests explaining briefly what's being tested