summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/curve25519/square_amd64.s
blob: 12f73734ff5aede956c2098faf473b862c72afe5 (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
// 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: https://bench.cr.yp.to/supercop.html

// +build amd64,!gccgo,!appengine

#include "const_amd64.h"

// func square(out, in *[5]uint64)
TEXT ·square(SB),7,$0-16
	MOVQ out+0(FP), DI
	MOVQ in+8(FP), SI

	MOVQ 0(SI),AX
	MULQ 0(SI)
	MOVQ AX,CX
	MOVQ DX,R8
	MOVQ 0(SI),AX
	SHLQ $1,AX
	MULQ 8(SI)
	MOVQ AX,R9
	MOVQ DX,R10
	MOVQ 0(SI),AX
	SHLQ $1,AX
	MULQ 16(SI)
	MOVQ AX,R11
	MOVQ DX,R12
	MOVQ 0(SI),AX
	SHLQ $1,AX
	MULQ 24(SI)
	MOVQ AX,R13
	MOVQ DX,R14
	MOVQ 0(SI),AX
	SHLQ $1,AX
	MULQ 32(SI)
	MOVQ AX,R15
	MOVQ DX,BX
	MOVQ 8(SI),AX
	MULQ 8(SI)
	ADDQ AX,R11
	ADCQ DX,R12
	MOVQ 8(SI),AX
	SHLQ $1,AX
	MULQ 16(SI)
	ADDQ AX,R13
	ADCQ DX,R14
	MOVQ 8(SI),AX
	SHLQ $1,AX
	MULQ 24(SI)
	ADDQ AX,R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