blob: 51dd73ab8fdfd71af12a7a37f18ef7c1a8c12da0 [file] [log] [blame]
Alexey Brodkin22723822014-02-04 12:56:15 +04001/*
2 * Copyright (C) 2004, 2007-2010, 2011-2014 Synopsys, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7.global memcpy
8.align 4
9memcpy:
10 or %r3, %r0, %r1
11 asl_s %r3, %r3, 30
12 mov_s %r5, %r0
13 brls.d %r2, %r3, .Lcopy_bytewise
14 sub.f %r3, %r2, 1
15 ld_s %r12, [%r1, 0]
16 asr.f %lp_count, %r3, 3
17 bbit0.d %r3, 2, .Lnox4
18 bmsk_s %r2, %r2, 1
19 st.ab %r12, [%r5, 4]
20 ld.a %r12, [%r1, 4]
21.Lnox4:
22 lppnz .Lendloop
23 ld_s %r3, [%r1, 4]
24 st.ab %r12, [%r5, 4]
25 ld.a %r12, [%r1, 8]
26 st.ab %r3, [%r5, 4]
27.Lendloop:
28 breq %r2, 0, .Last_store
29 ld %r3, [%r5, 0]
30#ifdef __LITTLE_ENDIAN__
31 add3 %r2, -1, %r2
32 /* uses long immediate */
33 xor_s %r12, %r12, %r3
34 bmsk %r12, %r12, %r2
35 xor_s %r12, %r12, %r3
36#else /* __BIG_ENDIAN__ */
37 sub3 %r2, 31, %r2
38 /* uses long immediate */
39 xor_s %r3, %r3, %r12
40 bmsk %r3, %r3, %r2
41 xor_s %r12, %r12, %r3
42#endif /* _ENDIAN__ */
43.Last_store:
44 j_s.d [%blink]
45 st %r12, [%r5, 0]
46
47 .balign 4
48.Lcopy_bytewise:
49 jcs [%blink]
50 ldb_s %r12, [%r1, 0]
51 lsr.f %lp_count, %r3
52 bhs_s .Lnox1
53 stb.ab %r12, [%r5, 1]
54 ldb.a %r12, [%r1, 1]
55.Lnox1:
56 lppnz .Lendbloop
57 ldb_s %r3, [%r1, 1]
58 stb.ab %r12, [%r5, 1]
59 ldb.a %r12, [%r1, 2]
60 stb.ab %r3, [%r5, 1]
61.Lendbloop:
62 j_s.d [%blink]
63 stb %r12, [%r5, 0]