1 /* Vector optimized 32/64 bit S/390 version of strcat.
2 Copyright (C) 2015-2016 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 <http://www.gnu.org/licenses/>. */
19 #if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
22 # include "asm-syntax.h"
26 /* char * strcat (const char *dest, const char *src)
27 Concatenate two strings.
30 -r0=saved dest pointer for return
42 .machinemode "zarch_nohighgprs"
44 lgr %r0,%r2 /* Save destination pointer for return. */
47 r1 = loaded bytes (tmp)
48 r4 = zero byte index (tmp)
51 vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
52 lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
54 vfenezb %v16,%v16,%v16 /* Find element not equal with zero search. */
55 vlgvb %r5,%v16,7 /* Load zero index or 16 if not found. */
56 clrjl %r5,%r1,.Llen_end /* Found zero within loaded bytes, end. */
58 /* Align s to 16 byte. */
59 risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
60 lghi %r5,16 /* current_len = 16. */
61 slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
63 /* Find zero in 16byte aligned loop. */
65 vl %v16,0(%r5,%r2) /* Load s. */
66 vfenezbs %v16,%v16,%v16 /* Find element not equal with zero search. */
67 je .Llen_found /* Jump away if zero was found. */
69 vfenezbs %v16,%v16,%v16
72 vfenezbs %v16,%v16,%v16
75 vfenezbs %v16,%v16,%v16
79 j .Llen_loop /* No zero -> loop. */
88 vlgvb %r4,%v16,7 /* Load byte index of zero. */
93 %r1 = loaded bytes (tmp)
94 %r4 = zero byte index (tmp)
95 %r3 = curr src pointer
96 %r2 = curr dst pointer
98 la %r2,0(%r5,%r2) /* strcpy at end of dst-string. */
100 vlbb %v16,0(%r3),6 /* Load s until next 4k-byte boundary. */
101 lcbb %r1,0(%r3),6 /* Get bytes to 4k-byte boundary or 16. */
103 vfenezb %v17,%v16,%v16 /* Find element not equal with zero search. */
104 vlgvb %r5,%v17,7 /* Load zero index or 16 if not found. */
105 clrjl %r5,%r1,.Lcpy_found_align /* If found zero within loaded bytes,
106 copy bytes before and return. */
108 /* Align s to 16 byte. */
109 risbgn %r4,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
110 lghi %r5,15 /* current_len = 15. */
111 slr %r5,%r4 /* Compute highest index to 16byte boundary. */
113 vstl %v16,%r5,0(%r2) /* Copy loaded characters - no zero. */
114 ahi %r5,1 /* Start loop at next character. */
116 /* Find zero in 16byte aligned loop. */
118 vl %v16,0(%r5,%r3) /* Load s. */
119 vfenezbs %v17,%v16,%v16 /* Find element not equal with zero search. */
120 je .Lcpy_found_v16_0 /* Jump away if zero was found. */
121 vl %v18,16(%r5,%r3)/* Load next part of s. */
122 vst %v16,0(%r5,%r2) /* Store previous part without zero to dst. */
123 vfenezbs %v17,%v18,%v18
124 je .Lcpy_found_v18_16
127 vfenezbs %v17,%v16,%v16
128 je .Lcpy_found_v16_32
131 vfenezbs %v17,%v18,%v18
132 je .Lcpy_found_v18_48
136 j .Lcpy_loop /* No zero -> loop. */
142 vlgvb %r1,%v17,7 /* Load byte index of zero. */
143 vstl %v16,%r1,0(%r4) /* Copy characters including zero. */
144 lgr %r2,%r0 /* Load saved dest-ptr. */
151 vlgvb %r1,%v17,7 /* Load byte index of zero. */
152 vstl %v18,%r1,0(%r4) /* Copy characters including zero. */
153 lgr %r2,%r0 /* Load saved dest-ptr. */
157 vstl %v16,%r5,0(%r2) /* Copy characters including zero. */
158 lgr %r2,%r0 /* Load saved dest-ptr. */
161 #endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */