locale: use a better fallback
[uclibc-ng.git] / libc / string / arc / memset.S
blobf4048455a43346680fa43b4632ffff816e2d1641
1 /*
2  * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
3  * Copyright (C) 2007 ARC International (UK) LTD
4  *
5  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
6  */
8 #include <sysdep.h>
10 #define SMALL   7 /* Must be at least 6 to deal with alignment/loop issues.  */
12 ENTRY(memset)
14         mov_s   r4,r0
15         or      r12,r0,r2
16         bmsk.f  r12,r12,1
17         extb_s  r1,r1
18         asl     r3,r1,8
19         beq.d   .Laligned
20         or_s    r1,r1,r3
21         brls    r2,SMALL,.Ltiny
22         add     r3,r2,r0
23         stb     r1,[r3,-1]
24         bclr_s  r3,r3,0
25         stw     r1,[r3,-2]
26         bmsk.f  r12,r0,1
27         add_s   r2,r2,r12
28         sub.ne  r2,r2,4
29         stb.ab  r1,[r4,1]
30         and     r4,r4,-2
31         stw.ab  r1,[r4,2]
32         and     r4,r4,-4
33 .Laligned:      ; This code address should be aligned for speed.
34         asl     r3,r1,16
35         lsr.f   lp_count,r2,2
36         or_s    r1,r1,r3
37         lpne    .Loop_end
38         st.ab   r1,[r4,4]
39 .Loop_end:
40         j_s     [blink]
43         .balign 4
44 .Ltiny:
45         mov.f   lp_count,r2
46         lpne    .Ltiny_end
47         stb.ab  r1,[r4,1]
48 .Ltiny_end:
49         j_s     [blink]
50 END(memset)
51 libc_hidden_def(memset)