Move Altivec memcpy to altivec directory
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 10 Jan 2010 11:05:53 +0000 (13:05 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 10 Jan 2010 11:05:53 +0000 (13:05 +0200)
configure.ac
modules/Makefile.am
modules/altivec/.gitignore [new file with mode: 0644]
modules/altivec/Modules.am [new file with mode: 0644]
modules/altivec/memcpy.c [new file with mode: 0644]
modules/misc/Modules.am
modules/misc/memcpy/Modules.am [deleted file]
modules/misc/memcpy/memcpyaltivec.c [deleted file]
po/POTFILES.in

index 6713ead..ab8f249 100644 (file)
@@ -1546,6 +1546,7 @@ AC_ARG_ENABLE(altivec,
   AS_IF([test "${host_cpu}" = "powerpc"],
         [enable_altivec=yes], [enable_altivec=no])
 ])
+have_altivec="no"
 AS_IF([test "${enable_altivec}" = "yes"], [
   ARCH="${ARCH} altivec";
   AC_CACHE_CHECK([if $CC groks AltiVec inline assembly],
@@ -1568,7 +1569,7 @@ AS_IF([test "${enable_altivec}" = "yes"], [
       VLC_ADD_CFLAGS([i420_yuy2_altivec],[${ac_cv_altivec_inline}])
       VLC_ADD_CFLAGS([libvlccore],[${ac_cv_altivec_inline}])
     ])
-    VLC_ADD_PLUGIN([memcpyaltivec])
+    have_altivec="yes"
     VLC_ADD_PLUGIN([i420_yuy2_altivec])
   ])
 
@@ -1631,7 +1632,7 @@ dnl - Others: test should fail
     VLC_ADD_CFLAGS([libvlccore],[${ac_cv_c_altivec}])
     VLC_ADD_CFLAGS([idctaltivec motionaltivec],[${ac_cv_c_altivec}])
     VLC_ADD_CFLAGS([i420_yuy2_altivec memcpyaltivec deinterlace],[${ac_cv_c_altivec} ${ac_cv_c_altivec_abi}])
-    VLC_ADD_PLUGIN([memcpyaltivec])
+    have_altivec="yes"
     VLC_ADD_PLUGIN([i420_yuy2_altivec])
   ])
 
@@ -1645,6 +1646,7 @@ dnl - Others: test should fail
     VLC_ADD_LDFLAGS([libvlccore idctaltivec motionaltivec memcpyaltivec],[-Wl,-framework,vecLib])
   ])
 ])
+AM_CONDITIONAL([HAVE_ALTIVEC], [test "$have_altivec" = "yes"])
 
 dnl
 dnl  Special arch tuning
@@ -5179,7 +5181,6 @@ AC_CONFIG_FILES([
   modules/misc/Makefile
   modules/misc/dummy/Makefile
   modules/misc/lua/Makefile
-  modules/misc/memcpy/Makefile
   modules/misc/notify/Makefile
   modules/misc/testsuite/Makefile
   modules/misc/playlist/Makefile
@@ -5203,6 +5204,7 @@ AC_CONFIG_FILES([
   modules/mmx/Makefile
   modules/mmxext/Makefile
   modules/3dnow/Makefile
+  modules/altivec/Makefile
 ])
 
 dnl Generate makefiles
index bdc946a..4227439 100644 (file)
@@ -40,6 +40,9 @@ endif
 if HAVE_3DNOW
 SUBDIRS += 3dnow
 endif
+if HAVE_ALTIVEC
+SUBDIRS += altivec
+endif
 
 dist_noinst_SCRIPTS = genmf list.sh
 dist_noinst_DATA = LIST
diff --git a/modules/altivec/.gitignore b/modules/altivec/.gitignore
new file mode 100644 (file)
index 0000000..08a6d72
--- /dev/null
@@ -0,0 +1 @@
+Makefile.am
diff --git a/modules/altivec/Modules.am b/modules/altivec/Modules.am
new file mode 100644 (file)
index 0000000..c7a8d87
--- /dev/null
@@ -0,0 +1,8 @@
+libmemcpyaltivec_plugin_la_SOURCES = memcpy.c
+libmemcpyaltivec_plugin_la_CFLAGS = $(AM_CFLAGS)
+libmemcpyaltivec_plugin_la_LIBADD = $(AM_LIBADD)
+libmemcpyaltivec_plugin_la_DEPENDENCIES =
+
+libvlc_LTLIBRARIES += \
+       libmemcpyaltivec_plugin.la \
+       $(NULL)
diff --git a/modules/altivec/memcpy.c b/modules/altivec/memcpy.c
new file mode 100644 (file)
index 0000000..2d91ea2
--- /dev/null
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * memcpy.c : AltiVec memcpy module
+ *****************************************************************************
+ * Copyright (C) 2001 the VideoLAN team
+ * $Id$
+ *
+ * Author: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef __BUILD_ALTIVEC_ASM__
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_cpu.h>
+
+#ifdef HAVE_ALTIVEC_H
+#   include <altivec.h>
+#endif
+
+/*****************************************************************************
+ * Local prototypes.
+ *****************************************************************************/
+static void * fast_memcpy ( void * to, const void * from, size_t len );
+
+/*****************************************************************************
+ * Module initializer.
+ *****************************************************************************/
+static int Activate ( vlc_object_t *p_this )
+{
+    VLC_UNUSED(p_this);
+    vlc_fastmem_register( fast_memcpy, NULL );
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Module descriptor.
+ *****************************************************************************/
+vlc_module_begin ()
+    set_description( N_("AltiVec memcpy") )
+    set_category( CAT_ADVANCED )
+    set_subcategory( SUBCAT_ADVANCED_MISC )
+    set_capability( "memcpy", 100 )
+    set_callbacks( Activate, NULL )
+    add_shortcut( "altivec" )
+vlc_module_end ()
+
+#else
+typedef unsigned long size_t;
+#endif /* __BUILD_ALTIVEC_ASM__ */
+
+#if defined(CAN_COMPILE_C_ALTIVEC) || defined( __BUILD_ALTIVEC_ASM__ )
+
+#define vector_s16_t vector signed short
+#define vector_u16_t vector unsigned short
+#define vector_s8_t vector signed char
+#define vector_u8_t vector unsigned char
+#define vector_s32_t vector signed int
+#define vector_u32_t vector unsigned int
+#define MMREG_SIZE 16
+
+#define SMALL_MEMCPY(to, from, len)                                         \
+{                                                                           \
+    unsigned char * end = to + len;                                         \
+    while( to < end )                                                       \
+    {                                                                       \
+        *to++ = *from++;                                                    \
+    }                                                                       \
+}
+
+static void * fast_memcpy( void * _to, const void * _from, size_t len )
+{
+    void * retval = _to;
+    unsigned char * to = (unsigned char *)_to;
+    unsigned char * from = (unsigned char *)_from;
+
+    if( len > 16 )
+    {
+        /* Align destination to MMREG_SIZE -boundary */
+        register unsigned long int delta;
+
+        delta = ((unsigned long)to)&(MMREG_SIZE-1);
+        if( delta )
+        {
+            delta = MMREG_SIZE - delta;
+            len -= delta;
+            SMALL_MEMCPY(to, from, delta);
+        }
+
+        if( len & ~(MMREG_SIZE-1) )
+        {
+            vector_u8_t perm, ref0, ref1, tmp;
+
+            perm = vec_lvsl( 0, from );
+            ref0 = vec_ld( 0, from );
+            ref1 = vec_ld( 15, from );
+            from += 16;
+            len -= 16;
+            tmp = vec_perm( ref0, ref1, perm );
+            while( len & ~(MMREG_SIZE-1) )
+            {
+                ref0 = vec_ld( 0, from );
+                ref1 = vec_ld( 15, from );
+                from += 16;
+                len -= 16;
+                vec_st( tmp, 0, to );
+                tmp = vec_perm( ref0, ref1, perm );
+                to += 16;
+            }
+            vec_st( tmp, 0, to );
+            to += 16;
+        }
+    }
+
+    if( len )
+    {
+        SMALL_MEMCPY( to, from, len );
+    }
+
+    return retval;
+}
+
+#endif
+
+#if !defined(CAN_COMPILE_C_ALTIVEC) && !defined(__BUILD_ALTIVEC_ASM__)
+
+/*
+ * The asm code is generated with:
+ *
+ * gcc-2.95 -fvec -D__BUILD_ALTIVEC_ASM__ -O9 -fomit-frame-pointer -mregnames -S *      memcpyaltivec.c
+ *
+ * sed 's/.L/._L/g' memcpyaltivec.s |
+ * awk '{args=""; len=split ($2, arg, ",");
+ *      for (i=1; i<=len; i++) { a=arg[i]; if (i<len) a=a",";
+ *                               args = args sprintf ("%-6s", a) }
+ *      printf ("\t\"\t%-16s%-24s\\n\"\n", $1, args) }' |
+ * unexpand -a
+ */
+
+static void * fast_memcpy( void * _to, const void * _from, size_t len )
+{
+    asm ("                                              \n"
+    "    cmplwi        %cr0, %r5,  16        \n"
+    "    mr        %r9,  %r3        \n"
+    "    bc        4,    1,    ._L3    \n"
+    "    andi.        %r0,  %r3,  15        \n"
+    "    bc        12,   2,    ._L4    \n"
+    "    subfic        %r0,  %r0,  16        \n"
+    "    add        %r11, %r3,  %r0        \n"
+    "    cmplw        %cr0, %r3,  %r11    \n"
+    "    subf        %r5,  %r0,  %r5        \n"
+    "    bc        4,    0,    ._L4    \n"
+    "    ._L7:                    \n"
+    "    lbz        %r0,  0(%r4)        \n"
+    "    stb        %r0,  0(%r9)        \n"
+    "    addi        %r9,  %r9,  1        \n"
+    "    cmplw        %cr0, %r9,  %r11    \n"
+    "    addi        %r4,  %r4,  1        \n"
+    "    bc        12,   0,    ._L7    \n"
+    "    ._L4:                    \n"
+    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
+    "    bc        12,   2,    ._L3    \n"
+    "    addi        %r5,  %r5,  -16        \n"
+    "    li        %r11, 15        \n"
+    "    lvsl        %v12, 0,    %r4        \n"
+    "    lvx        %v1,  0,    %r4        \n"
+    "    lvx        %v0,  %r11, %r4        \n"
+    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
+    "    vperm        %v13, %v1,  %v0,  %v12    \n"
+    "    addi        %r4,  %r4,  16        \n"
+    "    bc        12,   2,    ._L11    \n"
+    "    ._L12:                    \n"
+    "    addi        %r5,  %r5,  -16        \n"
+    "    li        %r11, 15        \n"
+    "    lvx        %v1,  0,    %r4        \n"
+    "    lvx        %v0,  %r11, %r4        \n"
+    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
+    "    stvx        %v13, 0,    %r9        \n"
+    "    vperm        %v13, %v1,  %v0,  %v12    \n"
+    "    addi        %r4,  %r4,  16        \n"
+    "    addi        %r9,  %r9,  16        \n"
+    "    bc        4,    2,    ._L12    \n"
+    "    ._L11:                    \n"
+    "    stvx        %v13, 0,    %r9        \n"
+    "    addi        %r9,  %r9,  16        \n"
+    "    ._L3:                    \n"
+    "    cmpwi        %cr0, %r5,  0        \n"
+    "    bclr        12,   2            \n"
+    "    add        %r5,  %r9,  %r5        \n"
+    "    cmplw        %cr0, %r9,  %r5        \n"
+    "    bclr        4,    0            \n"
+    "    ._L17:                    \n"
+    "    lbz        %r0,  0(%r4)        \n"
+    "    stb        %r0,  0(%r9)        \n"
+    "    addi        %r9,  %r9,  1        \n"
+    "    cmplw        %cr0, %r9,  %r5        \n"
+    "    addi        %r4,  %r4,  1        \n"
+    "    bc        12,   0,    ._L17    \n"
+        );
+}
+
+#endif
index c63b4bd..364160e 100644 (file)
@@ -1,4 +1,4 @@
-BASE_SUBDIRS = dummy memcpy notify testsuite playlist stats osd xml
+BASE_SUBDIRS = dummy notify testsuite playlist stats osd xml
 EXTRA_SUBDIRS = lua
 
 SUBDIRS = $(BASE_SUBDIRS)
diff --git a/modules/misc/memcpy/Modules.am b/modules/misc/memcpy/Modules.am
deleted file mode 100644 (file)
index 5240b2a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-SOURCES_memcpyaltivec = \
-       memcpyaltivec.c \
-       $(NULL)
diff --git a/modules/misc/memcpy/memcpyaltivec.c b/modules/misc/memcpy/memcpyaltivec.c
deleted file mode 100644 (file)
index 2678fd4..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*****************************************************************************
- * memcpyaltivec.c : AltiVec memcpy module
- *****************************************************************************
- * Copyright (C) 2001 the VideoLAN team
- * $Id$
- *
- * Author: Christophe Massiot <massiot@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef __BUILD_ALTIVEC_ASM__
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc_common.h>
-#include <vlc_plugin.h>
-#include <vlc_cpu.h>
-
-#ifdef HAVE_ALTIVEC_H
-#   include <altivec.h>
-#endif
-
-/*****************************************************************************
- * Local prototypes.
- *****************************************************************************/
-static void * fast_memcpy ( void * to, const void * from, size_t len );
-
-/*****************************************************************************
- * Module initializer.
- *****************************************************************************/
-static int Activate ( vlc_object_t *p_this )
-{
-    VLC_UNUSED(p_this);
-    vlc_fastmem_register( fast_memcpy, NULL );
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Module descriptor.
- *****************************************************************************/
-vlc_module_begin ()
-    set_description( N_("AltiVec memcpy") )
-    set_category( CAT_ADVANCED )
-    set_subcategory( SUBCAT_ADVANCED_MISC )
-    add_requirement( ALTIVEC )
-    set_capability( "memcpy", 100 )
-    set_callbacks( Activate, NULL )
-    add_shortcut( "altivec" )
-vlc_module_end ()
-
-#else
-typedef unsigned long size_t;
-#endif /* __BUILD_ALTIVEC_ASM__ */
-
-#if defined(CAN_COMPILE_C_ALTIVEC) || defined( __BUILD_ALTIVEC_ASM__ )
-
-#define vector_s16_t vector signed short
-#define vector_u16_t vector unsigned short
-#define vector_s8_t vector signed char
-#define vector_u8_t vector unsigned char
-#define vector_s32_t vector signed int
-#define vector_u32_t vector unsigned int
-#define MMREG_SIZE 16
-
-#define SMALL_MEMCPY(to, from, len)                                         \
-{                                                                           \
-    unsigned char * end = to + len;                                         \
-    while( to < end )                                                       \
-    {                                                                       \
-        *to++ = *from++;                                                    \
-    }                                                                       \
-}
-
-static void * fast_memcpy( void * _to, const void * _from, size_t len )
-{
-    void * retval = _to;
-    unsigned char * to = (unsigned char *)_to;
-    unsigned char * from = (unsigned char *)_from;
-
-    if( len > 16 )
-    {
-        /* Align destination to MMREG_SIZE -boundary */
-        register unsigned long int delta;
-
-        delta = ((unsigned long)to)&(MMREG_SIZE-1);
-        if( delta )
-        {
-            delta = MMREG_SIZE - delta;
-            len -= delta;
-            SMALL_MEMCPY(to, from, delta);
-        }
-
-        if( len & ~(MMREG_SIZE-1) )
-        {
-            vector_u8_t perm, ref0, ref1, tmp;
-
-            perm = vec_lvsl( 0, from );
-            ref0 = vec_ld( 0, from );
-            ref1 = vec_ld( 15, from );
-            from += 16;
-            len -= 16;
-            tmp = vec_perm( ref0, ref1, perm );
-            while( len & ~(MMREG_SIZE-1) )
-            {
-                ref0 = vec_ld( 0, from );
-                ref1 = vec_ld( 15, from );
-                from += 16;
-                len -= 16;
-                vec_st( tmp, 0, to );
-                tmp = vec_perm( ref0, ref1, perm );
-                to += 16;
-            }
-            vec_st( tmp, 0, to );
-            to += 16;
-        }
-    }
-
-    if( len )
-    {
-        SMALL_MEMCPY( to, from, len );
-    }
-
-    return retval;
-}
-
-#endif
-
-#if !defined(CAN_COMPILE_C_ALTIVEC) && !defined(__BUILD_ALTIVEC_ASM__)
-
-/*
- * The asm code is generated with:
- *
- * gcc-2.95 -fvec -D__BUILD_ALTIVEC_ASM__ -O9 -fomit-frame-pointer -mregnames -S *      memcpyaltivec.c
- *
- * sed 's/.L/._L/g' memcpyaltivec.s |
- * awk '{args=""; len=split ($2, arg, ",");
- *      for (i=1; i<=len; i++) { a=arg[i]; if (i<len) a=a",";
- *                               args = args sprintf ("%-6s", a) }
- *      printf ("\t\"\t%-16s%-24s\\n\"\n", $1, args) }' |
- * unexpand -a
- */
-
-static void * fast_memcpy( void * _to, const void * _from, size_t len )
-{
-    asm ("                                              \n"
-    "    cmplwi        %cr0, %r5,  16        \n"
-    "    mr        %r9,  %r3        \n"
-    "    bc        4,    1,    ._L3    \n"
-    "    andi.        %r0,  %r3,  15        \n"
-    "    bc        12,   2,    ._L4    \n"
-    "    subfic        %r0,  %r0,  16        \n"
-    "    add        %r11, %r3,  %r0        \n"
-    "    cmplw        %cr0, %r3,  %r11    \n"
-    "    subf        %r5,  %r0,  %r5        \n"
-    "    bc        4,    0,    ._L4    \n"
-    "    ._L7:                    \n"
-    "    lbz        %r0,  0(%r4)        \n"
-    "    stb        %r0,  0(%r9)        \n"
-    "    addi        %r9,  %r9,  1        \n"
-    "    cmplw        %cr0, %r9,  %r11    \n"
-    "    addi        %r4,  %r4,  1        \n"
-    "    bc        12,   0,    ._L7    \n"
-    "    ._L4:                    \n"
-    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
-    "    bc        12,   2,    ._L3    \n"
-    "    addi        %r5,  %r5,  -16        \n"
-    "    li        %r11, 15        \n"
-    "    lvsl        %v12, 0,    %r4        \n"
-    "    lvx        %v1,  0,    %r4        \n"
-    "    lvx        %v0,  %r11, %r4        \n"
-    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
-    "    vperm        %v13, %v1,  %v0,  %v12    \n"
-    "    addi        %r4,  %r4,  16        \n"
-    "    bc        12,   2,    ._L11    \n"
-    "    ._L12:                    \n"
-    "    addi        %r5,  %r5,  -16        \n"
-    "    li        %r11, 15        \n"
-    "    lvx        %v1,  0,    %r4        \n"
-    "    lvx        %v0,  %r11, %r4        \n"
-    "    rlwinm.        %r0,  %r5,  0,      0,    27    \n"
-    "    stvx        %v13, 0,    %r9        \n"
-    "    vperm        %v13, %v1,  %v0,  %v12    \n"
-    "    addi        %r4,  %r4,  16        \n"
-    "    addi        %r9,  %r9,  16        \n"
-    "    bc        4,    2,    ._L12    \n"
-    "    ._L11:                    \n"
-    "    stvx        %v13, 0,    %r9        \n"
-    "    addi        %r9,  %r9,  16        \n"
-    "    ._L3:                    \n"
-    "    cmpwi        %cr0, %r5,  0        \n"
-    "    bclr        12,   2            \n"
-    "    add        %r5,  %r9,  %r5        \n"
-    "    cmplw        %cr0, %r9,  %r5        \n"
-    "    bclr        4,    0            \n"
-    "    ._L17:                    \n"
-    "    lbz        %r0,  0(%r4)        \n"
-    "    stb        %r0,  0(%r9)        \n"
-    "    addi        %r9,  %r9,  1        \n"
-    "    cmplw        %cr0, %r9,  %r5        \n"
-    "    addi        %r4,  %r4,  1        \n"
-    "    bc        12,   0,    ._L17    \n"
-        );
-}
-
-#endif
index 3b34867..e58d8b2 100644 (file)
@@ -310,6 +310,7 @@ modules/access_output/http.c
 modules/access_output/rtmp.c
 modules/access_output/shout.c
 modules/access_output/udp.c
+modules/altivec/memcpy.c
 modules/audio_filter/channel_mixer/dolby.c
 modules/audio_filter/channel_mixer/headphone.c
 modules/audio_filter/channel_mixer/mono.c
@@ -976,7 +977,6 @@ modules/misc/lua/libs/volume.c
 modules/misc/lua/meta.c
 modules/misc/lua/vlc.c
 modules/misc/lua/vlc.h
-modules/misc/memcpy/memcpyaltivec.c
 modules/misc/notify/growl.m
 modules/misc/notify/growl_udp.c
 modules/misc/notify/msn.c