1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2013 Regents of the University of California
6 #include <linux/linkage.h>
9 /* void *memcpy(void *, const void *, size_t) */
10 SYM_FUNC_START(__memcpy)
11 move t6, a0 /* Preserve return value */
13 /* Defer to byte-oriented copy for small sizes */
16 /* Use word-oriented copy only if low-order bits match */
21 beqz a3, 2f /* Skip if already aligned */
23 * Round to nearest double word-aligned address
24 * greater than or equal to start address
26 andi a3, a1, ~(SZREG-1)
28 /* Handle initial misalignment */
36 sub a2, a2, a4 /* Update count */
39 andi a4, a2, ~((16*SZREG)-1)
63 REG_L a4, 10*SZREG(a1)
64 REG_L a5, 11*SZREG(a1)
65 REG_L a6, 12*SZREG(a1)
66 REG_L a7, 13*SZREG(a1)
67 REG_L t0, 14*SZREG(a1)
68 REG_L t1, 15*SZREG(a1)
70 REG_S a4, 10*SZREG(t6)
71 REG_S a5, 11*SZREG(t6)
72 REG_S a6, 12*SZREG(t6)
73 REG_S a7, 13*SZREG(t6)
74 REG_S t0, 14*SZREG(t6)
75 REG_S t1, 15*SZREG(t6)
78 andi a2, a2, (16*SZREG)-1 /* Update count */
81 /* Handle trailing misalignment */
85 /* Use word-oriented copy if co-aligned to word boundary */
107 SYM_FUNC_END(__memcpy)
108 SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
109 SYM_FUNC_ALIAS(__pi_memcpy, __memcpy)
110 SYM_FUNC_ALIAS(__pi___memcpy, __memcpy)