-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[HLSL] Add copy assignment and construtor to resource types #156075
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 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aaecbc5
[HLSL] Add copy assignment and construtor to resource types
s-perron 738e463
Merge branch 'main' into i154669
s-perron 7b04836
Refactor functions building the constructors.
s-perron 404b3c2
Fix failing sema test
s-perron a3d7123
Add checks for copy constructor and operator=
s-perron 219139a
Remove OVE related changes.
s-perron 307ef1a
Change getResourceHandle to template function.
s-perron 3da9615
Merge branch 'main' into i154669
s-perron 480ed25
Fixes from code reviews.
s-perron 2708a61
Remove blank lines
s-perron 9da9f4f
Fix use of PH
s-perron 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
114 changes: 65 additions & 49 deletions
114
clang/test/CodeGenHLSL/resources/res-array-local-multi-dim.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 |
---|---|---|
@@ -1,49 +1,65 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -finclude-default-header \ | ||
s-perron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s | ||
|
||
// This test verifies handling of multi-dimensional local arrays of resources | ||
// when used as a function argument and local variable. | ||
|
||
// CHECK: @_ZL1A = internal global %"class.hlsl::RWBuffer" poison, align 4 | ||
// CHECK: @_ZL1B = internal global %"class.hlsl::RWBuffer" poison, align 4 | ||
|
||
RWBuffer<float> A : register(u10); | ||
RWBuffer<float> B : register(u20); | ||
RWStructuredBuffer<float> Out; | ||
|
||
// NOTE: _ZN4hlsl8RWBufferIfEixEj is the subscript operator for RWBuffer<float> and | ||
// _ZN4hlsl18RWStructuredBufferIfEixEj is the subscript operator for RWStructuredBuffer<float> | ||
|
||
// CHECK: define {{.*}} float @_Z3fooA2_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([2 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %Arr) | ||
// CHECK-NEXT: entry: | ||
float foo(RWBuffer<float> Arr[2][2]) { | ||
// CHECK-NEXT: %[[Arr_1_Ptr:.*]] = getelementptr inbounds [2 x [2 x %"class.hlsl::RWBuffer"]], ptr %Arr, i32 0, i32 1 | ||
// CHECK-NEXT: %[[Arr_1_1_Ptr:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %[[Arr_1_Ptr]], i32 0, i32 1 | ||
// CHECK-NEXT: %[[BufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl8RWBufferIfEixEj(ptr {{.*}} %[[Arr_1_1_Ptr]], i32 noundef 0) | ||
// CHECK-NEXT: %[[Value:.*]] = load float, ptr %[[BufPtr]], align 4 | ||
// CHECK-NEXT: ret float %[[Value]] | ||
return Arr[1][1][0]; | ||
} | ||
|
||
// CHECK: define internal void @_Z4mainv() | ||
// CHECK-NEXT: entry: | ||
[numthreads(4,1,1)] | ||
void main() { | ||
// CHECK-NEXT: %L = alloca [2 x [2 x %"class.hlsl::RWBuffer"]], align 4 | ||
// CHECK-NEXT: %[[Tmp:.*]] = alloca [2 x [2 x %"class.hlsl::RWBuffer"]], align 4 | ||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %L, ptr align 4 @_ZL1A, i32 4, i1 false) | ||
// CHECK-NEXT: %[[Ptr1:.*]] = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %L, i32 1 | ||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[Ptr1]], ptr align 4 @_ZL1B, i32 4, i1 false) | ||
// CHECK-NEXT: %[[Ptr2:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %L, i32 1 | ||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[Ptr2]], ptr align 4 @_ZL1A, i32 4, i1 false) | ||
// CHECK-NEXT: %[[Ptr3:.*]] = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %[[Ptr2]], i32 1 | ||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[Ptr3]], ptr align 4 @_ZL1B, i32 4, i1 false) | ||
RWBuffer<float> L[2][2] = { { A, B }, { A, B } }; | ||
|
||
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[Tmp]], ptr align 4 %L, i32 16, i1 false) | ||
// CHECK-NEXT: %[[ReturnedValue:.*]] = call {{.*}}float @_Z3fooA2_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([2 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %[[Tmp]]) | ||
// CHECK-NEXT: %[[OutBufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl18RWStructuredBufferIfEixEj(ptr {{.*}} @_ZL3Out, i32 noundef 0) | ||
// CHECK-NEXT: store float %[[ReturnedValue]], ptr %[[OutBufPtr]], align 4 | ||
// CHECK-NEXT: ret void | ||
Out[0] = foo(L); | ||
} | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -finclude-default-header \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s | ||
|
||
// This test verifies handling of multi-dimensional local arrays of resources | ||
// when used as a function argument and local variable. | ||
|
||
// CHECK: @_ZL1A = internal global %"class.hlsl::RWBuffer" poison, align 4 | ||
// CHECK: @_ZL1B = internal global %"class.hlsl::RWBuffer" poison, align 4 | ||
|
||
RWBuffer<float> A : register(u10); | ||
RWBuffer<float> B : register(u20); | ||
RWStructuredBuffer<float> Out; | ||
|
||
// NOTE: _ZN4hlsl8RWBufferIfEixEj is the subscript operator for RWBuffer<float> and | ||
// _ZN4hlsl18RWStructuredBufferIfEixEj is the subscript operator for RWStructuredBuffer<float> | ||
|
||
// CHECK: define {{.*}} float @_Z3fooA2_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([2 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %Arr) | ||
// CHECK-NEXT: entry: | ||
float foo(RWBuffer<float> Arr[2][2]) { | ||
// CHECK-NEXT: %[[Arr_1_Ptr:.*]] = getelementptr inbounds [2 x [2 x %"class.hlsl::RWBuffer"]], ptr %Arr, i32 0, i32 1 | ||
// CHECK-NEXT: %[[Arr_1_1_Ptr:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %[[Arr_1_Ptr]], i32 0, i32 1 | ||
// CHECK-NEXT: %[[BufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl8RWBufferIfEixEj(ptr {{.*}} %[[Arr_1_1_Ptr]], i32 noundef 0) | ||
// CHECK-NEXT: %[[Value:.*]] = load float, ptr %[[BufPtr]], align 4 | ||
// CHECK-NEXT: ret float %[[Value]] | ||
return Arr[1][1][0]; | ||
} | ||
|
||
// CHECK: define internal void @_Z4mainv() | ||
// CHECK-NEXT: entry: | ||
[numthreads(4,1,1)] | ||
void main() { | ||
// CHECK: %L = alloca [2 x [2 x %"class.hlsl::RWBuffer"]], align 4 | ||
// CHECK: %[[ref_tmp:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp1:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp2:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp3:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp4:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp5:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp6:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[ref_tmp7:.*]] = alloca %"class.hlsl::RWBuffer", align 4 | ||
// CHECK: %[[agg_tmp:.*]] = alloca [2 x [2 x %"class.hlsl::RWBuffer"]], align 4 | ||
// CHECK: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp]], ptr noundef nonnull align 4 dereferenceable(4) @_ZL1A) | ||
s-perron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp1]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp]]) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp2]], ptr noundef nonnull align 4 dereferenceable(4) @_ZL1B) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp3]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp2]]) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp4]], ptr noundef nonnull align 4 dereferenceable(4) @_ZL1A) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp5]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp4]]) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp6]], ptr noundef nonnull align 4 dereferenceable(4) @_ZL1B) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp7]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp6]]) | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %L, ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp1]]) | ||
// CHECK-NEXT: %[[arrayinit_element:.*]] = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %L, i32 1 | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[arrayinit_element]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp3]]) | ||
// CHECK-NEXT: %[[arrayinit_element8:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %L, i32 1 | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[arrayinit_element8]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp5]]) | ||
// CHECK-NEXT: %[[arrayinit_element9:.*]] = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %[[arrayinit_element8]], i32 1 | ||
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(4) %[[arrayinit_element9]], ptr noundef nonnull align 4 dereferenceable(4) %[[ref_tmp7]]) | ||
RWBuffer<float> L[2][2] = { { A, B }, { A, B } }; | ||
|
||
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[agg_tmp]], ptr align 4 %L, i32 16, i1 false) | ||
// CHECK-NEXT: %[[ReturnedValue:.*]] = call {{.*}}float @_Z3fooA2_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([2 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %[[agg_tmp]]) | ||
// CHECK-NEXT: %[[OutBufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl18RWStructuredBufferIfEixEj(ptr {{.*}} @_ZL3Out, i32 noundef 0) | ||
// CHECK-NEXT: store float %[[ReturnedValue]], ptr %[[OutBufPtr]], align 4 | ||
// CHECK-NEXT: ret void | ||
Out[0] = foo(L); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.