2 * memset - fill memory with a constant byte
4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 * ARMv8-a, AArch64, Advanced SIMD, unaligned accesses.
15 #include "../asmdefs.h"
25 ENTRY (__memset_aarch64)
28 add dstend, dstin, count
36 /* Set 0..15 bytes. */
44 str valw, [dstend, -4]
49 strh valw, [dstend, -2]
52 /* Set 17..96 bytes. */
55 tbnz count, 6, L(set96)
63 /* Set 64..96 bytes. Write 64 bytes from the start and
64 32 bytes from the end. */
67 stp q0, q0, [dstin, 32]
68 stp q0, q0, [dstend, -32]
80 #ifndef SKIP_ZVA_CHECK
81 mrs zva_val, dczid_el0
82 and zva_val, zva_val, 31
83 cmp zva_val, 4 /* ZVA size is 64 bytes. */
89 sub count, dstend, dst /* Count is now 64 too large. */
90 sub count, count, 128 /* Adjust count and bias for loop. */
98 stp q0, q0, [dstend, -64]
99 stp q0, q0, [dstend, -32]
103 sub count, dstend, dst /* Count is 16 too large. */
104 sub dst, dst, 16 /* Dst is biased by -32. */
105 sub count, count, 64 + 16 /* Adjust count and bias for loop. */
107 stp q0, q0, [dst, 32]
108 stp q0, q0, [dst, 64]!
109 subs count, count, 64
111 stp q0, q0, [dstend, -64]
112 stp q0, q0, [dstend, -32]
115 END (__memset_aarch64)