Text file src/runtime/memclr_loong64.s

     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  	SGTU	R7, R6, R8
    30  	BEQ	R8, out
    31  	MOVV	R0, (R6)
    32  	ADDV	$8, R6
    33  	JMP	-4(PC)
    34  
    35  out:
    36  	BEQ	R6, R4, done
    37  	MOVB	R0, (R6)
    38  	ADDV	$1, R6
    39  	JMP	-3(PC)
    40  done:
    41  	RET
    42  

View as plain text