]> sourceware.org Git - glibc.git/blame - sysdeps/sparc/sparc32/memchr.S
Update.
[glibc.git] / sysdeps / sparc / sparc32 / memchr.S
CommitLineData
ae6b8730
RH
1/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
2 than N.
3 For SPARC v7.
62f29da7 4 Copyright (C) 1996, 1999, 2000, 2003 Free Software Foundation, Inc.
ae6b8730
RH
5 This file is part of the GNU C Library.
6 Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
7 David S. Miller <davem@caip.rutgers.edu>.
ae6b8730
RH
8 This version is developed using the same algorithm as the fast C
9 version which carries the following introduction:
ae6b8730
RH
10 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
11 with help from Dan Sahlin (dan@sics.se) and
12 commentary by Jim Blandy (jimb@ai.mit.edu);
13 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
14 and implemented by Roland McGrath (roland@ai.mit.edu).
15
16 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
17 modify it under the terms of the GNU Lesser General Public
18 License as published by the Free Software Foundation; either
19 version 2.1 of the License, or (at your option) any later version.
ae6b8730
RH
20
21 The GNU C Library is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 24 Lesser General Public License for more details.
ae6b8730 25
41bdb6e2
AJ
26 You should have received a copy of the GNU Lesser General Public
27 License along with the GNU C Library; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29 02111-1307 USA. */
ae6b8730
RH
30
31#include <sysdep.h>
32
33 .text
34 .align 4
350: cmp %o2, 0
36 be 9f
37 sethi %hi(0x80808080), %o4
38 ldub [%o0], %g4
39 cmp %g4, %o1
40 be 1f
41 add %o0, 1, %o0
42 subcc %o2, 1, %o2
43 be 9f
44 andcc %o0, 3, %g0
45 be 4f
46 or %o4, %lo(0x80808080), %o3
47 ldub [%o0], %g4
48 cmp %g4, %o1
49 be 1f
50 add %o0, 1, %o0
51 subcc %o2, 1, %o2
52 be 9f
53 andcc %o0, 3, %g0
54 be 5f
55 sethi %hi(0x01010101), %o5
56 ldub [%o0], %g4
57 cmp %g4, %o1
58 be 1f
59 add %o0, 1, %o0
60 subcc %o2, 1, %o2
61 bne,a 7f
62 and %o2, 3, %g1
63 retl
64 clr %o0
651: retl
66 sub %o0, 1, %o0
67
abf70633 68ENTRY(__memchr)
ae6b8730 69 andcc %o1, 0xff, %o1
62f29da7 70 sll %o1, 8, %g6
ae6b8730 71 andcc %o0, 3, %g0
62f29da7
UD
72 or %o1, %g6, %g6
73 sll %g6, 16, %o3
ae6b8730 74 bne 0b
62f29da7 75 or %o3, %g6, %g2
ae6b8730
RH
76 sethi %hi(0x80808080), %o4
77 or %o4, %lo(0x80808080), %o3
784: sethi %hi(0x01010101), %o5
795: and %o2, 3, %g1
807: andcc %o2, 0xfffffffc, %o2
81 be 0f
62f29da7 82 or %o5, %lo(0x01010101), %g6
ae6b8730
RH
83 ld [%o0], %g4
846: xor %g4, %g2, %g5
85 add %o0, 4, %o0
62f29da7 86 sub %g5, %g6, %g5
ae6b8730
RH
87 andcc %g5, %o3, %g0
88 bne 8f
89 subcc %o2, 4, %o2
90 bne,a 6b
91 ld [%o0], %g4
920: cmp %g1, 0
931: be 9f
94 add %o0, 4, %o0
95 ldub [%o0 - 4], %g4
96 cmp %g4, %o1
97 be 4f
98 cmp %g1, 1
99 be 9f
100 ldub [%o0 - 3], %g4
101 cmp %g4, %o1
102 be 3f
103 cmp %g1, 2
104 be 9f
105 ldub [%o0 - 2], %g4
106 cmp %g4, %o1
107 be 2f
108 nop
1099: retl
110 clr %o0
111
112 /* Check every byte. */
2ed5fd9a 1138: srl %g4, 24, %g5
ae6b8730
RH
114 and %g5, 0xff, %g5
115 cmp %g5, %o1
116 be 4f
117 srl %g4, 16, %g5
118 and %g5, 0xff, %g5
119 cmp %g5, %o1
120 be 3f
121 srl %g4, 8, %g5
122 and %g5, 0xff, %g5
123 cmp %g5, %o1
124 be 2f
125 and %g4, 0xff, %g5
126 cmp %g5, %o1
127 be 1f
128 cmp %o2, 0
129 bne,a 6b
130 ld [%o0], %g4
131 b 1b
132 cmp %g1, 0
1331: retl
134 sub %o0, 1, %o0
1352: retl
136 sub %o0, 2, %o0
1373: retl
138 sub %o0, 3, %o0
1394: retl
140 sub %o0, 4, %o0
abf70633
GM
141END(__memchr)
142
143weak_alias (__memchr, memchr)
2ed5fd9a
GM
144#if !__BOUNDED_POINTERS__
145weak_alias (__memchr, __ubp_memchr)
146#endif
This page took 0.198847 seconds and 5 git commands to generate.