1 /* Copyright (C) 2012-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/>. */
23 * ARMv8-a, AArch64, unaligned accesses
40 ENTRY_ALIGN (__memset, 6)
43 add dstend, dstin, count
51 /* Set 0..15 bytes. */
59 str valw, [dstend, -4]
64 strh valw, [dstend, -2]
67 /* Set 17..96 bytes. */
70 tbnz count, 6, L(set96)
78 /* Set 64..96 bytes. Write 64 bytes from the start and
79 32 bytes from the end. */
82 stp q0, q0, [dstin, 32]
83 stp q0, q0, [dstend, -32]
96 sub count, dstend, dst /* Count is 16 too large. */
98 sub count, count, 64 + 16 /* Adjust count and bias for loop. */
99 1: stp q0, q0, [dst], 64
100 stp q0, q0, [dst, -32]
102 subs count, count, 64
104 2: stp q0, q0, [dstend, -64]
105 stp q0, q0, [dstend, -32]
111 tbnz tmp1w, 4, L(no_zva)
113 cmp tmp1w, 4 /* ZVA size is 64 bytes. */
116 /* Write the first and last 64 byte aligned block using stp rather
117 than using DC ZVA. This is faster on some cores.
121 stp q0, q0, [dst, 32]
123 stp q0, q0, [dst, 64]
124 stp q0, q0, [dst, 96]
125 sub count, dstend, dst /* Count is now 128 too large. */
126 sub count, count, 128+64+64 /* Adjust count and bias for loop. */
131 subs count, count, 64
134 stp q0, q0, [dst, 32]
135 stp q0, q0, [dstend, -64]
136 stp q0, q0, [dstend, -32]
141 cmp tmp1w, 5 /* ZVA size is 128 bytes. */
145 stp q0, q0, [dst, 32]
146 stp q0, q0, [dst, 64]
147 stp q0, q0, [dst, 96]
149 sub count, dstend, dst /* Count is now 128 too large. */
150 sub count, count, 128+128 /* Adjust count and bias for loop. */
154 subs count, count, 128
156 stp q0, q0, [dstend, -128]
157 stp q0, q0, [dstend, -96]
158 stp q0, q0, [dstend, -64]
159 stp q0, q0, [dstend, -32]
164 lsl zva_lenw, tmp2w, tmp1w
165 add tmp1, zva_len, 64 /* Max alignment bytes written. */
170 add tmp1, dst, zva_len
172 subs count, tmp1, dst /* Actual alignment bytes to write. */
173 bic tmp1, tmp1, tmp2 /* Aligned dc zva start address. */
175 1: stp q0, q0, [dst], 64
176 stp q0, q0, [dst, -32]
177 subs count, count, 64
180 sub count, dstend, tmp1 /* Remaining bytes to write. */
181 subs count, count, zva_len
184 add dst, dst, zva_len
185 subs count, count, zva_len
187 4: add count, count, zva_len
191 weak_alias (__memset, memset)
192 libc_hidden_builtin_def (memset)