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 #define SMOVE_CHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
72 ldd [%src + offset + 0x00], %t0; \
73 ldd [%src + offset + 0x08], %t2; \
78 sll %t1, shil, %prev; \
84 std %t4, [%dst + offset + offset2 - 0x04]; \
85 std %t0, [%dst + offset + offset2 + 0x04]; \
86 sll %t3, shil, %prev; \
89 #define SMOVE_ALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
90 ldd [%src + offset + 0x00], %t0; \
91 ldd [%src + offset + 0x08], %t2; \
96 sll %t1, shil, %prev; \
100 sll %t2, shil, %t6; \
101 or %t4, %prev, %t2; \
102 sll %t3, shil, %prev; \
104 std %t0, [%dst + offset + offset2 + 0x00]; \
105 std %t2, [%dst + offset + offset2 + 0x08];
110 ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
139 77: andcc %o1, 4, %g0
148 2: andcc %g1, 0xffffff80, %g6
153 5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
154 MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
155 MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
156 MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
161 3: andcc %g1, 0x70, %g6
171 jmpl %o5 + (80f - 104b), %g0
174 79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
175 MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
176 MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
177 MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
178 MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
179 MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
180 MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
214 MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
215 MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
216 MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
217 MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
231 jmpl %o5 + (84f - 111b), %g0
234 83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
235 MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
236 MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
237 MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
238 MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
239 MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
240 MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
247 std %g2, [%o0 - 0x08]
351 9: ld [%o1 + 12], %g1
361 10: sll %o5, %g4, %g2
384 87: andcc %o1, 3, %g0
433 and %o2, 0xffffffc0, %o3
435 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
436 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
437 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
438 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
447 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
468 and %o2, 0xffffffc0, %o3
470 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
471 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
472 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
473 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
482 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
503 and %o2, 0xffffffc0, %o3
507 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
508 SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
509 SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
510 SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
519 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
529 41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
530 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
531 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
532 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
541 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
548 1: sth %g2, [%o0 - 3]
552 43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
553 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
554 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
555 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
564 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
571 1: stb %g2, [%o0 + 3]
574 42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
575 SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
576 SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
577 SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
586 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
593 1: sth %g2, [%o0 - 2]
597 88: and %o2, 0xe, %o3
604 jmpl %o5 + (89f - 106b), %g0
607 MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
608 MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
609 MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
610 MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
611 MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
612 MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
613 MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
644 libc_hidden_builtin_def (memcpy)