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