Remove obsolete #include <linux/config.h>
[linux-2.6.git] / 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 /* $Id$ */
14
15
16         .text
17 #include <linux/linkage.h>
18 #include <asm/assembler.h>
19
20 #ifdef CONFIG_ISA_DUAL_ISSUE
21
22         .text
23 ENTRY(memcpy)
24 memcopy:
25         mv      r4, r0              ||  mv      r7, r0
26         or      r7, r1              ||  cmpz    r2
27         jc      r14                 ||  cmpeq   r0, r1  ; return if r2=0
28         jc      r14                                     ; return if r0=r1
29
30         and3    r7, r7, #3
31         bnez    r7, byte_copy
32         srl3    r3, r2, #2
33         and3    r2, r2, #3
34         beqz    r3, byte_copy
35         addi    r4, #-4
36 word_copy:
37         ld      r7, @r1+            ||  addi    r3, #-1
38         st      r7, @+r4            ||  cmpz    r2
39         bnez    r3, word_copy
40         addi    r4, #4              ||  jc      r14     ; return if r2=0
41 #if defined(CONFIG_ISA_M32R2)
42 byte_copy:
43         ldb     r7, @r1             ||  addi    r1, #1
44         addi    r2, #-1             ||  stb     r7, @r4+
45         bnez    r2, byte_copy
46 #elif defined(CONFIG_ISA_M32R)
47 byte_copy:
48         ldb     r7, @r1             ||  addi    r1, #1
49         addi    r2, #-1             ||  stb     r7, @r4
50         addi    r4, #1
51         bnez    r2, byte_copy
52 #else
53 #error unknown isa configuration
54 #endif
55 end_memcopy:
56         jmp     r14
57
58 #else /* not CONFIG_ISA_DUAL_ISSUE */
59
60         .text
61 ENTRY(memcpy)
62 memcopy:
63         mv      r4, r0
64         mv      r7, r0
65         or      r7, r1
66         beq     r0, r1, end_memcopy
67         beqz    r2, end_memcopy
68
69         and3    r7, r7, #3
70         bnez    r7, byte_copy
71         srl3    r3, r2, #2
72         and3    r2, r2, #3
73         beqz    r3, byte_copy
74         addi    r4, #-4
75 word_copy:
76         ld      r7, @r1+
77         addi    r3, #-1
78         st      r7, @+r4
79         bnez    r3, word_copy
80         beqz    r2, end_memcopy
81         addi    r4, #4
82 byte_copy:
83         ldb     r7, @r1
84         addi    r1, #1
85         addi    r2, #-1
86         stb     r7, @r4
87         addi    r4, #1
88         bnez    r2, byte_copy
89 end_memcopy:
90         jmp     r14
91
92 #endif /* not CONFIG_ISA_DUAL_ISSUE */
93
94         .end