src/internal/bytealg/compare_arm.s 87 lines View on github.com → Search inside
1// Copyright 2018 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.45#include "go_asm.h"6#include "textflag.h"78TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-289	MOVW	a_base+0(FP), R210	MOVW	a_len+4(FP), R011	MOVW	b_base+12(FP), R312	MOVW	b_len+16(FP), R113	ADD	$28, R13, R714	B	cmpbody<>(SB)1516TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-2017	MOVW	a_base+0(FP), R218	MOVW	a_len+4(FP), R019	MOVW	b_base+8(FP), R320	MOVW	b_len+12(FP), R121	ADD	$20, R13, R722	B	cmpbody<>(SB)2324// On entry:25// R0 is the length of a26// R1 is the length of b27// R2 points to the start of a28// R3 points to the start of b29// R7 points to return value (-1/0/1 will be written here)30//31// On exit:32// R4, R5, R6 and R8 are clobbered33TEXT cmpbody<>(SB),NOSPLIT|NOFRAME,$0-034	CMP	R2, R335	BEQ	samebytes36	CMP 	R0, R137	MOVW 	R0, R638	MOVW.LT	R1, R6		// R6 is min(R0, R1)3940	CMP	$0, R641	BEQ	samebytes42	CMP	$4, R643	ADD	R2, R6		// R2 is current byte in a, R6 is the end of the range to compare44	BLT	byte_loop	// length < 445	AND	$3, R2, R846	CMP	$0, R847	BNE	byte_loop	// unaligned a, use byte-wise compare (TODO: try to align a)48aligned_a:49	AND	$3, R3, R850	CMP	$0, R851	BNE	byte_loop	// unaligned b, use byte-wise compare52	AND	$0xfffffffc, R6, R853	// length >= 454chunk4_loop:55	MOVW.P	4(R2), R456	MOVW.P	4(R3), R557	CMP	R4, R558	BNE	cmp59	CMP	R2, R860	BNE	chunk4_loop61	CMP	R2, R662	BEQ	samebytes	// all compared bytes were the same; compare lengths63byte_loop:64	MOVBU.P	1(R2), R465	MOVBU.P	1(R3), R566	CMP	R4, R567	BNE	ret68	CMP	R2, R669	BNE	byte_loop70samebytes:71	CMP	R0, R172	MOVW.LT	$1, R073	MOVW.GT	$-1, R074	MOVW.EQ	$0, R075	MOVW	R0, (R7)76	RET77ret:78	// bytes differed79	MOVW.LT	$1, R080	MOVW.GT	$-1, R081	MOVW	R0, (R7)82	RET83cmp:84	SUB	$4, R2, R285	SUB	$4, R3, R386	B	byte_loop

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.