1 | // REQUIRES: powerpc-registered-target |
2 | // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown \ |
3 | // RUN: -target-feature +crypto -target-feature +power8-vector \ |
4 | // RUN: -emit-llvm %s -o - | FileCheck %s |
5 | |
6 | // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown \ |
7 | // RUN: -target-feature +crypto -target-feature +power8-vector \ |
8 | // RUN: -emit-llvm %s -o - | FileCheck %s |
9 | #include <altivec.h> |
10 | #define B_INIT1 { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, \ |
11 | 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 }; |
12 | #define B_INIT2 { 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, \ |
13 | 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70 }; |
14 | #define H_INIT1 { 0x0102, 0x0304, 0x0506, 0x0708, \ |
15 | 0x090A, 0x0B0C, 0x0D0E, 0x0F10 }; |
16 | #define H_INIT2 { 0x7172, 0x7374, 0x7576, 0x7778, \ |
17 | 0x797A, 0x7B7C, 0x7D7E, 0x7F70 }; |
18 | #define W_INIT1 { 0x01020304, 0x05060708, \ |
19 | 0x090A0B0C, 0x0D0E0F10 }; |
20 | #define W_INIT2 { 0x71727374, 0x75767778, \ |
21 | 0x797A7B7C, 0x7D7E7F70 }; |
22 | #define D_INIT1 { 0x0102030405060708, \ |
23 | 0x090A0B0C0D0E0F10 }; |
24 | #define D_INIT2 { 0x7172737475767778, \ |
25 | 0x797A7B7C7D7E7F70 }; |
26 | |
27 | // CHECK-LABEL: define <16 x i8> @test_vpmsumb |
28 | vector unsigned char test_vpmsumb(void) |
29 | { |
30 | vector unsigned char a = B_INIT1 |
31 | vector unsigned char b = B_INIT2 |
32 | return __builtin_altivec_crypto_vpmsumb(a, b); |
33 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumb |
34 | } |
35 | |
36 | // CHECK-LABEL: define <8 x i16> @test_vpmsumh |
37 | vector unsigned short test_vpmsumh(void) |
38 | { |
39 | vector unsigned short a = H_INIT1 |
40 | vector unsigned short b = H_INIT2 |
41 | return __builtin_altivec_crypto_vpmsumh(a, b); |
42 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumh |
43 | } |
44 | |
45 | // CHECK-LABEL: define <4 x i32> @test_vpmsumw |
46 | vector unsigned int test_vpmsumw(void) |
47 | { |
48 | vector unsigned int a = W_INIT1 |
49 | vector unsigned int b = W_INIT2 |
50 | return __builtin_altivec_crypto_vpmsumw(a, b); |
51 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumw |
52 | } |
53 | |
54 | // CHECK-LABEL: define <2 x i64> @test_vpmsumd |
55 | vector unsigned long long test_vpmsumd(void) |
56 | { |
57 | vector unsigned long long a = D_INIT1 |
58 | vector unsigned long long b = D_INIT2 |
59 | return __builtin_altivec_crypto_vpmsumd(a, b); |
60 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumd |
61 | } |
62 | |
63 | // CHECK-LABEL: define <2 x i64> @test_vsbox |
64 | vector unsigned long long test_vsbox(void) |
65 | { |
66 | vector unsigned long long a = D_INIT1 |
67 | return __builtin_altivec_crypto_vsbox(a); |
68 | // CHECK: @llvm.ppc.altivec.crypto.vsbox |
69 | } |
70 | |
71 | // CHECK-LABEL: define <16 x i8> @test_vpermxorb |
72 | vector unsigned char test_vpermxorb(void) |
73 | { |
74 | vector unsigned char a = B_INIT1 |
75 | vector unsigned char b = B_INIT2 |
76 | vector unsigned char c = B_INIT2 |
77 | return __builtin_altivec_crypto_vpermxor(a, b, c); |
78 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
79 | } |
80 | |
81 | // CHECK-LABEL: define <8 x i16> @test_vpermxorh |
82 | vector unsigned short test_vpermxorh(void) |
83 | { |
84 | vector unsigned short a = H_INIT1 |
85 | vector unsigned short b = H_INIT2 |
86 | vector unsigned short c = H_INIT2 |
87 | return __builtin_altivec_crypto_vpermxor(a, b, c); |
88 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
89 | } |
90 | |
91 | // CHECK-LABEL: define <4 x i32> @test_vpermxorw |
92 | vector unsigned int test_vpermxorw(void) |
93 | { |
94 | vector unsigned int a = W_INIT1 |
95 | vector unsigned int b = W_INIT2 |
96 | vector unsigned int c = W_INIT2 |
97 | return __builtin_altivec_crypto_vpermxor(a, b, c); |
98 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
99 | } |
100 | |
101 | // CHECK-LABEL: define <2 x i64> @test_vpermxord |
102 | vector unsigned long long test_vpermxord(void) |
103 | { |
104 | vector unsigned long long a = D_INIT1 |
105 | vector unsigned long long b = D_INIT2 |
106 | vector unsigned long long c = D_INIT2 |
107 | return __builtin_altivec_crypto_vpermxor(a, b, c); |
108 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
109 | } |
110 | |
111 | // CHECK-LABEL: test_vpermxorbc |
112 | vector bool char test_vpermxorbc(vector bool char a, |
113 | vector bool char b, |
114 | vector bool char c) { |
115 | return vec_permxor(a, b, c); |
116 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
117 | } |
118 | |
119 | // CHECK-LABEL: test_vpermxorsc |
120 | vector signed char test_vpermxorsc(vector signed char a, |
121 | vector signed char b, |
122 | vector signed char c) { |
123 | return vec_permxor(a, b, c); |
124 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
125 | } |
126 | |
127 | // CHECK-LABEL: test_vpermxoruc |
128 | vector unsigned char test_vpermxoruc(vector unsigned char a, |
129 | vector unsigned char b, |
130 | vector unsigned char c) { |
131 | return vec_permxor(a, b, c); |
132 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
133 | } |
134 | |
135 | // CHECK-LABEL: define <2 x i64> @test_vcipher |
136 | vector unsigned long long test_vcipher(void) |
137 | { |
138 | vector unsigned long long a = D_INIT1 |
139 | vector unsigned long long b = D_INIT2 |
140 | return __builtin_altivec_crypto_vcipher(a, b); |
141 | // CHECK: @llvm.ppc.altivec.crypto.vcipher |
142 | } |
143 | |
144 | // CHECK-LABEL: define <2 x i64> @test_vcipherlast |
145 | vector unsigned long long test_vcipherlast(void) |
146 | { |
147 | vector unsigned long long a = D_INIT1 |
148 | vector unsigned long long b = D_INIT2 |
149 | return __builtin_altivec_crypto_vcipherlast(a, b); |
150 | // CHECK: @llvm.ppc.altivec.crypto.vcipherlast |
151 | } |
152 | |
153 | // CHECK-LABEL: @test_vncipher |
154 | vector unsigned long long test_vncipher(void) |
155 | { |
156 | vector unsigned long long a = D_INIT1 |
157 | vector unsigned long long b = D_INIT2 |
158 | return __builtin_altivec_crypto_vncipher(a, b); |
159 | // CHECK: @llvm.ppc.altivec.crypto.vncipher |
160 | } |
161 | |
162 | // CHECK-LABEL: define <2 x i64> @test_vncipherlast |
163 | vector unsigned long long test_vncipherlast(void) |
164 | { |
165 | vector unsigned long long a = D_INIT1 |
166 | vector unsigned long long b = D_INIT2 |
167 | return __builtin_altivec_crypto_vncipherlast(a, b); |
168 | // CHECK: @llvm.ppc.altivec.crypto.vncipherlast |
169 | } |
170 | |
171 | // CHECK-LABEL: define <4 x i32> @test_vshasigmaw |
172 | vector unsigned int test_vshasigmaw(void) |
173 | { |
174 | vector unsigned int a = W_INIT1 |
175 | return __builtin_altivec_crypto_vshasigmaw(a, 1, 15); |
176 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw |
177 | } |
178 | |
179 | // CHECK-LABEL: define <2 x i64> @test_vshasigmad |
180 | vector unsigned long long test_vshasigmad(void) |
181 | { |
182 | vector unsigned long long a = D_INIT2 |
183 | return __builtin_altivec_crypto_vshasigmad(a, 1, 15); |
184 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmad |
185 | } |
186 | |
187 | // Test cases for the builtins the way they are exposed to |
188 | // users through altivec.h |
189 | // CHECK-LABEL: define <16 x i8> @test_vpmsumb_e |
190 | vector unsigned char test_vpmsumb_e(void) |
191 | { |
192 | vector unsigned char a = B_INIT1 |
193 | vector unsigned char b = B_INIT2 |
194 | return __builtin_crypto_vpmsumb(a, b); |
195 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumb |
196 | } |
197 | |
198 | // CHECK-LABEL: define <8 x i16> @test_vpmsumh_e |
199 | vector unsigned short test_vpmsumh_e(void) |
200 | { |
201 | vector unsigned short a = H_INIT1 |
202 | vector unsigned short b = H_INIT2 |
203 | return __builtin_crypto_vpmsumb(a, b); |
204 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumh |
205 | } |
206 | |
207 | // CHECK-LABEL: define <4 x i32> @test_vpmsumw_e |
208 | vector unsigned int test_vpmsumw_e(void) |
209 | { |
210 | vector unsigned int a = W_INIT1 |
211 | vector unsigned int b = W_INIT2 |
212 | return __builtin_crypto_vpmsumb(a, b); |
213 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumw |
214 | } |
215 | |
216 | // CHECK-LABEL: define <2 x i64> @test_vpmsumd_e |
217 | vector unsigned long long test_vpmsumd_e(void) |
218 | { |
219 | vector unsigned long long a = D_INIT1 |
220 | vector unsigned long long b = D_INIT2 |
221 | return __builtin_crypto_vpmsumb(a, b); |
222 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumd |
223 | } |
224 | |
225 | // CHECK-LABEL: define <2 x i64> @test_vsbox_e |
226 | vector unsigned long long test_vsbox_e(void) |
227 | { |
228 | vector unsigned long long a = D_INIT1 |
229 | return __builtin_crypto_vsbox(a); |
230 | // CHECK: @llvm.ppc.altivec.crypto.vsbox |
231 | } |
232 | |
233 | // CHECK-LABEL: define <16 x i8> @test_vpermxorb_e |
234 | vector unsigned char test_vpermxorb_e(void) |
235 | { |
236 | vector unsigned char a = B_INIT1 |
237 | vector unsigned char b = B_INIT2 |
238 | vector unsigned char c = B_INIT2 |
239 | return __builtin_crypto_vpermxor(a, b, c); |
240 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
241 | } |
242 | |
243 | // CHECK-LABEL: define <8 x i16> @test_vpermxorh_e |
244 | vector unsigned short test_vpermxorh_e(void) |
245 | { |
246 | vector unsigned short a = H_INIT1 |
247 | vector unsigned short b = H_INIT2 |
248 | vector unsigned short c = H_INIT2 |
249 | return __builtin_crypto_vpermxor(a, b, c); |
250 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
251 | } |
252 | |
253 | // CHECK-LABEL: define <4 x i32> @test_vpermxorw_e |
254 | vector unsigned int test_vpermxorw_e(void) |
255 | { |
256 | vector unsigned int a = W_INIT1 |
257 | vector unsigned int b = W_INIT2 |
258 | vector unsigned int c = W_INIT2 |
259 | return __builtin_crypto_vpermxor(a, b, c); |
260 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
261 | } |
262 | |
263 | // CHECK-LABEL: define <2 x i64> @test_vpermxord_e |
264 | vector unsigned long long test_vpermxord_e(void) |
265 | { |
266 | vector unsigned long long a = D_INIT1 |
267 | vector unsigned long long b = D_INIT2 |
268 | vector unsigned long long c = D_INIT2 |
269 | return __builtin_crypto_vpermxor(a, b, c); |
270 | // CHECK: @llvm.ppc.altivec.crypto.vpermxor |
271 | } |
272 | |
273 | // CHECK-LABEL: define <2 x i64> @test_vcipher_e |
274 | vector unsigned long long test_vcipher_e(void) |
275 | { |
276 | vector unsigned long long a = D_INIT1 |
277 | vector unsigned long long b = D_INIT2 |
278 | return __builtin_crypto_vcipher(a, b); |
279 | // CHECK: @llvm.ppc.altivec.crypto.vcipher |
280 | } |
281 | |
282 | // CHECK-LABEL: define <2 x i64> @test_vcipherlast_e |
283 | vector unsigned long long test_vcipherlast_e(void) |
284 | { |
285 | vector unsigned long long a = D_INIT1 |
286 | vector unsigned long long b = D_INIT2 |
287 | return __builtin_crypto_vcipherlast(a, b); |
288 | // CHECK: @llvm.ppc.altivec.crypto.vcipherlast |
289 | } |
290 | |
291 | // CHECK-LABEL: define <2 x i64> @test_vncipher_e |
292 | vector unsigned long long test_vncipher_e(void) |
293 | { |
294 | vector unsigned long long a = D_INIT1 |
295 | vector unsigned long long b = D_INIT2 |
296 | return __builtin_crypto_vncipher(a, b); |
297 | // CHECK: @llvm.ppc.altivec.crypto.vncipher |
298 | } |
299 | |
300 | // CHECK-LABEL: define <2 x i64> @test_vncipherlast_e |
301 | vector unsigned long long test_vncipherlast_e(void) |
302 | { |
303 | vector unsigned long long a = D_INIT1 |
304 | vector unsigned long long b = D_INIT2 |
305 | return __builtin_crypto_vncipherlast(a, b); |
306 | // CHECK: @llvm.ppc.altivec.crypto.vncipherlast |
307 | } |
308 | |
309 | // CHECK-LABEL: define <4 x i32> @test_vshasigmaw_e |
310 | vector unsigned int test_vshasigmaw_e(void) |
311 | { |
312 | vector unsigned int a = W_INIT1 |
313 | return __builtin_crypto_vshasigmaw(a, 1, 15); |
314 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw |
315 | } |
316 | |
317 | // CHECK-LABEL: define <2 x i64> @test_vshasigmad_e |
318 | vector unsigned long long test_vshasigmad_e(void) |
319 | { |
320 | vector unsigned long long a = D_INIT2 |
321 | return __builtin_crypto_vshasigmad(a, 0, 15); |
322 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmad |
323 | } |
324 | |
325 | // CHECK-LABEL: @test_vec_sbox_be |
326 | vector unsigned char test_vec_sbox_be(void) |
327 | { |
328 | vector unsigned char a = B_INIT1 |
329 | return vec_sbox_be(a); |
330 | // CHECK: @llvm.ppc.altivec.crypto.vsbox |
331 | } |
332 | |
333 | // CHECK-LABEL: @test_vec_cipher_be |
334 | vector unsigned char test_vec_cipher_be(void) |
335 | { |
336 | vector unsigned char a = B_INIT1 |
337 | vector unsigned char b = B_INIT2 |
338 | return vec_cipher_be(a, b); |
339 | // CHECK: @llvm.ppc.altivec.crypto.vcipher |
340 | } |
341 | |
342 | // CHECK-LABEL: @test_vec_cipherlast_be |
343 | vector unsigned char test_vec_cipherlast_be(void) |
344 | { |
345 | vector unsigned char a = B_INIT1 |
346 | vector unsigned char b = B_INIT2 |
347 | return vec_cipherlast_be(a, b); |
348 | // CHECK: @llvm.ppc.altivec.crypto.vcipherlast |
349 | } |
350 | |
351 | // CHECK-LABEL: @test_vec_ncipher_be |
352 | vector unsigned char test_vec_ncipher_be(void) |
353 | { |
354 | vector unsigned char a = B_INIT1 |
355 | vector unsigned char b = B_INIT2 |
356 | return vec_ncipher_be(a, b); |
357 | // CHECK: @llvm.ppc.altivec.crypto.vncipher |
358 | } |
359 | |
360 | // CHECK-LABEL: @test_vec_ncipherlast_be |
361 | vector unsigned char test_vec_ncipherlast_be(void) |
362 | { |
363 | vector unsigned char a = B_INIT1 |
364 | vector unsigned char b = B_INIT2 |
365 | return vec_ncipherlast_be(a, b); |
366 | // CHECK: @llvm.ppc.altivec.crypto.vncipherlast |
367 | } |
368 | |
369 | // CHECK-LABEL: @test_vec_shasigma_bew |
370 | vector unsigned int test_vec_shasigma_bew(void) |
371 | { |
372 | vector unsigned int a = W_INIT1 |
373 | return vec_shasigma_be(a, 1, 15); |
374 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw |
375 | } |
376 | |
377 | // CHECK-LABEL: @test_vec_shasigma_bed |
378 | vector unsigned long long test_vec_shasigma_bed(void) |
379 | { |
380 | vector unsigned long long a = D_INIT2 |
381 | return vec_shasigma_be(a, 1, 15); |
382 | // CHECK: @llvm.ppc.altivec.crypto.vshasigmad |
383 | } |
384 | |
385 | // CHECK-LABEL: @test_vec_pmsum_beb |
386 | vector unsigned short test_vec_pmsum_beb(void) |
387 | { |
388 | vector unsigned char a = B_INIT1 |
389 | vector unsigned char b = B_INIT2 |
390 | return vec_pmsum_be(a, b); |
391 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumb |
392 | } |
393 | |
394 | // CHECK-LABEL: @test_vec_pmsum_beh |
395 | vector unsigned int test_vec_pmsum_beh(void) |
396 | { |
397 | vector unsigned short a = H_INIT1 |
398 | vector unsigned short b = H_INIT2 |
399 | return vec_pmsum_be(a, b); |
400 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumh |
401 | } |
402 | |
403 | // CHECK-LABEL: @test_vec_pmsum_bew |
404 | vector unsigned long long test_vec_pmsum_bew(void) |
405 | { |
406 | vector unsigned int a = W_INIT1 |
407 | vector unsigned int b = W_INIT2 |
408 | return vec_pmsum_be(a, b); |
409 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumw |
410 | } |
411 | |
412 | // CHECK-LABEL: @test_vec_pmsum_bed |
413 | vector unsigned __int128 test_vec_pmsum_bed(void) |
414 | { |
415 | vector unsigned long long a = D_INIT1 |
416 | vector unsigned long long b = D_INIT2 |
417 | return vec_pmsum_be(a, b); |
418 | // CHECK: @llvm.ppc.altivec.crypto.vpmsumd |
419 | } |
420 | |
421 | |