Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/EnqueueEmptyKernel.ll

raw
1 ;; This test checks that Invoke parameter of OpEnueueKernel instruction meet the
2 ;; following specification requirements in case of enqueueing empty block:
3 ;; "Invoke must be an OpFunction whose OpTypeFunction operand has:
4 ;; - Result Type must be OpTypeVoid.
5 ;; - The first parameter must have a type of OpTypePointer to an 8-bit OpTypeInt.
6 ;; - An optional list of parameters, each of which must have a type of OpTypePointer to the Workgroup Storage Class.
7 ;; ... "
8 ;; __kernel void test_enqueue_empty() {
9 ;; enqueue_kernel(get_default_queue(),
10 ;; CLK_ENQUEUE_FLAGS_WAIT_KERNEL,
11 ;; ndrange_1D(1),
12 ;; 0, NULL, NULL,
13 ;; ^(){});
14 ;; }
15 ; RUN: llvm-as -opaque-pointers=0 < %s > %t.bc
16 ; RUN: llvm-spirv %t.bc -opaque-pointers=0 -o - -spirv-text | FileCheck %s --check-prefix=CHECK-SPIRV
17 ; RUN: llvm-spirv %t.bc -opaque-pointers=0 -o %t.spv
18 ; RUN: spirv-val %t.spv
19
20 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
21 target triple = "spir64-unknown-unknown"
22
23 %struct.ndrange_t = type { i32, [3 x i64], [3 x i64], [3 x i64] }
24 %opencl.queue_t = type opaque
25 %opencl.clk_event_t = type opaque
26
27 @__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 }, align 4
28
29 ; CHECK-SPIRV: Name [[Block:[0-9]+]] "__block_literal_global"
30 ; CHECK-SPIRV: TypeInt [[Int8:[0-9]+]] 8
31 ; CHECK-SPIRV: TypeVoid [[Void:[0-9]+]]
32 ; CHECK-SPIRV: TypePointer [[Int8Ptr:[0-9]+]] 5 [[Int8]]
33 ; CHECK-SPIRV: TypePointer [[Int8PtrGen:[0-9]+]] 8 [[Int8]]
34 ; CHECK-SPIRV: Variable {{[0-9]+}} [[Block:[0-9]+]]
35
36 ; Function Attrs: convergent nounwind
37 define spir_kernel void @test_enqueue_empty() #0 !kernel_arg_addr_space !0 !kernel_arg_access_qual !0 !kernel_arg_type !0 !kernel_arg_base_type !0 !kernel_arg_type_qual !0 {
38 entry:
39 %tmp = alloca %struct.ndrange_t, align 8
40 %call = call spir_func %opencl.queue_t* @_Z17get_default_queuev() #4
41 call spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp, i64 1) #4
42 %0 = call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* %call, i32 1, %struct.ndrange_t* %tmp, i32 0, %opencl.clk_event_t* addrspace(4)* null, %opencl.clk_event_t* addrspace(4)* null, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__test_enqueue_empty_block_invoke_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*))
43 ret void
44 ; CHECK-SPIRV: Bitcast [[Int8Ptr]] [[Int8PtrBlock:[0-9]+]] [[Block]]
45 ; CHECK-SPIRV: PtrCastToGeneric [[Int8PtrGen]] [[Int8PtrGenBlock:[0-9]+]] [[Int8PtrBlock]]
46 ; CHECK-SPIRV: EnqueueKernel {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[Invoke:[0-9]+]] [[Int8PtrGenBlock]] {{[0-9]+}} {{[0-9]+}}
47 }
48
49 ; Function Attrs: convergent
50 declare spir_func %opencl.queue_t* @_Z17get_default_queuev() #1
51
52 ; Function Attrs: convergent
53 declare spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t), i64) #1
54
55 ; Function Attrs: convergent nounwind
56 define internal spir_func void @__test_enqueue_empty_block_invoke(i8 addrspace(4)* %.block_descriptor) #2 {
57 entry:
58 %.block_descriptor.addr = alloca i8 addrspace(4)*, align 8
59 store i8 addrspace(4)* %.block_descriptor, i8 addrspace(4)** %.block_descriptor.addr, align 8
60 %block = bitcast i8 addrspace(4)* %.block_descriptor to <{ i32, i32 }> addrspace(4)*
61 ret void
62 }
63
64 ; Function Attrs: nounwind
65 define internal spir_kernel void @__test_enqueue_empty_block_invoke_kernel(i8 addrspace(4)*) #3 {
66 entry:
67 call void @__test_enqueue_empty_block_invoke(i8 addrspace(4)* %0)
68 ret void
69 }
70
71 declare i32 @__enqueue_kernel_basic_events(%opencl.queue_t*, i32, %struct.ndrange_t*, i32, %opencl.clk_event_t* addrspace(4)*, %opencl.clk_event_t* addrspace(4)*, i8 addrspace(4)*, i8 addrspace(4)*)
72
73 ; CHECK-SPIRV: Function [[Void]] [[Invoke]] {{[0-9]+}} {{[0-9]+}}
74 ; CHECK-SPIRV-NEXT: FunctionParameter [[Int8PtrGen]] {{[0-9]+}}
75
76 attributes #0 = { convergent nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
77 attributes #1 = { convergent "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
78 attributes #2 = { convergent nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 attributes #3 = { nounwind }
80 attributes #4 = { convergent }
81
82 !opencl.enable.FP_CONTRACT = !{}
83 !opencl.spir.version = !{!1}
84 !opencl.ocl.version = !{!2}
85 !opencl.used.extensions = !{!0}
86 !opencl.used.optional.core.features = !{!0}
87 !opencl.compiler.options = !{!0}
88
89 !0 = !{}
90 !1 = !{i32 1, i32 2}
91 !2 = !{i32 2, i32 0}