linuxthreads: Fix up pthread.h for XPG7.
[uclibc-ng.git] / libc / string / arc / memcpy.S
blob1c11951e40d2e46bad79fdfdea6199ac2ad192c6
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 /* This memcpy implementation does not support objects of 1GB or larger -
11    the check for alignment does not work then.  */
12 /* We assume that most sources and destinations are aligned, and
13    that also lengths are mostly a multiple of four, although to a lesser
14    extent.  */
15 ENTRY(memcpy)
16         or      r3,r0,r1
17         asl_s   r3,r3,30
18         mov_s   r5,r0
19         brls.d  r2,r3,.Lcopy_bytewise
20         sub.f   r3,r2,1
21         ld_s    r12,[r1,0]
22         asr.f   lp_count,r3,3
23         bbit0.d r3,2,.Lnox4
24         bmsk_s  r2,r2,1
25         st.ab   r12,[r5,4]
26         ld.a    r12,[r1,4]
27 .Lnox4:
28         lppnz   .Lendloop
29         ld_s    r3,[r1,4]
30         st.ab   r12,[r5,4]
31         ld.a    r12,[r1,8]
32         st.ab   r3,[r5,4]
33 .Lendloop:
34         breq    r2,0,.Last_store
35         ld      r3,[r5,0]
36 #ifdef __LITTLE_ENDIAN__
37         add3    r2,-1,r2
38         ; uses long immediate
39         xor_s   r12,r12,r3
40         bmsk    r12,r12,r2
41         xor_s   r12,r12,r3
42 #else /* BIG ENDIAN */
43         sub3    r2,31,r2
44         ; uses long immediate
45         xor_s   r3,r3,r12
46         bmsk    r3,r3,r2
47         xor_s   r12,r12,r3
48 #endif /* ENDIAN */
49 .Last_store:
50         j_s.d   [blink]
51         st      r12,[r5,0]
53         .balign 4
54 .Lcopy_bytewise:
55         jcs     [blink]
56         ldb_s   r12,[r1,0]
57         lsr.f   lp_count,r3
58         bhs_s   .Lnox1
59         stb.ab  r12,[r5,1]
60         ldb.a   r12,[r1,1]
61 .Lnox1:
62         lppnz   .Lendbloop
63         ldb_s   r3,[r1,1]
64         stb.ab  r12,[r5,1]
65         ldb.a   r12,[r1,2]
66         stb.ab  r3,[r5,1]
67 .Lendbloop:
68         j_s.d   [blink]
69         stb     r12,[r5,0]
70 END(memcpy)
71 libc_hidden_def(memcpy)