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

View as plain text