Black Lives Matter. Support the Equal Justice Initiative.

Text file src/runtime/memclr_riscv64.s

Documentation: runtime

     1  // Copyright 2016 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 "textflag.h"
     6  
     7  // See memclrNoHeapPointers Go doc for important implementation constraints.
     8  
     9  // void runtime¬∑memclrNoHeapPointers(void*, uintptr)
    10  TEXT runtime¬∑memclrNoHeapPointers(SB),NOSPLIT,$0-16
    11  	MOV	ptr+0(FP), T1
    12  	MOV	n+8(FP), T2
    13  	ADD	T1, T2, T4
    14  
    15  	// If less than eight bytes, do one byte at a time.
    16  	SLTU	$8, T2, T3
    17  	BNE	T3, ZERO, outcheck
    18  
    19  	// Do one byte at a time until eight-aligned.
    20  	JMP	aligncheck
    21  align:
    22  	MOVB	ZERO, (T1)
    23  	ADD	$1, T1
    24  aligncheck:
    25  	AND	$7, T1, T3
    26  	BNE	T3, ZERO, align
    27  
    28  	// Do eight bytes at a time as long as there is room.
    29  	ADD	$-7, T4, T5
    30  	JMP	wordscheck
    31  words:
    32  	MOV	ZERO, (T1)
    33  	ADD	$8, T1
    34  wordscheck:
    35  	SLTU	T5, T1, T3
    36  	BNE	T3, ZERO, words
    37  
    38  	JMP	outcheck
    39  out:
    40  	MOVB	ZERO, (T1)
    41  	ADD	$1, T1
    42  outcheck:
    43  	BNE	T1, T4, out
    44  
    45  done:
    46  	RET
    47  

View as plain text