]>
Commit | Line | Data |
---|---|---|
63724a6d | 1 | /* Vector optimized 32/64 bit S/390 version of wcscmp. |
688903eb | 2 | Copyright (C) 2015-2018 Free Software Foundation, Inc. |
63724a6d 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 | /* int wcscmp (const wchar_t *s1, const wchar_t *s2) | |
27 | Compare two strings | |
28 | ||
29 | Register usage: | |
30 | -r1=loaded byte count s1 | |
31 | -r2=s1 | |
32 | -r3=s2 | |
33 | -r4=loaded byte coutn s2, tmp | |
34 | -r5=current_len | |
35 | -v16=part of s1 | |
36 | -v17=part of s2 | |
37 | -v18=index of unequal | |
38 | */ | |
39 | ENTRY(__wcscmp_vx) | |
40 | .machine "z13" | |
41 | .machinemode "zarch_nohighgprs" | |
42 | ||
43 | lghi %r5,0 /* current_len = 0. */ | |
44 | ||
45 | .Lloop: | |
46 | vlbb %v16,0(%r5,%r2),6 /* Load s1 to block boundary. */ | |
47 | vlbb %v17,0(%r5,%r3),6 /* Load s2 to block boundary. */ | |
48 | lcbb %r1,0(%r5,%r2),6 /* Get loaded byte count of s1. */ | |
49 | jo .Llt16_1 /* Jump away if vr is not fully loaded. */ | |
50 | lcbb %r4,0(%r5,%r3),6 | |
51 | jo .Llt16_2 /* Jump away if vr is not fully loaded. */ | |
52 | /* Both vrs are fully loaded. */ | |
53 | aghi %r5,16 | |
54 | vfenezfs %v18,%v16,%v17 /* Compare not equal with zero search. */ | |
55 | jno .Lfound | |
56 | ||
57 | vlbb %v16,0(%r5,%r2),6 | |
58 | vlbb %v17,0(%r5,%r3),6 | |
59 | lcbb %r1,0(%r5,%r2),6 | |
60 | jo .Llt16_1 | |
61 | lcbb %r4,0(%r5,%r3),6 | |
62 | jo .Llt16_2 | |
63 | aghi %r5,16 | |
64 | vfenezfs %v18,%v16,%v17 | |
65 | jno .Lfound | |
66 | ||
67 | vlbb %v16,0(%r5,%r2),6 | |
68 | vlbb %v17,0(%r5,%r3),6 | |
69 | lcbb %r1,0(%r5,%r2),6 | |
70 | jo .Llt16_1 | |
71 | lcbb %r4,0(%r5,%r3),6 | |
72 | jo .Llt16_2 | |
73 | aghi %r5,16 | |
74 | vfenezfs %v18,%v16,%v17 | |
75 | jno .Lfound | |
76 | ||
77 | vlbb %v16,0(%r5,%r2),6 | |
78 | vlbb %v17,0(%r5,%r3),6 | |
79 | lcbb %r1,0(%r5,%r2),6 | |
80 | jo .Llt16_1 | |
81 | lcbb %r4,0(%r5,%r3),6 | |
82 | jo .Llt16_2 | |
83 | aghi %r5,16 | |
84 | vfenezfs %v18,%v16,%v17 | |
85 | jno .Lfound | |
86 | j .Lloop | |
87 | ||
88 | .Lcmp_one_char: | |
89 | /* At least one of both strings is not 4-byte aligned | |
90 | and there is no full character before next block-boundary. | |
91 | Compare one character to get over the boundary and | |
92 | proceed with normal loop! */ | |
93 | vlef %v16,0(%r5,%r2),0 /* Load one character. */ | |
94 | vlef %v17,0(%r5,%r3),0 | |
95 | lghi %r1,4 /* Loaded byte count is 4. */ | |
96 | j .Llt_cmp /* Proceed with comparision. */ | |
97 | ||
98 | .Llt16_1: | |
99 | lcbb %r4,0(%r5,%r3),6 /* Get loaded byte count of s2. */ | |
100 | .Llt16_2: | |
101 | clr %r1,%r4 | |
102 | locrh %r1,%r4 /* Get minimum of bytes loaded in s1/2. */ | |
103 | nill %r1,65532 /* Align bytes loaded to full characters. */ | |
104 | jz .Lcmp_one_char /* Jump away if no full char is available. */ | |
105 | .Llt_cmp: | |
106 | algfr %r5,%r1 /* Add smallest loaded bytes to current_len. */ | |
107 | vfenezfs %v18,%v16,%v17 /* Compare not equal with zero search. */ | |
108 | vlgvb %r4,%v18,7 /* Get not equal index or 16 if all equal. */ | |
109 | clrjl %r4,%r1,.Lfound /* Jump away if miscompare is within loaded | |
110 | bytes. */ | |
111 | j .Lloop | |
112 | ||
113 | .Lfound: | |
114 | /* vfenezf found an unequal element or zero. | |
115 | This instruction compares unsigned words, but wchar_t is signed. | |
116 | Thus we have to compare the found element again. */ | |
117 | vlgvb %r4,%v18,7 /* Extract not equal byte-index, */ | |
118 | srl %r4,2 /* Convert it to character-index. */ | |
119 | vlgvf %r3,%v16,0(%r4) /* Load character-values. */ | |
120 | vlgvf %r4,%v17,0(%r4) | |
121 | cr %r3,%r4 | |
122 | je .Lend_equal | |
123 | lghi %r2,1 | |
124 | lghi %r1,-1 | |
125 | locgrl %r2,%r1 | |
126 | br %r14 | |
127 | .Lend_equal: | |
128 | lghi %r2,0 | |
129 | br %r14 | |
130 | END(__wcscmp_vx) | |
131 | #endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ |