2 * Copyright (C) 2008 The Android Open Source Project
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * This code assumes it is running on a processor that supports all arm v7
31 * instructions and that supports neon instructions.
37 /* memset() returns its first argument. */
39 .type memset,%function
42 # The neon memset only wins for less than 132.
51 /* make sure we have at least 32 bytes to write */
56 1: /* The main loop writes 32 bytes at a time */
58 vst1.8 {d0 - d3}, [r0]!
61 2: /* less than 32 left */
66 // writes 16 bytes, 128-bits aligned
67 vst1.8 {d0, d1}, [r0]!
68 3: /* write up to 15-bytes (count in r2) */
73 vst1.32 {d0[0]}, [r0]!
74 2: movs ip, r2, lsl #31
81 /* compute the offset to align the destination
82 * offset = (4-(src&3))&3 = -src & 3
86 stmfd sp!, {r0, r4-r7, lr}
94 orr r1, r1, r1, lsr #8
95 orr r1, r1, r1, lsr #16
98 strcsb r1, [r0], #1 /* can't use strh (alignment unknown) */
102 ldmlsfd sp!, {r0, r4-r7, lr} /* return */
105 /* align the destination to a cache-line */
120 /* conditionally writes 0 to 7 words (length in r3) */
122 stmcsia r0!, {r1, lr}
123 stmcsia r0!, {r1, lr}
124 stmmiia r0!, {r1, lr}
133 stmia r0!, {r1,r3,r4,r5,r6,r7,r12,lr}
137 /* conditionally stores 0 to 31 bytes */
139 stmcsia r0!, {r1,r3,r12,lr}
140 stmmiia r0!, {r1, lr}
146 ldmfd sp!, {r0, r4-r7, lr}
149 .size memset, .-memset