Commit 928d731d authored by Christophe Massiot's avatar Christophe Massiot

Fixed altivec memcpy module [OS X port]

parent dd5d92a4
......@@ -95,6 +95,7 @@ LIB_KDE = @LIB_KDE@
LIB_LIRC = @LIB_LIRC@
LIB_MACOSX = @LIB_MACOSX@
LIB_MAD = @LIB_MAD@
LIB_MEMCPYALTIVEC = @LIB_MEMCPYALTIVEC@
LIB_MOTIONALTIVEC = @LIB_MOTIONALTIVEC@
LIB_MPEG_TS = @LIB_MPEG_TS@
LIB_NCURSES = @LIB_NCURSES@
......@@ -126,6 +127,7 @@ CFLAGS_KDE = @CFLAGS_KDE@
CFLAGS_IDCTALTIVEC = @CFLAGS_IDCTALTIVEC@
CFLAGS_MACOSX = @CFLAGS_MACOSX@
CFLAGS_MAD = @CFLAGS_MAD@
CFLAGS_MEMCPYALTIVEC = @CFLAGS_MEMCPYALTIVEC@
CFLAGS_MOTIONALTIVEC = @CFLAGS_MOTIONALTIVEC@
CFLAGS_QT = @CFLAGS_QT@
CFLAGS_SDL = @CFLAGS_SDL@
......
This diff is collapsed.
......@@ -383,7 +383,7 @@ THREEDNOW_MODULES="memcpy3dn imdct3dn downmix3dn"
if test x$SYS != xmingw32; then
SSE_MODULES="imdctsse downmixsse"
fi
ALTIVEC_MODULES="idctaltivec motionaltivec memcpyaltivec"
ALTIVEC_MODULES="idctaltivec motionaltivec"
AC_CACHE_CHECK([if \$CC groks MMX inline assembly],
[ac_cv_mmx_inline],
......@@ -461,8 +461,9 @@ if test x"$ac_cv_c_altivec" != x"no"; then
AC_DEFINE(CAN_COMPILE_C_ALTIVEC, 1, Define if your compiler groks C altivec extensions.)
CFLAGS_IDCTALTIVEC="$CFLAGS_IDCTALTIVEC $ac_cv_c_altivec"
CFLAGS_MOTIONALTIVEC="$CFLAGS_MOTIONALTIVEC $ac_cv_c_altivec"
CFLAGS_MEMCPYALTIVEC="$CFLAGS_MEMCPYALTIVEC $ac_cv_c_altivec"
CFLAGS_VLC="$CFLAGS_VLC $ac_cv_c_altivec"
ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES}"
ACCEL_MODULES="${ACCEL_MODULES} ${ALTIVEC_MODULES} memcpyaltivec"
fi
AC_CACHE_CHECK([if linker needs -framework vecLib],
......@@ -475,6 +476,7 @@ AC_CACHE_CHECK([if linker needs -framework vecLib],
if test x"$ac_cv_ld_altivec" != x"no"; then
LIB_IDCTALTIVEC="${LIB_IDCTALTIVEC} -framework vecLib"
LIB_MOTIONALTIVEC="${LIB_MOTIONALTIVEC} -framework vecLib"
LIB_MEMCPYALTIVEC="${LIB_MEMCPYALTIVEC} -framework vecLib"
LIB_VLC="${LIB_VLC} -framework vecLib"
fi
fi # end if mingw32
......@@ -1458,6 +1460,7 @@ AC_SUBST(LIB_KDE)
AC_SUBST(LIB_LIRC)
AC_SUBST(LIB_MACOSX)
AC_SUBST(LIB_MAD)
AC_SUBST(LIB_MEMCPYALTIVEC)
AC_SUBST(LIB_MOTIONALTIVEC)
AC_SUBST(LIB_MPEG_TS)
AC_SUBST(LIB_NCURSES)
......@@ -1486,6 +1489,7 @@ AC_SUBST(CFLAGS_KDE)
AC_SUBST(CFLAGS_IDCTALTIVEC)
AC_SUBST(CFLAGS_MACOSX)
AC_SUBST(CFLAGS_MAD)
AC_SUBST(CFLAGS_MEMCPYALTIVEC)
AC_SUBST(CFLAGS_MOTIONALTIVEC)
AC_SUBST(CFLAGS_OPTIM)
AC_SUBST(CFLAGS_OPTIM_NODEBUG)
......
......@@ -2,4 +2,4 @@ memcpy_SOURCES = memcpy.c
memcpymmx_SOURCES = memcpy.c
memcpymmxext_SOURCES = memcpy.c
memcpy3dn_SOURCES = memcpy.c
memcpyaltivec_SOURCES = memcpy.c
memcpyaltivec_SOURCES = memcpyaltivec.c
/*****************************************************************************
* fastmemcpy.h : fast memcpy routines
*****************************************************************************
* $Id: fastmemcpy.h,v 1.2 2002/04/02 22:16:07 massiot Exp $
* $Id: fastmemcpy.h,v 1.3 2002/04/03 22:36:50 massiot Exp $
*
* Authors: various Linux kernel hackers
* various MPlayer hackers
* Nick Kurshev <nickols_k@mail.ru>
* Christophe Massiot <massiot@via.ecp.fr> (Altivec)
*
* 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
......@@ -383,71 +382,3 @@ void * _M( fast_memcpy )(void * to, const void * from, size_t len)
#endif /* #if defined( HAVE_MMX2 ) || defined( HAVE_3DNOW ) || defined( HAVE_MMX ) */
#ifdef HAVE_ALTIVEC
# 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
#undef MMREG_SIZE
#define MMREG_SIZE 16
void * _M( fast_memcpy )(void * _to, const void * _from, size_t len)
{
void * retval = _to;
u8 * to = (u8 *)_to;
u8 * from = (u8 *)_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;
memcpy(to, from, delta);
to += delta;
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 );
do
{
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;
} while( len & ~(MMREG_SIZE-1) );
vec_st( tmp, 0, to );
}
}
if( len )
{
memcpy( to, from, len );
}
return retval;
}
# endif
#endif
......@@ -2,7 +2,7 @@
* memcpy.c : classic memcpy module
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: memcpy.c,v 1.6 2002/04/02 22:16:07 massiot Exp $
* $Id: memcpy.c,v 1.7 2002/04/03 22:36:50 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -45,9 +45,6 @@
#elif defined( MODULE_NAME_IS_memcpymmxext )
# define HAVE_MMX2
# include "fastmemcpy.h"
#elif defined( MODULE_NAME_IS_memcpyaltivec )
# define HAVE_ALTIVEC
# include "fastmemcpy.h"
#endif
/*****************************************************************************
......@@ -91,12 +88,6 @@ MODULE_INIT_START
ADD_REQUIREMENT( MMXEXT )
ADD_SHORTCUT( "mmxext" )
ADD_SHORTCUT( "memcpymmxext" )
#elif defined( MODULE_NAME_IS_memcpyaltivec )
SET_DESCRIPTION( "Altivec memcpy module" )
ADD_CAPABILITY( MEMCPY, 100 )
ADD_REQUIREMENT( ALTIVEC )
ADD_SHORTCUT( "altivec" )
ADD_SHORTCUT( "memcpyaltivec" )
#endif
MODULE_INIT_STOP
......
/*****************************************************************************
* memcpy.c : classic memcpy module
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: memcpyaltivec.c,v 1.1 2002/04/03 22:36:50 massiot Exp $
*
* Authors: 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef __BUILD_ALTIVEC_ASM__
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <videolan/vlc.h>
/*****************************************************************************
* Local and extern prototypes.
*****************************************************************************/
static void memcpy_getfunctions( function_list_t * p_function_list );
void * _M( fast_memcpy ) ( void * to, const void * from, size_t len );
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "Altivec memcpy module" )
ADD_CAPABILITY( MEMCPY, 100 )
ADD_REQUIREMENT( ALTIVEC )
ADD_SHORTCUT( "altivec" )
ADD_SHORTCUT( "memcpyaltivec" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
memcpy_getfunctions( &p_module->p_functions->memcpy );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/* Following functions are local */
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
static void memcpy_getfunctions( function_list_t * p_function_list )
{
p_function_list->functions.memcpy.pf_memcpy = _M( fast_memcpy );
}
#else
# include <sys/types.h>
# define _M( toto ) toto
#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
void * _M( 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;
memcpy(to, from, delta);
to += delta;
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 );
do
{
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;
} while( len & ~(MMREG_SIZE-1) );
vec_st( tmp, 0, to );
}
}
if( len )
{
memcpy( to, from, len );
}
return retval;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment