1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
7 /* HEXAGON assembly optimized memset */
8 /* Replaces the standard library function memset */
11 .macro HEXAGON_OPT_FUNC_BEGIN name
15 .type \name, @function
19 .macro HEXAGON_OPT_FUNC_FINISH name
20 .size \name, . - \name
23 /* FUNCTION: memset (v2 version) */
24 #if __HEXAGON_ARCH__ < 3
25 HEXAGON_OPT_FUNC_BEGIN memset
28 r7 = extractu(r0, #3 , #0)
34 r8 = r0 /* leave r0 intact for return val */
35 r9 = sub(r6, r7) /* bytes until double alignment */
36 if p0 jumpr r31 /* count == 0, so return */
42 if p1 jump 2f /* skip byte loop */
45 /* less than 8 bytes to set, so just set a byte at a time and return */
47 loop0(1f, r2) /* byte loop */
55 2: /* skip byte loop */
60 if !p0 jump 3f /* skip initial byte store */
64 r3:2 = sub(r3:2, r7:6)
68 3: /* skip initial byte store */
73 if !p0 jump 4f /* skip initial half store */
77 r3:2 = sub(r3:2, r7:6)
81 4: /* skip initial half store */
86 if !p0 jump 5f /* skip initial word store */
90 r3:2 = sub(r3:2, r7:6)
95 5: /* skip initial word store */
99 if !p0 jump 7f /* skip double loop */
104 loop0(6f, r10) /* double loop */
107 /* set bytes a double word at a time */
113 r3:2 = sub(r3:2, r7:6)
117 7: /* skip double loop */
126 if !p0 jump 8f /* skip final word store */
130 r3:2 = sub(r3:2, r7:6)
134 8: /* skip final word store */
137 if !p0 jump 9f /* skip final half store */
144 9: /* skip final half store */
149 HEXAGON_OPT_FUNC_FINISH memset
153 /* FUNCTION: memset (v3 and higher version) */
154 #if __HEXAGON_ARCH__ >= 3
155 HEXAGON_OPT_FUNC_BEGIN memset
159 if (r2==#0) jump:nt .L1
164 if (p0.new) jump:nt .L3
174 }:endloop0 /* start=.L47 */
179 if (!p0.new) jump:nt .L8
191 if (!p0.new) jump:nt .L10
197 if (p0.new) jump:nt .L1
202 if (!p0.new) jump:nt .L12
208 if (p0.new) jump:nt .L1
212 p0 = cmp.gtu(r2,#127)
213 if (!p0.new) jump:nt .L14
216 if (r3==#0) jump:nt .L17
222 if (r3==#0) jump:nt .L17
228 if (r3==#0) jump:nt .L17
236 if (r1!=#0) jump:nt .L18
249 }:endloop0 /* start=.L46 */
253 if (!p0.new) jump:nt .L28
262 }:endloop0 /* start=.L44 */
266 if (!p0.new) jump:nt .L33
275 if (!p0.new) jump:nt .L35
283 if (p0) memb(r6) = r1
299 }:endloop0 /* start=.L45 */
301 HEXAGON_OPT_FUNC_FINISH memset