github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/src/runtime/memclr_ppc64x.s (about)

     1  // Copyright 2014 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  // +build ppc64 ppc64le
     6  
     7  #include "textflag.h"
     8  
     9  // void runtime·memclrNoHeapPointers(void*, uintptr)
    10  TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT|NOFRAME, $0-16
    11  	MOVD ptr+0(FP), R3
    12  	MOVD n+8(FP), R4
    13  
    14  	// Determine if there are doublewords to clear
    15  check:
    16  	ANDCC $7, R4, R5  // R5: leftover bytes to clear
    17  	SRAD  $3, R4, R6  // R6: double words to clear
    18  	CMP   R6, $0, CR1 // CR1[EQ] set if no double words
    19  
    20  	BC     12, 6, nozerolarge // only single bytes
    21  	MOVD   R6, CTR            // R6 = number of double words
    22  	SRADCC $2, R6, R7         // 32 byte chunks?
    23  	BNE    zero32setup
    24  
    25  	// Clear double words
    26  
    27  zero8:
    28  	MOVD R0, 0(R3)    // double word
    29  	ADD  $8, R3
    30  	BC   16, 0, zero8 // dec ctr, br zero8 if ctr not 0
    31  	BR   nozerolarge  // handle remainder
    32  
    33  	// Prepare to clear 32 bytes at a time.
    34  
    35  zero32setup:
    36  	DCBTST (R3)    // prepare data cache
    37  	MOVD   R7, CTR // number of 32 byte chunks
    38  
    39  zero32:
    40  	MOVD    R0, 0(R3)       // clear 4 double words
    41  	MOVD    R0, 8(R3)
    42  	MOVD    R0, 16(R3)
    43  	MOVD    R0, 24(R3)
    44  	ADD     $32, R3
    45  	BC      16, 0, zero32   // dec ctr, br zero32 if ctr not 0
    46  	RLDCLCC $61, R4, $3, R6 // remaining doublewords
    47  	BEQ     nozerolarge
    48  	MOVD    R6, CTR         // set up the CTR for doublewords
    49  	BR      zero8
    50  
    51  nozerolarge:
    52  	CMP R5, $0   // any remaining bytes
    53  	BC  4, 1, LR // ble lr
    54  
    55  zerotail:
    56  	MOVD R5, CTR // set up to clear tail bytes
    57  
    58  zerotailloop:
    59  	MOVB R0, 0(R3)           // clear single bytes
    60  	ADD  $1, R3
    61  	BC   16, 0, zerotailloop // dec ctr, br zerotailloop if ctr not 0
    62  	RET