github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/runtime/memclr_loong64.s (about)

     1  // Copyright 2022 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  // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
     9  TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
    10  	MOVV	ptr+0(FP), R6
    11  	MOVV	n+8(FP), R7
    12  	ADDV	R6, R7, R4
    13  
    14  	// if less than 8 bytes, do one byte at a time
    15  	SGTU	$8, R7, R8
    16  	BNE	R8, out
    17  
    18  	// do one byte at a time until 8-aligned
    19  	AND	$7, R6, R8
    20  	BEQ	R8, words
    21  	MOVB	R0, (R6)
    22  	ADDV	$1, R6
    23  	JMP	-4(PC)
    24  
    25  words:
    26  	// do 8 bytes at a time if there is room
    27  	ADDV	$-7, R4, R7
    28  
    29  	PCALIGN	$16
    30  	SGTU	R7, R6, R8
    31  	BEQ	R8, out
    32  	MOVV	R0, (R6)
    33  	ADDV	$8, R6
    34  	JMP	-4(PC)
    35  
    36  out:
    37  	BEQ	R6, R4, done
    38  	MOVB	R0, (R6)
    39  	ADDV	$1, R6
    40  	JMP	-3(PC)
    41  done:
    42  	RET