github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/bytealg/equal_arm.s (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  #include "go_asm.h"
     6  #include "textflag.h"
     7  
     8  // TODO: share code with memequal?
     9  TEXT ·Equal(SB),NOSPLIT,$0-25
    10  	MOVW	a_len+4(FP), R1
    11  	MOVW	b_len+16(FP), R3
    12  
    13  	CMP	R1, R3		// unequal lengths are not equal
    14  	B.NE	notequal
    15  
    16  	MOVW	a_base+0(FP), R0
    17  	MOVW	b_base+12(FP), R2
    18  	ADD	R0, R1		// end
    19  
    20  loop:
    21  	CMP	R0, R1
    22  	B.EQ	equal		// reached the end
    23  	MOVBU.P	1(R0), R4
    24  	MOVBU.P	1(R2), R5
    25  	CMP	R4, R5
    26  	B.EQ	loop
    27  
    28  notequal:
    29  	MOVW	$0, R0
    30  	MOVBU	R0, ret+24(FP)
    31  	RET
    32  
    33  equal:
    34  	MOVW	$1, R0
    35  	MOVBU	R0, ret+24(FP)
    36  	RET
    37  
    38  // memequal(a, b unsafe.Pointer, size uintptr) bool
    39  TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-13
    40  	MOVW	a+0(FP), R1
    41  	MOVW	b+4(FP), R2
    42  	MOVW	size+8(FP), R3
    43  	ADD	R1, R3, R6
    44  	MOVW	$1, R0
    45  	MOVB	R0, ret+12(FP)
    46  	CMP	R1, R2
    47  	RET.EQ
    48  loop:
    49  	CMP	R1, R6
    50  	RET.EQ
    51  	MOVBU.P	1(R1), R4
    52  	MOVBU.P	1(R2), R5
    53  	CMP	R4, R5
    54  	BEQ	loop
    55  
    56  	MOVW	$0, R0
    57  	MOVB	R0, ret+12(FP)
    58  	RET
    59  
    60  // memequal_varlen(a, b unsafe.Pointer) bool
    61  TEXT runtime·memequal_varlen(SB),NOSPLIT,$16-9
    62  	MOVW	a+0(FP), R0
    63  	MOVW	b+4(FP), R1
    64  	CMP	R0, R1
    65  	BEQ	eq
    66  	MOVW	4(R7), R2    // compiler stores size at offset 4 in the closure
    67  	MOVW	R0, 4(R13)
    68  	MOVW	R1, 8(R13)
    69  	MOVW	R2, 12(R13)
    70  	BL	runtime·memequal(SB)
    71  	MOVB	16(R13), R0
    72  	MOVB	R0, ret+8(FP)
    73  	RET
    74  eq:
    75  	MOVW	$1, R0
    76  	MOVB	R0, ret+8(FP)
    77  	RET