-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #1292 refs #1303 * Fixed a bug in remove unused arguments * attributes on parameters weren't handled parameters * rewrite tests to be more targeted at the actual feature
- Loading branch information
1 parent
47ee627
commit 5bc0eef
Showing
56 changed files
with
1,724 additions
and
1,214 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,62 @@ | ||
; RUN: clspv-opt -constant-args-ubo %s -o %t.ll -producer-out-file=%t.spv -int8=0 --passes=ubo-type-transform,spirv-producer | ||
; RUN: spirv-dis %t.spv -o %t.spvasm | ||
; RUN: spirv-val --target-env vulkan1.0 %t.spv | ||
; RUN: FileCheck %s < %t.spvasm | ||
; RUN: clspv-reflection %t.spv -o %t.map | ||
; RUN: FileCheck --check-prefix=MAP %s < %t.map | ||
|
||
; MAP: kernel,foo,arg,data,argOrdinal,0,descriptorSet,0,binding,0,offset,0,argKind,buffer | ||
; MAP-NEXT: kernel,foo,arg,c,argOrdinal,1,descriptorSet,0,binding,1,offset,0,argKind,buffer_ubo | ||
|
||
; CHECK-DAG: OpMemberDecorate [[s:%[0-9a-zA-Z_]+]] 0 Offset 0 | ||
; CHECK-DAG: OpMemberDecorate [[s]] 1 Offset 4 | ||
; CHECK-DAG: OpMemberDecorate [[s]] 2 Offset 16 | ||
; CHECK-DAG: OpMemberDecorate [[s]] 3 Offset 20 | ||
; CHECK-DAG: OpDecorate [[runtime:%[0-9a-zA-Z_]+]] ArrayStride 32 | ||
; CHECK-DAG: OpDecorate [[data:%[0-9a-zA-Z_]+]] Binding 0 | ||
; CHECK-DAG: OpDecorate [[data]] DescriptorSet 0 | ||
; CHECK-DAG: OpDecorate [[c:%[0-9a-zA-Z_]+]] Binding 1 | ||
; CHECK-DAG: OpDecorate [[c]] DescriptorSet 0 | ||
; CHECK: [[int:%[0-9a-zA-Z_]+]] = OpTypeInt 32 0 | ||
; CHECK: [[s]] = OpTypeStruct [[int]] [[int]] [[int]] [[int]] | ||
; CHECK: [[runtime]] = OpTypeRuntimeArray [[s]] | ||
; CHECK: [[struct:%[0-9a-zA-Z_]+]] = OpTypeStruct [[runtime]] | ||
; CHECK: [[data_ptr:%[0-9a-zA-Z_]+]] = OpTypePointer StorageBuffer [[struct]] | ||
; CHECK: [[int_2048:%[0-9a-zA-Z_]+]] = OpConstant [[int]] 2048 | ||
; CHECK: [[array:%[0-9a-zA-Z_]+]] = OpTypeArray [[s]] [[int_2048]] | ||
; CHECK: [[ubo_struct:%[0-9a-zA-Z_]+]] = OpTypeStruct [[array]] | ||
; CHECK: [[c_ptr:%[0-9a-zA-Z_]+]] = OpTypePointer Uniform [[ubo_struct]] | ||
; CHECK: [[data]] = OpVariable [[data_ptr]] StorageBuffer | ||
; CHECK: [[c]] = OpVariable [[c_ptr]] Uniform | ||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir-unknown-unknown" | ||
|
||
%struct.s = type { i32, [12 x i8], i32, [12 x i8] } | ||
|
||
@__spirv_GlobalInvocationId = local_unnamed_addr addrspace(5) global <3 x i32> zeroinitializer | ||
@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer | ||
|
||
define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture writeonly align 16 %data, ptr addrspace(2) nocapture readonly align 16 %c) !clspv.pod_args_impl !13 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x %struct.s] } zeroinitializer) | ||
%1 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [2048 x %struct.s] } zeroinitializer) | ||
%2 = getelementptr <3 x i32>, ptr addrspace(5) @__spirv_GlobalInvocationId, i32 0, i32 0 | ||
%3 = load i32, ptr addrspace(5) %2, align 16 | ||
%4 = getelementptr { [2048 x %struct.s] }, ptr addrspace(2) %1, i32 0, i32 0, i32 %3, i32 0 | ||
%5 = load i32, ptr addrspace(2) %4, align 16 | ||
%6 = getelementptr { [0 x %struct.s] }, ptr addrspace(1) %0, i32 0, i32 0, i32 %3, i32 0 | ||
store i32 %5, ptr addrspace(1) %6, align 16 | ||
%7 = getelementptr { [2048 x %struct.s] }, ptr addrspace(2) %1, i32 0, i32 0, i32 %3, i32 2 | ||
%8 = load i32, ptr addrspace(2) %7, align 16 | ||
%9 = getelementptr { [0 x %struct.s] }, ptr addrspace(1) %0, i32 0, i32 0, i32 %3, i32 2 | ||
store i32 %8, ptr addrspace(1) %9, align 16 | ||
ret void | ||
} | ||
|
||
declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x %struct.s] }) | ||
|
||
declare ptr addrspace(2) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [2048 x %struct.s] }) | ||
|
||
!13 = !{i32 2} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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,38 @@ | ||
; RUN: clspv-opt %s -o %t.ll -constant-args-ubo --passes=multi-version-ubo-functions,remove-unused-arguments | ||
; RUN: FileCheck %s < %t.ll | ||
|
||
; CHECK: define {{.*}} void @foo | ||
; CHECK: call <4 x i32> [[bar:@bar[a-zA-Z0-9_]+]] | ||
; CHECK: define {{.*}} <4 x i32> [[bar]]() | ||
; CHECK: [[res:%[a-zA-Z0-9_.]+]] = call ptr addrspace(2) @_Z14clspv.resource.1 | ||
; CHECK: [[gep:%[a-zA-Z0-9_.]+]] = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) [[res]], i32 0, i32 0, i32 0 | ||
; CHECK: load <4 x i32>, ptr addrspace(2) [[gep]] | ||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir-unknown-unknown" | ||
|
||
@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer | ||
|
||
define dso_local spir_func <4 x i32> @bar(ptr addrspace(2) nocapture readonly %data) { | ||
entry: | ||
%0 = load <4 x i32>, ptr addrspace(2) %data, align 16 | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture writeonly align 16 %out, ptr addrspace(2) nocapture readonly align 16 %in) !clspv.pod_args_impl !16 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x <4 x i32>] } zeroinitializer) | ||
%1 = getelementptr { [0 x <4 x i32>] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 | ||
%2 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [4096 x <4 x i32>] } zeroinitializer) | ||
%3 = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) %2, i32 0, i32 0, i32 0 | ||
%call = tail call spir_func <4 x i32> @bar(ptr addrspace(2) %3) | ||
store <4 x i32> %call, ptr addrspace(1) %1, align 16 | ||
ret void | ||
} | ||
|
||
declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x <4 x i32>] }) | ||
|
||
declare ptr addrspace(2) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [4096 x <4 x i32>] }) | ||
|
||
!16 = !{i32 2} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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: clspv-opt %s -o %t.ll -constant-args-ubo --passes=multi-version-ubo-functions,remove-unused-arguments | ||
; RUN: FileCheck %s < %t.ll | ||
|
||
; CHECK: define {{.*}} @k1 | ||
; CHECK: call {{.*}} [[bar1:@bar[a-zA-Z0-9_.]+]]() | ||
; CHECK: define {{.*}} @k2 | ||
; CHECK: call {{.*}} [[bar2:@bar[a-zA-Z0-9_.]+]]() | ||
; CHECK-DAG: define {{.*}} [[bar1]]() | ||
; CHECK-DAG: [[res:%[a-zA-Z0-9_.]+]] = call ptr addrspace(2) @_Z14clspv.resource.1 | ||
; CHECK-DAG: [[gep:%[a-zA-Z0-9_.]+]] = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) [[res]], i32 0, i32 0, i32 0 | ||
; CHECK-DAG: load <4 x i32>, ptr addrspace(2) [[gep]] | ||
; CHECK-DAG: define {{.*}} [[bar2]]() | ||
; CHECK-DAG: [[res:%[a-zA-Z0-9_.]+]] = call ptr addrspace(2) @_Z14clspv.resource.1 | ||
; CHECK-DAG: [[gep:%[a-zA-Z0-9_.]+]] = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) [[res]], i32 0, i32 0, i32 0 | ||
; CHECK-DAG: load <4 x i32>, ptr addrspace(2) [[gep]] | ||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir-unknown-unknown" | ||
|
||
@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer | ||
|
||
define dso_local spir_func <4 x i32> @bar(ptr addrspace(2) nocapture readonly %data) { | ||
entry: | ||
%0 = load <4 x i32>, ptr addrspace(2) %data, align 16 | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define dso_local spir_kernel void @k1(ptr addrspace(1) nocapture writeonly align 16 %out, ptr addrspace(2) nocapture readonly align 16 %in) !clspv.pod_args_impl !17 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x <4 x i32>] } zeroinitializer) | ||
%1 = getelementptr { [0 x <4 x i32>] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 | ||
%2 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [4096 x <4 x i32>] } zeroinitializer) | ||
%3 = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) %2, i32 0, i32 0, i32 0 | ||
%call = tail call spir_func <4 x i32> @bar(ptr addrspace(2) %3) | ||
store <4 x i32> %call, ptr addrspace(1) %1, align 16 | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @k2(ptr addrspace(1) nocapture writeonly align 16 %out, ptr addrspace(2) nocapture readonly align 16 %in) !clspv.pod_args_impl !17 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x <4 x i32>] } zeroinitializer) | ||
%1 = getelementptr { [0 x <4 x i32>] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 | ||
%2 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [4096 x <4 x i32>] } zeroinitializer) | ||
%3 = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) %2, i32 0, i32 0, i32 0 | ||
%call = tail call spir_func <4 x i32> @bar(ptr addrspace(2) %3) | ||
store <4 x i32> %call, ptr addrspace(1) %1, align 16 | ||
ret void | ||
} | ||
|
||
declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x <4 x i32>] }) | ||
|
||
declare ptr addrspace(2) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [4096 x <4 x i32>] }) | ||
|
||
!17 = !{i32 2} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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,61 @@ | ||
; RUN: clspv-opt %s -o %t.ll -constant-args-ubo --passes=multi-version-ubo-functions,remove-unused-arguments | ||
; RUN: FileCheck %s < %t.ll | ||
|
||
; CHECK: define {{.*}} @k1 | ||
; CHECK: call {{.*}} [[bar1:@bar[a-zA-Z0-9_.]+]] | ||
; CHECK: define {{.*}} @k2 | ||
; CHECK: call {{.*}} [[bar2:@bar[a-zA-Z0-9_.]+]] | ||
; CHECK-DAG: define {{.*}} [[bar1]]() | ||
; CHECK-DAG: [[res:%[a-zA-Z0-9_.]+]] = call ptr addrspace(2) @_Z14clspv.resource.1 | ||
; CHECK-DAG: [[gep:%[a-zA-Z0-9_.]+]] = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) [[res]], i32 0, i32 0, i32 0 | ||
; CHECK-DAG: load <4 x i32>, ptr addrspace(2) [[gep]] | ||
; CHECK-DAG: define {{.*}} [[bar2]]() | ||
; CHECK-DAG: [[res:%[a-zA-Z0-9_.]+]] = call ptr addrspace(2) @_Z14clspv.resource.1 | ||
; CHECK-DAG: [[gep:%[a-zA-Z0-9_.]+]] = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) [[res]], i32 0, i32 0, i32 1 | ||
; CHECK-DAG: load <4 x i32>, ptr addrspace(2) [[gep]] | ||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir-unknown-unknown" | ||
|
||
@__spirv_WorkgroupSize = local_unnamed_addr addrspace(8) global <3 x i32> zeroinitializer | ||
|
||
define dso_local spir_func <4 x i32> @bar(ptr addrspace(2) nocapture readonly %data) { | ||
entry: | ||
%0 = load <4 x i32>, ptr addrspace(2) %data, align 16 | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define dso_local spir_kernel void @k1(ptr addrspace(1) nocapture writeonly align 16 %out, ptr addrspace(2) nocapture readonly align 16 %in) !clspv.pod_args_impl !17 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x <4 x i32>] } zeroinitializer) | ||
%1 = getelementptr { [0 x <4 x i32>] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 | ||
%2 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [4096 x <4 x i32>] } zeroinitializer) | ||
%3 = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) %2, i32 0, i32 0, i32 0 | ||
%call = tail call spir_func <4 x i32> @bar(ptr addrspace(2) %3) | ||
store <4 x i32> %call, ptr addrspace(1) %1, align 16 | ||
ret void | ||
} | ||
|
||
define spir_kernel void @k2(ptr addrspace(1) nocapture writeonly align 16 %out, ptr addrspace(2) nocapture readonly align 16 %in) !clspv.pod_args_impl !17 { | ||
entry: | ||
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x <4 x i32>] } zeroinitializer) | ||
%1 = getelementptr { [0 x <4 x i32>] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0 | ||
%2 = call ptr addrspace(2) @_Z14clspv.resource.1(i32 0, i32 1, i32 1, i32 1, i32 1, i32 0, { [4096 x <4 x i32>] } zeroinitializer) | ||
%3 = call ptr addrspace(9) @_Z14clspv.resource.2(i32 -1, i32 2, i32 5, i32 2, i32 2, i32 0, { { i32 } } zeroinitializer) | ||
%4 = getelementptr { { i32 } }, ptr addrspace(9) %3, i32 0, i32 0 | ||
%5 = load { i32 }, ptr addrspace(9) %4, align 4 | ||
%x = extractvalue { i32 } %5, 0 | ||
%6 = getelementptr { [4096 x <4 x i32>] }, ptr addrspace(2) %2, i32 0, i32 0, i32 1 | ||
%call.i = tail call spir_func <4 x i32> @bar(ptr addrspace(2) %6) | ||
store <4 x i32> %call.i, ptr addrspace(1) %1, align 16 | ||
ret void | ||
} | ||
|
||
declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x <4 x i32>] }) | ||
|
||
declare ptr addrspace(2) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [4096 x <4 x i32>] }) | ||
|
||
declare ptr addrspace(9) @_Z14clspv.resource.2(i32, i32, i32, i32, i32, i32, { { i32 } }) | ||
|
||
!17 = !{i32 2} | ||
|
Oops, something went wrong.