...

Text file src/internal/bytealg/equal_s390x.s

Documentation: internal/bytealg

     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#include "go_asm.h"
     6#include "textflag.h"
     7
     8// memequal(a, b unsafe.Pointer, size uintptr) bool
     9TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25
    10	MOVD	a+0(FP), R3
    11	MOVD	b+8(FP), R5
    12	MOVD	size+16(FP), R6
    13	LA	ret+24(FP), R7
    14	BR	memeqbody<>(SB)
    15
    16// memequal_varlen(a, b unsafe.Pointer) bool
    17TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-17
    18	MOVD	a+0(FP), R3
    19	MOVD	b+8(FP), R5
    20	MOVD	8(R12), R6    // compiler stores size at offset 8 in the closure
    21	LA	ret+16(FP), R7
    22	BR	memeqbody<>(SB)
    23
    24// input:
    25//   R3 = a
    26//   R5 = b
    27//   R6 = len
    28//   R7 = address of output byte (stores 0 or 1 here)
    29//   a and b have the same length
    30TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0
    31	CMPBEQ	R3, R5, equal
    32loop:
    33	CMPBEQ	R6, $0, equal
    34	CMPBLT	R6, $32, tiny
    35	CMP	R6, $256
    36	BLT	tail
    37	CLC	$256, 0(R3), 0(R5)
    38	BNE	notequal
    39	SUB	$256, R6
    40	LA	256(R3), R3
    41	LA	256(R5), R5
    42	BR	loop
    43tail:
    44	SUB	$1, R6, R8
    45	EXRL	$memeqbodyclc<>(SB), R8
    46	BEQ	equal
    47notequal:
    48	MOVB	$0, 0(R7)
    49	RET
    50equal:
    51	MOVB	$1, 0(R7)
    52	RET
    53tiny:
    54	MOVD	$0, R2
    55	CMPBLT	R6, $16, lt16
    56	MOVD	0(R3), R8
    57	MOVD	0(R5), R9
    58	CMPBNE	R8, R9, notequal
    59	MOVD	8(R3), R8
    60	MOVD	8(R5), R9
    61	CMPBNE	R8, R9, notequal
    62	LA	16(R2), R2
    63	SUB	$16, R6
    64lt16:
    65	CMPBLT	R6, $8, lt8
    66	MOVD	0(R3)(R2*1), R8
    67	MOVD	0(R5)(R2*1), R9
    68	CMPBNE	R8, R9, notequal
    69	LA	8(R2), R2
    70	SUB	$8, R6
    71lt8:
    72	CMPBLT	R6, $4, lt4
    73	MOVWZ	0(R3)(R2*1), R8
    74	MOVWZ	0(R5)(R2*1), R9
    75	CMPBNE	R8, R9, notequal
    76	LA	4(R2), R2
    77	SUB	$4, R6
    78lt4:
    79#define CHECK(n) \
    80	CMPBEQ	R6, $n, equal \
    81	MOVB	n(R3)(R2*1), R8 \
    82	MOVB	n(R5)(R2*1), R9 \
    83	CMPBNE	R8, R9, notequal
    84	CHECK(0)
    85	CHECK(1)
    86	CHECK(2)
    87	CHECK(3)
    88	BR	equal
    89
    90TEXT memeqbodyclc<>(SB),NOSPLIT|NOFRAME,$0-0
    91	CLC	$1, 0(R3), 0(R5)
    92	RET

View as plain text