| 1 |
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
|
| 3 |
; TODO(#60133): Requires updates following opaque pointer migration. |
| 4 |
; XFAIL: * |
| 5 |
|
| 6 |
;; This test checks that Invoke parameter of OpEnueueKernel instruction meet the |
| 7 |
;; following specification requirements in case of enqueueing empty block: |
| 8 |
;; "Invoke must be an OpFunction whose OpTypeFunction operand has: |
| 9 |
;; - Result Type must be OpTypeVoid. |
| 10 |
;; - The first parameter must have a type of OpTypePointer to an 8-bit OpTypeInt. |
| 11 |
;; - An optional list of parameters, each of which must have a type of OpTypePointer to the Workgroup Storage Class. |
| 12 |
;; ... " |
| 13 |
;; __kernel void test_enqueue_empty() { |
| 14 |
;; enqueue_kernel(get_default_queue(), |
| 15 |
;; CLK_ENQUEUE_FLAGS_WAIT_KERNEL, |
| 16 |
;; ndrange_1D(1), |
| 17 |
;; 0, NULL, NULL, |
| 18 |
;; ^(){}); |
| 19 |
;; } |
| 20 |
|
| 21 |
%struct.ndrange_t = type { i32, [3 x i64], [3 x i64], [3 x i64] } |
| 22 |
%opencl.queue_t = type opaque |
| 23 |
%opencl.clk_event_t = type opaque |
| 24 |
|
| 25 |
@__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 }, align 4 |
| 26 |
|
| 27 |
; CHECK-SPIRV: OpName %[[#Block:]] "__block_literal_global" |
| 28 |
; CHECK-SPIRV: %[[#Void:]] = OpTypeVoid |
| 29 |
; CHECK-SPIRV: %[[#Int8:]] = OpTypeInt 8 |
| 30 |
; CHECK-SPIRV: %[[#Int8PtrGen:]] = OpTypePointer Generic %[[#Int8]] |
| 31 |
; CHECK-SPIRV: %[[#Int8Ptr:]] = OpTypePointer CrossWorkgroup %[[#Int8]] |
| 32 |
; CHECK-SPIRV: %[[#Block]] = OpVariable %[[#]] |
| 33 |
|
| 34 |
define spir_kernel void @test_enqueue_empty() { |
| 35 |
entry: |
| 36 |
%tmp = alloca %struct.ndrange_t, align 8 |
| 37 |
%call = call spir_func ptr @_Z17get_default_queuev() |
| 38 |
call spir_func void @_Z10ndrange_1Dm(ptr sret(ptr) %tmp, i64 1) |
| 39 |
%0 = call i32 @__enqueue_kernel_basic_events(ptr %call, i32 1, ptr %tmp, i32 0, ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @__test_enqueue_empty_block_invoke_kernel to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @__block_literal_global to ptr addrspace(4))) |
| 40 |
ret void |
| 41 |
; CHECK-SPIRV: %[[#Int8PtrBlock:]] = OpBitcast %[[#Int8Ptr]] %[[#Block]] |
| 42 |
; CHECK-SPIRV: %[[#Int8PtrGenBlock:]] = OpPtrCastToGeneric %[[#Int8PtrGen]] %[[#Int8PtrBlock]] |
| 43 |
; CHECK-SPIRV: %[[#]] = OpEnqueueKernel %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#Invoke:]] %[[#Int8PtrGenBlock]] %[[#]] %[[#]] |
| 44 |
} |
| 45 |
|
| 46 |
declare spir_func ptr @_Z17get_default_queuev() |
| 47 |
|
| 48 |
declare spir_func void @_Z10ndrange_1Dm(ptr sret(ptr), i64) |
| 49 |
|
| 50 |
define internal spir_func void @__test_enqueue_empty_block_invoke(ptr addrspace(4) %.block_descriptor) { |
| 51 |
entry: |
| 52 |
%.block_descriptor.addr = alloca ptr addrspace(4), align 8 |
| 53 |
store ptr addrspace(4) %.block_descriptor, ptr %.block_descriptor.addr, align 8 |
| 54 |
%block = bitcast ptr addrspace(4) %.block_descriptor to ptr addrspace(4) |
| 55 |
ret void |
| 56 |
} |
| 57 |
|
| 58 |
define internal spir_kernel void @__test_enqueue_empty_block_invoke_kernel(ptr addrspace(4)) { |
| 59 |
entry: |
| 60 |
call void @__test_enqueue_empty_block_invoke(ptr addrspace(4) %0) |
| 61 |
ret void |
| 62 |
} |
| 63 |
|
| 64 |
declare i32 @__enqueue_kernel_basic_events(ptr, i32, ptr, i32, ptr addrspace(4), ptr addrspace(4), ptr addrspace(4), ptr addrspace(4)) |
| 65 |
|
| 66 |
; CHECK-SPIRV: %[[#Invoke]] = OpFunction %[[#Void]] None %[[#]] |
| 67 |
; CHECK-SPIRV-NEXT: %[[#]] = OpFunctionParameter %[[#Int8PtrGen]] |