Text file src/internal/bytealg/equal_ppc64x.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  //go:build ppc64 || ppc64le
     6  
     7  #include "go_asm.h"
     8  #include "textflag.h"
     9  
    10  // memequal(a, b unsafe.Pointer, size uintptr) bool
    11  TEXT runtime·memequal<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-25
    12  #ifndef GOEXPERIMENT_regabiargs
    13  	MOVD    a+0(FP), R3
    14  	MOVD    b+8(FP), R4
    15  	MOVD    size+16(FP), R5
    16  	MOVD    $ret+24(FP), R10
    17  #endif
    18  	BR	memeqbody<>(SB)
    19  
    20  // memequal_varlen(a, b unsafe.Pointer) bool
    21  TEXT runtime·memequal_varlen<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-17
    22  #ifndef GOEXPERIMENT_regabiargs
    23  	MOVD	a+0(FP), R3
    24  	MOVD	b+8(FP), R4
    25  	MOVD    $ret+16(FP), R10
    26  #endif
    27  	CMP	R3, R4
    28  	BEQ	eq
    29  	MOVD	8(R11), R5    // compiler stores size at offset 8 in the closure
    30  	BR	memeqbody<>(SB)
    31  eq:
    32  	MOVD	$1, R3
    33  #ifndef GOEXPERIMENT_regabiargs
    34  	MOVB	R3, ret+16(FP)
    35  #endif
    36  	RET
    37  
    38  // Do an efficient memequal for ppc64
    39  // R3 = s1
    40  // R4 = s2
    41  // R5 = len
    42  // R10 = addr of return value (byte) when not regabi
    43  TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0
    44  	MOVD    R5,CTR
    45  	CMP     R5,$8		// only optimize >=8
    46  	BLT     simplecheck
    47  	DCBT	(R3)		// cache hint
    48  	DCBT	(R4)
    49  	CMP	R5,$32		// optimize >= 32
    50  	MOVD	R5,R6		// needed if setup8a branch
    51  	BLT	setup8a		// 8 byte moves only
    52  setup32a:                       // 8 byte aligned, >= 32 bytes
    53  	SRADCC  $5,R5,R6        // number of 32 byte chunks to compare
    54  	MOVD	R6,CTR
    55  	MOVD	$16,R14		// index for VSX loads and stores
    56  loop32a:
    57  	LXVD2X  (R3+R0), VS32	// VS32 = V0
    58  	LXVD2X  (R4+R0), VS33	// VS33 = V1
    59  	VCMPEQUBCC V0, V1, V2	// compare, setting CR6
    60  	BGE     CR6, noteq
    61  	LXVD2X  (R3+R14), VS32
    62  	LXVD2X  (R4+R14), VS33
    63  	VCMPEQUBCC V0, V1, V2
    64  	BGE     CR6, noteq
    65  	ADD     $32,R3		// bump up to next 32
    66  	ADD     $32,R4
    67  	BC      16, 0, loop32a  // br ctr and cr
    68  	ANDCC	$24,R5,R6       // Any 8 byte chunks?
    69  	BEQ	leftover	// and result is 0
    70  setup8a:
    71  	SRADCC  $3,R6,R6        // get the 8 byte count
    72  	BEQ	leftover	// shifted value is 0
    73  	MOVD    R6,CTR
    74  loop8:
    75  	MOVD    0(R3),R6        // doublewords to compare
    76  	ADD	$8,R3
    77  	MOVD    0(R4),R7
    78  	ADD     $8,R4
    79  	CMP     R6,R7           // match?
    80  	BC	8,2,loop8	// bt ctr <> 0 && cr
    81  	BNE     noteq
    82  leftover:
    83  	ANDCC   $7,R5,R6        // check for leftover bytes
    84  	BEQ     equal
    85  	MOVD    R6,CTR
    86  	BR	simple
    87  simplecheck:
    88  	CMP	R5,$0
    89  	BEQ	equal
    90  simple:
    91  	MOVBZ   0(R3), R6
    92  	ADD	$1,R3
    93  	MOVBZ   0(R4), R7
    94  	ADD     $1,R4
    95  	CMP     R6, R7
    96  	BNE     noteq
    97  	BC      8,2,simple
    98  	BNE	noteq
    99  	BR	equal
   100  noteq:
   101  #ifdef GOEXPERIMENT_regabiargs
   102  	MOVD	$0, R3
   103  #else
   104  	MOVB    $0, (R10)
   105  #endif
   106  	RET
   107  equal:
   108  	MOVD	$1, R3
   109  #ifndef GOEXPERIMENT_regabiargs
   110  	MOVB	R3, (R10)
   111  #endif
   112  	RET
   113  
   114  

View as plain text