Text file
src/runtime/memclr_arm.s
1 // Inferno's libkern/memset-arm.s
2 // https://bitbucket.org/inferno-os/inferno-os/src/master/libkern/memset-arm.s
3 //
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
5 // Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved.
6 // Portions Copyright 2009 The Go Authors. All rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 // THE SOFTWARE.
25
26 #include "textflag.h"
27
28 #define TO R8
29 #define TOE R11
30 #define N R12
31 #define TMP R12 /* N and TMP don't overlap */
32
33 // See memclrNoHeapPointers Go doc for important implementation constraints.
34
35 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
36 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
37 MOVW ptr+0(FP), TO
38 MOVW n+4(FP), N
39 MOVW $0, R0
40
41 ADD N, TO, TOE /* to end pointer */
42
43 CMP $4, N /* need at least 4 bytes to copy */
44 BLT _1tail
45
46 _4align: /* align on 4 */
47 AND.S $3, TO, TMP
48 BEQ _4aligned
49
50 MOVBU.P R0, 1(TO) /* implicit write back */
51 B _4align
52
53 _4aligned:
54 SUB $31, TOE, TMP /* do 32-byte chunks if possible */
55 CMP TMP, TO
56 BHS _4tail
57
58 MOVW R0, R1 /* replicate */
59 MOVW R0, R2
60 MOVW R0, R3
61 MOVW R0, R4
62 MOVW R0, R5
63 MOVW R0, R6
64 MOVW R0, R7
65
66 _f32loop:
67 CMP TMP, TO
68 BHS _4tail
69
70 MOVM.IA.W [R0-R7], (TO)
71 B _f32loop
72
73 _4tail:
74 SUB $3, TOE, TMP /* do remaining words if possible */
75 _4loop:
76 CMP TMP, TO
77 BHS _1tail
78
79 MOVW.P R0, 4(TO) /* implicit write back */
80 B _4loop
81
82 _1tail:
83 CMP TO, TOE
84 BEQ _return
85
86 MOVBU.P R0, 1(TO) /* implicit write back */
87 B _1tail
88
89 _return:
90 RET
91
View as plain text