2 * strcpy/stpcpy - copy a string returning pointer to start/end.
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
19 /* To build as stpcpy, define BUILD_STPCPY before compiling this file. */
21 #define FUNC __stpcpy_aarch64_sve
23 #define FUNC __strcpy_aarch64_sve
30 setffr /* initialize FFR */
31 ptrue p2.b, all /* all ones; loop invariant */
32 mov x2, 0 /* initialize offset */
35 /* Read a vector's worth of bytes, stopping on first fault. */
36 0: ldff1b z0.b, p2/z, [x1, x2]
40 /* First fault did not fail: the whole vector is valid.
41 Avoid depending on the contexts of FFR beyond the branch. */
42 cmpeq p1.b, p2/z, z0.b, 0 /* search for zeros */
45 /* No zero found. Store the whole vector and loop. */
46 st1b z0.b, p2, [x0, x2]
50 /* First fault failed: only some of the vector is valid.
51 Perform the comparison only on the valid bytes. */
52 1: cmpeq p1.b, p0/z, z0.b, 0 /* search for zeros */
55 /* No zero found. Store the valid portion of the vector and loop. */
56 setffr /* re-init FFR */
57 st1b z0.b, p0, [x0, x2]
61 /* Zero found. Crop the vector to the found zero and finish. */
62 2: brka p0.b, p2/z, p1.b
63 st1b z0.b, p0, [x0, x2]