1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu \
3 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu \
5 // RUN: -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
6 // RUN: %clang_cc1 -triple powerpc64-unknown-aix \
7 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
8 // RUN: %clang_cc1 -triple powerpc-unknown-aix \
9 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s --check-prefix=CHECK-32
10
11 extern unsigned long a;
12 extern const void *b;
13 extern void *c;
14
15 // CHECK-LABEL: @test_popcntb(
16 // CHECK: [[TMP0:%.*]] = load i64, ptr @a, align 8
17 // CHECK-NEXT: [[POPCNTB:%.*]] = call i64 @llvm.ppc.popcntb.i64.i64(i64 [[TMP0]])
18 // CHECK-NEXT: ret i64 [[POPCNTB]]
19 //
20 // CHECK-32-LABEL: @test_popcntb(
21 // CHECK-32: [[TMP0:%.*]] = load i32, ptr @a, align 4
22 // CHECK-32-NEXT: [[POPCNTB:%.*]] = call i32 @llvm.ppc.popcntb.i32.i32(i32 [[TMP0]])
23 // CHECK-32-NEXT: ret i32 [[POPCNTB]]
24 //
test_popcntb()25 unsigned long test_popcntb() {
26 return __popcntb(a);
27 }
28
29 // CHECK-LABEL: @test_eieio(
30 // CHECK: call void @llvm.ppc.eieio()
31 // CHECK-NEXT: ret void
32 //
33 // CHECK-32-LABEL: @test_eieio(
34 // CHECK-32: call void @llvm.ppc.eieio()
35 // CHECK-32-NEXT: ret void
36 //
test_eieio()37 void test_eieio() {
38 __eieio();
39 }
40
41 // CHECK-LABEL: @test_iospace_eieio(
42 // CHECK: call void @llvm.ppc.iospace.eieio()
43 // CHECK-NEXT: ret void
44 //
45 // CHECK-32-LABEL: @test_iospace_eieio(
46 // CHECK-32: call void @llvm.ppc.iospace.eieio()
47 // CHECK-32-NEXT: ret void
48 //
test_iospace_eieio()49 void test_iospace_eieio() {
50 __iospace_eieio();
51 }
52
53 // CHECK-LABEL: @test_isync(
54 // CHECK: call void @llvm.ppc.isync()
55 // CHECK-NEXT: ret void
56 //
57 // CHECK-32-LABEL: @test_isync(
58 // CHECK-32: call void @llvm.ppc.isync()
59 // CHECK-32-NEXT: ret void
60 //
test_isync()61 void test_isync() {
62 __isync();
63 }
64
65 // CHECK-LABEL: @test_lwsync(
66 // CHECK: call void @llvm.ppc.lwsync()
67 // CHECK-NEXT: ret void
68 //
69 // CHECK-32-LABEL: @test_lwsync(
70 // CHECK-32: call void @llvm.ppc.lwsync()
71 // CHECK-32-NEXT: ret void
72 //
test_lwsync()73 void test_lwsync() {
74 __lwsync();
75 }
76
77 // CHECK-LABEL: @test_iospace_lwsync(
78 // CHECK: call void @llvm.ppc.iospace.lwsync()
79 // CHECK-NEXT: ret void
80 //
81 // CHECK-32-LABEL: @test_iospace_lwsync(
82 // CHECK-32: call void @llvm.ppc.iospace.lwsync()
83 // CHECK-32-NEXT: ret void
84 //
test_iospace_lwsync()85 void test_iospace_lwsync() {
86 __iospace_lwsync();
87 }
88
89 // CHECK-LABEL: @test_sync(
90 // CHECK: call void @llvm.ppc.sync()
91 // CHECK-NEXT: ret void
92 //
93 // CHECK-32-LABEL: @test_sync(
94 // CHECK-32: call void @llvm.ppc.sync()
95 // CHECK-32-NEXT: ret void
96 //
test_sync()97 void test_sync() {
98 __sync();
99 }
100
101 // CHECK-LABEL: @test_iospace_sync(
102 // CHECK: call void @llvm.ppc.iospace.sync()
103 // CHECK-NEXT: ret void
104 //
105 // CHECK-32-LABEL: @test_iospace_sync(
106 // CHECK-32: call void @llvm.ppc.iospace.sync()
107 // CHECK-32-NEXT: ret void
108 //
test_iospace_sync()109 void test_iospace_sync() {
110 __iospace_sync();
111 }
112
113 // CHECK-LABEL: @test_dcbfl(
114 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
115 // CHECK-NEXT: call void @llvm.ppc.dcbfl(ptr [[TMP0]])
116 // CHECK-NEXT: ret void
117 //
118 // CHECK-32-LABEL: @test_dcbfl(
119 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
120 // CHECK-32-NEXT: call void @llvm.ppc.dcbfl(ptr [[TMP0]])
121 // CHECK-32-NEXT: ret void
122 //
test_dcbfl()123 void test_dcbfl() {
124 __dcbfl(b);
125 }
126
127 // CHECK-LABEL: @test_dcbflp(
128 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
129 // CHECK-NEXT: call void @llvm.ppc.dcbflp(ptr [[TMP0]])
130 // CHECK-NEXT: ret void
131 //
132 // CHECK-32-LABEL: @test_dcbflp(
133 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
134 // CHECK-32-NEXT: call void @llvm.ppc.dcbflp(ptr [[TMP0]])
135 // CHECK-32-NEXT: ret void
136 //
test_dcbflp()137 void test_dcbflp() {
138 __dcbflp(b);
139 }
140
141 // CHECK-LABEL: @test_dcbst(
142 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
143 // CHECK-NEXT: call void @llvm.ppc.dcbst(ptr [[TMP0]])
144 // CHECK-NEXT: ret void
145 //
146 // CHECK-32-LABEL: @test_dcbst(
147 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
148 // CHECK-32-NEXT: call void @llvm.ppc.dcbst(ptr [[TMP0]])
149 // CHECK-32-NEXT: ret void
150 //
test_dcbst()151 void test_dcbst() {
152 __dcbst(b);
153 }
154
155 // CHECK-LABEL: @test_dcbt(
156 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
157 // CHECK-NEXT: call void @llvm.ppc.dcbt(ptr [[TMP0]])
158 // CHECK-NEXT: ret void
159 //
160 // CHECK-32-LABEL: @test_dcbt(
161 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
162 // CHECK-32-NEXT: call void @llvm.ppc.dcbt(ptr [[TMP0]])
163 // CHECK-32-NEXT: ret void
164 //
test_dcbt()165 void test_dcbt() {
166 __dcbt(c);
167 }
168
169 // CHECK-LABEL: @test_dcbtst(
170 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
171 // CHECK-NEXT: call void @llvm.ppc.dcbtst(ptr [[TMP0]])
172 // CHECK-NEXT: ret void
173 //
174 // CHECK-32-LABEL: @test_dcbtst(
175 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
176 // CHECK-32-NEXT: call void @llvm.ppc.dcbtst(ptr [[TMP0]])
177 // CHECK-32-NEXT: ret void
178 //
test_dcbtst()179 void test_dcbtst() {
180 __dcbtst(c);
181 }
182
183 // CHECK-LABEL: @test_dcbz(
184 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
185 // CHECK-NEXT: call void @llvm.ppc.dcbz(ptr [[TMP0]])
186 // CHECK-NEXT: ret void
187 //
188 // CHECK-32-LABEL: @test_dcbz(
189 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
190 // CHECK-32-NEXT: call void @llvm.ppc.dcbz(ptr [[TMP0]])
191 // CHECK-32-NEXT: ret void
192 //
test_dcbz()193 void test_dcbz() {
194 __dcbz(c);
195 }
196
197 // CHECK-LABEL: @test_fence(
198 // CHECK: call void @llvm.ppc.fence()
199 // CHECK-NEXT: ret void
200 //
201 // CHECK-32-LABEL: @test_fence(
202 // CHECK-32: call void @llvm.ppc.fence()
203 // CHECK-32-NEXT: ret void
204 //
test_fence()205 void test_fence() {
206 __fence();
207 }
208
209 // CHECK-LABEL: @test_builtin_ppc_popcntb(
210 // CHECK: [[TMP0:%.*]] = load i64, ptr @a, align 8
211 // CHECK-NEXT: [[POPCNTB:%.*]] = call i64 @llvm.ppc.popcntb.i64.i64(i64 [[TMP0]])
212 // CHECK-NEXT: ret i64 [[POPCNTB]]
213 //
214 // CHECK-32-LABEL: @test_builtin_ppc_popcntb(
215 // CHECK-32: [[TMP0:%.*]] = load i32, ptr @a, align 4
216 // CHECK-32-NEXT: [[POPCNTB:%.*]] = call i32 @llvm.ppc.popcntb.i32.i32(i32 [[TMP0]])
217 // CHECK-32-NEXT: ret i32 [[POPCNTB]]
218 //
test_builtin_ppc_popcntb()219 unsigned long test_builtin_ppc_popcntb() {
220 return __builtin_ppc_popcntb(a);
221 }
222
223 // CHECK-LABEL: @test_builtin_ppc_eieio(
224 // CHECK: call void @llvm.ppc.eieio()
225 // CHECK-NEXT: ret void
226 //
227 // CHECK-32-LABEL: @test_builtin_ppc_eieio(
228 // CHECK-32: call void @llvm.ppc.eieio()
229 // CHECK-32-NEXT: ret void
230 //
test_builtin_ppc_eieio()231 void test_builtin_ppc_eieio() {
232 __builtin_ppc_eieio();
233 }
234
235 // CHECK-LABEL: @test_builtin_ppc_iospace_eieio(
236 // CHECK: call void @llvm.ppc.iospace.eieio()
237 // CHECK-NEXT: ret void
238 //
239 // CHECK-32-LABEL: @test_builtin_ppc_iospace_eieio(
240 // CHECK-32: call void @llvm.ppc.iospace.eieio()
241 // CHECK-32-NEXT: ret void
242 //
test_builtin_ppc_iospace_eieio()243 void test_builtin_ppc_iospace_eieio() {
244 __builtin_ppc_iospace_eieio();
245 }
246
247 // CHECK-LABEL: @test_builtin_ppc_isync(
248 // CHECK: call void @llvm.ppc.isync()
249 // CHECK-NEXT: ret void
250 //
251 // CHECK-32-LABEL: @test_builtin_ppc_isync(
252 // CHECK-32: call void @llvm.ppc.isync()
253 // CHECK-32-NEXT: ret void
254 //
test_builtin_ppc_isync()255 void test_builtin_ppc_isync() {
256 __builtin_ppc_isync();
257 }
258
259 // CHECK-LABEL: @test_builtin_ppc_lwsync(
260 // CHECK: call void @llvm.ppc.lwsync()
261 // CHECK-NEXT: ret void
262 //
263 // CHECK-32-LABEL: @test_builtin_ppc_lwsync(
264 // CHECK-32: call void @llvm.ppc.lwsync()
265 // CHECK-32-NEXT: ret void
266 //
test_builtin_ppc_lwsync()267 void test_builtin_ppc_lwsync() {
268 __builtin_ppc_lwsync();
269 }
270
271 // CHECK-LABEL: @test_builtin_ppc_iospace_lwsync(
272 // CHECK: call void @llvm.ppc.iospace.lwsync()
273 // CHECK-NEXT: ret void
274 //
275 // CHECK-32-LABEL: @test_builtin_ppc_iospace_lwsync(
276 // CHECK-32: call void @llvm.ppc.iospace.lwsync()
277 // CHECK-32-NEXT: ret void
278 //
test_builtin_ppc_iospace_lwsync()279 void test_builtin_ppc_iospace_lwsync() {
280 __builtin_ppc_iospace_lwsync();
281 }
282
283 // CHECK-LABEL: @test_builtin_ppc_sync(
284 // CHECK: call void @llvm.ppc.sync()
285 // CHECK-NEXT: ret void
286 //
287 // CHECK-32-LABEL: @test_builtin_ppc_sync(
288 // CHECK-32: call void @llvm.ppc.sync()
289 // CHECK-32-NEXT: ret void
290 //
test_builtin_ppc_sync()291 void test_builtin_ppc_sync() {
292 __builtin_ppc_sync();
293 }
294
295 // CHECK-LABEL: @test_builtin_ppc_iospace_sync(
296 // CHECK: call void @llvm.ppc.iospace.sync()
297 // CHECK-NEXT: ret void
298 //
299 // CHECK-32-LABEL: @test_builtin_ppc_iospace_sync(
300 // CHECK-32: call void @llvm.ppc.iospace.sync()
301 // CHECK-32-NEXT: ret void
302 //
test_builtin_ppc_iospace_sync()303 void test_builtin_ppc_iospace_sync() {
304 __builtin_ppc_iospace_sync();
305 }
306
307 // CHECK-LABEL: @test_builtin_ppc_dcbfl(
308 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
309 // CHECK-NEXT: call void @llvm.ppc.dcbfl(ptr [[TMP0]])
310 // CHECK-NEXT: ret void
311 //
312 // CHECK-32-LABEL: @test_builtin_ppc_dcbfl(
313 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
314 // CHECK-32-NEXT: call void @llvm.ppc.dcbfl(ptr [[TMP0]])
315 // CHECK-32-NEXT: ret void
316 //
test_builtin_ppc_dcbfl()317 void test_builtin_ppc_dcbfl() {
318 __builtin_ppc_dcbfl(b);
319 }
320
321 // CHECK-LABEL: @test_builtin_ppc_dcbflp(
322 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
323 // CHECK-NEXT: call void @llvm.ppc.dcbflp(ptr [[TMP0]])
324 // CHECK-NEXT: ret void
325 //
326 // CHECK-32-LABEL: @test_builtin_ppc_dcbflp(
327 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
328 // CHECK-32-NEXT: call void @llvm.ppc.dcbflp(ptr [[TMP0]])
329 // CHECK-32-NEXT: ret void
330 //
test_builtin_ppc_dcbflp()331 void test_builtin_ppc_dcbflp() {
332 __builtin_ppc_dcbflp(b);
333 }
334
335 // CHECK-LABEL: @test_builtin_ppc_dcbst(
336 // CHECK: [[TMP0:%.*]] = load ptr, ptr @b, align 8
337 // CHECK-NEXT: call void @llvm.ppc.dcbst(ptr [[TMP0]])
338 // CHECK-NEXT: ret void
339 //
340 // CHECK-32-LABEL: @test_builtin_ppc_dcbst(
341 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @b, align 4
342 // CHECK-32-NEXT: call void @llvm.ppc.dcbst(ptr [[TMP0]])
343 // CHECK-32-NEXT: ret void
344 //
test_builtin_ppc_dcbst()345 void test_builtin_ppc_dcbst() {
346 __builtin_ppc_dcbst(b);
347 }
348
349 // CHECK-LABEL: @test_builtin_ppc_dcbt(
350 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
351 // CHECK-NEXT: call void @llvm.ppc.dcbt(ptr [[TMP0]])
352 // CHECK-NEXT: ret void
353 //
354 // CHECK-32-LABEL: @test_builtin_ppc_dcbt(
355 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
356 // CHECK-32-NEXT: call void @llvm.ppc.dcbt(ptr [[TMP0]])
357 // CHECK-32-NEXT: ret void
358 //
test_builtin_ppc_dcbt()359 void test_builtin_ppc_dcbt() {
360 __builtin_ppc_dcbt(c);
361 }
362
363 // CHECK-LABEL: @test_builtin_ppc_dcbtst(
364 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
365 // CHECK-NEXT: call void @llvm.ppc.dcbtst(ptr [[TMP0]])
366 // CHECK-NEXT: ret void
367 //
368 // CHECK-32-LABEL: @test_builtin_ppc_dcbtst(
369 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
370 // CHECK-32-NEXT: call void @llvm.ppc.dcbtst(ptr [[TMP0]])
371 // CHECK-32-NEXT: ret void
372 //
test_builtin_ppc_dcbtst()373 void test_builtin_ppc_dcbtst() {
374 __builtin_ppc_dcbtst(c);
375 }
376
377 // CHECK-LABEL: @test_builtin_ppc_dcbz(
378 // CHECK: [[TMP0:%.*]] = load ptr, ptr @c, align 8
379 // CHECK-NEXT: call void @llvm.ppc.dcbz(ptr [[TMP0]])
380 // CHECK-NEXT: ret void
381 //
382 // CHECK-32-LABEL: @test_builtin_ppc_dcbz(
383 // CHECK-32: [[TMP0:%.*]] = load ptr, ptr @c, align 4
384 // CHECK-32-NEXT: call void @llvm.ppc.dcbz(ptr [[TMP0]])
385 // CHECK-32-NEXT: ret void
386 //
test_builtin_ppc_dcbz()387 void test_builtin_ppc_dcbz() {
388 __builtin_ppc_dcbz(c);
389 }
390
391 // CHECK-LABEL: @test_builtin_ppc_fence(
392 // CHECK: call void @llvm.ppc.fence()
393 // CHECK-NEXT: ret void
394 //
395 // CHECK-32-LABEL: @test_builtin_ppc_fence(
396 // CHECK-32: call void @llvm.ppc.fence()
397 // CHECK-32-NEXT: ret void
398 //
test_builtin_ppc_fence()399 void test_builtin_ppc_fence() {
400 __builtin_ppc_fence();
401 }
402