aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/digest/argonish/internal/blake2b/load_sse41.h
blob: 060455aac2d31aa21a9062c846b248465cec07e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#pragma once

/*
   BLAKE2 reference source code package - optimized C implementations
   Copyright 2012, Samuel Neves <sneves@dei.uc.pt>.  You may use this under the
   terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
   your option.  The terms of these licenses can be found at:
   - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
   - OpenSSL license   : https://www.openssl.org/source/license.html
   - Apache 2.0        : http://www.apache.org/licenses/LICENSE-2.0
   More information about the BLAKE2 hash function can be found at
   https://blake2.net.
*/

#define LOAD_MSG_0_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m0, m1); \
        b1 = _mm_unpacklo_epi64(m2, m3); \
    } while (0)

#define LOAD_MSG_0_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m0, m1); \
        b1 = _mm_unpackhi_epi64(m2, m3); \
    } while (0)

#define LOAD_MSG_0_3(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m4, m5); \
        b1 = _mm_unpacklo_epi64(m6, m7); \
    } while (0)

#define LOAD_MSG_0_4(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m4, m5); \
        b1 = _mm_unpackhi_epi64(m6, m7); \
    } while (0)

#define LOAD_MSG_1_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m7, m2); \
        b1 = _mm_unpackhi_epi64(m4, m6); \
    } while (0)

#define LOAD_MSG_1_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m5, m4); \
        b1 = _mm_alignr_epi8(m3, m7, 8); \
    } while (0)

#define LOAD_MSG_1_3(b0, b1)                                 \
    do {                                                     \
        b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1, 0, 3, 2)); \
        b1 = _mm_unpackhi_epi64(m5, m2);                     \
    } while (0)

#define LOAD_MSG_1_4(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m6, m1); \
        b1 = _mm_unpackhi_epi64(m3, m1); \
    } while (0)

#define LOAD_MSG_2_1(b0, b1)             \
    do {                                 \
        b0 = _mm_alignr_epi8(m6, m5, 8); \
        b1 = _mm_unpackhi_epi64(m2, m7); \
    } while (0)

#define LOAD_MSG_2_2(b0, b1)                \
    do {                                    \
        b0 = _mm_unpacklo_epi64(m4, m0);    \
        b1 = _mm_blend_epi16(m1, m6, 0xF0); \
    } while (0)

#define LOAD_MSG_2_3(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m5, m1, 0xF0); \
        b1 = _mm_unpackhi_epi64(m3, m4);    \
    } while (0)

#define LOAD_MSG_2_4(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m7, m3); \
        b1 = _mm_alignr_epi8(m2, m0, 8); \
    } while (0)

#define LOAD_MSG_3_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m3, m1); \
        b1 = _mm_unpackhi_epi64(m6, m5); \
    } while (0)

#define LOAD_MSG_3_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m4, m0); \
        b1 = _mm_unpacklo_epi64(m6, m7); \
    } while (0)

#define LOAD_MSG_3_3(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m1, m2, 0xF0); \
        b1 = _mm_blend_epi16(m2, m7, 0xF0); \
    } while (0)

#define LOAD_MSG_3_4(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m3, m5); \
        b1 = _mm_unpacklo_epi64(m0, m4); \
    } while (0)

#define LOAD_MSG_4_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m4, m2); \
        b1 = _mm_unpacklo_epi64(m1, m5); \
    } while (0)

#define LOAD_MSG_4_2(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m0, m3, 0xF0); \
        b1 = _mm_blend_epi16(m2, m7, 0xF0); \
    } while (0)

#define LOAD_MSG_4_3(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m7, m5, 0xF0); \
        b1 = _mm_blend_epi16(m3, m1, 0xF0); \
    } while (0)

#define LOAD_MSG_4_4(b0, b1)                \
    do {                                    \
        b0 = _mm_alignr_epi8(m6, m0, 8);    \
        b1 = _mm_blend_epi16(m4, m6, 0xF0); \
    } while (0)

#define LOAD_MSG_5_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m1, m3); \
        b1 = _mm_unpacklo_epi64(m0, m4); \
    } while (0)

#define LOAD_MSG_5_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m6, m5); \
        b1 = _mm_unpackhi_epi64(m5, m1); \
    } while (0)

#define LOAD_MSG_5_3(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m2, m3, 0xF0); \
        b1 = _mm_unpackhi_epi64(m7, m0);    \
    } while (0)

#define LOAD_MSG_5_4(b0, b1)                \
    do {                                    \
        b0 = _mm_unpackhi_epi64(m6, m2);    \
        b1 = _mm_blend_epi16(m7, m4, 0xF0); \
    } while (0)

#define LOAD_MSG_6_1(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m6, m0, 0xF0); \
        b1 = _mm_unpacklo_epi64(m7, m2);    \
    } while (0)

#define LOAD_MSG_6_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m2, m7); \
        b1 = _mm_alignr_epi8(m5, m6, 8); \
    } while (0)

#define LOAD_MSG_6_3(b0, b1)                                 \
    do {                                                     \
        b0 = _mm_unpacklo_epi64(m0, m3);                     \
        b1 = _mm_shuffle_epi32(m4, _MM_SHUFFLE(1, 0, 3, 2)); \
    } while (0)

#define LOAD_MSG_6_4(b0, b1)                \
    do {                                    \
        b0 = _mm_unpackhi_epi64(m3, m1);    \
        b1 = _mm_blend_epi16(m1, m5, 0xF0); \
    } while (0)

#define LOAD_MSG_7_1(b0, b1)                \
    do {                                    \
        b0 = _mm_unpackhi_epi64(m6, m3);    \
        b1 = _mm_blend_epi16(m6, m1, 0xF0); \
    } while (0)

#define LOAD_MSG_7_2(b0, b1)             \
    do {                                 \
        b0 = _mm_alignr_epi8(m7, m5, 8); \
        b1 = _mm_unpackhi_epi64(m0, m4); \
    } while (0)

#define LOAD_MSG_7_3(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m2, m7); \
        b1 = _mm_unpacklo_epi64(m4, m1); \
    } while (0)

#define LOAD_MSG_7_4(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m0, m2); \
        b1 = _mm_unpacklo_epi64(m3, m5); \
    } while (0)

#define LOAD_MSG_8_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m3, m7); \
        b1 = _mm_alignr_epi8(m0, m5, 8); \
    } while (0)

#define LOAD_MSG_8_2(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m7, m4); \
        b1 = _mm_alignr_epi8(m4, m1, 8); \
    } while (0)

#define LOAD_MSG_8_3(b0, b1)             \
    do {                                 \
        b0 = m6;                         \
        b1 = _mm_alignr_epi8(m5, m0, 8); \
    } while (0)

#define LOAD_MSG_8_4(b0, b1)                \
    do {                                    \
        b0 = _mm_blend_epi16(m1, m3, 0xF0); \
        b1 = m2;                            \
    } while (0)

#define LOAD_MSG_9_1(b0, b1)             \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m5, m4); \
        b1 = _mm_unpackhi_epi64(m3, m0); \
    } while (0)

#define LOAD_MSG_9_2(b0, b1)                \
    do {                                    \
        b0 = _mm_unpacklo_epi64(m1, m2);    \
        b1 = _mm_blend_epi16(m3, m2, 0xF0); \
    } while (0)

#define LOAD_MSG_9_3(b0, b1)             \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m7, m4); \
        b1 = _mm_unpackhi_epi64(m1, m6); \
    } while (0)

#define LOAD_MSG_9_4(b0, b1)             \
    do {                                 \
        b0 = _mm_alignr_epi8(m7, m5, 8); \
        b1 = _mm_unpacklo_epi64(m6, m0); \
    } while (0)

#define LOAD_MSG_10_1(b0, b1)            \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m0, m1); \
        b1 = _mm_unpacklo_epi64(m2, m3); \
    } while (0)

#define LOAD_MSG_10_2(b0, b1)            \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m0, m1); \
        b1 = _mm_unpackhi_epi64(m2, m3); \
    } while (0)

#define LOAD_MSG_10_3(b0, b1)            \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m4, m5); \
        b1 = _mm_unpacklo_epi64(m6, m7); \
    } while (0)

#define LOAD_MSG_10_4(b0, b1)            \
    do {                                 \
        b0 = _mm_unpackhi_epi64(m4, m5); \
        b1 = _mm_unpackhi_epi64(m6, m7); \
    } while (0)

#define LOAD_MSG_11_1(b0, b1)            \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m7, m2); \
        b1 = _mm_unpackhi_epi64(m4, m6); \
    } while (0)

#define LOAD_MSG_11_2(b0, b1)            \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m5, m4); \
        b1 = _mm_alignr_epi8(m3, m7, 8); \
    } while (0)

#define LOAD_MSG_11_3(b0, b1)                                \
    do {                                                     \
        b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1, 0, 3, 2)); \
        b1 = _mm_unpackhi_epi64(m5, m2);                     \
    } while (0)

#define LOAD_MSG_11_4(b0, b1)            \
    do {                                 \
        b0 = _mm_unpacklo_epi64(m6, m1); \
        b1 = _mm_unpackhi_epi64(m3, m1); \
    } while (0)