358
|
1 /*
|
|
2 This part of code was taken by from Linux-2.4.3 and slightly modified
|
|
3 for MMX2 instruction set. I have done it since linux uses page aligned
|
|
4 blocks but mplayer uses weakly ordered data and original sources can not
|
|
5 speedup their. Only using prefetch and movntq together have effect!
|
|
6 If you have questions please contact with me: Nick Kurshev: nickols_k@mail.ru.
|
|
7 */
|
|
8
|
|
9 #ifndef HAVE_MMX2
|
|
10 //static inline void * __memcpy(void * to, const void * from, unsigned n)
|
|
11 inline static void * memcpy(void * to, const void * from, unsigned n)
|
|
12 {
|
|
13 int d0, d1, d2;
|
|
14 __asm__ __volatile__(
|
|
15 "rep ; movsl\n\t"
|
|
16 "testb $2,%b4\n\t"
|
|
17 "je 1f\n\t"
|
|
18 "movsw\n"
|
|
19 "1:\ttestb $1,%b4\n\t"
|
|
20 "je 2f\n\t"
|
|
21 "movsb\n"
|
|
22 "2:"
|
|
23 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
|
24 :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
|
|
25 : "memory");
|
|
26 return (to);
|
|
27 }
|
|
28 #else
|
|
29 //inline static void *__memcpy_mmx2(void *to, const void *from, unsigned len)
|
|
30 inline static void * memcpy(void * to, const void * from, unsigned n)
|
|
31 {
|
|
32 void *p;
|
|
33 int i;
|
|
34
|
|
35 if(len >= 0x200) /* 512-byte blocks */
|
|
36 {
|
|
37 p = to;
|
|
38 i = len >> 6; /* len/64 */
|
|
39 __asm__ __volatile__ (
|
|
40 "1: prefetch (%0)\n" /* This set is 28 bytes */
|
|
41 " prefetch 64(%0)\n"
|
|
42 " prefetch 128(%0)\n"
|
|
43 " prefetch 192(%0)\n"
|
|
44 " prefetch 256(%0)\n"
|
|
45 "2: \n"
|
|
46 ".section .fixup, \"ax\"\n"
|
|
47 "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
|
|
48 " jmp 2b\n"
|
|
49 ".previous\n"
|
|
50 ".section __ex_table,\"a\"\n"
|
|
51 " .align 4\n"
|
|
52 " .long 1b, 3b\n"
|
|
53 ".previous"
|
|
54 : : "r" (from) );
|
|
55
|
|
56
|
|
57 for(; i>0; i--)
|
|
58 {
|
|
59 __asm__ __volatile__ (
|
|
60 "1: prefetch 320(%0)\n"
|
|
61 "2: movq (%0), %%mm0\n"
|
|
62 " movq 8(%0), %%mm1\n"
|
|
63 " movq 16(%0), %%mm2\n"
|
|
64 " movq 24(%0), %%mm3\n"
|
|
65 " movntq %%mm0, (%1)\n"
|
|
66 " movntq %%mm1, 8(%1)\n"
|
|
67 " movntq %%mm2, 16(%1)\n"
|
|
68 " movntq %%mm3, 24(%1)\n"
|
|
69 " movq 32(%0), %%mm0\n"
|
|
70 " movq 40(%0), %%mm1\n"
|
|
71 " movq 48(%0), %%mm2\n"
|
|
72 " movq 56(%0), %%mm3\n"
|
|
73 " movntq %%mm0, 32(%1)\n"
|
|
74 " movntq %%mm1, 40(%1)\n"
|
|
75 " movntq %%mm2, 48(%1)\n"
|
|
76 " movntq %%mm3, 56(%1)\n"
|
|
77 ".section .fixup, \"ax\"\n"
|
|
78 "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
|
|
79 " jmp 2b\n"
|
|
80 ".previous\n"
|
|
81 ".section __ex_table,\"a\"\n"
|
|
82 " .align 4\n"
|
|
83 " .long 1b, 3b\n"
|
|
84 ".previous"
|
|
85 : : "r" (from), "r" (to) : "memory");
|
|
86 from+=64;
|
|
87 to+=64;
|
|
88 }
|
|
89 __asm__ __volatile__ ("emms":::"memory");
|
|
90 }
|
|
91 /*
|
|
92 * Now do the tail of the block
|
|
93 */
|
|
94 __memcpy(to, from, len&63);
|
|
95 return p;
|
|
96 }
|
|
97 #endif
|
|
98
|