Text file
src/runtime/memclr_mipsx.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 //go:build mips || mipsle
6
7 #include "textflag.h"
8
9 #ifdef GOARCH_mips
10 #define MOVWHI MOVWL
11 #define MOVWLO MOVWR
12 #else
13 #define MOVWHI MOVWR
14 #define MOVWLO MOVWL
15 #endif
16
17 // See memclrNoHeapPointers Go doc for important implementation constraints.
18
19 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
20 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
21 MOVW n+4(FP), R2
22 MOVW ptr+0(FP), R1
23
24 SGTU $4, R2, R3
25 ADDU R2, R1, R4
26 BNE R3, small_zero
27
28 ptr_align:
29 AND $3, R1, R3
30 BEQ R3, setup
31 SUBU R1, R0, R3
32 AND $3, R3 // R3 contains number of bytes needed to align ptr
33 MOVWHI R0, 0(R1) // MOVWHI will write zeros up to next word boundary
34 SUBU R3, R2
35 ADDU R3, R1
36
37 setup:
38 AND $31, R2, R6
39 AND $3, R2, R5
40 SUBU R6, R4, R6 // end pointer for 32-byte chunks
41 SUBU R5, R4, R5 // end pointer for 4-byte chunks
42
43 large:
44 BEQ R1, R6, words
45 MOVW R0, 0(R1)
46 MOVW R0, 4(R1)
47 MOVW R0, 8(R1)
48 MOVW R0, 12(R1)
49 MOVW R0, 16(R1)
50 MOVW R0, 20(R1)
51 MOVW R0, 24(R1)
52 MOVW R0, 28(R1)
53 ADDU $32, R1
54 JMP large
55
56 words:
57 BEQ R1, R5, tail
58 MOVW R0, 0(R1)
59 ADDU $4, R1
60 JMP words
61
62 tail:
63 BEQ R1, R4, ret
64 MOVWLO R0, -1(R4)
65
66 ret:
67 RET
68
69 small_zero:
70 BEQ R1, R4, ret
71 MOVB R0, 0(R1)
72 ADDU $1, R1
73 JMP small_zero
74
View as plain text