mailing list of musl libc
 help / color / mirror / code / Atom feed
blob 77877e6952f16cc0305af64320c87633c2ad3045 1429 bytes (raw)
name: src/string/riscv64/memmove_vector.S 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
    .text
    .global __memmove_vect
    .type __memmove_vect,%function
    .option push
    .option arch, +v
/* void *__memmove_vect(void *dest, const void *src, size_t n)
 * a0 = dest, a1 = src, a2 = n
 * Returns a0.
 */
__memmove_vect:
    beqz    a2, .Ldone_move           /* n == 0 */
    beq     a0, a1, .Ldone_move       /* dst == src */

    /* overlap check */
    bgeu    a1, a0, .Lforward_move    /* src >= dst then forward move*/

    sub     t2, a0, a1                /* t2 = dst - src */
    bgeu    t2, a2, .Lforward_move    /* no overlap then forward move */

    /* backward move */
    add     t0, a0, a2                /* running dst_end */
    add     t1, a1, a2                /* running src_end */

.Lbackward_loop:
    vsetvli t3, a2, e8, m8, ta, ma    /* t3 = vl (bytes) */
    sub     t0, t0, t3
    sub     t1, t1, t3
    vle8.v  v0, (t1)
    vse8.v  v0, (t0)
    sub     a2, a2, t3
    bnez    a2, .Lbackward_loop
    j       .Ldone_move

    /* forward move, same as __memcpy_vect */
.Lforward_move:
    mv      t0, a0                    /* running dst */
    mv      t1, a1                    /* running src */

.Lforward_loop:
    vsetvli t3, a2, e8, m8, ta, ma
    vle8.v  v0, (t1)
    vse8.v  v0, (t0)
    add     t0, t0, t3
    add     t1, t1, t3
    sub     a2, a2, t3
    bnez    a2, .Lforward_loop
    /* fallthrough */

.Ldone_move:
    ret
.size __memmove_vect, .-__memmove_vect
.option pop

debug log:

solving 77877e69 ...
found 77877e69 in https://inbox.vuxu.org/musl/20251119054059.514848-2-pincheng.plct@isrc.iscas.ac.cn/

applying [1/1] https://inbox.vuxu.org/musl/20251119054059.514848-2-pincheng.plct@isrc.iscas.ac.cn/
diff --git a/src/string/riscv64/memmove_vector.S b/src/string/riscv64/memmove_vector.S
new file mode 100644
index 00000000..77877e69

Checking patch src/string/riscv64/memmove_vector.S...
Applied patch src/string/riscv64/memmove_vector.S cleanly.

index at:
100644 77877e6952f16cc0305af64320c87633c2ad3045	src/string/riscv64/memmove_vector.S

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).