1 /* Copyright (c) 2010-2011,2013 Linaro Limited
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
15 * Neither the name of Linaro Limited nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ARMv6T2 or ARMv7E-M, AArch32
35 /* Copyright (c) 2015 ARM Ltd.
38 Redistribution and use in source and binary forms, with or without
39 modification, are permitted provided that the following conditions are met:
40 * Redistributions of source code must retain the above copyright
41 notice, this list of conditions and the following disclaimer.
42 * Redistributions in binary form must reproduce the above copyright
43 notice, this list of conditions and the following disclaimer in the
44 documentation and/or other materials provided with the distribution.
45 * Neither the name of the Linaro nor the
46 names of its contributors may be used to endorse or promote products
47 derived from this software without specific prior written permission.
49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
61 #include "arm-acle-compat.h"
64 .macro def_fn f p2align=0
80 /* This code requires Thumb. */
81 #if __ARM_ARCH_PROFILE == 'M'
83 /* keep config inherited from -march=. */
86 #endif /* if __ARM_ARCH >= 8 */
90 .eabi_attribute Tag_ARM_ISA_use, 0
94 /* Parameters and result. */
98 /* Internal variables. */
104 #define tmp1 r4 /* Overlaps const_0 */
107 def_fn strlen p2align=6
109 .cfi_sections .debug_frame
111 prologue 4 5 push_ip=HAVE_PAC_LEAF
115 ands tmp1, srcin, #7 /* (8 - bytes) to alignment. */
122 ldrd data1a, data1b, [src]
124 add result, result, #8
126 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
127 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
128 uadd8 data1b, data1b, const_m1
129 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
130 cbnz data1b, .Lnull_found
133 ldrd data1a, data1b, [src, #8]
134 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
135 add result, result, #8
136 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
137 uadd8 data1b, data1b, const_m1
138 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
139 cbnz data1b, .Lnull_found
142 ldrd data1a, data1b, [src, #16]
143 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
144 add result, result, #8
145 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
146 uadd8 data1b, data1b, const_m1
147 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
148 cbnz data1b, .Lnull_found
151 ldrd data1a, data1b, [src, #24]
153 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
154 add result, result, #8
155 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
156 uadd8 data1b, data1b, const_m1
157 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
165 addeq result, result, #4
171 add result, result, data1a, lsr #3 /* Bits -> Bytes. */
172 epilogue 4 5 push_ip=HAVE_PAC_LEAF
176 ldrd data1a, data1b, [src]
179 lsl tmp2, tmp2, #3 /* Bytes -> bits. */
182 S2HI tmp2, const_m1, tmp2
183 orn data1a, data1a, tmp2
185 ornne data1b, data1b, tmp2
186 movne data1a, const_m1
192 .size strlen, . - strlen