summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/poly1305/poly1305_amd64.s
blob: f8d4ee928988bdace3ec14574e2a8e90aaadc6f9 (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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This code was translated into a form compatible with 6a from the public
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html

// +build amd64,!gccgo,!appengine

// func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]key)
TEXT ·poly1305(SB),0,$224-32
	MOVQ out+0(FP),DI
	MOVQ m+8(FP),SI
	MOVQ mlen+16(FP),DX
	MOVQ key+24(FP),CX

	MOVQ SP,R11
	MOVQ $31,R9
	NOTQ R9
	ANDQ R9,SP
	ADDQ $32,SP

	MOVQ R11,32(SP)
	MOVQ R12,40(SP)
	MOVQ R13,48(SP)
	MOVQ R14,56(SP)
	MOVQ R15,64(SP)
	MOVQ BX,72(SP)
	MOVQ BP,80(SP)
	FLDCW ·ROUNDING(SB)
	MOVL 0(CX),R8
	MOVL 4(CX),R9
	MOVL 8(CX),AX
	MOVL 12(CX),R10
	MOVQ DI,88(SP)
	MOVQ CX,96(SP)
	MOVL $0X43300000,108(SP)
	MOVL $0X45300000,116(SP)
	MOVL $0X47300000,124(SP)
	MOVL $0X49300000,132(SP)
	ANDL $0X0FFFFFFF,R8
	ANDL $0X0FFFFFFC,R9
	ANDL $0X0FFFFFFC,AX
	ANDL $0X0FFFFFFC,R10
	MOVL R8,104(SP)
	MOVL R9,112(SP)
	MOVL AX,120(SP)
	MOVL R10,128(SP)
	FMOVD 104(SP), F0
	FSUBD ·DOFFSET0(SB), F0
	FMOVD 112(SP), F0
	FSUBD ·DOFFSET1(SB), F0
	FMOVD 120(SP), F0
	FSUBD ·DOFFSET2(SB), F0
	FMOVD 128(SP), F0
	FSUBD ·DOFFSET3(SB), F0
	FXCHD F0, F3
	FMOVDP F0, 136(SP)
	FXCHD F0, F1
	FMOVD F0, 144(SP)
	FMULD ·SCALE(SB), F0
	FMOVDP F0, 152(SP)
	FMOVD F0, 160(SP)
	FMULD ·SCALE(SB), F0
	FMOVDP F0, 168(SP)
	FMOVD F0, 176(SP)
	FMULD ·SCALE(SB), F0
	FMOVDP F0, 184(SP)
	FLDZ
	FLDZ
	FLDZ
	FLDZ
	CMPQ DX,$16
	JB ADDATMOST15BYTES
	INITIALATLEAST16BYTES:
	MOVL 12(SI),DI
	MOVL 8(SI),CX
	MOVL 4(SI),R8
	MOVL 0(SI),R9
	MOVL DI,128(SP)
	MOVL CX,120(SP)
	MOVL R8,112(SP)
	MOVL R9,104(SP)
	ADDQ $16,SI
	SUBQ $16,DX
	FXCHD F0, F3
	FADDD 128(SP), F0
	FSUBD ·DOFFSET3MINUSTWO128(SB), F0
	FXCHD F0, F1
	FADDD 112(SP), F0
	FSUBD ·DOFFSET1(SB), F0
	FXCHD F0, F2
	FADDD 120(SP), F0
	FSUBD ·DOFFSET2(SB), F0
	FXCHD F0, F3
	FADDD 104(SP), F0
	FSUBD ·DOFFSET0(SB), F0
	CMPQ DX,$16
	JB MULTIPLYADDATMOST15BYTES
	MULTIPLYADDATLEAST16BYTES:
	MOVL 12(SI),DI
	MOVL 8(SI),CX
	MOVL 4(SI),R8
	MOVL 0(SI),R9
	MOVL DI,128(SP)
	MOVL CX,120(SP)
	MOVL R8,112(SP)
	MOVL R9,104(SP)
	ADDQ $16,SI
	SUBQ $16,DX
	FMOVD ·ALPHA130(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA130(SB), F0
	FSUBD F0,F2
	FMULD ·SCALE(SB), F0
	FMOVD ·ALPHA32(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA32(SB), F0
	FSUBD F0,F2
	FXCHD F0, F2
	FADDDP F0,F1
	FMOVD ·ALPHA64(SB), F0
	FADDD F4,F0
	FSUBD ·ALPHA64(SB), F0
	FSUBD F0,F4
	FMOVD ·ALPHA96(SB), F0
	FADDD F6,F0
	FSUBD ·ALPHA96(SB), F0
	FSUBD F0,F6
	FXCHD F0, F6
	FADDDP F0,F1
	FXCHD F0, F3
	FADDDP F0,F5
	FXCHD F0, F3
	FADDDP F0,F1
	FMOVD 176(SP), F0
	FMULD F3,F0
	FMOVD 160(SP), F0
	FMULD F4,F0
	FMOVD 144(SP), F0
	FMULD F5,F0
	FMOVD 136(SP), F0
	FMULDP F0,F6
	FMOVD 160(SP), F0
	FMULD F4,F0
	FADDDP F0,F3
	FMOVD 144(SP), F0
	FMULD F4,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F4,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULDP F0,F4
	FXCHD F0, F3
	FADDDP F0,F5
	FMOVD 144(SP), F0
	FMULD F4,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F4,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULD F4,F0
	FADDDP F0,F3
	FMOVD 168(SP), F0
	FMULDP F0,F4
	FXCHD F0, F3
	FADDDP F0,F4
	FMOVD 136(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FXCHD F0, F3
	FMOVD 184(SP), F0
	FMULD F5,F0
	FADDDP F0,F3
	FXCHD F0, F1
	FMOVD 168(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FMOVD 152(SP), F0
	FMULDP F0,F5
	FXCHD F0, F4
	FADDDP F0,F1
	CMPQ DX,$16
	FXCHD F0, F2
	FMOVD 128(SP), F0
	FSUBD ·DOFFSET3MINUSTWO128(SB), F0
	FADDDP F0,F1
	FXCHD F0, F1
	FMOVD 120(SP), F0
	FSUBD ·DOFFSET2(SB), F0
	FADDDP F0,F1
	FXCHD F0, F3
	FMOVD 112(SP), F0
	FSUBD ·DOFFSET1(SB), F0
	FADDDP F0,F1
	FXCHD F0, F2
	FMOVD 104(SP), F0
	FSUBD ·DOFFSET0(SB), F0
	FADDDP F0,F1
	JAE MULTIPLYADDATLEAST16BYTES
	MULTIPLYADDATMOST15BYTES:
	FMOVD ·ALPHA130(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA130(SB), F0
	FSUBD F0,F2
	FMULD ·SCALE(SB), F0
	FMOVD ·ALPHA32(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA32(SB), F0
	FSUBD F0,F2
	FMOVD ·ALPHA64(SB), F0
	FADDD F5,F0
	FSUBD ·ALPHA64(SB), F0
	FSUBD F0,F5
	FMOVD ·ALPHA96(SB), F0
	FADDD F7,F0
	FSUBD ·ALPHA96(SB), F0
	FSUBD F0,F7
	FXCHD F0, F7
	FADDDP F0,F1
	FXCHD F0, F5
	FADDDP F0,F1
	FXCHD F0, F3
	FADDDP F0,F5
	FADDDP F0,F1
	FMOVD 176(SP), F0
	FMULD F1,F0
	FMOVD 160(SP), F0
	FMULD F2,F0
	FMOVD 144(SP), F0
	FMULD F3,F0
	FMOVD 136(SP), F0
	FMULDP F0,F4
	FMOVD 160(SP), F0
	FMULD F5,F0
	FADDDP F0,F3
	FMOVD 144(SP), F0
	FMULD F5,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULDP F0,F5
	FXCHD F0, F4
	FADDDP F0,F3
	FMOVD 144(SP), F0
	FMULD F5,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULD F5,F0
	FADDDP F0,F4
	FMOVD 168(SP), F0
	FMULDP F0,F5
	FXCHD F0, F4
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULD F5,F0
	FADDDP F0,F4
	FMOVD 168(SP), F0
	FMULD F5,F0
	FADDDP F0,F3
	FMOVD 152(SP), F0
	FMULDP F0,F5
	FXCHD F0, F4
	FADDDP F0,F1
	ADDATMOST15BYTES:
	CMPQ DX,$0
	JE NOMOREBYTES
	MOVL $0,0(SP)
	MOVL $0, 4 (SP)
	MOVL $0, 8 (SP)
	MOVL $0, 12 (SP)
	LEAQ 0(SP),DI
	MOVQ DX,CX
	REP; MOVSB
	MOVB $1,0(DI)
	MOVL  12 (SP),DI
	MOVL  8 (SP),SI
	MOVL  4 (SP),DX
	MOVL 0(SP),CX
	MOVL DI,128(SP)
	MOVL SI,120(SP)
	MOVL DX,112(SP)
	MOVL CX,104(SP)
	FXCHD F0, F3
	FADDD 128(SP), F0
	FSUBD ·DOFFSET3(SB), F0
	FXCHD F0, F2
	FADDD 120(SP), F0
	FSUBD ·DOFFSET2(SB), F0
	FXCHD F0, F1
	FADDD 112(SP), F0
	FSUBD ·DOFFSET1(SB), F0
	FXCHD F0, F3
	FADDD 104(SP), F0
	FSUBD ·DOFFSET0(SB), F0
	FMOVD ·ALPHA130(SB), F0
	FADDD F3,F0
	FSUBD ·ALPHA130(SB), F0
	FSUBD F0,F3
	FMULD ·SCALE(SB), F0
	FMOVD ·ALPHA32(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA32(SB), F0
	FSUBD F0,F2
	FMOVD ·ALPHA64(SB), F0
	FADDD F6,F0
	FSUBD ·ALPHA64(SB), F0
	FSUBD F0,F6
	FMOVD ·ALPHA96(SB), F0
	FADDD F5,F0
	FSUBD ·ALPHA96(SB), F0
	FSUBD F0,F5
	FXCHD F0, F4
	FADDDP F0,F3
	FXCHD F0, F6
	FADDDP F0,F1
	FXCHD F0, F3
	FADDDP F0,F5
	FXCHD F0, F3
	FADDDP F0,F1
	FMOVD 176(SP), F0
	FMULD F3,F0
	FMOVD 160(SP), F0
	FMULD F4,F0
	FMOVD 144(SP), F0
	FMULD F5,F0
	FMOVD 136(SP), F0
	FMULDP F0,F6
	FMOVD 160(SP), F0
	FMULD F5,F0
	FADDDP F0,F3
	FMOVD 144(SP), F0
	FMULD F5,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F5,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULDP F0,F5
	FXCHD F0, F4
	FADDDP F0,F5
	FMOVD 144(SP), F0
	FMULD F6,F0
	FADDDP F0,F2
	FMOVD 136(SP), F0
	FMULD F6,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULD F6,F0
	FADDDP F0,F4
	FMOVD 168(SP), F0
	FMULDP F0,F6
	FXCHD F0, F5
	FADDDP F0,F4
	FMOVD 136(SP), F0
	FMULD F2,F0
	FADDDP F0,F1
	FMOVD 184(SP), F0
	FMULD F2,F0
	FADDDP F0,F5
	FMOVD 168(SP), F0
	FMULD F2,F0
	FADDDP F0,F3
	FMOVD 152(SP), F0
	FMULDP F0,F2
	FXCHD F0, F1
	FADDDP F0,F3
	FXCHD F0, F3
	FXCHD F0, F2
	NOMOREBYTES:
	MOVL $0,R10
	FMOVD ·ALPHA130(SB), F0
	FADDD F4,F0
	FSUBD ·ALPHA130(SB), F0
	FSUBD F0,F4
	FMULD ·SCALE(SB), F0
	FMOVD ·ALPHA32(SB), F0
	FADDD F2,F0
	FSUBD ·ALPHA32(SB), F0
	FSUBD F0,F2
	FMOVD ·ALPHA64(SB), F0
	FADDD F4,F0
	FSUBD ·ALPHA64(SB), F0
	FSUBD F0,F4
	FMOVD ·ALPHA96(SB), F0
	FADDD F6,F0
	FSUBD ·ALPHA96(SB), F0
	FXCHD F0, F6
	FSUBD F6,F0
	FXCHD F0, F4
	FADDDP F0,F3
	FXCHD F0, F4
	FADDDP F0,F1
	FXCHD F0, F2
	FADDDP F0,F3
	FXCHD F0, F4
	FADDDP F0,F3
	FXCHD F0, F3
	FADDD ·HOFFSET0(SB), F0
	FXCHD F0, F3
	FADDD ·HOFFSET1(SB), F0
	FXCHD F0, F1
	FADDD ·HOFFSET2(SB), F0
	FXCHD F0, F2
	FADDD ·HOFFSET3(SB), F0
	FXCHD F0, F3
	FMOVDP F0, 104(SP)
	FMOVDP F0, 112(SP)
	FMOVDP F0, 120(SP)
	FMOVDP F0, 128(SP)
	MOVL 108(SP),DI
	ANDL $63,DI
	MOVL 116(SP),SI
	ANDL $63,SI
	MOVL 124(SP),DX
	ANDL $63,DX
	MOVL 132(SP),CX
	ANDL $63,CX
	MOVL 112(SP),R8
	ADDL DI,R8
	MOVQ R8,112(SP)
	MOVL 120(SP),DI
	ADCL SI,DI
	MOVQ DI,120(SP)
	MOVL 128(SP),DI
	ADCL DX,DI
	MOVQ DI,128(SP)
	MOVL R10,DI
	ADCL CX,DI
	MOVQ DI,136(SP)
	MOVQ $5,DI
	MOVL 104(SP),SI
	ADDL SI,DI
	MOVQ DI,104(SP)
	MOVL R10,DI
	MOVQ 112(SP),DX
	ADCL DX,DI
	MOVQ DI,112(SP)
	MOVL R10,DI
	MOVQ 120(SP),CX
	ADCL CX,DI
	MOVQ DI,120(SP)
	MOVL R10,DI
	MOVQ 128(SP),R8
	ADCL R8,DI
	MOVQ DI,128(SP)
	MOVQ $0XFFFFFFFC,DI
	MOVQ 136(SP),R9
	ADCL R9,DI
	SARL $16,DI
	MOVQ DI,R9
	XORL $0XFFFFFFFF,R9
	ANDQ DI,SI
	MOVQ 104(SP),AX
	ANDQ R9,AX
	ORQ AX,SI
	ANDQ DI,DX
	MOVQ 112(SP),AX
	ANDQ R9,AX
	ORQ AX,DX
	ANDQ DI,CX
	MOVQ 120(SP),AX
	ANDQ R9,AX
	ORQ AX,CX
	ANDQ DI,R8
	MOVQ 128(SP),DI
	ANDQ R9,DI
	ORQ DI,R8
	MOVQ 88(SP),DI
	MOVQ 96(SP),R9
	ADDL 16(R9),SI
	ADCL 20(R9),DX
	ADCL 24(R9),CX
	ADCL 28(R9),R8
	MOVL SI,0(DI)
	MOVL DX,4(DI)
	MOVL CX,8(DI)
	MOVL R8,12(DI)
	MOVQ 32(SP),R11
	MOVQ 40(SP),R12
	MOVQ 48(SP),R13
	MOVQ 56(SP),R14
	MOVQ 64(SP),R15
	MOVQ 72(SP),BX
	MOVQ 80(SP),BP
	MOVQ R11,SP
	RET