• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
2target triple = "spir64-unknown-unknown"
3
4; RUN: llvm-as %s -o %t.bc
5; RUN: llvm-spirv %t.bc -o %t.spv
6; RUN: llvm-spirv -r %t.spv -o %t.bc
7; RUN: llvm-dis < %t.bc | FileCheck %s
8
9; Check the mangling of 1.2 atomic functions. This test expects that all
10; built-ins are promoted to OpenCL C 2.0 atomics.
11; Most of atomics lost information about the sign of the integer operand
12; but since this concerns only built-ins  with two-complement's arithmetics
13; it shouldn't cause any problems.
14
15
16; Function Attrs: nounwind
17define spir_kernel void @test_atomic_global(i32 addrspace(1)* %dst) #0 {
18  ; atomic_inc
19  %inc_ig = tail call spir_func i32 @_Z10atomic_incPVU3AS1i(i32 addrspace(1)* %dst) #0
20  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS1U7_Atomiciiii(i32 addrspace(1)* {{.*}}, i32 1
21  %dec_jg = tail call spir_func i32 @_Z10atomic_decPVU3AS1j(i32 addrspace(1)* %dst) #0
22  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS1U7_Atomiciiii(i32 addrspace(1)* {{.*}}, i32 1
23
24  ; atomic_max
25  %max_ig = tail call spir_func i32 @_Z10atomic_maxPVU3AS1ii(i32 addrspace(1)* %dst, i32 0) #0
26  ; CHECK: _Z25atomic_fetch_max_explicitPVU3AS1U7_Atomiciiii
27  %max_jg = tail call spir_func i32 @_Z10atomic_maxPVU3AS1jj(i32 addrspace(1)* %dst, i32 0) #0
28  ; CHECK: _Z25atomic_fetch_max_explicitPVU3AS1U7_Atomicjjii
29
30  ; atomic_min
31  %min_ig = tail call spir_func i32 @_Z10atomic_minPVU3AS1ii(i32 addrspace(1)* %dst, i32 0) #0
32  ; CHECK: _Z25atomic_fetch_min_explicitPVU3AS1U7_Atomiciiii
33  %min_jg = tail call spir_func i32 @_Z10atomic_minPVU3AS1jj(i32 addrspace(1)* %dst, i32 0) #0
34  ; CHECK: _Z25atomic_fetch_min_explicitPVU3AS1U7_Atomicjjii
35
36  ; atomic_add
37  %add_ig = tail call spir_func i32 @_Z10atomic_addPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
38  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS1U7_Atomiciiii
39  %add_jg = tail call spir_func i32 @_Z10atomic_addPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
40  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS1U7_Atomiciiii
41
42  ; atomic_sub
43  %sub_ig = tail call spir_func i32 @_Z10atomic_subPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
44  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS1U7_Atomiciiii
45  %sub_jg = tail call spir_func i32 @_Z10atomic_subPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
46  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS1U7_Atomiciiii
47
48  ; atomic_or
49  %or_ig = tail call spir_func i32 @_Z9atomic_orPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
50  ; CHECK: _Z24atomic_fetch_or_explicitPVU3AS1U7_Atomiciiii
51  %or_jg = tail call spir_func i32 @_Z9atomic_orPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
52  ; CHECK: _Z24atomic_fetch_or_explicitPVU3AS1U7_Atomiciiii
53
54  ; atomic_xor
55  %xor_ig = tail call spir_func i32 @_Z10atomic_xorPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
56  ; CHECK: _Z25atomic_fetch_xor_explicitPVU3AS1U7_Atomiciiii
57  %xor_jg = tail call spir_func i32 @_Z10atomic_xorPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
58  ; CHECK: _Z25atomic_fetch_xor_explicitPVU3AS1U7_Atomiciiii
59
60  ; atomic_and
61  %and_ig = tail call spir_func i32 @_Z10atomic_andPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
62  ; CHECK: _Z25atomic_fetch_and_explicitPVU3AS1U7_Atomiciiii
63  %and_jg = tail call spir_func i32 @_Z10atomic_andPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
64  ; CHECK: _Z25atomic_fetch_and_explicitPVU3AS1U7_Atomiciiii
65
66  ; atomic_cmpxchg
67  %cmpxchg_ig = call spir_func i32 @_Z14atomic_cmpxchgPVU3AS1iii(i32 addrspace(1)* %dst, i32 0, i32 1) #0
68  ; CHECK: _Z39atomic_compare_exchange_strong_explicitPVU3AS1U7
69  %cmpxchg_jg = call spir_func i32 @_Z14atomic_cmpxchgPVU3AS1jjj(i32 addrspace(1)* %dst, i32 0, i32 1) #0
70  ; CHECK: _Z39atomic_compare_exchange_strong_explicitPVU3AS1U7
71
72  ; atomic_xchg
73  %xchg_ig = call spir_func i32 @_Z11atomic_xchgPVU3AS1ii(i32 addrspace(1)* %dst, i32 1) #0
74  ; CHECK: _Z24atomic_exchange_explicitPVU3AS1U7_Atomiciiii
75  %xchg_jg = call spir_func i32 @_Z11atomic_xchgPVU3AS1jj(i32 addrspace(1)* %dst, i32 1) #0
76  ; CHECK: _Z24atomic_exchange_explicitPVU3AS1U7_Atomiciiii
77  ret void
78}
79
80; Function Attrs: nounwind
81define spir_kernel void @test_atomic_local(i32 addrspace(3)* %dst) #0 {
82  ; atomic_inc
83  %inc_il = tail call spir_func i32 @_Z10atomic_incPVU3AS3i(i32 addrspace(3)* %dst) #0
84  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS3U7_Atomiciiii(i32 addrspace(3)* {{.*}}, i32 1
85
86  ; atomic dec
87  %dec_jl = tail call spir_func i32 @_Z10atomic_decPVU3AS3j(i32 addrspace(3)* %dst) #0
88  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS3U7_Atomiciiii(i32 addrspace(3)* {{.*}}, i32 1
89
90  ; atomic_max
91  %max_il = tail call spir_func i32 @_Z10atomic_maxPVU3AS3ii(i32 addrspace(3)* %dst, i32 0) #0
92  ; CHECK: _Z25atomic_fetch_max_explicitPVU3AS3U7_Atomiciiii
93  %max_jl = tail call spir_func i32 @_Z10atomic_maxPVU3AS3jj(i32 addrspace(3)* %dst, i32 0) #0
94  ; CHECK: _Z25atomic_fetch_max_explicitPVU3AS3U7_Atomicjjii
95
96  ; atomic_min
97  %min_il = tail call spir_func i32 @_Z10atomic_minPVU3AS3ii(i32 addrspace(3)* %dst, i32 0) #0
98  ; CHECK: _Z25atomic_fetch_min_explicitPVU3AS3U7_Atomiciiii
99  %min_jl = tail call spir_func i32 @_Z10atomic_minPVU3AS3jj(i32 addrspace(3)* %dst, i32 0) #0
100  ; CHECK: _Z25atomic_fetch_min_explicitPVU3AS3U7_Atomicjjii
101
102  ; atomic_add
103  %add_il = tail call spir_func i32 @_Z10atomic_addPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
104  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS3U7_Atomiciiii
105  %add_jl = tail call spir_func i32 @_Z10atomic_addPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
106  ; CHECK: _Z25atomic_fetch_add_explicitPVU3AS3U7_Atomiciiii
107
108  ; atomic_sub
109  %sub_il = tail call spir_func i32 @_Z10atomic_subPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
110  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS3U7_Atomiciiii
111  %sub_jl = tail call spir_func i32 @_Z10atomic_subPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
112  ; CHECK: _Z25atomic_fetch_sub_explicitPVU3AS3U7_Atomiciiii
113
114  ; atomic_or
115  %or_il = tail call spir_func i32 @_Z9atomic_orPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
116  ; CHECK: _Z24atomic_fetch_or_explicitPVU3AS3U7_Atomiciiii
117  %or_jl = tail call spir_func i32 @_Z9atomic_orPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
118  ; CHECK: _Z24atomic_fetch_or_explicitPVU3AS3U7_Atomiciiii
119
120  ; atomic_xor
121  %xor_il = tail call spir_func i32 @_Z10atomic_xorPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
122  ; CHECK: _Z25atomic_fetch_xor_explicitPVU3AS3U7_Atomiciiii
123  %xor_jl = tail call spir_func i32 @_Z10atomic_xorPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
124  ; CHECK: _Z25atomic_fetch_xor_explicitPVU3AS3U7_Atomiciiii
125
126  ; atomic_and
127  %and_il = tail call spir_func i32 @_Z10atomic_andPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
128  ; CHECK: _Z25atomic_fetch_and_explicitPVU3AS3U7_Atomiciiii
129  %and_jl = tail call spir_func i32 @_Z10atomic_andPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
130  ; CHECK: _Z25atomic_fetch_and_explicitPVU3AS3U7_Atomiciiii
131
132  ; atomic_cmpxchg
133  %cmpxchg_il = call spir_func i32 @_Z14atomic_cmpxchgPVU3AS3iii(i32 addrspace(3)* %dst, i32 0, i32 1) #0
134  ; CHECK: _Z39atomic_compare_exchange_strong_explicitPVU3AS3U7
135  %cmpxchg_jl = call spir_func i32 @_Z14atomic_cmpxchgPVU3AS3jjj(i32 addrspace(3)* %dst, i32 0, i32 1) #0
136  ; CHECK: _Z39atomic_compare_exchange_strong_explicitPVU3AS3U7
137
138  ; atomic_xchg
139  %xchg_il = call spir_func i32 @_Z11atomic_xchgPVU3AS3ii(i32 addrspace(3)* %dst, i32 1) #0
140  ; CHECK: _Z24atomic_exchange_explicitPVU3AS3U7_Atomiciiii
141  %xchg_jl = call spir_func i32 @_Z11atomic_xchgPVU3AS3jj(i32 addrspace(3)* %dst, i32 1) #0
142  ; CHECK: _Z24atomic_exchange_explicitPVU3AS3U7_Atomiciiii
143
144  ret void
145}
146
147; Function Attrs: nounwind readnone
148declare spir_func i32 @_Z10atomic_incPVU3AS1i(i32 addrspace(1)*)
149declare spir_func i32 @_Z10atomic_decPVU3AS1j(i32 addrspace(1)*)
150declare spir_func i32 @_Z10atomic_maxPVU3AS1ii(i32 addrspace(1)*, i32)
151declare spir_func i32 @_Z10atomic_maxPVU3AS1jj(i32 addrspace(1)*, i32)
152declare spir_func i32 @_Z10atomic_minPVU3AS1ii(i32 addrspace(1)*, i32)
153declare spir_func i32 @_Z10atomic_minPVU3AS1jj(i32 addrspace(1)*, i32)
154declare spir_func i32 @_Z10atomic_addPVU3AS1ii(i32 addrspace(1)*, i32)
155declare spir_func i32 @_Z10atomic_addPVU3AS1jj(i32 addrspace(1)*, i32)
156declare spir_func i32 @_Z10atomic_subPVU3AS1ii(i32 addrspace(1)*, i32)
157declare spir_func i32 @_Z10atomic_subPVU3AS1jj(i32 addrspace(1)*, i32)
158declare spir_func i32 @_Z9atomic_orPVU3AS1ii(i32 addrspace(1)*, i32)
159declare spir_func i32 @_Z9atomic_orPVU3AS1jj(i32 addrspace(1)*, i32)
160declare spir_func i32 @_Z10atomic_xorPVU3AS1ii(i32 addrspace(1)*, i32)
161declare spir_func i32 @_Z10atomic_xorPVU3AS1jj(i32 addrspace(1)*, i32)
162declare spir_func i32 @_Z10atomic_andPVU3AS1ii(i32 addrspace(1)*, i32)
163declare spir_func i32 @_Z10atomic_andPVU3AS1jj(i32 addrspace(1)*, i32)
164declare spir_func i32 @_Z14atomic_cmpxchgPVU3AS1iii(i32 addrspace(1)*, i32, i32)
165declare spir_func i32 @_Z14atomic_cmpxchgPVU3AS1jjj(i32 addrspace(1)*, i32, i32)
166declare spir_func i32 @_Z11atomic_xchgPVU3AS1ii(i32 addrspace(1)*, i32)
167declare spir_func i32 @_Z11atomic_xchgPVU3AS1jj(i32 addrspace(1)*, i32)
168
169declare spir_func i32 @_Z10atomic_incPVU3AS3i(i32 addrspace(3)*)
170declare spir_func i32 @_Z10atomic_decPVU3AS3j(i32 addrspace(3)*)
171declare spir_func i32 @_Z10atomic_maxPVU3AS3ii(i32 addrspace(3)*, i32)
172declare spir_func i32 @_Z10atomic_maxPVU3AS3jj(i32 addrspace(3)*, i32)
173declare spir_func i32 @_Z10atomic_minPVU3AS3ii(i32 addrspace(3)*, i32)
174declare spir_func i32 @_Z10atomic_minPVU3AS3jj(i32 addrspace(3)*, i32)
175declare spir_func i32 @_Z10atomic_addPVU3AS3ii(i32 addrspace(3)*, i32)
176declare spir_func i32 @_Z10atomic_addPVU3AS3jj(i32 addrspace(3)*, i32)
177declare spir_func i32 @_Z10atomic_subPVU3AS3ii(i32 addrspace(3)*, i32)
178declare spir_func i32 @_Z10atomic_subPVU3AS3jj(i32 addrspace(3)*, i32)
179declare spir_func i32 @_Z9atomic_orPVU3AS3ii(i32 addrspace(3)*, i32)
180declare spir_func i32 @_Z9atomic_orPVU3AS3jj(i32 addrspace(3)*, i32)
181declare spir_func i32 @_Z10atomic_xorPVU3AS3ii(i32 addrspace(3)*, i32)
182declare spir_func i32 @_Z10atomic_xorPVU3AS3jj(i32 addrspace(3)*, i32)
183declare spir_func i32 @_Z10atomic_andPVU3AS3ii(i32 addrspace(3)*, i32)
184declare spir_func i32 @_Z10atomic_andPVU3AS3jj(i32 addrspace(3)*, i32)
185declare spir_func i32 @_Z14atomic_cmpxchgPVU3AS3iii(i32 addrspace(3)*, i32, i32)
186declare spir_func i32 @_Z14atomic_cmpxchgPVU3AS3jjj(i32 addrspace(3)*, i32, i32)
187declare spir_func i32 @_Z11atomic_xchgPVU3AS3ii(i32 addrspace(3)*, i32)
188declare spir_func i32 @_Z11atomic_xchgPVU3AS3jj(i32 addrspace(3)*, i32)
189
190attributes #0 = { nounwind }
191attributes #1 = { nounwind readnone }
192
193!opencl.kernels = !{!0, !10}
194!opencl.enable.FP_CONTRACT = !{}
195!opencl.spir.version = !{!7}
196!opencl.ocl.version = !{!7}
197!opencl.used.extensions = !{!8}
198!opencl.used.optional.core.features = !{!8}
199!opencl.compiler.options = !{!9}
200
201!0 = !{void (i32 addrspace(1)*)* @test_atomic_global, !1, !2, !3, !4, !5, !6}
202!1 = !{!"kernel_arg_addr_space", i32 1}
203!2 = !{!"kernel_arg_access_qual", !"none"}
204!3 = !{!"kernel_arg_type", !"int*"}
205!4 = !{!"kernel_arg_type_qual", !"volatile"}
206!5 = !{!"kernel_arg_base_type", !"int*"}
207!6 = !{!"kernel_arg_name", !"dst"}
208!7 = !{i32 1, i32 2}
209!8 = !{}
210!9 = !{!"-cl-kernel-arg-info"}
211!10 = !{void (i32 addrspace(3)*)* @test_atomic_local, !11, !2, !3, !4, !5, !6}
212!11 = !{!"kernel_arg_addr_space", i32 1}
213