[clang][NFC] simplify the unset check in `ParseLabeledStatement` (#117430)
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-crypto.c
blobb4a3a2e33683b17ca62fad640be9637c5c813023
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +altivec -triple powerpc64le-unknown-unknown \
3 // RUN: -target-feature +crypto -target-feature +power8-vector \
4 // RUN: -emit-llvm %s -o - | FileCheck %s
6 // RUN: %clang_cc1 -flax-vector-conversions=none -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 };
27 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb
28 vector unsigned char test_vpmsumb(void)
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
36 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh
37 vector unsigned short test_vpmsumh(void)
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
45 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw
46 vector unsigned int test_vpmsumw(void)
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
54 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd
55 vector unsigned long long test_vpmsumd(void)
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
63 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vsbox
64 vector unsigned char test_vsbox(void)
66 vector unsigned char a = B_INIT1
67 return __builtin_altivec_crypto_vsbox(a);
68 // CHECK: @llvm.ppc.altivec.crypto.vsbox
71 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb
72 vector unsigned char test_vpermxorb(void)
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
81 // CHECK-LABEL: test_vpermxorbc
82 vector bool char test_vpermxorbc(vector bool char a,
83 vector bool char b,
84 vector bool char c) {
85 return vec_permxor(a, b, c);
86 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
89 // CHECK-LABEL: test_vpermxorsc
90 vector signed char test_vpermxorsc(vector signed char a,
91 vector signed char b,
92 vector signed char c) {
93 return vec_permxor(a, b, c);
94 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
97 // CHECK-LABEL: test_vpermxoruc
98 vector unsigned char test_vpermxoruc(vector unsigned char a,
99 vector unsigned char b,
100 vector unsigned char c) {
101 return vec_permxor(a, b, c);
102 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
105 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxoruc_be
106 vector unsigned char test_vpermxoruc_be(vector unsigned char a,
107 vector unsigned char b,
108 vector unsigned char c) {
109 return __builtin_altivec_crypto_vpermxor_be(a, b, c);
110 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
113 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher
114 vector unsigned char test_vcipher(void)
116 vector unsigned char a = B_INIT1
117 vector unsigned char b = B_INIT2
118 return __builtin_altivec_crypto_vcipher(a, b);
119 // CHECK: @llvm.ppc.altivec.crypto.vcipher
122 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast
123 vector unsigned char test_vcipherlast(void)
125 vector unsigned char a = B_INIT1
126 vector unsigned char b = B_INIT2
127 return __builtin_altivec_crypto_vcipherlast(a, b);
128 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
131 // CHECK-LABEL: @test_vncipher
132 vector unsigned char test_vncipher(void)
134 vector unsigned char a = B_INIT1
135 vector unsigned char b = B_INIT2
136 return __builtin_altivec_crypto_vncipher(a, b);
137 // CHECK: @llvm.ppc.altivec.crypto.vncipher
140 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vncipherlast
141 vector unsigned char test_vncipherlast(void)
143 vector unsigned char a = B_INIT1
144 vector unsigned char b = B_INIT2
145 return __builtin_altivec_crypto_vncipherlast(a, b);
146 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
149 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw
150 vector unsigned int test_vshasigmaw(void)
152 vector unsigned int a = W_INIT1
153 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15);
154 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
157 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad
158 vector unsigned long long test_vshasigmad(void)
160 vector unsigned long long a = D_INIT2
161 return __builtin_altivec_crypto_vshasigmad(a, 1, 15);
162 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
165 // Test cases for the builtins the way they are exposed to
166 // users through altivec.h
167 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb_e
168 vector unsigned char test_vpmsumb_e(void)
170 vector unsigned char a = B_INIT1
171 vector unsigned char b = B_INIT2
172 return __builtin_crypto_vpmsumb(a, b);
173 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb
176 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh_e
177 vector unsigned short test_vpmsumh_e(void)
179 vector unsigned short a = H_INIT1
180 vector unsigned short b = H_INIT2
181 return __builtin_crypto_vpmsumb(a, b);
182 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh
185 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw_e
186 vector unsigned int test_vpmsumw_e(void)
188 vector unsigned int a = W_INIT1
189 vector unsigned int b = W_INIT2
190 return __builtin_crypto_vpmsumb(a, b);
191 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw
194 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd_e
195 vector unsigned long long test_vpmsumd_e(void)
197 vector unsigned long long a = D_INIT1
198 vector unsigned long long b = D_INIT2
199 return __builtin_crypto_vpmsumb(a, b);
200 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd
203 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vsbox_e
204 vector unsigned char test_vsbox_e(void)
206 vector unsigned char a = B_INIT1
207 return __builtin_crypto_vsbox(a);
208 // CHECK: @llvm.ppc.altivec.crypto.vsbox
211 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_e
212 vector unsigned char test_vpermxorb_e(void)
214 vector unsigned char a = B_INIT1
215 vector unsigned char b = B_INIT2
216 vector unsigned char c = B_INIT2
217 return __builtin_crypto_vpermxor(a, b, c);
218 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
221 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_e
222 vector unsigned short test_vpermxorh_e(void)
224 vector unsigned short a = H_INIT1
225 vector unsigned short b = H_INIT2
226 vector unsigned short c = H_INIT2
227 return __builtin_crypto_vpermxor(a, b, c);
228 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
231 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_e
232 vector unsigned int test_vpermxorw_e(void)
234 vector unsigned int a = W_INIT1
235 vector unsigned int b = W_INIT2
236 vector unsigned int c = W_INIT2
237 return __builtin_crypto_vpermxor(a, b, c);
238 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
241 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_e
242 vector unsigned long long test_vpermxord_e(void)
244 vector unsigned long long a = D_INIT1
245 vector unsigned long long b = D_INIT2
246 vector unsigned long long c = D_INIT2
247 return __builtin_crypto_vpermxor(a, b, c);
248 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
251 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher_e
252 vector unsigned char test_vcipher_e(void)
254 vector unsigned char a = B_INIT1
255 vector unsigned char b = B_INIT2
256 return __builtin_crypto_vcipher(a, b);
257 // CHECK: @llvm.ppc.altivec.crypto.vcipher
260 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast_e
261 vector unsigned char test_vcipherlast_e(void)
263 vector unsigned char a = B_INIT1
264 vector unsigned char b = B_INIT2
265 return __builtin_crypto_vcipherlast(a, b);
266 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
269 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw_e
270 vector unsigned int test_vshasigmaw_e(void)
272 vector unsigned int a = W_INIT1
273 return __builtin_crypto_vshasigmaw(a, 1, 15);
274 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
277 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad_e
278 vector unsigned long long test_vshasigmad_e(void)
280 vector unsigned long long a = D_INIT2
281 return __builtin_crypto_vshasigmad(a, 0, 15);
282 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
285 // CHECK-LABEL: @test_vec_sbox_be
286 vector unsigned char test_vec_sbox_be(void)
288 vector unsigned char a = B_INIT1
289 return vec_sbox_be(a);
290 // CHECK: @llvm.ppc.altivec.crypto.vsbox
293 // CHECK-LABEL: @test_vec_cipher_be
294 vector unsigned char test_vec_cipher_be(void)
296 vector unsigned char a = B_INIT1
297 vector unsigned char b = B_INIT2
298 return vec_cipher_be(a, b);
299 // CHECK: @llvm.ppc.altivec.crypto.vcipher
302 // CHECK-LABEL: @test_vec_cipherlast_be
303 vector unsigned char test_vec_cipherlast_be(void)
305 vector unsigned char a = B_INIT1
306 vector unsigned char b = B_INIT2
307 return vec_cipherlast_be(a, b);
308 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
311 // CHECK-LABEL: @test_vec_ncipher_be
312 vector unsigned char test_vec_ncipher_be(void)
314 vector unsigned char a = B_INIT1
315 vector unsigned char b = B_INIT2
316 return vec_ncipher_be(a, b);
317 // CHECK: @llvm.ppc.altivec.crypto.vncipher
320 // CHECK-LABEL: @test_vec_ncipherlast_be
321 vector unsigned char test_vec_ncipherlast_be(void)
323 vector unsigned char a = B_INIT1
324 vector unsigned char b = B_INIT2
325 return vec_ncipherlast_be(a, b);
326 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
329 // CHECK-LABEL: @test_vec_shasigma_bew
330 vector unsigned int test_vec_shasigma_bew(void)
332 vector unsigned int a = W_INIT1
333 return vec_shasigma_be(a, 1, 15);
334 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
337 // CHECK-LABEL: @test_vec_shasigma_bed
338 vector unsigned long long test_vec_shasigma_bed(void)
340 vector unsigned long long a = D_INIT2
341 return vec_shasigma_be(a, 1, 15);
342 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
345 // CHECK-LABEL: @test_vec_pmsum_beb
346 vector unsigned char test_vec_pmsum_beb(void)
348 vector unsigned char a = B_INIT1
349 vector unsigned char b = B_INIT2
350 return vec_pmsum_be(a, b);
351 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb
354 // CHECK-LABEL: @test_vec_pmsum_beh
355 vector unsigned short test_vec_pmsum_beh(void)
357 vector unsigned short a = H_INIT1
358 vector unsigned short b = H_INIT2
359 return vec_pmsum_be(a, b);
360 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh
363 // CHECK-LABEL: @test_vec_pmsum_bew
364 vector unsigned int test_vec_pmsum_bew(void)
366 vector unsigned int a = W_INIT1
367 vector unsigned int b = W_INIT2
368 return vec_pmsum_be(a, b);
369 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw
372 // CHECK-LABEL: @test_vec_pmsum_bed
373 vector unsigned long long test_vec_pmsum_bed(void)
375 vector unsigned long long a = D_INIT1
376 vector unsigned long long b = D_INIT2
377 return vec_pmsum_be(a, b);
378 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd