Blame sysdeps/i386/i586/memcopy.h

Packit 6c4009
/* memcopy.h -- definitions for memory copy functions.  Pentium version.
Packit 6c4009
   Copyright (C) 1994-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by Torbjorn Granlund (tege@sics.se).
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* Get the i386 definitions.  We will override some of them below.  */
Packit 6c4009
#include <sysdeps/i386/memcopy.h>
Packit 6c4009
Packit 6c4009
/* Written like this, the Pentium pipeline can execute the loop at a
Packit 6c4009
   sustained rate of 2 instructions/clock, or asymptotically 480
Packit 6c4009
   Mbytes/second at 60Mhz.  */
Packit 6c4009
Packit 6c4009
#undef	WORD_COPY_FWD
Packit 6c4009
#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)		\
Packit 6c4009
  do									\
Packit 6c4009
    {									\
Packit 6c4009
      asm volatile ("subl	$32,%2\n"				\
Packit 6c4009
		    "js		2f\n"					\
Packit 6c4009
		    "movl	0(%0),%%edx\n"	/* alloc dest line */	\
Packit 6c4009
		    "1:\n"						\
Packit 6c4009
		    "movl	28(%0),%%eax\n"	/* alloc dest line */	\
Packit 6c4009
		    "subl	$32,%2\n"	/* decr loop count */	\
Packit 6c4009
		    "movl	0(%1),%%eax\n"	/* U pipe */		\
Packit 6c4009
		    "movl	4(%1),%%edx\n"	/* V pipe */		\
Packit 6c4009
		    "movl	%%eax,0(%0)\n"	/* U pipe */		\
Packit 6c4009
		    "movl	%%edx,4(%0)\n"	/* V pipe */		\
Packit 6c4009
		    "movl	8(%1),%%eax\n"				\
Packit 6c4009
		    "movl	12(%1),%%edx\n"				\
Packit 6c4009
		    "movl	%%eax,8(%0)\n"				\
Packit 6c4009
		    "movl	%%edx,12(%0)\n"				\
Packit 6c4009
		    "movl	16(%1),%%eax\n"				\
Packit 6c4009
		    "movl	20(%1),%%edx\n"				\
Packit 6c4009
		    "movl	%%eax,16(%0)\n"				\
Packit 6c4009
		    "movl	%%edx,20(%0)\n"				\
Packit 6c4009
		    "movl	24(%1),%%eax\n"				\
Packit 6c4009
		    "movl	28(%1),%%edx\n"				\
Packit 6c4009
		    "movl	%%eax,24(%0)\n"				\
Packit 6c4009
		    "movl	%%edx,28(%0)\n"				\
Packit 6c4009
		    "leal	32(%1),%1\n"	/* update src ptr */	\
Packit 6c4009
		    "leal	32(%0),%0\n"	/* update dst ptr */	\
Packit 6c4009
		    "jns	1b\n"					\
Packit 6c4009
		    "2: addl	$32,%2" :				\
Packit 6c4009
		    "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) :	\
Packit 6c4009
		    "0" (dst_bp), "1" (src_bp), "2" (nbytes) :		\
Packit 6c4009
		    "ax", "dx");					\
Packit 6c4009
    } while (0)
Packit 6c4009
Packit 6c4009
#undef	WORD_COPY_BWD
Packit 6c4009
#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes)		\
Packit 6c4009
  do									\
Packit 6c4009
    {									\
Packit 6c4009
      asm volatile ("subl	$32,%2\n"				\
Packit 6c4009
		    "js		2f\n"					\
Packit 6c4009
		    "movl	-4(%0),%%edx\n"				\
Packit 6c4009
		    "1:\n"						\
Packit 6c4009
		    "movl	-32(%0),%%eax\n"			\
Packit 6c4009
		    "subl	$32,%2\n"				\
Packit 6c4009
		    "movl	-4(%1),%%eax\n"				\
Packit 6c4009
		    "movl	-8(%1),%%edx\n"				\
Packit 6c4009
		    "movl	%%eax,-4(%0)\n"				\
Packit 6c4009
		    "movl	%%edx,-8(%0)\n"				\
Packit 6c4009
		    "movl	-12(%1),%%eax\n"			\
Packit 6c4009
		    "movl	-16(%1),%%edx\n"			\
Packit 6c4009
		    "movl	%%eax,-12(%0)\n"			\
Packit 6c4009
		    "movl	%%edx,-16(%0)\n"			\
Packit 6c4009
		    "movl	-20(%1),%%eax\n"			\
Packit 6c4009
		    "movl	-24(%1),%%edx\n"			\
Packit 6c4009
		    "movl	%%eax,-20(%0)\n"			\
Packit 6c4009
		    "movl	%%edx,-24(%0)\n"			\
Packit 6c4009
		    "movl	-28(%1),%%eax\n"			\
Packit 6c4009
		    "movl	-32(%1),%%edx\n"			\
Packit 6c4009
		    "movl	%%eax,-28(%0)\n"			\
Packit 6c4009
		    "movl	%%edx,-32(%0)\n"			\
Packit 6c4009
		    "leal	-32(%1),%1\n"				\
Packit 6c4009
		    "leal	-32(%0),%0\n"				\
Packit 6c4009
		    "jns	1b\n"					\
Packit 6c4009
		    "2: addl	$32,%2" :				\
Packit 6c4009
		    "=r" (dst_ep), "=r" (src_ep), "=r" (nbytes_left) :	\
Packit 6c4009
		    "0" (dst_ep), "1" (src_ep), "2" (nbytes) :		\
Packit 6c4009
		    "ax", "dx");					\
Packit 6c4009
    } while (0)