1 /* Copyright (C) 2012-2020 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 <https://www.gnu.org/licenses/>. */
20 #include "memset-reg.h"
23 # define MEMSET memset
28 * ARMv8-a, AArch64, unaligned accesses
32 ENTRY_ALIGN (MEMSET, 6)
38 add dstend, dstin, count
46 /* Set 0..15 bytes. */
54 str valw, [dstend, -4]
59 strh valw, [dstend, -2]
62 /* Set 17..96 bytes. */
65 tbnz count, 6, L(set96)
73 /* Set 64..96 bytes. Write 64 bytes from the start and
74 32 bytes from the end. */
77 stp q0, q0, [dstin, 32]
78 stp q0, q0, [dstend, -32]
91 sub count, dstend, dst /* Count is 16 too large. */
92 sub dst, dst, 16 /* Dst is biased by -32. */
93 sub count, count, 64 + 16 /* Adjust count and bias for loop. */
94 1: stp q0, q0, [dst, 32]
95 stp q0, q0, [dst, 64]!
99 2: stp q0, q0, [dstend, -64]
100 stp q0, q0, [dstend, -32]
109 tbnz tmp1w, 4, L(no_zva)
111 cmp tmp1w, 4 /* ZVA size is 64 bytes. */
114 /* Write the first and last 64 byte aligned block using stp rather
115 than using DC ZVA. This is faster on some cores.
119 stp q0, q0, [dst, 32]
121 stp q0, q0, [dst, 64]
122 stp q0, q0, [dst, 96]
123 sub count, dstend, dst /* Count is now 128 too large. */
124 sub count, count, 128+64+64 /* Adjust count and bias for loop. */
129 subs count, count, 64
132 stp q0, q0, [dst, 32]
133 stp q0, q0, [dstend, -64]
134 stp q0, q0, [dstend, -32]
139 cmp tmp1w, 5 /* ZVA size is 128 bytes. */
143 stp q0, q0, [dst, 32]
144 stp q0, q0, [dst, 64]
145 stp q0, q0, [dst, 96]
147 sub count, dstend, dst /* Count is now 128 too large. */
148 sub count, count, 128+128 /* Adjust count and bias for loop. */
152 subs count, count, 128
154 stp q0, q0, [dstend, -128]
155 stp q0, q0, [dstend, -96]
156 stp q0, q0, [dstend, -64]
157 stp q0, q0, [dstend, -32]
162 lsl zva_lenw, tmp2w, tmp1w
163 add tmp1, zva_len, 64 /* Max alignment bytes written. */
168 add tmp1, dst, zva_len
170 subs count, tmp1, dst /* Actual alignment bytes to write. */
171 bic tmp1, tmp1, tmp2 /* Aligned dc zva start address. */
173 1: stp q0, q0, [dst], 64
174 stp q0, q0, [dst, -32]
175 subs count, count, 64
178 sub count, dstend, tmp1 /* Remaining bytes to write. */
179 subs count, count, zva_len
182 add dst, dst, zva_len
183 subs count, count, zva_len
185 4: add count, count, zva_len
186 sub dst, dst, 32 /* Bias dst for tail loop. */
191 libc_hidden_builtin_def (MEMSET)