OSDN Git Service

Use strong_alias everywhere instead of .global/.set. Correct some cases where the...
[uclinux-h8/uClibc.git] / libc / string / sparc / sparc32 / strcat.S
1 /* strcat (dest, src) -- Append SRC on the end of DEST.
2    For SPARC v7.
3    Copyright (C) 1996, 1999, 2003 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
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.
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
15    Lesser General Public License for more details.
16
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.  */
21
22         /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
23            to find out if any byte in xword could be zero. This is fast, but
24            also gives false alarm for any byte in range 0x81-0xff. It does
25            not matter for correctness, as if this test tells us there could
26            be some zero byte, we check it byte by byte, but if bytes with
27            high bits set are common in the strings, then this will give poor
28            performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
29            will use one tick slower, but more precise test
30            ((xword - 0x01010101) & (~xword) & 0x80808080),
31            which does not give any false alarms (but if some bits are set,
32            one cannot assume from it which bytes are zero and which are not).
33            It is yet to be measured, what is the correct default for glibc
34            in these days for an average user.
35          */
36
37         .text
38         .align          4
39 10:     cmp             %o4, 2
40         be              1f
41          cmp            %o4, 3
42         ldub            [%o1], %o5
43         add             %o1, 1, %o1
44         stb             %o5, [%o0]
45         be              3f
46          cmp            %o5, 0
47         be              0f
48          add            %o0, 1, %o0
49 1:      lduh            [%o1], %o5
50         add             %o1, 2, %o1
51         srl             %o5, 8, %o4
52         cmp             %o4, 0
53         stb             %o4, [%o0]
54         bne,a           2f
55          stb            %o5, [%o0 + 1]
56         retl
57          mov            %g2, %o0
58 2:      andcc           %o5, 0xff, %o5
59         bne             4f
60          add            %o0, 2, %o0
61         retl
62          mov            %g2, %o0
63 3:      bne             4f
64          add            %o0, 1, %o0
65         retl
66          mov            %g2, %o0
67
68 11:     ldub            [%o0], %o5
69         cmp             %o5, 0
70         be              1f
71          add            %o0, 1, %o0
72         andcc           %o0, 3, %g0
73         be              7f
74          or             %o4, %lo(0x80808080), %o3
75         ldub            [%o0], %o5
76         cmp             %o5, 0
77         be              2f
78          add            %o0, 1, %o0
79         andcc           %o0, 3, %g0
80         be              8f
81          sethi          %hi(0x01010101), %o4
82         ldub            [%o0], %o5
83         cmp             %o5, 0
84         be              3f
85          add            %o0, 1, %o0
86         b               9f
87          or             %o4, %lo(0x01010101), %o2
88 1:      or              %o4, %lo(0x80808080), %o3
89 2:      sethi           %hi(0x01010101), %o4
90 3:      or              %o4, %lo(0x01010101), %o2
91         b               3f
92          sub            %o0, 1, %o0
93
94 ENTRY(__strcat)
95         mov             %o0, %g2
96         andcc           %o0, 3, %g0
97         bne             11b
98          sethi          %hi(0x80808080), %o4
99         or              %o4, %lo(0x80808080), %o3
100 7:      sethi           %hi(0x01010101), %o4
101 8:      or              %o4, %lo(0x01010101), %o2
102 9:      ld              [%o0], %o5
103 7:      sub             %o5, %o2, %o4
104 #ifdef EIGHTBIT_NOT_RARE
105         andn            %o4, %o5, %o4
106 #endif
107         andcc           %o4, %o3, %g0
108         be              9b
109          add            %o0, 4, %o0
110
111         srl             %o5, 24, %g5
112         andcc           %g5, 0xff, %g0
113         be              3f
114          add            %o0, -4, %o0
115         srl             %o5, 16, %g5
116         andcc           %g5, 0xff, %g0
117         be              3f
118          add            %o0, 1, %o0
119         srl             %o5, 8, %g5
120         andcc           %g5, 0xff, %g0
121         be              3f
122          add            %o0, 1, %o0
123         andcc           %o5, 0xff, %g0
124         add             %o0, 2, %o0
125         bne,a           7b
126          ld             [%o0], %o5
127         sub             %o0, 1, %o0
128 3:      andcc           %o1, 3, %o4
129         bne             10b
130 4:       andcc          %o0, 3, %g3
131         bne             12f
132 1:      ld              [%o1], %o5
133         add             %o1, 4, %o1
134         sub             %o5, %o2, %o4
135 #ifdef EIGHTBIT_NOT_RARE
136         andn            %o4, %o5, %o4
137 #endif
138         add             %o0, 4, %o0
139         andcc           %o4, %o3, %g0
140         be,a            1b
141          st             %o5, [%o0 - 4]
142
143         srl             %o5, 24, %g5
144         andcc           %g5, 0xff, %g0
145         be              1f
146          srl            %o5, 16, %g5
147         andcc           %g5, 0xff, %g0
148         be              2f
149          srl            %o5, 8, %g5
150         andcc           %g5, 0xff, %g0
151         be              3f
152          andcc          %o5, 0xff, %g0
153         bne             1b
154          st             %o5, [%o0 - 4]
155         retl
156          mov            %g2, %o0
157 3:      srl             %o5, 16, %o5
158         sth             %o5, [%o0 - 4]
159         stb             %g0, [%o0 - 2]
160         retl
161          mov            %g2, %o0
162 2:      srl             %o5, 16, %o5
163         sth             %o5, [%o0 - 4]
164         retl
165          mov            %g2, %o0
166 1:      stb             %g0, [%o0 - 4]
167         retl
168          mov            %g2, %o0
169
170 12:     add             %o1, 4, %o1
171         sub             %o5, %o2, %o4
172         cmp             %g3, 2
173         be              2f
174          cmp            %g3, 3
175         be              3f
176          andcc          %o4, %o3, %g0
177         bne             5f
178          srl            %o5, 24, %g5
179         stb             %g5, [%o0]
180         sub             %o0, 1, %o0
181         srl             %o5, 8, %g5
182         sth             %g5, [%o0 + 2]
183 1:      add             %o0, 4, %o0
184 4:      sll             %o5, 24, %g6
185         ld              [%o1], %o5
186         add             %o1, 4, %o1
187         srl             %o5, 8, %g5
188         sub             %o5, %o2, %o4
189 #ifdef EIGHTBIT_NOT_RARE
190         andn            %o4, %o5, %o4
191 #endif
192         or              %g5, %g6, %g5
193         andcc           %o4, %o3, %g0
194         be,a            1b
195          st             %g5, [%o0]
196         srl             %o5, 24, %o4
197         andcc           %o4, 0xff, %g0
198         be              6f
199          srl            %o5, 16, %o4
200         andcc           %o4, 0xff, %g0
201         be              7f
202          srl            %o5, 8, %o4
203         st              %g5, [%o0]
204         andcc           %o4, 0xff, %g0
205         be              0f
206          andcc          %o5, 0xff, %g0
207 1:      bne             4b
208          add            %o0, 4, %o0
209 9:      stb             %g0, [%o0]
210 0:      retl
211          mov            %g2, %o0
212
213 6:      srl             %g5, 16, %g5
214         sth             %g5, [%o0]
215         retl
216          mov            %g2, %o0
217
218 7:      srl             %g5, 16, %g5
219         sth             %g5, [%o0]
220         stb             %g0, [%o0 + 2]
221         retl
222          mov            %g2, %o0
223
224 5:      andcc           %g5, 0xff, %g4
225         be              9b
226          srl            %o5, 16, %g5
227         andcc           %g5, 0xff, %g0
228         be              7f
229          srl            %o5, 8, %g5
230         andcc           %g5, 0xff, %g0
231         stb             %g4, [%o0]
232         sth             %g5, [%o0 + 1]
233         sub             %o0, 1, %o0
234         bne             1b
235          andcc          %o5, 0xff, %g0
236         retl
237          mov            %g2, %o0
238
239 7:      stb             %g4, [%o0]
240         stb             %g0, [%o0 + 1]
241         retl
242          mov            %g2, %o0
243
244 2:      andcc           %o4, %o3, %g0
245         bne             5f
246          srl            %o5, 16, %g5
247         sth             %g5, [%o0]
248         sub             %o0, 2, %o0
249 1:      add             %o0, 4, %o0
250 4:      sll             %o5, 16, %g6
251         ld              [%o1], %o5
252         add             %o1, 4, %o1
253         srl             %o5, 16, %g5
254         sub             %o5, %o2, %o4
255 #ifdef EIGHTBIT_NOT_RARE
256         andn            %o4, %o5, %o4
257 #endif
258         or              %g5, %g6, %g5
259         andcc           %o4, %o3, %g0
260         be,a            1b
261          st             %g5, [%o0]
262         srl             %o5, 24, %o4
263         andcc           %o4, 0xff, %g0
264         be              7f
265          srl            %o5, 16, %o4
266         st              %g5, [%o0]
267         andcc           %o4, 0xff, %g0
268         be              0b
269          srl            %o5, 8, %o4
270 1:      andcc           %o4, 0xff, %g0
271         be              8f
272          andcc          %o5, 0xff, %g0
273         bne             4b
274          add            %o0, 4, %o0
275         sth             %o5, [%o0]
276         retl
277          mov            %g2, %o0
278
279 7:      srl             %g5, 16, %g5
280         sth             %g5, [%o0]
281         stb             %g0, [%o0 + 2]
282         retl
283          mov            %g2, %o0
284
285 8:      stb             %g0, [%o0 + 4]
286         retl
287          mov            %g2, %o0
288
289 5:      srl             %o5, 24, %g5
290         andcc           %g5, 0xff, %g0
291         be              9b
292          srl            %o5, 16, %g5
293         andcc           %g5, 0xff, %g0
294         sth             %g5, [%o0]
295         sub             %o0, 2, %o0
296         bne             1b
297          srl            %o5, 8, %o4
298         retl
299          mov            %g2, %o0
300
301 3:      bne             5f
302          srl            %o5, 24, %g5
303         stb             %g5, [%o0]
304         sub             %o0, 3, %o0
305 1:      add             %o0, 4, %o0
306 4:      sll             %o5, 8, %g6
307         ld              [%o1], %o5
308         add             %o1, 4, %o1
309         srl             %o5, 24, %g5
310         sub             %o5, %o2, %o4
311 #ifdef EIGHTBIT_NOT_RARE
312         andn            %o4, %o5, %o4
313 #endif
314         or              %g5, %g6, %g5
315         andcc           %o4, %o3, %g0
316         be              1b
317          st             %g5, [%o0]
318         srl             %o5, 24, %o4
319         andcc           %o4, 0xff, %g0
320         be              0b
321          srl            %o5, 16, %o4
322 1:      andcc           %o4, 0xff, %g0
323         be              8b
324          srl            %o5, 8, %o4
325         andcc           %o4, 0xff, %g0
326         be              9f
327          andcc          %o5, 0xff, %g0
328         bne             4b
329          add            %o0, 4, %o0
330         srl             %o5, 8, %o5
331         sth             %o5, [%o0]
332         stb             %g0, [%o0 + 2]
333         retl
334          mov            %g2, %o0
335 9:      srl             %o5, 8, %o5
336         sth             %o5, [%o0 + 4]
337         retl
338          mov            %g2, %o0
339 5:      andcc           %g5, 0xff, %g0
340         stb             %g5, [%o0]
341         sub             %o0, 3, %o0
342         bne             1b
343          srl            %o5, 16, %o4
344         retl
345          mov            %g2, %o0
346 END(__strcat)
347
348 strong_alias(__strcat,strcat)