Staging: android: lowmemorykiller: cleanup android low memory killer
[linux-2.6] / arch / m32r / lib / memcpy.S
1 /*
2  *  linux/arch/m32r/lib/memcpy.S
3  *
4  *  Copyright (C) 2001  Hiroyuki Kondo, and Hirokazu Takata
5  *  Copyright (C) 2004  Hirokazu Takata
6  *
7  *  void *memcopy(void *dst, const void *src, int n);
8  *
9  *        dst: r0
10  *        src: r1
11  *        n  : r2
12  */
13
14         .text
15 #include <linux/linkage.h>
16 #include <asm/assembler.h>
17
18 #ifdef CONFIG_ISA_DUAL_ISSUE
19
20         .text
21 ENTRY(memcpy)
22 memcopy:
23         mv      r4, r0              ||  mv      r7, r0
24         or      r7, r1              ||  cmpz    r2
25         jc      r14                 ||  cmpeq   r0, r1  ; return if r2=0
26         jc      r14                                     ; return if r0=r1
27
28         and3    r7, r7, #3
29         bnez    r7, byte_copy
30         srl3    r3, r2, #2
31         and3    r2, r2, #3
32         beqz    r3, byte_copy
33         addi    r4, #-4
34 word_copy:
35         ld      r7, @r1+            ||  addi    r3, #-1
36         st      r7, @+r4            ||  cmpz    r2
37         bnez    r3, word_copy
38         addi    r4, #4              ||  jc      r14     ; return if r2=0
39 #if defined(CONFIG_ISA_M32R2)
40 byte_copy:
41         ldb     r7, @r1             ||  addi    r1, #1
42         addi    r2, #-1             ||  stb     r7, @r4+
43         bnez    r2, byte_copy
44 #elif defined(CONFIG_ISA_M32R)
45 byte_copy:
46         ldb     r7, @r1             ||  addi    r1, #1
47         addi    r2, #-1             ||  stb     r7, @r4
48         addi    r4, #1
49         bnez    r2, byte_copy
50 #else
51 #error unknown isa configuration
52 #endif
53 end_memcopy:
54         jmp     r14
55
56 #else /* not CONFIG_ISA_DUAL_ISSUE */
57
58         .text
59 ENTRY(memcpy)
60 memcopy:
61         mv      r4, r0
62         mv      r7, r0
63         or      r7, r1
64         beq     r0, r1, end_memcopy
65         beqz    r2, end_memcopy
66
67         and3    r7, r7, #3
68         bnez    r7, byte_copy
69         srl3    r3, r2, #2
70         and3    r2, r2, #3
71         beqz    r3, byte_copy
72         addi    r4, #-4
73 word_copy:
74         ld      r7, @r1+
75         addi    r3, #-1
76         st      r7, @+r4
77         bnez    r3, word_copy
78         beqz    r2, end_memcopy
79         addi    r4, #4
80 byte_copy:
81         ldb     r7, @r1
82         addi    r1, #1
83         addi    r2, #-1
84         stb     r7, @r4
85         addi    r4, #1
86         bnez    r2, byte_copy
87 end_memcopy:
88         jmp     r14
89
90 #endif /* not CONFIG_ISA_DUAL_ISSUE */
91
92         .end