]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sparc/sparc32/strcat.S
Update.
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / strcat.S
CommitLineData
ae6b8730
RH
1/* strcat (dest, src) -- Append SRC on the end of DEST.
2 For SPARC v7.
3 Copyright (C) 1996, 1999 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
6
7 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
ae6b8730
RH
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 15 Lesser General Public License for more details.
ae6b8730 16
41bdb6e2
AJ
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
ae6b8730
RH
21
22#include <sysdep.h>
23
24 /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
25 to find out if any byte in xword could be zero. This is fast, but
26 also gives false alarm for any byte in range 0x81-0xff. It does
27 not matter for correctness, as if this test tells us there could
28 be some zero byte, we check it byte by byte, but if bytes with
29 high bits set are common in the strings, then this will give poor
30 performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
31 will use one tick slower, but more precise test
32 ((xword - 0x01010101) & (~xword) & 0x80808080),
33 which does not give any false alarms (but if some bits are set,
34 one cannot assume from it which bytes are zero and which are not).
35 It is yet to be measured, what is the correct default for glibc
36 in these days for an average user.
37 */
38
39 .text
40 .align 4
4110: cmp %o4, 2
42 be 1f
43 cmp %o4, 3
44 ldub [%o1], %o5
45 add %o1, 1, %o1
46 stb %o5, [%o0]
47 be 3f
48 cmp %o5, 0
49 be 0f
50 add %o0, 1, %o0
511: lduh [%o1], %o5
52 add %o1, 2, %o1
53 srl %o5, 8, %o4
54 cmp %o4, 0
55 stb %o4, [%o0]
56 bne,a 2f
57 stb %o5, [%o0 + 1]
58 retl
59 mov %g2, %o0
602: andcc %o5, 0xff, %o5
61 bne 4f
62 add %o0, 2, %o0
63 retl
64 mov %g2, %o0
653: bne 4f
66 add %o0, 1, %o0
67 retl
68 mov %g2, %o0
69
7011: ldub [%o0], %o5
71 cmp %o5, 0
72 be 1f
73 add %o0, 1, %o0
74 andcc %o0, 3, %g0
75 be 7f
76 or %o4, %lo(0x80808080), %o3
77 ldub [%o0], %o5
78 cmp %o5, 0
79 be 2f
80 add %o0, 1, %o0
81 andcc %o0, 3, %g0
82 be 8f
83 sethi %hi(0x01010101), %o4
84 ldub [%o0], %o5
85 cmp %o5, 0
86 be 3f
87 add %o0, 1, %o0
88 b 9f
89 or %o4, %lo(0x01010101), %o2
901: or %o4, %lo(0x80808080), %o3
912: sethi %hi(0x01010101), %o4
923: or %o4, %lo(0x01010101), %o2
93 b 3f
94 sub %o0, 1, %o0
95
96ENTRY(strcat)
97 mov %o0, %g2
98 andcc %o0, 3, %g0
99 bne 11b
100 sethi %hi(0x80808080), %o4
101 or %o4, %lo(0x80808080), %o3
1027: sethi %hi(0x01010101), %o4
1038: or %o4, %lo(0x01010101), %o2
1049: ld [%o0], %o5
1057: sub %o5, %o2, %o4
106#ifdef EIGHTBIT_NOT_RARE
107 andn %o4, %o5, %o4
108#endif
109 andcc %o4, %o3, %g0
110 be 9b
111 add %o0, 4, %o0
112
113 srl %o5, 24, %g5
114 andcc %g5, 0xff, %g0
115 be 3f
116 add %o0, -4, %o0
117 srl %o5, 16, %g5
118 andcc %g5, 0xff, %g0
119 be 3f
120 add %o0, 1, %o0
121 srl %o5, 8, %g5
122 andcc %g5, 0xff, %g0
123 be 3f
124 add %o0, 1, %o0
125 andcc %o5, 0xff, %g0
126 add %o0, 2, %o0
127 bne,a 7b
128 ld [%o0], %o5
129 sub %o0, 1, %o0
1303: andcc %o1, 3, %o4
131 bne 10b
1324: andcc %o0, 3, %g3
133 bne 12f
1341: ld [%o1], %o5
135 add %o1, 4, %o1
136 sub %o5, %o2, %o4
137#ifdef EIGHTBIT_NOT_RARE
138 andn %o4, %o5, %o4
139#endif
140 add %o0, 4, %o0
141 andcc %o4, %o3, %g0
142 be,a 1b
143 st %o5, [%o0 - 4]
144
145 srl %o5, 24, %g5
146 andcc %g5, 0xff, %g0
147 be 1f
148 srl %o5, 16, %g5
149 andcc %g5, 0xff, %g0
150 be 2f
151 srl %o5, 8, %g5
152 andcc %g5, 0xff, %g0
153 be 3f
154 andcc %o5, 0xff, %g0
155 bne 1b
156 st %o5, [%o0 - 4]
157 retl
158 mov %g2, %o0
1593: srl %o5, 16, %o5
160 sth %o5, [%o0 - 4]
161 stb %g0, [%o0 - 2]
162 retl
163 mov %g2, %o0
1642: srl %o5, 16, %o5
165 sth %o5, [%o0 - 4]
166 retl
167 mov %g2, %o0
1681: stb %g0, [%o0 - 4]
169 retl
170 mov %g2, %o0
171
17212: add %o1, 4, %o1
173 sub %o5, %o2, %o4
174 cmp %g3, 2
175 be 2f
176 cmp %g3, 3
177 be 3f
178 andcc %o4, %o3, %g0
179 bne 5f
180 srl %o5, 24, %g5
181 stb %g5, [%o0]
182 sub %o0, 1, %o0
183 srl %o5, 8, %g5
184 sth %g5, [%o0 + 2]
1851: add %o0, 4, %o0
5d15fc5c 1864: sll %o5, 24, %g7
ae6b8730
RH
187 ld [%o1], %o5
188 add %o1, 4, %o1
189 srl %o5, 8, %g5
190 sub %o5, %o2, %o4
191#ifdef EIGHTBIT_NOT_RARE
192 andn %o4, %o5, %o4
193#endif
5d15fc5c 194 or %g5, %g7, %g5
ae6b8730
RH
195 andcc %o4, %o3, %g0
196 be,a 1b
197 st %g5, [%o0]
198 srl %o5, 24, %o4
199 andcc %o4, 0xff, %g0
200 be 6f
201 srl %o5, 16, %o4
202 andcc %o4, 0xff, %g0
203 be 7f
204 srl %o5, 8, %o4
205 st %g5, [%o0]
206 andcc %o4, 0xff, %g0
207 be 0f
208 andcc %o5, 0xff, %g0
2091: bne 4b
210 add %o0, 4, %o0
2119: stb %g0, [%o0]
2120: retl
213 mov %g2, %o0
214
2156: srl %g5, 16, %g5
216 sth %g5, [%o0]
217 retl
218 mov %g2, %o0
219
2207: srl %g5, 16, %g5
221 sth %g5, [%o0]
222 stb %g0, [%o0 + 2]
223 retl
224 mov %g2, %o0
225
2265: andcc %g5, 0xff, %g4
227 be 9b
228 srl %o5, 16, %g5
229 andcc %g5, 0xff, %g0
230 be 7f
231 srl %o5, 8, %g5
232 andcc %g5, 0xff, %g0
233 stb %g4, [%o0]
234 sth %g5, [%o0 + 1]
235 sub %o0, 1, %o0
236 bne 1b
237 andcc %o5, 0xff, %g0
238 retl
239 mov %g2, %o0
240
2417: stb %g4, [%o0]
242 stb %g0, [%o0 + 1]
243 retl
244 mov %g2, %o0
245
2462: andcc %o4, %o3, %g0
247 bne 5f
248 srl %o5, 16, %g5
249 sth %g5, [%o0]
250 sub %o0, 2, %o0
2511: add %o0, 4, %o0
5d15fc5c 2524: sll %o5, 16, %g7
ae6b8730
RH
253 ld [%o1], %o5
254 add %o1, 4, %o1
255 srl %o5, 16, %g5
256 sub %o5, %o2, %o4
257#ifdef EIGHTBIT_NOT_RARE
258 andn %o4, %o5, %o4
259#endif
5d15fc5c 260 or %g5, %g7, %g5
ae6b8730
RH
261 andcc %o4, %o3, %g0
262 be,a 1b
263 st %g5, [%o0]
264 srl %o5, 24, %o4
265 andcc %o4, 0xff, %g0
266 be 7f
267 srl %o5, 16, %o4
268 st %g5, [%o0]
269 andcc %o4, 0xff, %g0
270 be 0b
271 srl %o5, 8, %o4
2721: andcc %o4, 0xff, %g0
273 be 8f
274 andcc %o5, 0xff, %g0
275 bne 4b
276 add %o0, 4, %o0
277 sth %o5, [%o0]
278 retl
279 mov %g2, %o0
280
2817: srl %g5, 16, %g5
282 sth %g5, [%o0]
283 stb %g0, [%o0 + 2]
284 retl
285 mov %g2, %o0
286
2878: stb %g0, [%o0 + 4]
288 retl
289 mov %g2, %o0
290
2915: srl %o5, 24, %g5
292 andcc %g5, 0xff, %g0
293 be 9b
294 srl %o5, 16, %g5
295 andcc %g5, 0xff, %g0
296 sth %g5, [%o0]
297 sub %o0, 2, %o0
298 bne 1b
299 srl %o5, 8, %o4
300 retl
301 mov %g2, %o0
302
3033: bne 5f
304 srl %o5, 24, %g5
305 stb %g5, [%o0]
306 sub %o0, 3, %o0
3071: add %o0, 4, %o0
5d15fc5c 3084: sll %o5, 8, %g7
ae6b8730
RH
309 ld [%o1], %o5
310 add %o1, 4, %o1
311 srl %o5, 24, %g5
312 sub %o5, %o2, %o4
313#ifdef EIGHTBIT_NOT_RARE
314 andn %o4, %o5, %o4
315#endif
5d15fc5c 316 or %g5, %g7, %g5
ae6b8730
RH
317 andcc %o4, %o3, %g0
318 be 1b
319 st %g5, [%o0]
320 srl %o5, 24, %o4
321 andcc %o4, 0xff, %g0
322 be 0b
323 srl %o5, 16, %o4
3241: andcc %o4, 0xff, %g0
325 be 8b
326 srl %o5, 8, %o4
327 andcc %o4, 0xff, %g0
328 be 9f
329 andcc %o5, 0xff, %g0
330 bne 4b
331 add %o0, 4, %o0
332 srl %o5, 8, %o5
333 sth %o5, [%o0]
334 stb %g0, [%o0 + 2]
335 retl
336 mov %g2, %o0
3379: srl %o5, 8, %o5
338 sth %o5, [%o0 + 4]
339 retl
340 mov %g2, %o0
3415: andcc %g5, 0xff, %g0
342 stb %g5, [%o0]
343 sub %o0, 3, %o0
344 bne 1b
345 srl %o5, 16, %o4
346 retl
347 mov %g2, %o0
348END(strcat)