fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / machine / xscale / memmove.c
blob04d1a14d2ee96930973f381a023f69e4517519a7
1 #if defined __thumb__
3 #include "../../string/memmove.c"
5 #else
7 #include <string.h>
8 #include "xscale.h"
10 static inline void *
11 do_memcpy (void *dst0, const void *src0, size_t len)
13 int dummy;
14 asm volatile (
15 #ifndef __OPTIMIZE_SIZE__
16 "cmp %2, #0x3\n\
17 bls 3f\n\
18 and lr, %1, #0x3\n\
19 and r3, %0, #0x3\n\
20 cmp lr, r3\n\
21 bne 3f\n\
22 cmp lr, #0x0\n\
23 beq 2f\n\
24 b 1f\n\
25 0:\n\
26 ldrb r3, [%1], #1\n\
28 PRELOADSTR ("%1")
29 "\n\
30 tst %1, #0x3\n\
31 strb r3, [%0], #1\n\
32 beq 3f\n\
33 1:\n\
34 sub %2, %2, #1\n\
35 cmn %2, #1\n\
36 bne 0b\n\
37 2:\n\
38 cmp %2, #0xf\n\
39 bls 1f\n\
40 0:\n\
41 ldmia %1!, { r3, r4, r5, lr }\n\
43 PRELOADSTR ("%1")
44 "\n\
45 \n\
46 sub %2, %2, #16\n\
47 cmp %2, #0xf\n\
48 stmia %0!, { r3, r4, r5, lr }\n\
49 bhi 0b\n\
50 1:\n\
51 cmp %2, #0x7\n\
52 bls 1f\n\
53 0:\n\
54 ldmia %1!, { r3, r4 }\n\
56 PRELOADSTR ("%1")
57 "\n\
58 \n\
59 sub %2, %2, #8\n\
60 cmp %2, #0x7\n\
61 stmia %0!, { r3, r4 }\n\
62 bhi 0b\n\
63 1:\n\
64 cmp %2, #0x3\n\
65 bls 3f\n\
66 0:\n\
67 sub %2, %2, #4\n\
68 ldr r3, [%1], #4\n\
70 PRELOADSTR ("%1")
71 "\n\
72 \n\
73 cmp %2, #0x3\n\
74 str r3, [%0], #4\n\
75 bhi 0b\n\
77 #endif /* !__OPTIMIZE_SIZE__ */
78 "\n\
79 3:\n\
81 PRELOADSTR ("%1")
82 "\n\
83 sub %2, %2, #1\n\
84 cmn %2, #1\n\
85 beq 1f\n\
86 0:\n\
87 sub %2, %2, #1\n\
88 ldrb r3, [%1], #1\n\
90 PRELOADSTR ("%1")
91 "\n\
92 cmn %2, #1\n\
93 strb r3, [%0], #1\n\
94 bne 0b\n\
95 1:"
96 : "=&r" (dummy), "=&r" (src0), "=&r" (len)
97 : "0" (dst0), "1" (src0), "2" (len)
98 : "memory", "lr", "r3", "r4", "r5", "cc");
99 return dst0;
102 void *
103 memmove (void *dst, const void *src, size_t len)
105 char *d = dst;
106 const char *s = src;
108 if (s < d && d < s + len)
110 /* Destructive overlap...have to copy backwards. */
111 s += len;
112 d += len;
114 while (len--)
115 *--d = *--s;
117 return dst;
119 else
120 return do_memcpy (dst, src, len);
122 #endif