Text file src/internal/bytealg/equal_mips64x.s

     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  //go:build mips64 || mips64le
     6  
     7  #include "go_asm.h"
     8  #include "textflag.h"
     9  
    10  #define	REGCTXT	R22
    11  
    12  // memequal(a, b unsafe.Pointer, size uintptr) bool
    13  TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25
    14  	MOVV	a+0(FP), R1
    15  	MOVV	b+8(FP), R2
    16  	BEQ	R1, R2, eq
    17  	MOVV	size+16(FP), R3
    18  	ADDV	R1, R3, R4
    19  
    20  	// chunk size is 16
    21  	SGTU	$16, R3, R8
    22  	BEQ	R0, R8, chunk_entry
    23  
    24  byte_loop:
    25  	BNE	R1, R4, byte_test
    26  	MOVV	$1, R1
    27  	MOVB	R1, ret+24(FP)
    28  	RET
    29  byte_test:
    30  	MOVBU	(R1), R6
    31  	ADDV	$1, R1
    32  	MOVBU	(R2), R7
    33  	ADDV	$1, R2
    34  	BEQ	R6, R7, byte_loop
    35  	JMP	not_eq
    36  
    37  chunk_entry:
    38  	// make sure both a and b are aligned
    39  	OR	R1, R2, R9
    40  	AND	$0x7, R9
    41  	BNE	R0, R9, byte_loop
    42  	JMP	chunk_loop_1
    43  
    44  chunk_loop:
    45  	// chunk size is 16
    46  	SGTU	$16, R3, R8
    47  	BNE	R0, R8, chunk_tail_8
    48  chunk_loop_1:
    49  	MOVV	(R1), R6
    50  	MOVV	(R2), R7
    51  	BNE	R6, R7, not_eq
    52  	MOVV	8(R1), R12
    53  	MOVV	8(R2), R13
    54  	ADDV	$16, R1
    55  	ADDV	$16, R2
    56  	SUBV	$16, R3
    57  	BEQ	R12, R13, chunk_loop
    58  	JMP	not_eq
    59  
    60  chunk_tail_8:
    61  	AND	$8, R3, R14
    62  	BEQ	R0, R14, chunk_tail_4
    63  	MOVV	(R1), R6
    64  	MOVV	(R2), R7
    65  	BNE	R6, R7, not_eq
    66  	ADDV	$8, R1
    67  	ADDV	$8, R2
    68  
    69  chunk_tail_4:
    70  	AND	$4, R3, R14
    71  	BEQ	R0, R14, chunk_tail_2
    72  	MOVWU	(R1), R6
    73  	MOVWU	(R2), R7
    74  	BNE	R6, R7, not_eq
    75  	ADDV	$4, R1
    76  	ADDV	$4, R2
    77  
    78  chunk_tail_2:
    79  	AND	$2, R3, R14
    80  	BEQ	R0, R14, chunk_tail_1
    81  	MOVHU	(R1), R6
    82  	MOVHU	(R2), R7
    83  	BNE	R6, R7, not_eq
    84  	ADDV	$2, R1
    85  	ADDV	$2, R2
    86  
    87  chunk_tail_1:
    88  	AND	$1, R3, R14
    89  	BEQ	R0, R14, eq
    90  	MOVBU	(R1), R6
    91  	MOVBU	(R2), R7
    92  	BEQ	R6, R7, eq
    93  
    94  not_eq:
    95  	MOVB	R0, ret+24(FP)
    96  	RET
    97  eq:
    98  	MOVV	$1, R1
    99  	MOVB	R1, ret+24(FP)
   100  	RET
   101  
   102  // memequal_varlen(a, b unsafe.Pointer) bool
   103  TEXT runtime·memequal_varlen(SB),NOSPLIT,$40-17
   104  	MOVV	a+0(FP), R1
   105  	MOVV	b+8(FP), R2
   106  	BEQ	R1, R2, eq
   107  	MOVV	8(REGCTXT), R3    // compiler stores size at offset 8 in the closure
   108  	MOVV	R1, 8(R29)
   109  	MOVV	R2, 16(R29)
   110  	MOVV	R3, 24(R29)
   111  	JAL	runtime·memequal(SB)
   112  	MOVBU	32(R29), R1
   113  	MOVB	R1, ret+16(FP)
   114  	RET
   115  eq:
   116  	MOVV	$1, R1
   117  	MOVB	R1, ret+16(FP)
   118  	RET
   119  

View as plain text