~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to reference/newlib-xscale/memcpy.c

  • Committer: Michael Hope
  • Date: 2011-08-31 23:54:55 UTC
  • Revision ID: michael.hope@linaro.org-20110831235455-1knk9yxvfcoxlm3a
Added the XScale specific routines from Newlib 1.19.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <string.h>
 
2
#include "xscale.h"
 
3
 
 
4
void *
 
5
memcpy (void *dst0, const void *src0, size_t len)
 
6
{
 
7
  int dummy;
 
8
  asm volatile (
 
9
#ifndef __OPTIMIZE_SIZE__
 
10
       "cmp     %2, #0x3\n\
 
11
        bls     3f\n\
 
12
        and     lr, %1, #0x3\n\
 
13
        and     r3, %0, #0x3\n\
 
14
        cmp     lr, r3\n\
 
15
        bne     3f\n\
 
16
        cmp     lr, #0x0\n\
 
17
        beq     2f\n\
 
18
        b       1f\n\
 
19
0:\n\
 
20
        ldrb    r3, [%1], #1\n\
 
21
"
 
22
        PRELOADSTR ("%1")
 
23
"\n\
 
24
        tst     %1, #0x3\n\
 
25
        strb    r3, [%0], #1\n\
 
26
        beq     3f\n\
 
27
1:\n\
 
28
        sub     %2, %2, #1\n\
 
29
        cmn     %2, #1\n\
 
30
        bne     0b\n\
 
31
2:\n\
 
32
        cmp     %2, #0xf\n\
 
33
        bls     1f\n\
 
34
0:\n\
 
35
        ldmia   %1!, { r3, r4, r5, lr }\n\
 
36
"
 
37
        PRELOADSTR ("%1")
 
38
"\n\
 
39
\n\
 
40
        sub     %2, %2, #16\n\
 
41
        cmp     %2, #0xf\n\
 
42
        stmia   %0!, { r3, r4, r5, lr }\n\
 
43
        bhi     0b\n\
 
44
1:\n\
 
45
        cmp     %2, #0x7\n\
 
46
        bls     1f\n\
 
47
0:\n\
 
48
        ldmia   %1!, { r3, r4 }\n\
 
49
"
 
50
        PRELOADSTR ("%1")
 
51
"\n\
 
52
\n\
 
53
        sub     %2, %2, #8\n\
 
54
        cmp     %2, #0x7\n\
 
55
        stmia   %0!, { r3, r4 }\n\
 
56
        bhi     0b\n\
 
57
1:\n\
 
58
        cmp     %2, #0x3\n\
 
59
        bls     3f\n\
 
60
0:\n\
 
61
        sub     %2, %2, #4\n\
 
62
        ldr     r3, [%1], #4\n\
 
63
"
 
64
        PRELOADSTR ("%1")
 
65
"\n\
 
66
\n\
 
67
        cmp     %2, #0x3\n\
 
68
        str     r3, [%0], #4\n\
 
69
        bhi     0b\n\
 
70
"
 
71
#endif /* !__OPTIMIZE_SIZE__ */
 
72
"\n\
 
73
3:\n\
 
74
"
 
75
        PRELOADSTR ("%1")
 
76
"\n\
 
77
        sub     %2, %2, #1\n\
 
78
        cmn     %2, #1\n\
 
79
        beq     1f\n\
 
80
0:\n\
 
81
        sub     %2, %2, #1\n\
 
82
        ldrb    r3, [%1], #1\n\
 
83
"
 
84
        PRELOADSTR ("%1")
 
85
"\n\
 
86
        cmn     %2, #1\n\
 
87
        strb    r3, [%0], #1\n\
 
88
        bne     0b\n\
 
89
1:"
 
90
       : "=&r" (dummy), "=&r" (src0), "=&r" (len)
 
91
       : "0" (dst0), "1" (src0), "2" (len)
 
92
       : "memory", "lr", "r3", "r4", "r5", "cc");
 
93
  return dst0;
 
94
}