ia64/xen-unstable

changeset 15744:8c77ae93f982

x86: Improved memcpy() asm implementation.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Fri Aug 10 15:01:09 2007 +0100 (2007-08-10)
parents 95f90f24f3b1
children 66a262700cf7
files xen/arch/x86/string.c
line diff
     1.1 --- a/xen/arch/x86/string.c	Thu Aug 09 16:21:41 2007 +0100
     1.2 +++ b/xen/arch/x86/string.c	Fri Aug 10 15:01:09 2007 +0100
     1.3 @@ -11,10 +11,18 @@
     1.4  #undef memcpy
     1.5  void *memcpy(void *dest, const void *src, size_t n)
     1.6  {
     1.7 -    int d0, d1, d2;
     1.8 +    long d0, d1, d2;
     1.9  
    1.10      __asm__ __volatile__ (
    1.11 -        "   rep ; movsl      ; "
    1.12 +#ifdef __i386__
    1.13 +        "   rep movsl        ; "
    1.14 +#else
    1.15 +        "   rep movsq        ; "
    1.16 +        "   testb $4,%b4     ; "
    1.17 +        "   je 0f            ; "
    1.18 +        "   movsl            ; "
    1.19 +        "0:                  ; "
    1.20 +#endif
    1.21          "   testb $2,%b4     ; "
    1.22          "   je 1f            ; "
    1.23          "   movsw            ; "
    1.24 @@ -23,7 +31,7 @@ void *memcpy(void *dest, const void *src
    1.25          "   movsb            ; "
    1.26          "2:                    "
    1.27          : "=&c" (d0), "=&D" (d1), "=&S" (d2)
    1.28 -        : "0" (n/4), "q" (n), "1" (dest), "2" (src)
    1.29 +        : "0" (n/sizeof(long)), "q" (n), "1" (dest), "2" (src)
    1.30          : "memory");
    1.31  
    1.32      return dest;
    1.33 @@ -32,10 +40,10 @@ void *memcpy(void *dest, const void *src
    1.34  #undef memset
    1.35  void *memset(void *s, int c, size_t n)
    1.36  {
    1.37 -    int d0, d1;
    1.38 +    long d0, d1;
    1.39  
    1.40      __asm__ __volatile__ (
    1.41 -        "rep ; stosb"
    1.42 +        "rep stosb"
    1.43          : "=&c" (d0), "=&D" (d1)
    1.44          : "a" (c), "1" (s), "0" (n)
    1.45          : "memory");
    1.46 @@ -46,14 +54,14 @@ void *memset(void *s, int c, size_t n)
    1.47  #undef memmove
    1.48  void *memmove(void *dest, const void *src, size_t n)
    1.49  {
    1.50 -    int d0, d1, d2;
    1.51 +    long d0, d1, d2;
    1.52   
    1.53      if ( dest < src )
    1.54          return memcpy(dest, src, n);
    1.55  
    1.56      __asm__ __volatile__ (
    1.57          "   std         ; "
    1.58 -        "   rep ; movsb ; "
    1.59 +        "   rep movsb   ; "
    1.60          "   cld           "
    1.61          : "=&c" (d0), "=&S" (d1), "=&D" (d2)
    1.62          : "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)