2 * strlen - calculate the length of a string
4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 #if __ARM_ARCH >= 6 && __ARM_ARCH_ISA_THUMB == 2
17 #include "../asmdefs.h"
27 /* This code requires Thumb. */
31 /* Parameters and result. */
35 /* Internal variables. */
41 #define tmp1 r4 /* Overlaps const_0 */
44 ENTRY (__strlen_armv6t2)
46 strd r4, r5, [sp, #-8]!
49 ands tmp1, srcin, #7 /* (8 - bytes) to alignment. */
56 ldrd data1a, data1b, [src]
58 add result, result, #8
60 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
61 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
62 uadd8 data1b, data1b, const_m1
63 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
64 cbnz data1b, L(null_found)
67 ldrd data1a, data1b, [src, #8]
68 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
69 add result, result, #8
70 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
71 uadd8 data1b, data1b, const_m1
72 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
73 cbnz data1b, L(null_found)
76 ldrd data1a, data1b, [src, #16]
77 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
78 add result, result, #8
79 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
80 uadd8 data1b, data1b, const_m1
81 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
82 cbnz data1b, L(null_found)
85 ldrd data1a, data1b, [src, #24]
87 uadd8 data1a, data1a, const_m1 /* Saturating GE<0:3> set. */
88 add result, result, #8
89 sel data1a, const_0, const_m1 /* Select based on GE<0:3>. */
90 uadd8 data1b, data1b, const_m1
91 sel data1b, data1a, const_m1 /* Only used if d1a == 0. */
98 addeq result, result, #4
104 ldrd r4, r5, [sp], #8
105 add result, result, data1a, lsr #3 /* Bits -> Bytes. */
109 ldrd data1a, data1b, [src]
112 lsl tmp2, tmp2, #3 /* Bytes -> bits. */
115 S2HI tmp2, const_m1, tmp2
116 orn data1a, data1a, tmp2
118 ornne data1b, data1b, tmp2
119 movne data1a, const_m1
123 END (__strlen_armv6t2)
125 #endif /* __ARM_ARCH >= 6 && __ARM_ARCH_ISA_THUMB == 2 */