1 /* Copyright (C) 2010-2018 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. */
85 ldrd data1a, data1b, [src]
87 add result, result, #8
89 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
90 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
91 uadd8 data1b, data1b, const_m1
92 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
93 cbnz data1b, .Lnull_found
96 ldrd data1a, data1b, [src, #8]
97 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
98 add result, result, #8
99 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
100 uadd8 data1b, data1b, const_m1
101 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
102 cbnz data1b, .Lnull_found
105 ldrd data1a, data1b, [src, #16]
106 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
107 add result, result, #8
108 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
109 uadd8 data1b, data1b, const_m1
110 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
111 cbnz data1b, .Lnull_found
114 ldrd data1a, data1b, [src, #24]
116 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
117 add result, result, #8
118 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
119 uadd8 data1b, data1b, const_m1
120 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
127 addeq result, result, #4
133 ldrd r4, r5, [sp], #8
134 cfi_adjust_cfa_offset (-8)
137 add result, result, data1a, lsr #3 /* Bits -> Bytes. */
142 ldrd data1a, data1b, [src]
145 lsl tmp2, tmp2, #3 /* Bytes -> bits. */
148 S2HI tmp2, const_m1, tmp2
151 orr data1a, data1a, tmp1
153 orrne data1b, data1b, tmp1
155 orn data1a, data1a, tmp2
157 ornne data1b, data1b, tmp2
159 movne data1a, const_m1
164 libc_hidden_builtin_def (strlen)