1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2013 Regents of the University of California
7 #include <linux/linkage.h>
10 /* void *memset(void *, int, size_t) */
13 move t0, a0 /* Preserve return value */
15 /* Defer to byte-oriented fill for small sizes */
20 * Round to nearest XLEN-aligned address
21 * greater than or equal to start address
24 andi a3, a3, ~(SZREG-1)
25 beq a3, t0, 2f /* Skip if already aligned */
26 /* Handle initial misalignment */
32 sub a2, a2, a4 /* Update count */
34 2: /* Duff's device with 32 XLEN stores per iteration */
35 /* Broadcast value into all bytes */
46 /* Calculate end address */
47 andi a4, a2, ~(SZREG-1)
50 andi a4, a4, 31*SZREG /* Calculate remainder */
51 beqz a4, 3f /* Shortcut if no remainder */
53 addi a4, a4, 32*SZREG /* Calculate initial offset */
55 /* Adjust start address with offset */
58 /* Jump into loop body */
59 /* Assumes 32-bit instruction lengths */
77 REG_S a1, 10*SZREG(t0)
78 REG_S a1, 11*SZREG(t0)
79 REG_S a1, 12*SZREG(t0)
80 REG_S a1, 13*SZREG(t0)
81 REG_S a1, 14*SZREG(t0)
82 REG_S a1, 15*SZREG(t0)
83 REG_S a1, 16*SZREG(t0)
84 REG_S a1, 17*SZREG(t0)
85 REG_S a1, 18*SZREG(t0)
86 REG_S a1, 19*SZREG(t0)
87 REG_S a1, 20*SZREG(t0)
88 REG_S a1, 21*SZREG(t0)
89 REG_S a1, 22*SZREG(t0)
90 REG_S a1, 23*SZREG(t0)
91 REG_S a1, 24*SZREG(t0)
92 REG_S a1, 25*SZREG(t0)
93 REG_S a1, 26*SZREG(t0)
94 REG_S a1, 27*SZREG(t0)
95 REG_S a1, 28*SZREG(t0)
96 REG_S a1, 29*SZREG(t0)
97 REG_S a1, 30*SZREG(t0)
98 REG_S a1, 31*SZREG(t0)
101 andi a2, a2, SZREG-1 /* Update count */
104 /* Handle trailing misalignment */