summaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.23/src/internal/bytealg/equal_loong64.s
blob: 830b09bd2cf3d59c22af0f415158ccc0fa5d5710 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "go_asm.h"
#include "textflag.h"

#define	REGCTXT	R29

// memequal(a, b unsafe.Pointer, size uintptr) bool
TEXT runtime·memequal<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-25
	BEQ	R4, R5, eq
	ADDV	R4, R6, R7
	PCALIGN	$16
loop:
	BNE	R4, R7, test
	MOVV	$1, R4
	RET
test:
	MOVBU	(R4), R9
	ADDV	$1, R4
	MOVBU	(R5), R10
	ADDV	$1, R5
	BEQ	R9, R10, loop

	MOVB    R0, R4
	RET
eq:
	MOVV	$1, R4
	RET

// memequal_varlen(a, b unsafe.Pointer) bool
TEXT runtime·memequal_varlen<ABIInternal>(SB),NOSPLIT,$40-17
	BEQ	R4, R5, eq
	MOVV	8(REGCTXT), R6    // compiler stores size at offset 8 in the closure
	MOVV	R4, 8(R3)
	MOVV	R5, 16(R3)
	MOVV	R6, 24(R3)
	JAL	runtime·memequal(SB)
	MOVBU	32(R3), R4
	RET
eq:
	MOVV	$1, R4
	RET