1 /* memcpy.S: Sparc optimized memcpy and memmove code
2 * Hand optimized from GNU libc's memcpy and memmove
3 * Copyright (C) 1991,1996 Free Software Foundation
4 * Copyright (C) 1995 Linus Torvalds (Linus.Torvalds@helsinki.fi)
5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
7 * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
10 #include <asm/export.h>
17 /* Both these macros have to start with exactly the same insn */
18 #define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
19 ldd [%src + (offset) + 0x00], %t0; \
20 ldd [%src + (offset) + 0x08], %t2; \
21 ldd [%src + (offset) + 0x10], %t4; \
22 ldd [%src + (offset) + 0x18], %t6; \
23 st %t0, [%dst + (offset) + 0x00]; \
24 st %t1, [%dst + (offset) + 0x04]; \
25 st %t2, [%dst + (offset) + 0x08]; \
26 st %t3, [%dst + (offset) + 0x0c]; \
27 st %t4, [%dst + (offset) + 0x10]; \
28 st %t5, [%dst + (offset) + 0x14]; \
29 st %t6, [%dst + (offset) + 0x18]; \
30 st %t7, [%dst + (offset) + 0x1c];
32 #define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
33 ldd [%src + (offset) + 0x00], %t0; \
34 ldd [%src + (offset) + 0x08], %t2; \
35 ldd [%src + (offset) + 0x10], %t4; \
36 ldd [%src + (offset) + 0x18], %t6; \
37 std %t0, [%dst + (offset) + 0x00]; \
38 std %t2, [%dst + (offset) + 0x08]; \
39 std %t4, [%dst + (offset) + 0x10]; \
40 std %t6, [%dst + (offset) + 0x18];
42 #define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
43 ldd [%src - (offset) - 0x10], %t0; \
44 ldd [%src - (offset) - 0x08], %t2; \
45 st %t0, [%dst - (offset) - 0x10]; \
46 st %t1, [%dst - (offset) - 0x0c]; \
47 st %t2, [%dst - (offset) - 0x08]; \
48 st %t3, [%dst - (offset) - 0x04];
50 #define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
51 ldd [%src - (offset) - 0x10], %t0; \
52 ldd [%src - (offset) - 0x08], %t2; \
53 std %t0, [%dst - (offset) - 0x10]; \
54 std %t2, [%dst - (offset) - 0x08];
56 #define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
57 ldub [%src - (offset) - 0x02], %t0; \
58 ldub [%src - (offset) - 0x01], %t1; \
59 stb %t0, [%dst - (offset) - 0x02]; \
60 stb %t1, [%dst - (offset) - 0x01];
66 EXPORT_SYMBOL(memmove)
82 1: /* reverse_bytes */
94 /* NOTE: This code is executed just for the cases,
95 where %src (=%o1) & 3 is != 0.
96 We need to align it to 4. So, for (%src & 3)
97 1 we need to do ldub,lduh
100 so even if it looks weird, the branches
101 are correct here. -jj
103 78: /* dword_align */
123 FUNC(memcpy) /* %o0=dst %o1=src %o2=len */
124 EXPORT_SYMBOL(memcpy)
150 andcc %g1, 0xffffff80, %g0
156 MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
157 MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
158 MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
159 MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
175 jmpl %o5 + %lo(80f), %g0
178 79: /* memcpy_table */
180 MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
181 MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
182 MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
183 MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
184 MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
185 MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
186 MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
188 80: /* memcpy_table_end */
198 81: /* memcpy_last7 */
226 MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
227 MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
228 MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
229 MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
243 jmpl %o5 + %lo(84f), %g0
246 83: /* amemcpy_table */
248 MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
249 MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
250 MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
251 MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
252 MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
253 MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
254 MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
256 84: /* amemcpy_table_end */
262 std %g2, [%o0 - 0x08]
264 85: /* amemcpy_last7 */
290 86: /* non_aligned */
413 restore %g7, %g0, %o0
424 jmpl %o5 + %lo(89f), %g0
427 MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
428 MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
429 MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
430 MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
431 MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
432 MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
433 MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
435 89: /* short_table_end */
446 90: /* short_aligned_end */