memset.S revision 04954a43b362b8c817cc5859513efad0c344f412
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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 13 * distribution. 14 * 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 26 * SUCH DAMAGE. 27 */ 28 29#include <machine/cpu-features.h> 30#include <machine/asm.h> 31 32/* 33 * This code assumes it is running on a processor that supports all arm v7 34 * instructions, that supports neon instructions, and that supports 35 * unaligned neon instruction accesses to memory. 36 */ 37 38 .fpu neon 39 40ENTRY(bzero) 41 mov r2, r1 42 mov r1, #0 43END(bzero) 44 45/* memset() returns its first argument. */ 46ENTRY(memset) 47 .save {r0} 48 stmfd sp!, {r0} 49 50 vdup.8 q0, r1 51 52 /* make sure we have at least 32 bytes to write */ 53 subs r2, r2, #32 54 blo 2f 55 vmov q1, q0 56 571: /* The main loop writes 32 bytes at a time */ 58 subs r2, r2, #32 59 vst1.8 {d0 - d3}, [r0]! 60 bhs 1b 61 622: /* less than 32 left */ 63 add r2, r2, #32 64 tst r2, #0x10 65 beq 3f 66 67 // writes 16 bytes, 128-bits aligned 68 vst1.8 {d0, d1}, [r0]! 693: /* write up to 15-bytes (count in r2) */ 70 movs ip, r2, lsl #29 71 bcc 1f 72 vst1.8 {d0}, [r0]! 731: bge 2f 74 vst1.32 {d0[0]}, [r0]! 752: movs ip, r2, lsl #31 76 strmib r1, [r0], #1 77 strcsb r1, [r0], #1 78 strcsb r1, [r0], #1 79 ldmfd sp!, {r0} 80 bx lr 81END(memset) 82