blob: 50a42e06cff77d69607a396dde1a6593e316657d [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001/* Copyright (C) 1999-2016 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>
5
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.
10
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.
15
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/>. */
19
20#include <sysdep.h>
21
22/* void *memset (t, c, len); */
23
24ENTRY(memset)
25 mov #12,r0
26 cmp/gt r6,r0
27 bt.s L_byte_loop_init
28 mov r4,r7
29
30 extu.b r5,r5
31 swap.b r5,r1
32 or r1,r5
33 swap.w r5,r1
34 or r1,r5
35
36 mov r4,r0
37 tst #1,r0
38 bt L_wordalign
39
40 mov.b r5,@r4
41 add #-1,r6
42 add #1,r4
43 mov r4,r0
44
45 .balignw 4,0x0009
46L_wordalign:
47 tst #2,r0
48 bt L_word_loop_init
49
50 mov.w r5,@r4
51 add #-2,r6
52 add #2,r4
53 mov r4,r0
54
55 .balignw 4,0x0009
56L_word_loop_init:
57 mov r6,r3
58 shlr2 r3
59 mov #7,r0
60 shlr r3
61 and r0,r6
62
63 .balignw 4,0x0009
64L_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
70
71 .balignw 4,0x0009
72L_byte_loop_init:
73 tst r6,r6
74 bt L_byte_exit
75
76 .balignw 4,0x0009
77L_byte_loop:
78 mov.b r5,@r4
79 dt r6
80 bf.s L_byte_loop
81 add #1,r4
82
83 .balignw 4,0x0009
84L_byte_exit:
85 rts
86 mov r7,r0
87END(memset)
88libc_hidden_builtin_def (memset)