Skip to content

Commit 1d64431

Browse files
authored
zstd: Add noasm tag for xxhash (#475)
1 parent 505dc06 commit 1d64431

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
lines changed

zstd/internal/xxhash/xxhash_amd64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// +build !appengine
22
// +build gc
33
// +build !purego
4+
// +build !noasm
45

56
#include "textflag.h"
67

zstd/internal/xxhash/xxhash_arm64.s

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// +build gc,!purego
1+
// +build gc,!purego,!noasm
22

33
#include "textflag.h"
44

55
// Register allocation.
66
#define digest R1
7-
#define h R2 // Return value.
8-
#define p R3 // Input pointer.
7+
#define h R2 // Return value.
8+
#define p R3 // Input pointer.
99
#define len R4
10-
#define nblocks R5 // len / 32.
10+
#define nblocks R5 // len / 32.
1111
#define prime1 R7
1212
#define prime2 R8
1313
#define prime3 R9
@@ -22,50 +22,48 @@
2222
#define x3 R22
2323
#define x4 R23
2424

25-
#define round(acc, x) \
26-
MADD prime2, acc, x, acc \
27-
ROR $64-31, acc \
28-
MUL prime1, acc \
25+
#define round(acc, x) \
26+
MADD prime2, acc, x, acc \
27+
ROR $64-31, acc \
28+
MUL prime1, acc \
2929

3030
// x = round(0, x).
31-
#define round0(x) \
32-
MUL prime2, x \
33-
ROR $64-31, x \
34-
MUL prime1, x \
31+
#define round0(x) \
32+
MUL prime2, x \
33+
ROR $64-31, x \
34+
MUL prime1, x \
3535

36-
#define mergeRound(x) \
37-
round0(x) \
38-
EOR x, h \
39-
MADD h, prime4, prime1, h \
36+
#define mergeRound(x) \
37+
round0(x) \
38+
EOR x, h \
39+
MADD h, prime4, prime1, h \
4040

4141
// Update v[1-4] with 32-byte blocks. Assumes len >= 32.
42-
#define blocksLoop() \
43-
LSR $5, len, nblocks \
44-
PCALIGN $16 \
45-
loop: \
46-
LDP.P 32(p), (x1, x2) \
47-
round(v1, x1) \
48-
LDP -16(p), (x3, x4) \
49-
round(v2, x2) \
50-
SUB $1, nblocks \
51-
round(v3, x3) \
52-
round(v4, x4) \
53-
CBNZ nblocks, loop \
54-
42+
#define blocksLoop() \
43+
LSR $5, len, nblocks \
44+
PCALIGN $16 \
45+
loop: \
46+
LDP.P 32(p), (x1, x2) \
47+
round(v1, x1) \
48+
LDP -16(p), (x3, x4) \
49+
round(v2, x2) \
50+
SUB $1, nblocks \
51+
round(v3, x3) \
52+
round(v4, x4) \
53+
CBNZ nblocks, loop \
5554

5655
// The primes are repeated here to ensure that they're stored
5756
// in a contiguous array, so we can load them with LDP.
58-
DATA primes<> +0(SB)/8, $11400714785074694791
59-
DATA primes<> +8(SB)/8, $14029467366897019727
60-
DATA primes<>+16(SB)/8, $1609587929392839161
61-
DATA primes<>+24(SB)/8, $9650029242287828579
62-
DATA primes<>+32(SB)/8, $2870177450012600261
57+
DATA primes<> +0(SB)/8, $11400714785074694791
58+
DATA primes<> +8(SB)/8, $14029467366897019727
59+
DATA primes<>+16(SB)/8, $1609587929392839161
60+
DATA primes<>+24(SB)/8, $9650029242287828579
61+
DATA primes<>+32(SB)/8, $2870177450012600261
6362
GLOBL primes<>(SB), NOPTR+RODATA, $40
6463

65-
6664
// func Sum64(b []byte) uint64
6765
TEXT ·Sum64(SB), NOFRAME+NOSPLIT, $0-32
68-
LDP b_base+0(FP), (p, len)
66+
LDP b_base+0(FP), (p, len)
6967

7068
LDP primes<> +0(SB), (prime1, prime2)
7169
LDP primes<>+16(SB), (prime3, prime4)
@@ -156,32 +154,31 @@ try1:
156154

157155
end:
158156
EOR h >> 33, h
159-
MUL prime2, h
157+
MUL prime2, h
160158
EOR h >> 29, h
161-
MUL prime3, h
159+
MUL prime3, h
162160
EOR h >> 32, h
163161

164162
MOVD h, ret+24(FP)
165163
RET
166164

167-
168165
// func writeBlocks(d *Digest, b []byte) int
169166
//
170167
// Assumes len(b) >= 32.
171168
TEXT ·writeBlocks(SB), NOFRAME+NOSPLIT, $0-40
172-
LDP primes<>(SB), (prime1, prime2)
169+
LDP primes<>(SB), (prime1, prime2)
173170

174171
// Load state. Assume v[1-4] are stored contiguously.
175172
MOVD d+0(FP), digest
176-
LDP 0(digest), (v1, v2)
173+
LDP 0(digest), (v1, v2)
177174
LDP 16(digest), (v3, v4)
178175

179176
LDP b_base+8(FP), (p, len)
180177

181178
blocksLoop()
182179

183180
// Store updated state.
184-
STP (v1, v2), 0(digest)
181+
STP (v1, v2), 0(digest)
185182
STP (v3, v4), 16(digest)
186183

187184
BIC $31, len

zstd/internal/xxhash/xxhash_asm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//go:build (amd64 || arm64) && !appengine && gc && !purego
1+
//go:build (amd64 || arm64) && !appengine && gc && !purego && !noasm
22
// +build amd64 arm64
33
// +build !appengine
44
// +build gc
55
// +build !purego
6+
// +build !noasm
67

78
package xxhash
89

zstd/internal/xxhash/xxhash_other.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build (!amd64 && !arm64) || appengine || !gc || purego
2-
// +build !amd64,!arm64 appengine !gc purego
1+
//go:build (!amd64 && !arm64) || appengine || !gc || purego || noasm
2+
// +build !amd64,!arm64 appengine !gc purego noasm
33

44
package xxhash
55

0 commit comments

Comments
 (0)