Text file src/internal/bytealg/equal_s390x.s

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

View as plain text