1// Copyright 2022 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#define	REGCTXT	R29
9
10// memequal(a, b unsafe.Pointer, size uintptr) bool
11TEXT runtime·memequal<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-25
12	BEQ	R4, R5, eq
13	ADDV	R4, R6, R7
14	PCALIGN	$16
15loop:
16	BNE	R4, R7, test
17	MOVV	$1, R4
18	RET
19test:
20	MOVBU	(R4), R9
21	ADDV	$1, R4
22	MOVBU	(R5), R10
23	ADDV	$1, R5
24	BEQ	R9, R10, loop
25
26	MOVB    R0, R4
27	RET
28eq:
29	MOVV	$1, R4
30	RET
31
32// memequal_varlen(a, b unsafe.Pointer) bool
33TEXT runtime·memequal_varlen<ABIInternal>(SB),NOSPLIT,$40-17
34	BEQ	R4, R5, eq
35	MOVV	8(REGCTXT), R6    // compiler stores size at offset 8 in the closure
36	MOVV	R4, 8(R3)
37	MOVV	R5, 16(R3)
38	MOVV	R6, 24(R3)
39	JAL	runtime·memequal(SB)
40	MOVBU	32(R3), R4
41	RET
42eq:
43	MOVV	$1, R4
44	RET
45