xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm64_crypto.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-feature +neon -target-feature +crypto -ffreestanding -Os -S -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc // REQUIRES: aarch64-registered-target
3*0a6a1f1dSLionel Sambuc 
4*0a6a1f1dSLionel Sambuc #include <arm_neon.h>
5*0a6a1f1dSLionel Sambuc 
test_aese(uint8x16_t data,uint8x16_t key)6*0a6a1f1dSLionel Sambuc uint8x16_t test_aese(uint8x16_t data, uint8x16_t key) {
7*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_aese:
8*0a6a1f1dSLionel Sambuc   // CHECK: aese.16b v0, v1
9*0a6a1f1dSLionel Sambuc   return vaeseq_u8(data, key);
10*0a6a1f1dSLionel Sambuc }
11*0a6a1f1dSLionel Sambuc 
test_aesd(uint8x16_t data,uint8x16_t key)12*0a6a1f1dSLionel Sambuc uint8x16_t test_aesd(uint8x16_t data, uint8x16_t key) {
13*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_aesd:
14*0a6a1f1dSLionel Sambuc   // CHECK: aesd.16b v0, v1
15*0a6a1f1dSLionel Sambuc   return vaesdq_u8(data, key);
16*0a6a1f1dSLionel Sambuc }
17*0a6a1f1dSLionel Sambuc 
test_aesmc(uint8x16_t data,uint8x16_t key)18*0a6a1f1dSLionel Sambuc uint8x16_t test_aesmc(uint8x16_t data, uint8x16_t key) {
19*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_aesmc:
20*0a6a1f1dSLionel Sambuc   // CHECK: aesmc.16b v0, v0
21*0a6a1f1dSLionel Sambuc   return vaesmcq_u8(data);
22*0a6a1f1dSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc 
test_aesimc(uint8x16_t data,uint8x16_t key)24*0a6a1f1dSLionel Sambuc uint8x16_t test_aesimc(uint8x16_t data, uint8x16_t key) {
25*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_aesimc:
26*0a6a1f1dSLionel Sambuc   // CHECK: aesimc.16b v0, v0
27*0a6a1f1dSLionel Sambuc   return vaesimcq_u8(data);
28*0a6a1f1dSLionel Sambuc }
29*0a6a1f1dSLionel Sambuc 
test_sha1c(uint32x4_t hash_abcd,uint32_t hash_e,uint32x4_t wk)30*0a6a1f1dSLionel Sambuc uint32x4_t test_sha1c(uint32x4_t hash_abcd, uint32_t hash_e, uint32x4_t wk) {
31*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1c:
32*0a6a1f1dSLionel Sambuc   // CHECK: fmov [[HASH_E:s[0-9]+]], w0
33*0a6a1f1dSLionel Sambuc   // CHECK: sha1c.4s q0, [[HASH_E]], v1
34*0a6a1f1dSLionel Sambuc   return vsha1cq_u32(hash_abcd, hash_e, wk);
35*0a6a1f1dSLionel Sambuc }
36*0a6a1f1dSLionel Sambuc 
test_sha1p(uint32x4_t hash_abcd,uint32_t hash_e,uint32x4_t wk)37*0a6a1f1dSLionel Sambuc uint32x4_t test_sha1p(uint32x4_t hash_abcd, uint32_t hash_e, uint32x4_t wk) {
38*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1p:
39*0a6a1f1dSLionel Sambuc   // CHECK: fmov [[HASH_E:s[0-9]+]], w0
40*0a6a1f1dSLionel Sambuc   // CHECK: sha1p.4s q0, [[HASH_E]], v1
41*0a6a1f1dSLionel Sambuc   return vsha1pq_u32(hash_abcd, hash_e, wk);
42*0a6a1f1dSLionel Sambuc }
43*0a6a1f1dSLionel Sambuc 
test_sha1m(uint32x4_t hash_abcd,uint32_t hash_e,uint32x4_t wk)44*0a6a1f1dSLionel Sambuc uint32x4_t test_sha1m(uint32x4_t hash_abcd, uint32_t hash_e, uint32x4_t wk) {
45*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1m:
46*0a6a1f1dSLionel Sambuc   // CHECK: fmov [[HASH_E:s[0-9]+]], w0
47*0a6a1f1dSLionel Sambuc   // CHECK: sha1m.4s q0, [[HASH_E]], v1
48*0a6a1f1dSLionel Sambuc   return vsha1mq_u32(hash_abcd, hash_e, wk);
49*0a6a1f1dSLionel Sambuc }
50*0a6a1f1dSLionel Sambuc 
test_sha1h(uint32_t hash_e)51*0a6a1f1dSLionel Sambuc uint32_t test_sha1h(uint32_t hash_e) {
52*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1h:
53*0a6a1f1dSLionel Sambuc   // CHECK: fmov [[HASH_E:s[0-9]+]], w0
54*0a6a1f1dSLionel Sambuc   // CHECK: sha1h [[RES:s[0-9]+]], [[HASH_E]]
55*0a6a1f1dSLionel Sambuc   // CHECK: fmov w0, [[RES]]
56*0a6a1f1dSLionel Sambuc   return vsha1h_u32(hash_e);
57*0a6a1f1dSLionel Sambuc }
58*0a6a1f1dSLionel Sambuc 
test_sha1su0(uint32x4_t wk0_3,uint32x4_t wk4_7,uint32x4_t wk8_11)59*0a6a1f1dSLionel Sambuc uint32x4_t test_sha1su0(uint32x4_t wk0_3, uint32x4_t wk4_7, uint32x4_t wk8_11) {
60*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1su0:
61*0a6a1f1dSLionel Sambuc   // CHECK: sha1su0.4s v0, v1, v2
62*0a6a1f1dSLionel Sambuc   return vsha1su0q_u32(wk0_3, wk4_7, wk8_11);
63*0a6a1f1dSLionel Sambuc }
64*0a6a1f1dSLionel Sambuc 
test_sha1su1(uint32x4_t wk0_3,uint32x4_t wk12_15)65*0a6a1f1dSLionel Sambuc uint32x4_t test_sha1su1(uint32x4_t wk0_3, uint32x4_t wk12_15) {
66*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha1su1:
67*0a6a1f1dSLionel Sambuc   // CHECK: sha1su1.4s v0, v1
68*0a6a1f1dSLionel Sambuc   return vsha1su1q_u32(wk0_3, wk12_15);
69*0a6a1f1dSLionel Sambuc }
70*0a6a1f1dSLionel Sambuc 
test_sha256h(uint32x4_t hash_abcd,uint32x4_t hash_efgh,uint32x4_t wk)71*0a6a1f1dSLionel Sambuc uint32x4_t test_sha256h(uint32x4_t hash_abcd, uint32x4_t hash_efgh, uint32x4_t wk) {
72*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha256h:
73*0a6a1f1dSLionel Sambuc   // CHECK: sha256h.4s q0, q1, v2
74*0a6a1f1dSLionel Sambuc   return vsha256hq_u32(hash_abcd, hash_efgh, wk);
75*0a6a1f1dSLionel Sambuc }
76*0a6a1f1dSLionel Sambuc 
test_sha256h2(uint32x4_t hash_efgh,uint32x4_t hash_abcd,uint32x4_t wk)77*0a6a1f1dSLionel Sambuc uint32x4_t test_sha256h2(uint32x4_t hash_efgh, uint32x4_t hash_abcd, uint32x4_t wk) {
78*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha256h2:
79*0a6a1f1dSLionel Sambuc   // CHECK: sha256h2.4s q0, q1, v2
80*0a6a1f1dSLionel Sambuc   return vsha256h2q_u32(hash_efgh, hash_abcd, wk);
81*0a6a1f1dSLionel Sambuc }
82*0a6a1f1dSLionel Sambuc 
test_sha256su0(uint32x4_t w0_3,uint32x4_t w4_7)83*0a6a1f1dSLionel Sambuc uint32x4_t test_sha256su0(uint32x4_t w0_3, uint32x4_t w4_7) {
84*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha256su0:
85*0a6a1f1dSLionel Sambuc   // CHECK: sha256su0.4s v0, v1
86*0a6a1f1dSLionel Sambuc   return vsha256su0q_u32(w0_3, w4_7);
87*0a6a1f1dSLionel Sambuc }
88*0a6a1f1dSLionel Sambuc 
test_sha256su1(uint32x4_t w0_3,uint32x4_t w8_11,uint32x4_t w12_15)89*0a6a1f1dSLionel Sambuc uint32x4_t test_sha256su1(uint32x4_t w0_3, uint32x4_t w8_11, uint32x4_t w12_15) {
90*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: test_sha256su1:
91*0a6a1f1dSLionel Sambuc   // CHECK: sha256su1.4s v0, v1, v2
92*0a6a1f1dSLionel Sambuc   return vsha256su1q_u32(w0_3, w8_11, w12_15);
93*0a6a1f1dSLionel Sambuc }
94