| 1 |
#include "textflag.h" |
| 2 |
|
| 3 |
// MASK64 computes into R the 64-bit mask of the bytes of the block in V0..V3 which are equal to the byte |
| 4 |
// broadcast in Vc. Every lane of a compare is 0xff or 0: it is masked to the weight of the lane in its |
| 5 |
// byte of the mask ( V20: 1, 2, 4 ... 128, repeated ), and three pairwise additions sum the weights of |
| 6 |
// the eight lanes of every byte of the mask, in the order of the block. |
| 7 |
#define MASK64(Vc, R) \ |
| 8 |
VCMEQ Vc.B16, V0.B16, V4.B16 \ |
| 9 |
VCMEQ Vc.B16, V1.B16, V5.B16 \ |
| 10 |
VCMEQ Vc.B16, V2.B16, V6.B16 \ |
| 11 |
VCMEQ Vc.B16, V3.B16, V7.B16 \ |
| 12 |
VAND V20.B16, V4.B16, V4.B16 \ |
| 13 |
VAND V20.B16, V5.B16, V5.B16 \ |
| 14 |
VAND V20.B16, V6.B16, V6.B16 \ |
| 15 |
VAND V20.B16, V7.B16, V7.B16 \ |
| 16 |
VADDP V5.B16, V4.B16, V4.B16 \ |
| 17 |
VADDP V7.B16, V6.B16, V6.B16 \ |
| 18 |
VADDP V6.B16, V4.B16, V4.B16 \ |
| 19 |
VADDP V4.B16, V4.B16, V4.B16 \ |
| 20 |
VMOV V4.D[0], R |
| 21 |
|
| 22 |
// func scanBlockNEON(p unsafe.Pointer, m *scanMasks) |
| 23 |
// |
| 24 |
// It computes the masks of the 64 bytes at p: bit i of a mask is set if the byte i is the character. |
| 25 |
// The brackets are folded by clearing the bit 5, which makes '{' a '[' and '}' a ']'. |
| 26 |
TEXT ·scanBlockNEON(SB), NOSPLIT, $0-16 |
| 27 |
MOVD p+0(FP), R0 |
| 28 |
MOVD m+8(FP), R1 |
| 29 |
|
| 30 |
VLD1 (R0), [V0.B16, V1.B16, V2.B16, V3.B16] |
| 31 |
MOVD $weights<>(SB), R2 |
| 32 |
VLD1 (R2), [V20.B16] |
| 33 |
MOVD $0x22, R3 |
| 34 |
VMOV R3, V16.B16 |
| 35 |
MOVD $0x5c, R3 |
| 36 |
VMOV R3, V17.B16 |
| 37 |
MOVD $0x5b, R3 |
| 38 |
VMOV R3, V18.B16 |
| 39 |
MOVD $0x5d, R3 |
| 40 |
VMOV R3, V19.B16 |
| 41 |
MOVD $0xdf, R3 |
| 42 |
VMOV R3, V21.B16 |
| 43 |
|
| 44 |
MASK64(V16, R4) |
| 45 |
MOVD R4, 0(R1) |
| 46 |
MASK64(V17, R4) |
| 47 |
MOVD R4, 8(R1) |
| 48 |
VAND V21.B16, V0.B16, V0.B16 |
| 49 |
VAND V21.B16, V1.B16, V1.B16 |
| 50 |
VAND V21.B16, V2.B16, V2.B16 |
| 51 |
VAND V21.B16, V3.B16, V3.B16 |
| 52 |
MASK64(V18, R4) |
| 53 |
MOVD R4, 16(R1) |
| 54 |
MASK64(V19, R4) |
| 55 |
MOVD R4, 24(R1) |
| 56 |
RET |
| 57 |
|
| 58 |
DATA weights<>+0(SB)/8, $0x8040201008040201 |
| 59 |
DATA weights<>+8(SB)/8, $0x8040201008040201 |
| 60 |
GLOBL weights<>(SB), RODATA|NOPTR, $16 |