mirror of
https://github.com/golang/go
synced 2024-11-17 23:14:49 -07:00
internal/bytealg: share code for equal functions on arm
Move the shared code into byteal.memeqbody. This will allow to implement optimizations (e.g. for #29001) in a single function. Change-Id: Iaa34ddeb7068d92c35a8b4e581b7fd92da56535c Reviewed-on: https://go-review.googlesource.com/c/go/+/166677 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
21a634e2e9
commit
14a58d65e3
@ -12,3 +12,4 @@ runtime/tls_arm.s: [arm] load_g: function load_g missing Go declaration
|
||||
runtime/tls_arm.s: [arm] _initcgo: function _initcgo missing Go declaration
|
||||
|
||||
runtime/internal/atomic/asm_arm.s: [arm] cas: function cas missing Go declaration
|
||||
internal/bytealg/equal_arm.s: [arm] Equal: invalid MOVW of ret+24(FP); bool is 1-byte value
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "go_asm.h"
|
||||
#include "textflag.h"
|
||||
|
||||
// TODO: share code with memequal?
|
||||
TEXT ·Equal(SB),NOSPLIT,$0-25
|
||||
MOVW a_len+4(FP), R1
|
||||
MOVW b_len+16(FP), R3
|
||||
@ -15,8 +14,48 @@ TEXT ·Equal(SB),NOSPLIT,$0-25
|
||||
|
||||
MOVW a_base+0(FP), R0
|
||||
MOVW b_base+12(FP), R2
|
||||
ADD R0, R1 // end
|
||||
MOVW $ret+24(FP), R7
|
||||
B memeqbody<>(SB)
|
||||
notequal:
|
||||
MOVW $0, R0
|
||||
MOVBU R0, ret+24(FP)
|
||||
RET
|
||||
|
||||
// memequal(a, b unsafe.Pointer, size uintptr) bool
|
||||
TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-13
|
||||
MOVW a+0(FP), R0
|
||||
MOVW b+4(FP), R2
|
||||
CMP R0, R2
|
||||
B.EQ eq
|
||||
MOVW size+8(FP), R1
|
||||
MOVW $ret+12(FP), R7
|
||||
B memeqbody<>(SB)
|
||||
eq:
|
||||
MOVW $1, R0
|
||||
MOVB R0, ret+12(FP)
|
||||
RET
|
||||
|
||||
// memequal_varlen(a, b unsafe.Pointer) bool
|
||||
TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-9
|
||||
MOVW a+0(FP), R0
|
||||
MOVW b+4(FP), R2
|
||||
CMP R0, R2
|
||||
B.EQ eq
|
||||
MOVW 4(R7), R1 // compiler stores size at offset 4 in the closure
|
||||
MOVW $ret+8(FP), R7
|
||||
B memeqbody<>(SB)
|
||||
eq:
|
||||
MOVW $1, R0
|
||||
MOVB R0, ret+8(FP)
|
||||
RET
|
||||
|
||||
// Input:
|
||||
// R0: data of a
|
||||
// R1: length
|
||||
// R2: data of b
|
||||
// R7: points to return value
|
||||
TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0
|
||||
ADD R0, R1 // end
|
||||
loop:
|
||||
CMP R0, R1
|
||||
B.EQ equal // reached the end
|
||||
@ -24,54 +63,11 @@ loop:
|
||||
MOVBU.P 1(R2), R5
|
||||
CMP R4, R5
|
||||
B.EQ loop
|
||||
|
||||
notequal:
|
||||
MOVW $0, R0
|
||||
MOVBU R0, ret+24(FP)
|
||||
MOVB R0, (R7)
|
||||
RET
|
||||
|
||||
equal:
|
||||
MOVW $1, R0
|
||||
MOVBU R0, ret+24(FP)
|
||||
RET
|
||||
|
||||
// memequal(a, b unsafe.Pointer, size uintptr) bool
|
||||
TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-13
|
||||
MOVW a+0(FP), R1
|
||||
MOVW b+4(FP), R2
|
||||
MOVW size+8(FP), R3
|
||||
ADD R1, R3, R6
|
||||
MOVW $1, R0
|
||||
MOVB R0, ret+12(FP)
|
||||
CMP R1, R2
|
||||
RET.EQ
|
||||
loop:
|
||||
CMP R1, R6
|
||||
RET.EQ
|
||||
MOVBU.P 1(R1), R4
|
||||
MOVBU.P 1(R2), R5
|
||||
CMP R4, R5
|
||||
BEQ loop
|
||||
|
||||
MOVW $0, R0
|
||||
MOVB R0, ret+12(FP)
|
||||
RET
|
||||
|
||||
// memequal_varlen(a, b unsafe.Pointer) bool
|
||||
TEXT runtime·memequal_varlen(SB),NOSPLIT,$16-9
|
||||
MOVW a+0(FP), R0
|
||||
MOVW b+4(FP), R1
|
||||
CMP R0, R1
|
||||
BEQ eq
|
||||
MOVW 4(R7), R2 // compiler stores size at offset 4 in the closure
|
||||
MOVW R0, 4(R13)
|
||||
MOVW R1, 8(R13)
|
||||
MOVW R2, 12(R13)
|
||||
BL runtime·memequal(SB)
|
||||
MOVB 16(R13), R0
|
||||
MOVB R0, ret+8(FP)
|
||||
RET
|
||||
eq:
|
||||
MOVW $1, R0
|
||||
MOVB R0, ret+8(FP)
|
||||
MOVB R0, (R7)
|
||||
RET
|
||||
|
Loading…
Reference in New Issue
Block a user