1 /* Copyright (C) 2010-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
24 #include <arm-features.h> /* This might #define NO_THUMB. */
36 /* This code is best on Thumb. */
39 /* Using bne.w explicitly is desirable in Thumb mode because it helps
40 align the following label without a nop. In ARM mode there is no
46 /* This clobbers the condition codes, which the real Thumb cbnz instruction
47 does not do. But it doesn't matter for any of the uses here. */
48 .macro cbnz reg, label
54 /* Parameters and result. */
58 /* Internal variables. */
64 #define tmp1 r4 /* Overlaps const_0 */
71 strd r4, r5, [sp, #-8]!
72 cfi_adjust_cfa_offset (8)
73 cfi_rel_offset (r4, 0)
74 cfi_rel_offset (r5, 4)
78 ands tmp1, srcin, #7 /* (8 - bytes) to alignment. */
86 ldrd data1a, data1b, [\B]
88 add result, result, #8
90 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
91 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
92 uadd8 data1b, data1b, const_m1
93 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
94 cbnz data1b, .Lnull_found
98 ldrd data1a, data1b, [\B, #8]
99 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
100 add result, result, #8
101 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
102 uadd8 data1b, data1b, const_m1
103 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
104 cbnz data1b, .Lnull_found
108 ldrd data1a, data1b, [\B, #16]
109 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
110 add result, result, #8
111 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
112 uadd8 data1b, data1b, const_m1
113 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
114 cbnz data1b, .Lnull_found
118 ldrd data1a, data1b, [\B, #24]
120 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
121 add result, result, #8
122 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
123 uadd8 data1b, data1b, const_m1
124 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
131 addeq result, result, #4
137 ldrd r4, r5, [sp], #8
138 cfi_adjust_cfa_offset (-8)
141 add result, result, data1a, lsr #3 /* Bits -> Bytes. */
147 ldrd data1a, data1b, [\B]
150 lsl tmp2, tmp2, #3 /* Bytes -> bits. */
153 S2HI tmp2, const_m1, tmp2
156 orr data1a, data1a, tmp1
158 orrne data1b, data1b, tmp1
160 orn data1a, data1a, tmp2
162 ornne data1b, data1b, tmp2
164 movne data1a, const_m1
169 libc_hidden_builtin_def (strlen)