1 /* Copy SIZE bytes from SRC to DEST.
3 Copyright (C) 1996, 1999, 2003 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by David S. Miller <davem@caip.rutgers.edu>,
6 Eddie C. Dost <ecd@skynet.be> and
7 Jakub Jelinek <jj@ultra.linux.cz>.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library; if not, write to the Free
21 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 /* Both these macros have to start with exactly the same insn */
27 #define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
28 ldd [%src + offset + 0x00], %t0; \
29 ldd [%src + offset + 0x08], %t2; \
30 ldd [%src + offset + 0x10], %t4; \
31 ldd [%src + offset + 0x18], %t6; \
32 st %t0, [%dst + offset + 0x00]; \
33 st %t1, [%dst + offset + 0x04]; \
34 st %t2, [%dst + offset + 0x08]; \
35 st %t3, [%dst + offset + 0x0c]; \
36 st %t4, [%dst + offset + 0x10]; \
37 st %t5, [%dst + offset + 0x14]; \
38 st %t6, [%dst + offset + 0x18]; \
39 st %t7, [%dst + offset + 0x1c];
41 #define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
42 ldd [%src + offset + 0x00], %t0; \
43 ldd [%src + offset + 0x08], %t2; \
44 ldd [%src + offset + 0x10], %t4; \
45 ldd [%src + offset + 0x18], %t6; \
46 std %t0, [%dst + offset + 0x00]; \
47 std %t2, [%dst + offset + 0x08]; \
48 std %t4, [%dst + offset + 0x10]; \
49 std %t6, [%dst + offset + 0x18];
51 #define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
52 ldd [%src - offset - 0x10], %t0; \
53 ldd [%src - offset - 0x08], %t2; \
54 st %t0, [%dst - offset - 0x10]; \
55 st %t1, [%dst - offset - 0x0c]; \
56 st %t2, [%dst - offset - 0x08]; \
57 st %t3, [%dst - offset - 0x04];
59 #define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
60 ldd [%src - offset - 0x10], %t0; \
61 ldd [%src - offset - 0x08], %t2; \
62 std %t0, [%dst - offset - 0x10]; \
63 std %t2, [%dst - offset - 0x08];
65 #define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
66 ldub [%src - offset - 0x02], %t0; \
67 ldub [%src - offset - 0x01], %t1; \
68 stb %t0, [%dst - offset - 0x02]; \
69 stb %t1, [%dst - offset - 0x01];
71 /* Both these macros have to start with exactly the same insn */
72 #define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
73 ldd [%src - offset - 0x20], %t0; \
74 ldd [%src - offset - 0x18], %t2; \
75 ldd [%src - offset - 0x10], %t4; \
76 ldd [%src - offset - 0x08], %t6; \
77 st %t0, [%dst - offset - 0x20]; \
78 st %t1, [%dst - offset - 0x1c]; \
79 st %t2, [%dst - offset - 0x18]; \
80 st %t3, [%dst - offset - 0x14]; \
81 st %t4, [%dst - offset - 0x10]; \
82 st %t5, [%dst - offset - 0x0c]; \
83 st %t6, [%dst - offset - 0x08]; \
84 st %t7, [%dst - offset - 0x04];
86 #define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
87 ldd [%src - offset - 0x20], %t0; \
88 ldd [%src - offset - 0x18], %t2; \
89 ldd [%src - offset - 0x10], %t4; \
90 ldd [%src - offset - 0x08], %t6; \
91 std %t0, [%dst - offset - 0x20]; \
92 std %t2, [%dst - offset - 0x18]; \
93 std %t4, [%dst - offset - 0x10]; \
94 std %t6, [%dst - offset - 0x08];
96 #define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
97 ldd [%src + offset + 0x00], %t0; \
98 ldd [%src + offset + 0x08], %t2; \
99 st %t0, [%dst + offset + 0x00]; \
100 st %t1, [%dst + offset + 0x04]; \
101 st %t2, [%dst + offset + 0x08]; \
102 st %t3, [%dst + offset + 0x0c];
104 #define RMOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
105 ldub [%src + offset + 0x00], %t0; \
106 ldub [%src + offset + 0x01], %t1; \
107 stb %t0, [%dst + offset + 0x00]; \
108 stb %t1, [%dst + offset + 0x01];
110 #define SMOVE_CHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
111 ldd [%src + offset + 0x00], %t0; \
112 ldd [%src + offset + 0x08], %t2; \
113 srl %t0, shir, %t5; \
114 srl %t1, shir, %t6; \
115 sll %t0, shil, %t0; \
116 or %t5, %prev, %t5; \
117 sll %t1, shil, %prev; \
119 srl %t2, shir, %t1; \
120 srl %t3, shir, %t6; \
121 sll %t2, shil, %t2; \
122 or %t1, %prev, %t1; \
123 std %t4, [%dst + offset + offset2 - 0x04]; \
124 std %t0, [%dst + offset + offset2 + 0x04]; \
125 sll %t3, shil, %prev; \
128 #define SMOVE_ALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
129 ldd [%src + offset + 0x00], %t0; \
130 ldd [%src + offset + 0x08], %t2; \
131 srl %t0, shir, %t4; \
132 srl %t1, shir, %t5; \
133 sll %t0, shil, %t6; \
134 or %t4, %prev, %t0; \
135 sll %t1, shil, %prev; \
137 srl %t2, shir, %t4; \
138 srl %t3, shir, %t5; \
139 sll %t2, shil, %t6; \
140 or %t4, %prev, %t2; \
141 sll %t3, shil, %prev; \
143 std %t0, [%dst + offset + offset2 + 0x00]; \
144 std %t2, [%dst + offset + offset2 + 0x08];
149 70: andcc %o1, 1, %g0
159 4: lduh [%o1 - 2], %g2
199 2: andcc %g1, 0xffffff80, %g6
204 5: RMOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
205 RMOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
206 RMOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
207 RMOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
213 3: andcc %g1, 0x70, %g6
223 jmpl %o5 + (72f - 101b), %g0
226 71: RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
227 RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
228 RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
229 RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
230 RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
231 RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
232 RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
236 ldd [%o1 - 0x08], %g2
263 74: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
264 RMOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
265 RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
266 RMOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
282 jmpl %o5 + (72b - 102b), %g0
285 75: and %o2, 0xe, %o3
292 jmpl %o5 + (76f - 103b), %g0
295 RMOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
296 RMOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
297 RMOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
298 RMOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
299 RMOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
300 RMOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
301 RMOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
339 63: ldub [%o1 - 1], %g5
435 78: andcc %o1, 1, %g0
453 ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
474 2: andcc %g1, 0xffffff80, %g6
479 5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
480 MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
481 MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
482 MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
487 3: andcc %g1, 0x70, %g6
497 jmpl %o5 + (80f - 104b), %g0
500 79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
501 MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
502 MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
503 MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
504 MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
505 MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
506 MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
540 MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
541 MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
542 MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
543 MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
557 jmpl %o5 + (84f - 111b), %g0
560 83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
561 MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
562 MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
563 MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
564 MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
565 MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
566 MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
573 std %g2, [%o0 - 0x08]
677 9: ld [%o1 + 12], %g1
687 10: sll %o5, %g4, %g2
710 87: andcc %o1, 3, %g0
759 and %o2, 0xffffffc0, %o3
761 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
762 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
763 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
764 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
773 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
794 and %o2, 0xffffffc0, %o3
796 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
797 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
798 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
799 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
808 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
829 and %o2, 0xffffffc0, %o3
833 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
834 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
835 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
836 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
845 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
855 41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
856 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
857 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
858 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
867 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
874 1: sth %g2, [%o0 - 3]
878 43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
879 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
880 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
881 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
890 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
897 1: stb %g2, [%o0 + 3]
900 42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
901 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
902 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
903 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
912 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
919 1: sth %g2, [%o0 - 2]
923 88: and %o2, 0xe, %o3
930 jmpl %o5 + (89f - 106b), %g0
933 MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
934 MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
935 MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
936 MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
937 MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
938 MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
939 MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
969 libc_hidden_builtin_def (memcpy)
970 libc_hidden_builtin_def (memmove)