LEFT | RIGHT |
(no file at all) | |
1 // Inferno's libkern/memset-arm.s | 1 // Inferno's libkern/memset-arm.s |
2 // http://code.google.com/p/inferno-os/source/browse/libkern/memset-arm.s | 2 // http://code.google.com/p/inferno-os/source/browse/libkern/memset-arm.s |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vita
nuova.com). All rights reserved. | 5 // Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vita
nuova.com). All rights reserved. |
6 // Portions Copyright 2009 The Go Authors. All rights reserved. | 6 // Portions Copyright 2009 The Go Authors. All rights reserved. |
7 // | 7 // |
8 // Permission is hereby granted, free of charge, to any person obtaining a copy | 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 | 9 // of this software and associated documentation files (the "Software"), to deal |
10 // in the Software without restriction, including without limitation the rights | 10 // in the Software without restriction, including without limitation the rights |
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 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 | 12 // copies of the Software, and to permit persons to whom the Software is |
13 // furnished to do so, subject to the following conditions: | 13 // furnished to do so, subject to the following conditions: |
14 // | 14 // |
15 // The above copyright notice and this permission notice shall be included in | 15 // The above copyright notice and this permission notice shall be included in |
16 // all copies or substantial portions of the Software. | 16 // all copies or substantial portions of the Software. |
17 // | 17 // |
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 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, | 19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 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 | 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, | 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 | 23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24 // THE SOFTWARE. | 24 // THE SOFTWARE. |
25 | 25 |
26 TO = 1 | 26 TO = 8 |
27 TOE = 2 | 27 TOE = 11 |
28 N = 3 | 28 N = 12 |
29 TMP = 3»» » » » /* N and TMP don't overlap */ | 29 TMP = 12» » » » /* N and TMP don't overlap */ |
30 | 30 |
31 // TODO(kaib): memset clobbers R9 and R10 (m and g). This makes the | |
32 // registers unpredictable if (when) memset SIGSEGV's. Fix it by | |
33 // moving the R4-R11 register bank. | |
34 TEXT runtime·memset(SB), $0 | 31 TEXT runtime·memset(SB), $0 |
35 MOVW R0, R(TO) | 32 MOVW R0, R(TO) |
36 » MOVW» data+4(FP), R(4) | 33 » MOVW» data+4(FP), R(0) |
37 MOVW n+8(FP), R(N) | 34 MOVW n+8(FP), R(N) |
38 | 35 |
39 ADD R(N), R(TO), R(TOE) /* to end pointer */ | 36 ADD R(N), R(TO), R(TOE) /* to end pointer */ |
40 | 37 |
41 CMP $4, R(N) /* need at least 4 bytes to copy */ | 38 CMP $4, R(N) /* need at least 4 bytes to copy */ |
42 BLT _1tail | 39 BLT _1tail |
43 | 40 |
44 » AND» $0xFF, R(4)» » /* it's a byte */ | 41 » AND» $0xFF, R(0)» » /* it's a byte */ |
45 » SLL» $8, R(4), R(TMP)» /* replicate to a word */ | 42 » SLL» $8, R(0), R(TMP)» /* replicate to a word */ |
46 » ORR» R(TMP), R(4) | 43 » ORR» R(TMP), R(0) |
47 » SLL» $16, R(4), R(TMP) | 44 » SLL» $16, R(0), R(TMP) |
48 » ORR» R(TMP), R(4) | 45 » ORR» R(TMP), R(0) |
49 | 46 |
50 _4align: /* align on 4 */ | 47 _4align: /* align on 4 */ |
51 AND.S $3, R(TO), R(TMP) | 48 AND.S $3, R(TO), R(TMP) |
52 BEQ _4aligned | 49 BEQ _4aligned |
53 | 50 |
54 » MOVBU.P»R(4), 1(R(TO))» » /* implicit write back */ | 51 » MOVBU.P»R(0), 1(R(TO))» » /* implicit write back */ |
55 B _4align | 52 B _4align |
56 | 53 |
57 _4aligned: | 54 _4aligned: |
58 SUB $31, R(TOE), R(TMP) /* do 32-byte chunks if possible */ | 55 SUB $31, R(TOE), R(TMP) /* do 32-byte chunks if possible */ |
59 CMP R(TMP), R(TO) | 56 CMP R(TMP), R(TO) |
60 BHS _4tail | 57 BHS _4tail |
61 | 58 |
62 » MOVW» R4, R5» » » /* replicate */ | 59 » MOVW» R0, R1» » » /* replicate */ |
63 » MOVW» R4, R6 | 60 » MOVW» R0, R2 |
64 » MOVW» R4, R7 | 61 » MOVW» R0, R3 |
65 » MOVW» R4, R8 | 62 » MOVW» R0, R4 |
66 » MOVW» R4, R9 | 63 » MOVW» R0, R5 |
67 » MOVW» R4, R10 | 64 » MOVW» R0, R6 |
68 » MOVW» R4, R11 | 65 » MOVW» R0, R7 |
69 | 66 |
70 _f32loop: | 67 _f32loop: |
71 CMP R(TMP), R(TO) | 68 CMP R(TMP), R(TO) |
72 BHS _4tail | 69 BHS _4tail |
73 | 70 |
74 » MOVM.IA.W [R4-R11], (R(TO)) | 71 » MOVM.IA.W [R0-R7], (R(TO)) |
75 B _f32loop | 72 B _f32loop |
76 | 73 |
77 _4tail: | 74 _4tail: |
78 SUB $3, R(TOE), R(TMP) /* do remaining words if possible */ | 75 SUB $3, R(TOE), R(TMP) /* do remaining words if possible */ |
79 _4loop: | 76 _4loop: |
80 CMP R(TMP), R(TO) | 77 CMP R(TMP), R(TO) |
81 BHS _1tail | 78 BHS _1tail |
82 | 79 |
83 » MOVW.P» R(4), 4(R(TO))» » /* implicit write back */ | 80 » MOVW.P» R(0), 4(R(TO))» » /* implicit write back */ |
84 B _4loop | 81 B _4loop |
85 | 82 |
86 _1tail: | 83 _1tail: |
87 CMP R(TO), R(TOE) | 84 CMP R(TO), R(TOE) |
88 BEQ _return | 85 BEQ _return |
89 | 86 |
90 » MOVBU.P»R(4), 1(R(TO))» » /* implicit write back */ | 87 » MOVBU.P»R(0), 1(R(TO))» » /* implicit write back */ |
91 B _1tail | 88 B _1tail |
92 | 89 |
93 _return: | 90 _return: |
94 RET | 91 RET |
LEFT | RIGHT |