2 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 /* HEXAGON assembly optimized memset */
21 /* Replaces the standard library function memset */
24 .macro HEXAGON_OPT_FUNC_BEGIN name
28 .type \name, @function
32 .macro HEXAGON_OPT_FUNC_FINISH name
33 .size \name, . - \name
36 /* FUNCTION: memset (v2 version) */
37 #if __HEXAGON_ARCH__ < 3
38 HEXAGON_OPT_FUNC_BEGIN memset
41 r7 = extractu(r0, #3 , #0)
47 r8 = r0 /* leave r0 intact for return val */
48 r9 = sub(r6, r7) /* bytes until double alignment */
49 if p0 jumpr r31 /* count == 0, so return */
55 if p1 jump 2f /* skip byte loop */
58 /* less than 8 bytes to set, so just set a byte at a time and return */
60 loop0(1f, r2) /* byte loop */
68 2: /* skip byte loop */
73 if !p0 jump 3f /* skip initial byte store */
77 r3:2 = sub(r3:2, r7:6)
81 3: /* skip initial byte store */
86 if !p0 jump 4f /* skip initial half store */
90 r3:2 = sub(r3:2, r7:6)
94 4: /* skip initial half store */
99 if !p0 jump 5f /* skip initial word store */
103 r3:2 = sub(r3:2, r7:6)
104 p0 = cmp.gtu(r2, #11)
108 5: /* skip initial word store */
112 if !p0 jump 7f /* skip double loop */
117 loop0(6f, r10) /* double loop */
120 /* set bytes a double word at a time */
126 r3:2 = sub(r3:2, r7:6)
130 7: /* skip double loop */
139 if !p0 jump 8f /* skip final word store */
143 r3:2 = sub(r3:2, r7:6)
147 8: /* skip final word store */
150 if !p0 jump 9f /* skip final half store */
157 9: /* skip final half store */
162 HEXAGON_OPT_FUNC_FINISH memset
166 /* FUNCTION: memset (v3 and higher version) */
167 #if __HEXAGON_ARCH__ >= 3
168 HEXAGON_OPT_FUNC_BEGIN memset
172 if (r2==#0) jump:nt .L1
177 if (p0.new) jump:nt .L3
187 }:endloop0 /* start=.L47 */
192 if (!p0.new) jump:nt .L8
204 if (!p0.new) jump:nt .L10
210 if (p0.new) jump:nt .L1
215 if (!p0.new) jump:nt .L12
221 if (p0.new) jump:nt .L1
225 p0 = cmp.gtu(r2,#127)
226 if (!p0.new) jump:nt .L14
229 if (r3==#0) jump:nt .L17
235 if (r3==#0) jump:nt .L17
241 if (r3==#0) jump:nt .L17
249 if (r1!=#0) jump:nt .L18
262 }:endloop0 /* start=.L46 */
266 if (!p0.new) jump:nt .L28
275 }:endloop0 /* start=.L44 */
279 if (!p0.new) jump:nt .L33
288 if (!p0.new) jump:nt .L35
296 if (p0) memb(r6) = r1
312 }:endloop0 /* start=.L45 */
314 HEXAGON_OPT_FUNC_FINISH memset