Text file
src/runtime/memclr_mips64x.s
1 // Copyright 2015 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 mips64 || mips64le
6
7 #include "go_asm.h"
8 #include "textflag.h"
9
10 // See memclrNoHeapPointers Go doc for important implementation constraints.
11
12 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
13 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
14 MOVV ptr+0(FP), R1
15 MOVV n+8(FP), R2
16 ADDV R1, R2, R4
17
18 // if less than 16 bytes or no MSA, do words check
19 SGTU $16, R2, R3
20 BNE R3, no_msa
21 MOVBU internal∕cpu·MIPS64X+const_offsetMIPS64XHasMSA(SB), R3
22 BEQ R3, R0, no_msa
23
24 VMOVB $0, W0
25
26 SGTU $128, R2, R3
27 BEQ R3, msa_large
28
29 AND $15, R2, R5
30 XOR R2, R5, R6
31 ADDVU R1, R6
32
33 msa_small:
34 VMOVB W0, (R1)
35 ADDVU $16, R1
36 SGTU R6, R1, R3
37 BNE R3, R0, msa_small
38 BEQ R5, R0, done
39 VMOVB W0, -16(R4)
40 JMP done
41
42 msa_large:
43 AND $127, R2, R5
44 XOR R2, R5, R6
45 ADDVU R1, R6
46
47 msa_large_loop:
48 VMOVB W0, (R1)
49 VMOVB W0, 16(R1)
50 VMOVB W0, 32(R1)
51 VMOVB W0, 48(R1)
52 VMOVB W0, 64(R1)
53 VMOVB W0, 80(R1)
54 VMOVB W0, 96(R1)
55 VMOVB W0, 112(R1)
56
57 ADDVU $128, R1
58 SGTU R6, R1, R3
59 BNE R3, R0, msa_large_loop
60 BEQ R5, R0, done
61 VMOVB W0, -128(R4)
62 VMOVB W0, -112(R4)
63 VMOVB W0, -96(R4)
64 VMOVB W0, -80(R4)
65 VMOVB W0, -64(R4)
66 VMOVB W0, -48(R4)
67 VMOVB W0, -32(R4)
68 VMOVB W0, -16(R4)
69 JMP done
70
71 no_msa:
72 // if less than 8 bytes, do one byte at a time
73 SGTU $8, R2, R3
74 BNE R3, out
75
76 // do one byte at a time until 8-aligned
77 AND $7, R1, R3
78 BEQ R3, words
79 MOVB R0, (R1)
80 ADDV $1, R1
81 JMP -4(PC)
82
83 words:
84 // do 8 bytes at a time if there is room
85 ADDV $-7, R4, R2
86
87 SGTU R2, R1, R3
88 BEQ R3, out
89 MOVV R0, (R1)
90 ADDV $8, R1
91 JMP -4(PC)
92
93 out:
94 BEQ R1, R4, done
95 MOVB R0, (R1)
96 ADDV $1, R1
97 JMP -3(PC)
98 done:
99 RET
100
View as plain text