2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / i586 / memcopy.h
blobd300d7c96e34f4acf62ec838679085455ede6a3b
1 /* memcopy.h -- definitions for memory copy functions. Pentium version.
2 Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Torbjorn Granlund (tege@sics.se).
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 /* Get the i386 definitions. We will override some of them below. */
22 #include <sysdeps/i386/memcopy.h>
24 /* Written like this, the Pentium pipeline can execute the loop at a
25 sustained rate of 2 instructions/clock, or asymptotically 480
26 Mbytes/second at 60Mhz. */
28 #undef WORD_COPY_FWD
29 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
30 do \
31 { \
32 asm volatile ("subl $32,%2\n" \
33 "js 2f\n" \
34 "movl 0(%0),%%edx\n" /* alloc dest line */ \
35 "1:\n" \
36 "movl 28(%0),%%eax\n" /* alloc dest line */ \
37 "subl $32,%2\n" /* decr loop count */ \
38 "movl 0(%1),%%eax\n" /* U pipe */ \
39 "movl 4(%1),%%edx\n" /* V pipe */ \
40 "movl %%eax,0(%0)\n" /* U pipe */ \
41 "movl %%edx,4(%0)\n" /* V pipe */ \
42 "movl 8(%1),%%eax\n" \
43 "movl 12(%1),%%edx\n" \
44 "movl %%eax,8(%0)\n" \
45 "movl %%edx,12(%0)\n" \
46 "movl 16(%1),%%eax\n" \
47 "movl 20(%1),%%edx\n" \
48 "movl %%eax,16(%0)\n" \
49 "movl %%edx,20(%0)\n" \
50 "movl 24(%1),%%eax\n" \
51 "movl 28(%1),%%edx\n" \
52 "movl %%eax,24(%0)\n" \
53 "movl %%edx,28(%0)\n" \
54 "leal 32(%1),%1\n" /* update src ptr */ \
55 "leal 32(%0),%0\n" /* update dst ptr */ \
56 "jns 1b\n" \
57 "2: addl $32,%2" : \
58 "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \
59 "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \
60 "ax", "dx"); \
61 } while (0)
63 #undef WORD_COPY_BWD
64 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
65 do \
66 { \
67 asm volatile ("subl $32,%2\n" \
68 "js 2f\n" \
69 "movl -4(%0),%%edx\n" \
70 "1:\n" \
71 "movl -32(%0),%%eax\n" \
72 "subl $32,%2\n" \
73 "movl -4(%1),%%eax\n" \
74 "movl -8(%1),%%edx\n" \
75 "movl %%eax,-4(%0)\n" \
76 "movl %%edx,-8(%0)\n" \
77 "movl -12(%1),%%eax\n" \
78 "movl -16(%1),%%edx\n" \
79 "movl %%eax,-12(%0)\n" \
80 "movl %%edx,-16(%0)\n" \
81 "movl -20(%1),%%eax\n" \
82 "movl -24(%1),%%edx\n" \
83 "movl %%eax,-20(%0)\n" \
84 "movl %%edx,-24(%0)\n" \
85 "movl -28(%1),%%eax\n" \
86 "movl -32(%1),%%edx\n" \
87 "movl %%eax,-28(%0)\n" \
88 "movl %%edx,-32(%0)\n" \
89 "leal -32(%1),%1\n" \
90 "leal -32(%0),%0\n" \
91 "jns 1b\n" \
92 "2: addl $32,%2" : \
93 "=r" (dst_ep), "=r" (src_ep), "=r" (nbytes_left) : \
94 "0" (dst_ep), "1" (src_ep), "2" (nbytes) : \
95 "ax", "dx"); \
96 } while (0)