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];
185 4: lduh [%o1 - 2], %g2
201 2: andcc %g1, 0xffffff80, %g6
206 5: RMOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
207 RMOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
208 RMOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
209 RMOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
215 3: andcc %g1, 0x70, %g6
225 jmpl %o5 + (72f - 101b), %g0
228 71: RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
229 RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
230 RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
231 RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
232 RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
233 RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
234 RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
238 ldd [%o1 - 0x08], %g2
265 74: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
266 RMOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
267 RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
268 RMOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
284 jmpl %o5 + (72b - 102b), %g0
287 75: and %o2, 0xe, %o3
294 jmpl %o5 + (76f - 103b), %g0
297 RMOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
298 RMOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
299 RMOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
300 RMOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
301 RMOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
302 RMOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
303 RMOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
341 63: ldub [%o1 - 1], %g5
437 78: andcc %o1, 1, %g0
455 ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
476 2: andcc %g1, 0xffffff80, %g6
481 5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
482 MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
483 MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
484 MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
489 3: andcc %g1, 0x70, %g6
499 jmpl %o5 + (80f - 104b), %g0
502 79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
503 MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
504 MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
505 MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
506 MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
507 MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
508 MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
542 MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
543 MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
544 MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
545 MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
559 jmpl %o5 + (84f - 111b), %g0
562 83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
563 MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
564 MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
565 MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
566 MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
567 MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
568 MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
575 std %g2, [%o0 - 0x08]
679 9: ld [%o1 + 12], %g1
689 10: sll %o5, %g4, %g2
712 87: andcc %o1, 3, %g0
761 and %o2, 0xffffffc0, %o3
763 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
764 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
765 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
766 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
775 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
796 and %o2, 0xffffffc0, %o3
798 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
799 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
800 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
801 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
810 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
831 and %o2, 0xffffffc0, %o3
835 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
836 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
837 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
838 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
847 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
857 41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
858 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
859 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
860 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
869 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
876 1: sth %g2, [%o0 - 3]
880 43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
881 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
882 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
883 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
892 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
899 1: stb %g2, [%o0 + 3]
902 42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
903 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
904 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
905 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
914 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
921 1: sth %g2, [%o0 - 2]
925 88: and %o2, 0xe, %o3
932 jmpl %o5 + (89f - 106b), %g0
935 MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
936 MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
937 MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
938 MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
939 MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
940 MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
941 MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
971 libc_hidden_builtin_def (memcpy)
972 libc_hidden_builtin_def (memmove)