]>
Commit | Line | Data |
---|---|---|
9472f35a | 1 | /* Vector optimized 32/64 bit S/390 version of strlen. |
688903eb | 2 | Copyright (C) 2015-2018 Free Software Foundation, Inc. |
9472f35a SL |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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 | <http://www.gnu.org/licenses/>. */ | |
18 | ||
ff3ca374 SL |
19 | #include <ifunc-strlen.h> |
20 | #if HAVE_STRLEN_Z13 | |
9472f35a SL |
21 | |
22 | # include "sysdep.h" | |
23 | # include "asm-syntax.h" | |
24 | ||
25 | .text | |
26 | ||
27 | /* size_t strlen (const char *s) | |
28 | Returns length of string s. | |
29 | ||
30 | Register usage: | |
31 | -r1=bytes to 4k-byte boundary | |
32 | -r2=s | |
33 | -r3=tmp | |
34 | -r4=tmp | |
35 | -r5=current_len and return_value | |
36 | -v16=part of s | |
37 | */ | |
ff3ca374 | 38 | ENTRY(STRLEN_Z13) |
9472f35a SL |
39 | .machine "z13" |
40 | .machinemode "zarch_nohighgprs" | |
41 | ||
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. */ | |
44 | ||
45 | vfenezb %v16,%v16,%v16 /* Find element not equal with zero search. */ | |
46 | vlgvb %r4,%v16,7 /* Load zero index or 16 if not found. */ | |
47 | clr %r4,%r1 /* If found zero within loaded bytes? */ | |
48 | locgrl %r2,%r4 /* Then copy return value. */ | |
49 | blr %r14 /* And return. */ | |
50 | ||
51 | /* Align s to 16 byte. */ | |
52 | risbgn %r3,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */ | |
53 | lghi %r5,16 /* current_len = 16. */ | |
54 | slr %r5,%r3 /* Compute bytes to 16bytes boundary. */ | |
55 | ||
56 | /* Find zero in 16 byte aligned loop. */ | |
57 | .Lloop: | |
58 | vl %v16,0(%r5,%r2) /* Load s. */ | |
59 | vfenezbs %v16,%v16,%v16 /* Find element not equal with zero search. */ | |
60 | je .Lfound /* Jump away if zero was found. */ | |
61 | vl %v16,16(%r5,%r2) | |
62 | vfenezbs %v16,%v16,%v16 | |
63 | je .Lfound16 | |
64 | vl %v16,32(%r5,%r2) | |
65 | vfenezbs %v16,%v16,%v16 | |
66 | je .Lfound32 | |
67 | vl %v16,48(%r5,%r2) | |
68 | vfenezbs %v16,%v16,%v16 | |
69 | je .Lfound48 | |
70 | ||
71 | aghi %r5,64 | |
72 | j .Lloop /* No zero found -> loop. */ | |
73 | ||
74 | .Lfound48: | |
75 | aghi %r5,16 | |
76 | .Lfound32: | |
77 | aghi %r5,16 | |
78 | .Lfound16: | |
79 | aghi %r5,16 | |
80 | .Lfound: | |
81 | vlgvb %r2,%v16,7 /* Load byte index of zero. */ | |
82 | algr %r2,%r5 | |
83 | br %r14 | |
ff3ca374 SL |
84 | END(STRLEN_Z13) |
85 | ||
86 | # if ! HAVE_STRLEN_IFUNC | |
87 | strong_alias (STRLEN_Z13, strlen) | |
88 | # endif | |
89 | ||
90 | # if ! HAVE_STRLEN_C && defined SHARED && IS_IN (libc) | |
91 | strong_alias (STRLEN_Z13, __GI_strlen) | |
92 | # endif | |
93 | #endif |