built on arm64
This commit is contained in:
parent
235bcd7a0c
commit
a0ee8f6e0b
3 changed files with 20 additions and 5 deletions
14
countlines_arm64.go
Normal file
14
countlines_arm64.go
Normal 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)
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
TEXT ·countNewlinesASM(SB),NOSPLIT,$0
|
TEXT ·countNewlinesASM(SB),NOSPLIT,$0
|
||||||
MOVQ src+0(FP), R1
|
MOVD src+0(FP), R1
|
||||||
MOVQ len+8(FP), R2
|
MOVD len+8(FP), R2
|
||||||
|
|
||||||
MOVD ZR, R0
|
MOVD ZR, R0
|
||||||
VMOVI $0x0A V23.B16
|
VMOVI $0x0A, V23.B16
|
||||||
|
|
||||||
CMP $16, R2
|
CMP $16, R2
|
||||||
BLT tail
|
BLT tail
|
||||||
|
|
@ -65,7 +65,8 @@ tail:
|
||||||
next:
|
next:
|
||||||
|
|
||||||
SUB $1, R2
|
SUB $1, R2
|
||||||
JNZ tail
|
CMP ZR, R2
|
||||||
|
BNE tail
|
||||||
|
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build !amd64 || gccgo || appengine
|
//go:build (!amd64 && !arm64) || gccgo || appengine
|
||||||
|
|
||||||
package countlines
|
package countlines
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue