]>
Commit | Line | Data |
---|---|---|
9472f35a | 1 | /* Vector optimized 32/64 bit S/390 version of wcslen. |
f7a9f785 | 2 | Copyright (C) 2015-2016 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 | ||
19 | #if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) | |
20 | ||
21 | # include "sysdep.h" | |
22 | # include "asm-syntax.h" | |
23 | ||
24 | .text | |
25 | ||
26 | /* size_t wcslen (const wchar_t *s) | |
27 | Returns length of string s. | |
28 | ||
29 | Register usage: | |
30 | -r1=bytes to 4k-byte boundary | |
31 | -r2=s | |
32 | -r3=tmp | |
33 | -r4=tmp | |
34 | -r5=current_len and return_value | |
35 | -v16=part of s | |
36 | */ | |
37 | ENTRY(__wcslen_vx) | |
38 | .machine "z13" | |
39 | .machinemode "zarch_nohighgprs" | |
40 | ||
41 | vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */ | |
42 | lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */ | |
43 | ||
44 | tmll %r2,3 /* Test if s is 4-byte aligned? */ | |
45 | jne .Lfallback /* And use common-code variant if not. */ | |
46 | ||
47 | vfenezf %v16,%v16,%v16 /* Find element not equal with zero search. */ | |
48 | vlgvb %r4,%v16,7 /* Load zero index or 16 if not found. */ | |
49 | clr %r4,%r1 /* If found zero within loaded bytes? */ | |
50 | locgrl %r2,%r4 /* Then copy return value. */ | |
51 | jl .Lend /* And return. */ | |
52 | ||
53 | /* Align s to 16 byte. */ | |
54 | risbgn %r3,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */ | |
55 | lghi %r5,16 /* current_len = 16. */ | |
56 | slr %r5,%r3 /* Compute bytes to 16bytes boundary. */ | |
57 | ||
58 | /* Find zero in 16byte aligned loop. */ | |
59 | .Lloop: | |
60 | vl %v16,0(%r5,%r2) /* Load s. */ | |
61 | vfenezfs %v16,%v16,%v16 /* Find element not equal with zero search. */ | |
62 | je .Lfound /* Jump away if zero was found. */ | |
63 | vl %v16,16(%r5,%r2) | |
64 | vfenezfs %v16,%v16,%v16 | |
65 | je .Lfound16 | |
66 | vl %v16,32(%r5,%r2) | |
67 | vfenezfs %v16,%v16,%v16 | |
68 | je .Lfound32 | |
69 | vl %v16,48(%r5,%r2) | |
70 | vfenezfs %v16,%v16,%v16 | |
71 | je .Lfound48 | |
72 | ||
73 | aghi %r5,64 | |
74 | j .Lloop /* No zero found -> loop. */ | |
75 | ||
76 | .Lfound48: | |
77 | aghi %r5,16 | |
78 | .Lfound32: | |
79 | aghi %r5,16 | |
80 | .Lfound16: | |
81 | aghi %r5,16 | |
82 | .Lfound: | |
83 | vlgvb %r2,%v16,7 /* Load byte index of zero. */ | |
84 | algr %r2,%r5 | |
85 | .Lend: | |
86 | srlg %r2,%r2,2 /* Convert byte-count to character-count. */ | |
87 | br %r14 | |
88 | .Lfallback: | |
89 | jg __wcslen_c | |
90 | END(__wcslen_vx) | |
91 | #endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ |