Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / sh / memset.S
blobff6c94588bb2429c021190edf033877b1782eae9
1 /* Copyright (C) 1999-2014 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4    Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
22 /* void *memset (t, c, len);  */
24 ENTRY(memset)
25         mov     #12,r0
26         cmp/gt  r6,r0
27         bt.s    L_byte_loop_init
28         mov     r4,r7
30         extu.b  r5,r5
31         swap.b  r5,r1
32         or      r1,r5
33         swap.w  r5,r1
34         or      r1,r5
36         mov     r4,r0
37         tst     #1,r0
38         bt      L_wordalign
40         mov.b   r5,@r4
41         add     #-1,r6
42         add     #1,r4
43         mov     r4,r0
45         .balignw 4,0x0009
46 L_wordalign:
47         tst     #2,r0
48         bt      L_word_loop_init
50         mov.w   r5,@r4
51         add     #-2,r6
52         add     #2,r4
53         mov     r4,r0
55         .balignw 4,0x0009
56 L_word_loop_init:
57         mov     r6,r3
58         shlr2   r3
59         mov     #7,r0
60         shlr    r3
61         and     r0,r6
63         .balignw 4,0x0009
64 L_2word_loop:
65         mov.l   r5,@r4
66         dt      r3
67         mov.l   r5,@(4,r4)
68         bf.s    L_2word_loop
69         add     #8,r4
71         .balignw 4,0x0009
72 L_byte_loop_init:
73         tst     r6,r6
74         bt      L_byte_exit
76         .balignw 4,0x0009
77 L_byte_loop:
78         mov.b   r5,@r4
79         dt      r6
80         bf.s    L_byte_loop
81         add     #1,r4
83         .balignw 4,0x0009
84 L_byte_exit:
85         rts
86         mov     r7,r0
87 END(memset)
88 libc_hidden_builtin_def (memset)