built on arm64

This commit is contained in:
Barak Michener 2021-11-15 17:01:15 -08:00
parent 235bcd7a0c
commit a0ee8f6e0b
3 changed files with 20 additions and 5 deletions

14
countlines_arm64.go Normal file
View file

@ -0,0 +1,14 @@
//go:build arm64 && !gccgo && !appengine
package countlines
func CountNewlines(s []byte) uint64 {
if len(s) == 0 {
return 0
}
return countNewlinesASM(&s[0], uint64(len(s)))
}
//go:noescape
func countNewlinesASM(src *byte, len uint64) (ret uint64)

View file

@ -3,11 +3,11 @@
#include "textflag.h"
TEXT ·countNewlinesASM(SB),NOSPLIT,$0
MOVQ src+0(FP), R1
MOVQ len+8(FP), R2
MOVD src+0(FP), R1
MOVD len+8(FP), R2
MOVD ZR, R0
VMOVI $0x0A V23.B16
VMOVI $0x0A, V23.B16
CMP $16, R2
BLT tail
@ -65,7 +65,8 @@ tail:
next:
SUB $1, R2
JNZ tail
CMP ZR, R2
BNE tail
ret:

View file

@ -1,4 +1,4 @@
//go:build !amd64 || gccgo || appengine
//go:build (!amd64 && !arm64) || gccgo || appengine
package countlines