xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1998-2016 Free Software Foundation, Inc. |
| 2 | This file is part of the GNU C Library. |
| 3 | Contributed by Philip Blundell <philb@gnu.org> |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library. If not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | /* Thumb requires excessive IT insns here. */ |
| 20 | #define NO_THUMB |
| 21 | #include <sysdep.h> |
| 22 | |
| 23 | .text |
| 24 | .syntax unified |
| 25 | |
| 26 | /* void *memset (dstpp, c, len) */ |
| 27 | |
| 28 | ENTRY(memset) |
| 29 | mov r3, r0 |
| 30 | cmp r2, #8 |
| 31 | bcc 2f @ less than 8 bytes to move |
| 32 | |
| 33 | 1: |
| 34 | tst r3, #3 @ aligned yet? |
| 35 | sfi_breg r3, \ |
| 36 | strbne r1, [\B], #1 |
| 37 | subne r2, r2, #1 |
| 38 | bne 1b |
| 39 | |
| 40 | and r1, r1, #255 @ clear any sign bits |
| 41 | orr r1, r1, r1, lsl $8 |
| 42 | orr r1, r1, r1, lsl $16 |
| 43 | mov ip, r1 |
| 44 | |
| 45 | 1: |
| 46 | subs r2, r2, #8 |
| 47 | sfi_breg r3, \ |
| 48 | stmiacs \B!, {r1, ip} @ store up to 32 bytes per loop iteration |
| 49 | subscs r2, r2, #8 |
| 50 | sfi_breg r3, \ |
| 51 | stmiacs \B!, {r1, ip} |
| 52 | subscs r2, r2, #8 |
| 53 | sfi_breg r3, \ |
| 54 | stmiacs \B!, {r1, ip} |
| 55 | subscs r2, r2, #8 |
| 56 | sfi_breg r3, \ |
| 57 | stmiacs \B!, {r1, ip} |
| 58 | bcs 1b |
| 59 | |
| 60 | and r2, r2, #7 |
| 61 | 2: |
| 62 | subs r2, r2, #1 @ store up to 4 bytes per loop iteration |
| 63 | sfi_breg r3, \ |
| 64 | strbcs r1, [\B], #1 |
| 65 | subscs r2, r2, #1 |
| 66 | sfi_breg r3, \ |
| 67 | strbcs r1, [\B], #1 |
| 68 | subscs r2, r2, #1 |
| 69 | sfi_breg r3, \ |
| 70 | strbcs r1, [\B], #1 |
| 71 | subscs r2, r2, #1 |
| 72 | sfi_breg r3, \ |
| 73 | strbcs r1, [\B], #1 |
| 74 | bcs 2b |
| 75 | |
| 76 | DO_RET(lr) |
| 77 | END(memset) |
| 78 | libc_hidden_builtin_def (memset) |