-
Notifications
You must be signed in to change notification settings - Fork 1
/
and_arm64.s
300 lines (238 loc) · 8.41 KB
/
and_arm64.s
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
// +build arm64,!purego
#include "textflag.h"
// func andNEON(dst *byte, a *byte, b *byte, l uint64)
TEXT ·andNEON(SB), NOSPLIT, $0-32
MOVD dst+0(FP), R0
MOVD a+8(FP), R1
MOVD b+16(FP), R2
MOVD l+24(FP), R3
loop:
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R2), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R2), [V12.B16, V13.B16, V14.B16, V15.B16]
VLD1.P 64(R1), [V16.B16, V17.B16, V18.B16, V19.B16]
VLD1.P 64(R2), [V20.B16, V21.B16, V22.B16, V23.B16]
VLD1.P 64(R1), [V24.B16, V25.B16, V26.B16, V27.B16]
VLD1.P 64(R2), [V28.B16, V29.B16, V30.B16, V31.B16]
VAND V0.B16, V4.B16, V0.B16
VAND V1.B16, V5.B16, V1.B16
VAND V2.B16, V6.B16, V2.B16
VAND V3.B16, V7.B16, V3.B16
VAND V8.B16, V12.B16, V8.B16
VAND V9.B16, V13.B16, V9.B16
VAND V10.B16, V14.B16, V10.B16
VAND V11.B16, V15.B16, V11.B16
VAND V16.B16, V20.B16, V16.B16
VAND V17.B16, V21.B16, V17.B16
VAND V18.B16, V22.B16, V18.B16
VAND V19.B16, V23.B16, V19.B16
VAND V24.B16, V28.B16, V24.B16
VAND V25.B16, V29.B16, V25.B16
VAND V26.B16, V30.B16, V26.B16
VAND V27.B16, V31.B16, V27.B16
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R0)
VST1.P [ V8.B16, V9.B16, V10.B16, V11.B16], 64(R0)
VST1.P [V16.B16, V17.B16, V18.B16, V19.B16], 64(R0)
VST1.P [V24.B16, V25.B16, V26.B16, V27.B16], 64(R0)
SUBS $1, R3, R3
CBNZ R3, loop
RET
// func andNotNEON(dst *byte, a *byte, b *byte, l uint64)
TEXT ·andNotNEON(SB), NOSPLIT, $0-32
MOVD dst+0(FP), R0
MOVD a+8(FP), R1
MOVD b+16(FP), R2
MOVD l+24(FP), R3
MOVD $-1, R4
VDUP R4, V16.B16
loop:
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R2), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R2), [V12.B16, V13.B16, V14.B16, V15.B16]
VEOR V0.B16, V16.B16, V0.B16
VEOR V1.B16, V16.B16, V1.B16
VEOR V2.B16, V16.B16, V2.B16
VEOR V3.B16, V16.B16, V3.B16
VAND V0.B16, V4.B16, V0.B16
VAND V1.B16, V5.B16, V1.B16
VAND V2.B16, V6.B16, V2.B16
VAND V3.B16, V7.B16, V3.B16
VEOR V8.B16, V16.B16, V8.B16
VEOR V9.B16, V16.B16, V9.B16
VEOR V10.B16, V16.B16, V10.B16
VEOR V11.B16, V16.B16, V11.B16
VAND V8.B16, V12.B16, V8.B16
VAND V9.B16, V13.B16, V9.B16
VAND V10.B16, V14.B16, V10.B16
VAND V11.B16, V15.B16, V11.B16
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R0)
VST1.P [ V8.B16, V9.B16, V10.B16, V11.B16], 64(R0)
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R2), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R2), [V12.B16, V13.B16, V14.B16, V15.B16]
VEOR V0.B16, V16.B16, V0.B16
VEOR V1.B16, V16.B16, V1.B16
VEOR V2.B16, V16.B16, V2.B16
VEOR V3.B16, V16.B16, V3.B16
VAND V0.B16, V4.B16, V0.B16
VAND V1.B16, V5.B16, V1.B16
VAND V2.B16, V6.B16, V2.B16
VAND V3.B16, V7.B16, V3.B16
VEOR V8.B16, V16.B16, V8.B16
VEOR V9.B16, V16.B16, V9.B16
VEOR V10.B16, V16.B16, V10.B16
VEOR V11.B16, V16.B16, V11.B16
VAND V8.B16, V12.B16, V8.B16
VAND V9.B16, V13.B16, V9.B16
VAND V10.B16, V14.B16, V10.B16
VAND V11.B16, V15.B16, V11.B16
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R0)
VST1.P [ V8.B16, V9.B16, V10.B16, V11.B16], 64(R0)
SUBS $1, R3, R3
CBNZ R3, loop
RET
// func xorNEON(dst *byte, a *byte, b *byte, l uint64)
TEXT ·xorNEON(SB), NOSPLIT, $0-32
MOVD dst+0(FP), R0
MOVD a+8(FP), R1
MOVD b+16(FP), R2
MOVD l+24(FP), R3
loop:
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R2), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R2), [V12.B16, V13.B16, V14.B16, V15.B16]
VLD1.P 64(R1), [V16.B16, V17.B16, V18.B16, V19.B16]
VLD1.P 64(R2), [V20.B16, V21.B16, V22.B16, V23.B16]
VLD1.P 64(R1), [V24.B16, V25.B16, V26.B16, V27.B16]
VLD1.P 64(R2), [V28.B16, V29.B16, V30.B16, V31.B16]
VEOR V0.B16, V4.B16, V0.B16
VEOR V1.B16, V5.B16, V1.B16
VEOR V2.B16, V6.B16, V2.B16
VEOR V3.B16, V7.B16, V3.B16
VEOR V8.B16, V12.B16, V8.B16
VEOR V9.B16, V13.B16, V9.B16
VEOR V10.B16, V14.B16, V10.B16
VEOR V11.B16, V15.B16, V11.B16
VEOR V16.B16, V20.B16, V16.B16
VEOR V17.B16, V21.B16, V17.B16
VEOR V18.B16, V22.B16, V18.B16
VEOR V19.B16, V23.B16, V19.B16
VEOR V24.B16, V28.B16, V24.B16
VEOR V25.B16, V29.B16, V25.B16
VEOR V26.B16, V30.B16, V26.B16
VEOR V27.B16, V31.B16, V27.B16
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R0)
VST1.P [ V8.B16, V9.B16, V10.B16, V11.B16], 64(R0)
VST1.P [V16.B16, V17.B16, V18.B16, V19.B16], 64(R0)
VST1.P [V24.B16, V25.B16, V26.B16, V27.B16], 64(R0)
SUBS $1, R3, R3
CBNZ R3, loop
RET
// func orNEON(dst *byte, a *byte, b *byte, l uint64)
TEXT ·orNEON(SB), NOSPLIT, $0-32
MOVD dst+0(FP), R0
MOVD a+8(FP), R1
MOVD b+16(FP), R2
MOVD l+24(FP), R3
loop:
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R2), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R2), [V12.B16, V13.B16, V14.B16, V15.B16]
VLD1.P 64(R1), [V16.B16, V17.B16, V18.B16, V19.B16]
VLD1.P 64(R2), [V20.B16, V21.B16, V22.B16, V23.B16]
VLD1.P 64(R1), [V24.B16, V25.B16, V26.B16, V27.B16]
VLD1.P 64(R2), [V28.B16, V29.B16, V30.B16, V31.B16]
VORR V0.B16, V4.B16, V0.B16
VORR V1.B16, V5.B16, V1.B16
VORR V2.B16, V6.B16, V2.B16
VORR V3.B16, V7.B16, V3.B16
VORR V8.B16, V12.B16, V8.B16
VORR V9.B16, V13.B16, V9.B16
VORR V10.B16, V14.B16, V10.B16
VORR V11.B16, V15.B16, V11.B16
VORR V16.B16, V20.B16, V16.B16
VORR V17.B16, V21.B16, V17.B16
VORR V18.B16, V22.B16, V18.B16
VORR V19.B16, V23.B16, V19.B16
VORR V24.B16, V28.B16, V24.B16
VORR V25.B16, V29.B16, V25.B16
VORR V26.B16, V30.B16, V26.B16
VORR V27.B16, V31.B16, V27.B16
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R0)
VST1.P [ V8.B16, V9.B16, V10.B16, V11.B16], 64(R0)
VST1.P [V16.B16, V17.B16, V18.B16, V19.B16], 64(R0)
VST1.P [V24.B16, V25.B16, V26.B16, V27.B16], 64(R0)
SUBS $1, R3, R3
CBNZ R3, loop
RET
// func popcntNEON(a *byte, l uint64) uint64
TEXT ·popcntNEON(SB), NOSPLIT, $0-24
MOVD a+0(FP), R1
MOVD l+8(FP), R2
VEOR V16.B16, V16.B16, V16.B16 // zero
loop:
VLD1.P 64(R1), [ V0.B16, V1.B16, V2.B16, V3.B16]
VLD1.P 64(R1), [ V4.B16, V5.B16, V6.B16, V7.B16]
VLD1.P 64(R1), [ V8.B16, V9.B16, V10.B16, V11.B16]
VLD1.P 64(R1), [V12.B16, V13.B16, V14.B16, V15.B16]
VCNT V0.B16, V0.B16
VCNT V1.B16, V1.B16
VCNT V2.B16, V2.B16
VCNT V3.B16, V3.B16
VCNT V4.B16, V4.B16
VCNT V5.B16, V5.B16
VCNT V6.B16, V6.B16
VCNT V7.B16, V7.B16
VCNT V8.B16, V8.B16
VCNT V9.B16, V9.B16
VCNT V10.B16, V10.B16
VCNT V11.B16, V11.B16
VCNT V12.B16, V12.B16
VCNT V13.B16, V13.B16
VCNT V14.B16, V14.B16
VCNT V15.B16, V15.B16
VADD V0.B16, V1.B16, V0.B16
VADD V2.B16, V3.B16, V2.B16
VADD V4.B16, V5.B16, V4.B16
VADD V6.B16, V7.B16, V6.B16
VADD V8.B16, V9.B16, V8.B16
VADD V10.B16, V11.B16, V10.B16
VADD V12.B16, V13.B16, V12.B16
VADD V14.B16, V15.B16, V14.B16
VADD V0.B16, V2.B16, V0.B16
VADD V4.B16, V6.B16, V4.B16
VADD V8.B16, V10.B16, V8.B16
VADD V12.B16, V14.B16, V12.B16
VADD V0.B16, V4.B16, V0.B16
VADD V8.B16, V12.B16, V8.B16
VADD V0.B16, V8.B16, V0.B16
VUADDLV V0.B16, V0
VADDV V0.H8, V0
VADD V16.D2, V0.D2, V16.D2
SUBS $1, R2, R2
CBNZ R2, loop
VMOV V16.D[0], R0
MOVD R0, ret+16(FP)
RET
// func memsetNEON(dst *byte, l uint64, b byte)
TEXT ·memsetNEON(SB), NOSPLIT, $0-17
MOVD dst+0(FP), R1
MOVD l+8(FP), R2
MOVB b+16(FP), R0
VDUP R0, V0.B16
VORR V0.B16, V0.B16, V1.B16
VORR V0.B16, V0.B16, V2.B16
VORR V0.B16, V0.B16, V3.B16
loop:
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R1)
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R1)
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R1)
VST1.P [ V0.B16, V1.B16, V2.B16, V3.B16], 64(R1)
SUBS $1, R2, R2
CBNZ R2, loop
RET