1 /* Vector optimized 32/64 bit S/390 version of wcslen.
2 Copyright (C) 2015-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <ifunc-wcslen.h>
23 # include "asm-syntax.h"
27 /* size_t wcslen (const wchar_t *s)
28 Returns length of string s.
31 -r1=bytes to 4k-byte boundary
35 -r5=current_len and return_value
40 .machinemode "zarch_nohighgprs"
42 vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
43 lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
45 tmll %r2,3 /* Test if s is 4-byte aligned? */
46 jne .Lfallback /* And use common-code variant if not. */
48 vfenezf %v16,%v16,%v16 /* Find element not equal with zero search. */
49 vlgvb %r4,%v16,7 /* Load zero index or 16 if not found. */
50 clr %r4,%r1 /* If found zero within loaded bytes? */
51 locgrl %r2,%r4 /* Then copy return value. */
52 jl .Lend /* And return. */
54 /* Align s to 16 byte. */
55 risbgn %r3,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
56 lghi %r5,16 /* current_len = 16. */
57 slr %r5,%r3 /* Compute bytes to 16bytes boundary. */
59 /* Find zero in 16byte aligned loop. */
61 vl %v16,0(%r5,%r2) /* Load s. */
62 vfenezfs %v16,%v16,%v16 /* Find element not equal with zero search. */
63 je .Lfound /* Jump away if zero was found. */
65 vfenezfs %v16,%v16,%v16
68 vfenezfs %v16,%v16,%v16
71 vfenezfs %v16,%v16,%v16
75 j .Lloop /* No zero found -> loop. */
84 vlgvb %r2,%v16,7 /* Load byte index of zero. */
87 srlg %r2,%r2,2 /* Convert byte-count to character-count. */
93 # if ! HAVE_WCSLEN_IFUNC
94 strong_alias (WCSLEN_Z13, __wcslen)
95 weak_alias (__wcslen, wcslen)