Skip to content
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

Rewrite variable pointers tests as SPIRVProducer tests #1300

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions test/VariablePointers/function_call_image_param.cl

This file was deleted.

34 changes: 34 additions & 0 deletions test/VariablePointers/function_call_image_param.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; CHECK-NOT: OpCapability VariablePointers
; CHECK-NOT: OpExtension "SPV_KHR_variable_pointers"
; CHECK: [[image:%[a-zA-Z0-9_]+]] = OpTypeImage
; CHECK: OpFunctionParameter [[image]]

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

declare spir_func void @_Z12write_imagef22ocl_image2d_wo_t.floatDv2_iDv4_f(target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0), <2 x i32>, <4 x float>)

define spir_func void @bar(target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) %image) {
entry:
tail call spir_func void @_Z12write_imagef22ocl_image2d_wo_t.floatDv2_iDv4_f(target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) %image, <2 x i32> zeroinitializer, <4 x float> zeroinitializer)
ret void
}

define spir_kernel void @foo(target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) %image) !clspv.pod_args_impl !15 {
entry:
%0 = call target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) @_Z14clspv.resource.0(i32 0, i32 0, i32 7, i32 0, i32 0, i32 0, target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) undef)
tail call spir_func void @bar(target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) %0)
ret void
}

declare target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, target("spirv.Image", float, 1, 0, 0, 0, 2, 0, 1, 0))

!15 = !{i32 2}

21 changes: 0 additions & 21 deletions test/VariablePointers/function_call_sampler_param.cl

This file was deleted.

44 changes: 44 additions & 0 deletions test/VariablePointers/function_call_sampler_param.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; CHECK-NOT: OpCapability VariablePointers
; CHECK-NOT: OpExtension "SPV_KHR_variable_pointers"
; CHECK-DAG: [[image:%[a-zA-Z0-9_]+]] = OpTypeImage
; CHECK-DAG: [[sampler:%[a-zA-Z0-9_]+]] = OpTypeSampler
; CHECK: OpFunctionParameter [[image]]
; CHECK: OpFunctionParameter [[sampler]]

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

declare spir_func <4 x float> @_Z11read_imagef30ocl_image2d_ro_t.float.sampled11ocl_samplerDv2_f(target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0), target("spirv.Sampler"), <2 x float>)

define spir_func <4 x float> @bar(target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) %image, target("spirv.Sampler") %sampler) {
entry:
%call = tail call spir_func <4 x float> @_Z11read_imagef30ocl_image2d_ro_t.float.sampled11ocl_samplerDv2_f(target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) %image, target("spirv.Sampler") %sampler, <2 x float> zeroinitializer)
ret <4 x float> %call
}

define spir_kernel void @foo(target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) %image, target("spirv.Sampler") %sampler, ptr addrspace(1) nocapture writeonly align 16 %out) !clspv.pod_args_impl !17 {
entry:
%0 = call target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) @_Z14clspv.resource.0(i32 0, i32 0, i32 6, i32 0, i32 0, i32 0, target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) undef)
%1 = call target("spirv.Sampler") @_Z14clspv.resource.1(i32 0, i32 1, i32 8, i32 1, i32 1, i32 0, target("spirv.Sampler") zeroinitializer)
%2 = call ptr addrspace(1) @_Z14clspv.resource.2(i32 0, i32 2, i32 0, i32 2, i32 2, i32 0, { [0 x <4 x float>] } zeroinitializer)
%3 = getelementptr { [0 x <4 x float>] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0
%call = tail call spir_func <4 x float> @bar(target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) %0, target("spirv.Sampler") %1) #4
store <4 x float> %call, ptr addrspace(1) %3, align 16
ret void
}

declare target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, target("spirv.Image", float, 1, 0, 0, 0, 1, 0, 0, 0))

declare target("spirv.Sampler") @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, target("spirv.Sampler"))

declare ptr addrspace(1) @_Z14clspv.resource.2(i32, i32, i32, i32, i32, i32, { [0 x <4 x float>] })

!17 = !{i32 2}

20 changes: 0 additions & 20 deletions test/VariablePointers/function_call_ssbo.cl

This file was deleted.

41 changes: 41 additions & 0 deletions test/VariablePointers/function_call_ssbo.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpCapability VariablePointersStorageBuffer
; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpExtension "SPV_KHR_variable_pointers"
; CHECK: [[uint:%[a-zA-Z0-9_]+]] = OpTypeInt 32 0
; CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer StorageBuffer [[uint]]
; CHECK: OpFunctionParameter [[ptr]]

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 i32 @bar(ptr addrspace(1) nocapture readonly %x) {
entry:
%0 = load i32, ptr addrspace(1) %x, align 4
ret i32 %0
}

define dso_local spir_kernel void @foo(ptr addrspace(1) nocapture readonly align 4 %in, ptr addrspace(1) nocapture writeonly align 4 %out) !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 i32] } zeroinitializer)
%1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0
%2 = call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, { [0 x i32] } zeroinitializer)
%3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0
%call = tail call spir_func i32 @bar(ptr addrspace(1) %1)
store i32 %call, ptr addrspace(1) %3, align 4
ret void
}

declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] })

declare ptr addrspace(1) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [0 x i32] })

!16 = !{i32 2}

27 changes: 0 additions & 27 deletions test/VariablePointers/function_call_ssbo_subobject.cl

This file was deleted.

48 changes: 48 additions & 0 deletions test/VariablePointers/function_call_ssbo_subobject.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; Passing SSBO to function call requires VariablePointersStorageBuffer.
; SSBO args do not require memory object declarations.
; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpCapability VariablePointersStorageBuffer
; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpExtension "SPV_KHR_variable_pointers"
; CHECK: [[uint:%[a-zA-Z0-9_]+]] = OpTypeInt 32 0
; CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer StorageBuffer [[uint]]
; CHECK: [[uint_0:%[a-zA-Z0-9_]+]] = OpConstant [[uint]] 0
; CHECK: [[uint_1:%[a-zA-Z0-9_]+]] = OpConstant [[uint]] 1
; CHECK: [[gep:%[a-zA-Z0-9_]+]] = OpAccessChain [[ptr]] {{.*}} [[uint_0]] [[uint_1]]
; CHECK-NEXT: OpFunctionCall [[uint]] {{.*}} [[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 i32 @bar(ptr addrspace(1) nocapture readonly %x) {
entry:
%0 = load i32, ptr addrspace(1) %x, align 4
ret i32 %0
}

define spir_kernel void @foo(ptr addrspace(1) nocapture readonly align 4 %in, ptr addrspace(1) nocapture writeonly align 4 %out) !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 i32] } zeroinitializer)
%1 = call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, { [0 x i32] } zeroinitializer)
%2 = getelementptr { [0 x i32] }, ptr addrspace(1) %1, i32 0, i32 0, i32 0
%3 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 1
%call.i = tail call spir_func i32 @bar(ptr addrspace(1) %3)
store i32 %call.i, ptr addrspace(1) %2, align 4
ret void
}

declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] })

declare ptr addrspace(1) @_Z14clspv.resource.1(i32, i32, i32, i32, i32, i32, { [0 x i32] })

declare ptr addrspace(9) @_Z14clspv.resource.2(i32, i32, i32, i32, i32, i32, { { i32 } })

!16 = !{i32 2}

24 changes: 0 additions & 24 deletions test/VariablePointers/function_call_wg.cl

This file was deleted.

45 changes: 45 additions & 0 deletions test/VariablePointers/function_call_wg.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; Pass base workgroup object to a function shouldn't require variable
; pointers, but the representation inserts an OpAccessChain so we require
; VariablePointers because it is NOT a memory object declaration.
; CHECK-NOT: OpCapability VariablePointersStorageBuffer
; CHECK: OpCapability VariablePointers
; CHECK-NOT: StorageBuffer
; CHECK: OpExtension "SPV_KHR_variable_pointers"
; CHECK: [[uint:%[a-zA-Z0-9_]+]] = OpTypeInt 32 0
; CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer Workgroup [[uint]]
; CHECK: [[gep:%[a-zA-Z0-9_]+]] = OpAccessChain [[ptr]]
; CHECK: OpFunctionCall [[uint]] {{.*}} [[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 i32 @bar(ptr addrspace(3) nocapture readonly %x) {
entry:
%0 = load i32, ptr addrspace(3) %x, align 4
ret i32 %0
}

define dso_local spir_kernel void @foo(ptr addrspace(3) nocapture readonly align 4 %in, ptr addrspace(1) nocapture writeonly align 4 %out) !clspv.pod_args_impl !19 {
entry:
%0 = call ptr addrspace(3) @_Z11clspv.local.3(i32 3, [0 x i32] zeroinitializer)
%1 = getelementptr [0 x i32], ptr addrspace(3) %0, i32 0, i32 0
%2 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, { [0 x i32] } zeroinitializer)
%3 = getelementptr { [0 x i32] }, ptr addrspace(1) %2, i32 0, i32 0, i32 0
%call = tail call spir_func i32 @bar(ptr addrspace(3) %1)
store i32 %call, ptr addrspace(1) %3, align 4
ret void
}

declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] })

declare ptr addrspace(3) @_Z11clspv.local.3(i32, [0 x i32])

!19 = !{i32 2}

18 changes: 0 additions & 18 deletions test/VariablePointers/null_pointer_ssbo.cl

This file was deleted.

35 changes: 35 additions & 0 deletions test/VariablePointers/null_pointer_ssbo.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
; RUN: clspv-opt %s -o %t -producer-out-file %t.spv --passes=spirv-producer
; RUN: spirv-dis %t.spv -o %t.spvasm
; RUN: spirv-val --target-env vulkan1.0 %t.spv
; RUN: FileCheck %s < %t.spvasm

; Null pointer for SSBO requires VariablePointersStorageBuffer.
; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpCapability VariablePointersStorageBuffer
; CHECK-NOT: OpCapability VariablePointers
; CHECK: OpExtension "SPV_KHR_variable_pointers"
; CHECK: [[uint:%[a-zA-Z0-9_]+]] = OpTypeInt 32 0
; CHECK: [[ptr:%[a-zA-Z0-9_]+]] = OpTypePointer StorageBuffer [[uint]]
; CHECK: OpConstantNull [[ptr]]

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 spir_kernel void @foo(ptr addrspace(1) nocapture writeonly align 4 %out, { i32 } %podargs) !clspv.pod_args_impl !14 !kernel_arg_map !15 {
entry:
%0 = call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x i32] } zeroinitializer)
%1 = getelementptr { [0 x i32] }, ptr addrspace(1) %0, i32 0, i32 0, i32 0
%2 = load i32, ptr addrspace(1) null, align 2147483648
store i32 %2, ptr addrspace(1) %1, align 4
ret void
}

declare ptr addrspace(1) @_Z14clspv.resource.0(i32, i32, i32, i32, i32, i32, { [0 x i32] })

!14 = !{i32 2}
!15 = !{!16, !17}
!16 = !{!"out", i32 0, i32 0, i32 0, i32 0, !"buffer"}
!17 = !{!"n", i32 1, i32 1, i32 0, i32 4, !"pod_pushconstant"}

Loading