2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- //go:build gc && !purego
5
+ //go:build gc && !purego && (ppc64 || ppc64le)
6
6
7
7
#include "textflag.h"
8
8
9
9
// This was ported from the amd64 implementation.
10
10
11
+ #ifdef GOARCH_ppc64le
12
+ #define LE_MOVD MOVD
13
+ #define LE_MOVWZ MOVWZ
14
+ #define LE_MOVHZ MOVHZ
15
+ #else
16
+ #define LE_MOVD MOVDBR
17
+ #define LE_MOVWZ MOVWBR
18
+ #define LE_MOVHZ MOVHBR
19
+ #endif
20
+
11
21
#define POLY1305_ADD(msg, h0, h1, h2, t0, t1, t2) \
12
- MOVD (msg), t0; \
13
- MOVD 8 (msg), t1; \
22
+ LE_MOVD (msg)( R0) , t0; \
23
+ LE_MOVD (msg)(R24 ), t1; \
14
24
MOVD $1 , t2; \
15
25
ADDC t0, h0, h0; \
16
26
ADDE t1, h1, h1; \
50
60
ADDE t3, h1, h1; \
51
61
ADDZE h2
52
62
53
- DATA ·poly1305Mask<>+0x00 (SB)/8 , $0x0FFFFFFC0FFFFFFF
54
- DATA ·poly1305Mask<>+0x08 (SB)/8 , $0x0FFFFFFC0FFFFFFC
55
- GLOBL ·poly1305Mask<>(SB), RODATA, $16
56
-
57
63
// func update(state *[7]uint64, msg []byte)
58
64
TEXT ·update(SB), $0 -32
59
65
MOVD state+0 (FP), R3
@@ -66,6 +72,8 @@ TEXT ·update(SB), $0-32
66
72
MOVD 24 (R3), R11 // r0
67
73
MOVD 32 (R3), R12 // r1
68
74
75
+ MOVD $8 , R24
76
+
69
77
CMP R5, $16
70
78
BLT bytes_between_0_and_15
71
79
@@ -94,7 +102,7 @@ flush_buffer:
94
102
95
103
// Greater than 8 -- load the rightmost remaining bytes in msg
96
104
// and put into R17 (h1)
97
- MOVD (R4)(R21), R17
105
+ LE_MOVD (R4)(R21), R17
98
106
MOVD $16 , R22
99
107
100
108
// Find the offset to those bytes
@@ -118,7 +126,7 @@ just1:
118
126
BLT less8
119
127
120
128
// Exactly 8
121
- MOVD (R4), R16
129
+ LE_MOVD (R4), R16
122
130
123
131
CMP R17, $0
124
132
@@ -133,15 +141,15 @@ less8:
133
141
MOVD $0 , R22 // shift count
134
142
CMP R5, $4
135
143
BLT less4
136
- MOVWZ (R4), R16
144
+ LE_MOVWZ (R4), R16
137
145
ADD $4 , R4
138
146
ADD $-4 , R5
139
147
MOVD $32 , R22
140
148
141
149
less4:
142
150
CMP R5, $2
143
151
BLT less2
144
- MOVHZ (R4), R21
152
+ LE_MOVHZ (R4), R21
145
153
SLD R22, R21, R21
146
154
OR R16, R21, R16
147
155
ADD $16 , R22
0 commit comments