This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / sh64 / lib / page_copy.S
1 /*
2    Copyright 2003 Richard Curnow, SuperH (UK) Ltd.
3
4    This file is subject to the terms and conditions of the GNU General Public
5    License.  See the file "COPYING" in the main directory of this archive
6    for more details.
7
8    Tight version of mempy for the case of just copying a page.
9    Prefetch strategy empirically optimised against RTL simulations
10    of SH5-101 cut2 eval chip with Cayman board DDR memory.
11
12    Parameters:
13    r2 : source effective address (start of page)
14    r3 : destination effective address (start of page)
15
16    Always copies 4096 bytes.
17
18    Points to review.
19    * Currently the prefetch is 4 lines ahead and the alloco is 2 lines ahead.
20      It seems like the prefetch needs to be at at least 4 lines ahead to get
21      the data into the cache in time, and the allocos contend with outstanding
22      prefetches for the same cache set, so it's better to have the numbers
23      different.
24    */
25
26         .section .text..SHmedia32,"ax"
27         .little
28
29         .balign 8
30         .global sh64_page_copy
31 sh64_page_copy:
32
33         /* Copy 4096 bytes worth of data from r2 to r3.
34            Do prefetches 4 lines ahead.
35            Do alloco 2 lines ahead */
36
37         pta 1f, tr1
38         pta 2f, tr2
39         pta 3f, tr3
40         ptabs r18, tr0
41
42         ld.q r2, 0x00, r63
43         ld.q r2, 0x20, r63
44         ld.q r2, 0x40, r63
45         ld.q r2, 0x60, r63
46         alloco r3, 0x00
47         alloco r3, 0x20
48
49         movi 3968, r6
50         add  r3, r6, r6
51         addi r6, 64, r7
52         addi r7, 64, r8
53         sub r2, r3, r60
54         addi r60, 8, r61
55         addi r61, 8, r62
56         addi r62, 8, r23
57         addi r60, 0x80, r22
58
59 /* Minimal code size.  The extra branches inside the loop don't cost much
60    because they overlap with the time spent waiting for prefetches to
61    complete. */
62 1:
63         bge/u r3, r6, tr2  ! skip prefetch for last 4 lines
64         ldx.q r3, r22, r63 ! prefetch 4 lines hence
65 2:
66         bge/u r3, r7, tr3  ! skip alloco for last 2 lines
67         alloco r3, 0x40    ! alloc destination line 2 lines ahead
68 3:
69         ldx.q r3, r60, r36
70         ldx.q r3, r61, r37
71         ldx.q r3, r62, r38
72         ldx.q r3, r23, r39
73         st.q  r3,   0, r36
74         st.q  r3,   8, r37
75         st.q  r3,  16, r38
76         st.q  r3,  24, r39
77         addi r3, 32, r3
78         bgt/l r8, r3, tr1
79
80         blink tr0, r63     ! return
81
82