]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/s390/memset-z900.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / memset-z900.S
CommitLineData
5f1743d1 1/* Set a block of memory to some byte value. 31/64 bit S/390 version.
d614a753 2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
712a254a 3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
08f43f9b
AK
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
5a82c748 18 <https://www.gnu.org/licenses/>. */
08f43f9b
AK
19
20
712a254a 21#include <sysdep.h>
08f43f9b 22#include "asm-syntax.h"
712a254a 23#include <ifunc-memset.h>
08f43f9b 24
07be3928 25/* INPUT PARAMETERS - MEMSET
08f43f9b
AK
26 %r2 = address of memory area
27 %r3 = byte to fill memory with
07be3928
SL
28 %r4 = number of bytes to fill.
29
30 INPUT PARAMETERS - BZERO
31 %r2 = address of memory area
32 %r3 = number of bytes to fill. */
08f43f9b
AK
33
34 .text
35
712a254a
SL
36#if HAVE_MEMSET_Z900_G5
37# if defined __s390x__
38# define LTGR ltgr
39# define CGHI cghi
40# define LGR lgr
41# define AGHI aghi
42# define BRCTG brctg
43# else
44# define LTGR ltr
45# define CGHI chi
46# define LGR lr
47# define AGHI ahi
48# define BRCTG brct
49# endif /* ! defined __s390x__ */
08f43f9b 50
07be3928
SL
51ENTRY(BZERO_Z900_G5)
52 LGR %r4,%r3
53 xr %r3,%r3
54 j .L_Z900_G5_start
55END(BZERO_Z900_G5)
56
712a254a 57ENTRY(MEMSET_Z900_G5)
07be3928 58.L_Z900_G5_start:
712a254a
SL
59#if defined __s390x__
60 .machine "z900"
61#else
62 .machine "g5"
63#endif /* ! defined __s390x__ */
64 LTGR %r4,%r4
65 je .L_Z900_G5_4
31556246 66 stc %r3,0(%r2)
712a254a
SL
67 CGHI %r4,1
68 LGR %r1,%r2
69 je .L_Z900_G5_4
70 AGHI %r4,-2
71#if defined __s390x__
72 larl %r5,.L_Z900_G5_18
73 srlg %r3,%r4,8
74# define Z900_G5_EX_D 0
75#else
76 basr %r5,0
77.L_Z900_G5_19:
78# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19
79 lr %r3,%r4
80 srl %r3,8
81#endif /* ! defined __s390x__ */
82 LTGR %r3,%r3
83 jne .L_Z900_G5_14
84.L_Z900_G5_3:
85 ex %r4,Z900_G5_EX_D(%r5)
86.L_Z900_G5_4:
31556246 87 br %r14
712a254a 88.L_Z900_G5_14:
31556246 89 mvc 1(256,%r1),0(%r1)
31556246 90 la %r1,256(%r1)
712a254a
SL
91 BRCTG %r3,.L_Z900_G5_14
92 j .L_Z900_G5_3
93.L_Z900_G5_18:
31556246 94 mvc 1(1,%r1),0(%r1)
712a254a
SL
95END(MEMSET_Z900_G5)
96# undef LTGR
97# undef CGHI
98# undef LGR
99# undef AGHI
100# undef BRCTG
101#endif /* HAVE_MEMSET_Z900_G5 */
08f43f9b 102
712a254a 103#if HAVE_MEMSET_Z10
07be3928
SL
104ENTRY(BZERO_Z10)
105 .machine "z10"
106 .machinemode "zarch_nohighgprs"
107 lgr %r4,%r3
108 xr %r3,%r3
109 j .L_Z10_start
110END(BZERO_Z10)
111
712a254a 112ENTRY(MEMSET_Z10)
07be3928 113.L_Z10_start:
08f43f9b 114 .machine "z10"
5f1743d1
SL
115 .machinemode "zarch_nohighgprs"
116# if !defined __s390x__
117 llgfr %r4,%r4
118# endif /* !defined __s390x__ */
31556246
SL
119 cgije %r4,0,.L_Z10_4
120 stc %r3,0(%r2)
121 lgr %r1,%r2
122 cgije %r4,1,.L_Z10_4
123 aghi %r4,-2
124 srlg %r5,%r4,8
125 cgijlh %r5,0,.L_Z10_15
08f43f9b 126.L_Z10_3:
31556246 127 exrl %r4,.L_Z10_18
08f43f9b 128.L_Z10_4:
31556246 129 br %r14
08f43f9b
AK
130.L_Z10_15:
131 cgfi %r5,163840 # Switch to mvcle for >40MB
1d532483 132 jh __memset_mvcle
08f43f9b 133.L_Z10_14:
31556246
SL
134 pfd 2,1024(%r1)
135 mvc 1(256,%r1),0(%r1)
136 la %r1,256(%r1)
137 brctg %r5,.L_Z10_14
138 j .L_Z10_3
08f43f9b 139.L_Z10_18:
31556246 140 mvc 1(1,%r1),0(%r1)
712a254a
SL
141END(MEMSET_Z10)
142#endif /* HAVE_MEMSET_Z10 */
143
144#if HAVE_MEMSET_Z196
07be3928
SL
145ENTRY(BZERO_Z196)
146 .machine "z196"
147 .machinemode "zarch_nohighgprs"
148 lgr %r4,%r3
149 xr %r3,%r3
150 j .L_Z196_start
151END(BZERO_Z196)
152
712a254a 153ENTRY(MEMSET_Z196)
07be3928 154.L_Z196_start:
712a254a
SL
155 .machine "z196"
156 .machinemode "zarch_nohighgprs"
157# if !defined __s390x__
158 llgfr %r4,%r4
159# endif /* !defined __s390x__ */
160 ltgr %r4,%r4
161 je .L_Z196_4
162 stc %r3,0(%r2)
163 lgr %r1,%r2
164 cghi %r4,1
165 je .L_Z196_4
166 aghi %r4,-2
167 srlg %r5,%r4,8
168 ltgr %r5,%r5
169 jne .L_Z196_1
170.L_Z196_3:
171 exrl %r4,.L_Z196_17
172.L_Z196_4:
173 br %r14
174.L_Z196_1:
175 cgfi %r5,1048576
176 jh __memset_mvcle # Switch to mvcle for >256MB
177.L_Z196_2:
178 pfd 2,1024(%r1)
179 mvc 1(256,%r1),0(%r1)
180 aghi %r5,-1
181 la %r1,256(%r1)
182 jne .L_Z196_2
183 j .L_Z196_3
184.L_Z196_17:
185 mvc 1(1,%r1),0(%r1)
186END(MEMSET_Z196)
187#endif /* HAVE_MEMSET_Z196 */
08f43f9b 188
712a254a 189#if HAVE_MEMSET_MVCLE
1d532483 190ENTRY(__memset_mvcle)
08f43f9b
AK
191 aghi %r4,2 # take back the change done by the caller
192 lgr %r0,%r2 # save source address
193 lgr %r1,%r3 # move pad byte to R1
194 lgr %r3,%r4 # move length to r3
195 sgr %r4,%r4 # no source for MVCLE, only a pad byte
196 sgr %r5,%r5
197.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend
198 jo .L0
199 lgr %r2,%r0 # return value is source address
200.L1:
201 br %r14
1d532483 202END(__memset_mvcle)
712a254a 203#endif /* HAVE_MEMSET_MVCLE */
08f43f9b 204
712a254a
SL
205#if ! HAVE_MEMSET_IFUNC
206/* If we don't use ifunc, define an alias for memset here.
207 Otherwise see sysdeps/s390/memset.c. */
208strong_alias (MEMSET_DEFAULT, memset)
07be3928
SL
209/* Same for bzero. If ifunc is used, see
210 sysdeps/s390/bzero.c. */
211strong_alias (BZERO_DEFAULT, __bzero)
212weak_alias (__bzero, bzero)
712a254a 213#endif
08f43f9b 214
712a254a
SL
215#if defined SHARED && IS_IN (libc)
216/* Defines the internal symbol.
217 Compare to libc_hidden_builtin_def (memset) in string/memset.c. */
218strong_alias (MEMSET_DEFAULT, __GI_memset)
08f43f9b 219#endif