]> 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.
2b778ceb 2 Copyright (C) 2001-2021 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__ */
1d21fb10
SL
160 clgfi %r4,1
161 jl .L_Z196_4 # n == 0
712a254a 162 stc %r3,0(%r2)
1d21fb10
SL
163 je .L_Z196_4 # n == 1
164 aghi %r4,-2
712a254a 165 lgr %r1,%r2
1d21fb10
SL
166 risbg %r5,%r4,8,128+63,56 # r5 = n / 256
167 jne .L_Z196_1 # Jump away if r5 != 0
712a254a
SL
168.L_Z196_3:
169 exrl %r4,.L_Z196_17
170.L_Z196_4:
171 br %r14
172.L_Z196_1:
173 cgfi %r5,1048576
1d21fb10 174 jh __memset_mvcle # Switch to mvcle for >256MB
712a254a
SL
175.L_Z196_2:
176 pfd 2,1024(%r1)
1d21fb10 177 mvc 1(255,%r1),0(%r1)
712a254a
SL
178 aghi %r5,-1
179 la %r1,256(%r1)
1d21fb10 180 stc %r3,0(%r1)
712a254a
SL
181 jne .L_Z196_2
182 j .L_Z196_3
183.L_Z196_17:
184 mvc 1(1,%r1),0(%r1)
185END(MEMSET_Z196)
186#endif /* HAVE_MEMSET_Z196 */
08f43f9b 187
712a254a 188#if HAVE_MEMSET_MVCLE
1d532483 189ENTRY(__memset_mvcle)
08f43f9b
AK
190 aghi %r4,2 # take back the change done by the caller
191 lgr %r0,%r2 # save source address
192 lgr %r1,%r3 # move pad byte to R1
193 lgr %r3,%r4 # move length to r3
194 sgr %r4,%r4 # no source for MVCLE, only a pad byte
195 sgr %r5,%r5
196.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend
197 jo .L0
198 lgr %r2,%r0 # return value is source address
199.L1:
200 br %r14
1d532483 201END(__memset_mvcle)
712a254a 202#endif /* HAVE_MEMSET_MVCLE */
08f43f9b 203
712a254a
SL
204#if ! HAVE_MEMSET_IFUNC
205/* If we don't use ifunc, define an alias for memset here.
206 Otherwise see sysdeps/s390/memset.c. */
207strong_alias (MEMSET_DEFAULT, memset)
07be3928
SL
208/* Same for bzero. If ifunc is used, see
209 sysdeps/s390/bzero.c. */
210strong_alias (BZERO_DEFAULT, __bzero)
211weak_alias (__bzero, bzero)
712a254a 212#endif
08f43f9b 213
712a254a
SL
214#if defined SHARED && IS_IN (libc)
215/* Defines the internal symbol.
216 Compare to libc_hidden_builtin_def (memset) in string/memset.c. */
217strong_alias (MEMSET_DEFAULT, __GI_memset)
08f43f9b 218#endif