github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/bytealg/equal_mipsx.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  // +build mips mipsle
     6  
     7  #include "go_asm.h"
     8  #include "textflag.h"
     9  
    10  #define	REGCTXT	R22
    11  
    12  TEXT ·Equal(SB),NOSPLIT,$0-25
    13  	MOVW	a_len+4(FP), R3
    14  	MOVW	b_len+16(FP), R4
    15  	BNE	R3, R4, noteq	// unequal lengths are not equal
    16  
    17  	MOVW	a_base+0(FP), R1
    18  	MOVW	b_base+12(FP), R2
    19  	ADDU	R1, R3	// end
    20  
    21  loop:
    22  	BEQ	R1, R3, equal	// reached the end
    23  	MOVBU	(R1), R6
    24  	ADDU	$1, R1
    25  	MOVBU	(R2), R7
    26  	ADDU	$1, R2
    27  	BEQ	R6, R7, loop
    28  
    29  noteq:
    30  	MOVB	R0, ret+24(FP)
    31  	RET
    32  
    33  equal:
    34  	MOVW	$1, R1
    35  	MOVB	R1, ret+24(FP)
    36  	RET
    37  
    38  // memequal(a, b unsafe.Pointer, size uintptr) bool
    39  TEXT runtime·memequal(SB),NOSPLIT,$0-13
    40  	MOVW	a+0(FP), R1
    41  	MOVW	b+4(FP), R2
    42  	BEQ	R1, R2, eq
    43  	MOVW	size+8(FP), R3
    44  	ADDU	R1, R3, R4
    45  loop:
    46  	BNE	R1, R4, test
    47  	MOVW	$1, R1
    48  	MOVB	R1, ret+12(FP)
    49  	RET
    50  test:
    51  	MOVBU	(R1), R6
    52  	ADDU	$1, R1
    53  	MOVBU	(R2), R7
    54  	ADDU	$1, R2
    55  	BEQ	R6, R7, loop
    56  
    57  	MOVB	R0, ret+12(FP)
    58  	RET
    59  eq:
    60  	MOVW	$1, R1
    61  	MOVB	R1, ret+12(FP)
    62  	RET
    63  
    64  // memequal_varlen(a, b unsafe.Pointer) bool
    65  TEXT runtime·memequal_varlen(SB),NOSPLIT,$0-9
    66  	MOVW	a+0(FP), R1
    67  	MOVW	b+4(FP), R2
    68  	BEQ	R1, R2, eq
    69  	MOVW	4(REGCTXT), R3	// compiler stores size at offset 4 in the closure
    70  	ADDU	R1, R3, R4
    71  loop:
    72  	BNE	R1, R4, test
    73  	MOVW	$1, R1
    74  	MOVB	R1, ret+8(FP)
    75  	RET
    76  test:
    77  	MOVBU	(R1), R6
    78  	ADDU	$1, R1
    79  	MOVBU	(R2), R7
    80  	ADDU	$1, R2
    81  	BEQ	R6, R7, loop
    82  
    83  	MOVB	R0, ret+8(FP)
    84  	RET
    85  eq:
    86  	MOVW	$1, R1
    87  	MOVB	R1, ret+8(FP)
    88  	RET