]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/memclr_riscv64.s
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / runtime / memclr_riscv64.s
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<ABIInternal>(SB),NOSPLIT,$0-16
11 #ifndef GOEXPERIMENT_regabiargs
12         MOV     ptr+0(FP), A0
13         MOV     n+8(FP), A1
14 #endif
15         ADD     A0, A1, T4
16
17         // If less than eight bytes, do one byte at a time.
18         SLTU    $8, A1, T3
19         BNE     T3, ZERO, outcheck
20
21         // Do one byte at a time until eight-aligned.
22         JMP     aligncheck
23 align:
24         MOVB    ZERO, (A0)
25         ADD     $1, A0
26 aligncheck:
27         AND     $7, A0, T3
28         BNE     T3, ZERO, align
29
30         // Do eight bytes at a time as long as there is room.
31         ADD     $-7, T4, T5
32         JMP     wordscheck
33 words:
34         MOV     ZERO, (A0)
35         ADD     $8, A0
36 wordscheck:
37         SLTU    T5, A0, T3
38         BNE     T3, ZERO, words
39
40         JMP     outcheck
41 out:
42         MOVB    ZERO, (A0)
43         ADD     $1, A0
44 outcheck:
45         BNE     A0, T4, out
46
47 done:
48         RET