1 | /* Memset for falkor. |
2 | Copyright (C) 2017-2022 Free Software Foundation, Inc. |
3 | |
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 |
18 | <https://www.gnu.org/licenses/>. */ |
19 | |
20 | #include <sysdep.h> |
21 | #include <memset-reg.h> |
22 | |
23 | /* Reading dczid_el0 is expensive on falkor so move it into the ifunc |
24 | resolver and assume ZVA size of 64 bytes. The IFUNC resolver takes care to |
25 | use this function only when ZVA is enabled. */ |
26 | |
27 | #if IS_IN (libc) |
28 | .macro zva_macro |
29 | .p2align 4 |
30 | /* Write the first and last 64 byte aligned block using stp rather |
31 | than using DC ZVA. This is faster on some cores. */ |
32 | str q0, [dst, 16] |
33 | stp q0, q0, [dst, 32] |
34 | bic dst, dst, 63 |
35 | stp q0, q0, [dst, 64] |
36 | stp q0, q0, [dst, 96] |
37 | sub count, dstend, dst /* Count is now 128 too large. */ |
38 | sub count, count, 128+64+64 /* Adjust count and bias for loop. */ |
39 | add dst, dst, 128 |
40 | 1: dc zva, dst |
41 | add dst, dst, 64 |
42 | subs count, count, 64 |
43 | b.hi 1b |
44 | stp q0, q0, [dst, 0] |
45 | stp q0, q0, [dst, 32] |
46 | stp q0, q0, [dstend, -64] |
47 | stp q0, q0, [dstend, -32] |
48 | ret |
49 | .endm |
50 | |
51 | # define ZVA_MACRO zva_macro |
52 | # define MEMSET __memset_falkor |
53 | # include <sysdeps/aarch64/memset.S> |
54 | #endif |
55 | |