[Mplayer-cvslog] CVS: main bswap.h, 1.4, 1.5 configure, 1.922, 1.923 cpudetect.c, 1.36, 1.37 cpudetect.h, 1.10, 1.11
Aurelien Jacobs CVS
syncmail at mplayerhq.hu
Thu Oct 21 13:55:22 CEST 2004
- Previous message: [Mplayer-cvslog] CVS: main/libvo vo_quartz.c,1.26,1.27
- Next message: [Mplayer-cvslog] CVS: main/libvo aclib.c, 1.12, 1.13 aclib_template.c, 1.9, 1.10 osd.c, 1.22, 1.23 osd_template.c, 1.21, 1.22
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
CVS change done by Aurelien Jacobs CVS
Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv9471
Modified Files:
bswap.h configure cpudetect.c cpudetect.h
Log Message:
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
Index: bswap.h
===================================================================
RCS file: /cvsroot/mplayer/main/bswap.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- bswap.h 27 Jul 2003 21:24:33 -0000 1.4
+++ bswap.h 21 Oct 2004 11:55:19 -0000 1.5
@@ -7,17 +7,23 @@
#include <inttypes.h>
-#ifdef ARCH_X86
-static inline unsigned short ByteSwap16(unsigned short x)
+#ifdef ARCH_X86_64
+# define LEGACY_REGS "=Q"
+#else
+# define LEGACY_REGS "=q"
+#endif
+
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
+static inline uint16_t ByteSwap16(uint16_t x)
{
__asm("xchgb %b0,%h0" :
- "=q" (x) :
+ LEGACY_REGS (x) :
"0" (x));
return x;
}
#define bswap_16(x) ByteSwap16(x)
-static inline unsigned int ByteSwap32(unsigned int x)
+static inline uint32_t ByteSwap32(uint32_t x)
{
#if __CPU__ > 386
__asm("bswap %0":
@@ -26,21 +32,28 @@
__asm("xchgb %b0,%h0\n"
" rorl $16,%0\n"
" xchgb %b0,%h0":
- "=q" (x) :
+ LEGACY_REGS (x) :
#endif
"0" (x));
return x;
}
#define bswap_32(x) ByteSwap32(x)
-static inline unsigned long long int ByteSwap64(unsigned long long int x)
+static inline uint64_t ByteSwap64(uint64_t x)
{
+#ifdef ARCH_X86_64
+ __asm("bswap %0":
+ "=r" (x) :
+ "0" (x));
+ return x;
+#else
register union { __extension__ uint64_t __ll;
uint32_t __l[2]; } __x;
asm("xchgl %0,%1":
"=r"(__x.__l[0]),"=r"(__x.__l[1]):
"0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
return __x.__ll;
+#endif
}
#define bswap_64(x) ByteSwap64(x)
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.922
retrieving revision 1.923
diff -u -r1.922 -r1.923
--- configure 20 Oct 2004 14:23:33 -0000 1.922
+++ configure 21 Oct 2004 11:55:19 -0000 1.923
@@ -456,7 +456,14 @@
case "`( uname -m ) 2>&1`" in
i[3-9]86*|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;
ia64) host_arch=ia64 ;;
- x86_64|amd64) host_arch=x86_64 ;;
+ x86_64|amd64)
+ if [ "`$_cc -dumpmachine | grep x86_64 | cut -d- -f1`" = "x86_64" -a \
+ -z "`echo $CFLAGS | grep -- -m32`" ]; then
+ host_arch=x86_64
+ else
+ host_arch=i386
+ fi
+ ;;
macppc|ppc) host_arch=ppc ;;
alpha) host_arch=alpha ;;
sparc) host_arch=sparc ;;
@@ -672,17 +679,8 @@
_cpuinfo="TOOLS/cpuinfo"
fi
-case "$host_arch" in
- i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
- _def_arch="#define ARCH_X86 1"
- _target_arch="TARGET_ARCH_X86 = yes"
-
- pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
- pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- pfamily=`$_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
- pstepping=`$_cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
-
+x86_exts_check()
+{
pparam=`$_cpuinfo | grep 'features' | cut -d ':' -f 2 | head -1`
if test -z "$pparam" ; then
pparam=`$_cpuinfo | grep 'flags' | cut -d ':' -f 2 | head -1`
@@ -707,6 +705,20 @@
sse2) _sse2=yes ;;
esac
done
+}
+
+case "$host_arch" in
+ i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
+ _def_arch="#define ARCH_X86 1"
+ _target_arch="TARGET_ARCH_X86 = yes"
+
+ pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
+ pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+ pfamily=`$_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+ pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+ pstepping=`$_cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
+
+ x86_exts_check
echocheck "CPU vendor"
echores "$pvendor ($pfamily:$pmodel:$pstepping)"
@@ -904,6 +916,7 @@
_march=''
_mcpu=''
_optimizing=''
+ x86_exts_check
;;
sparc)
Index: cpudetect.c
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- cpudetect.c 13 Oct 2004 09:37:32 -0000 1.36
+++ cpudetect.c 21 Oct 2004 11:55:19 -0000 1.37
@@ -9,7 +9,7 @@
#endif
#include <stdlib.h>
-#ifdef ARCH_X86
+#if defined(ARCH_X86) || defined(ARCH_X86_64)
#include <stdio.h>
#include <string.h>
@@ -47,25 +47,25 @@
// return TRUE if cpuid supported
static int has_cpuid()
{
- int a, c;
+ long a, c;
// code from libavcodec:
__asm__ __volatile__ (
/* See if CPUID instruction is supported ... */
/* ... Get copies of EFLAGS into eax and ecx */
"pushf\n\t"
- "popl %0\n\t"
- "movl %0, %1\n\t"
+ "pop %0\n\t"
+ "mov %0, %1\n\t"
/* ... Toggle the ID bit in one copy and store */
/* to the EFLAGS reg */
- "xorl $0x200000, %0\n\t"
+ "xor $0x200000, %0\n\t"
"push %0\n\t"
"popf\n\t"
/* ... Get the (hopefully modified) EFLAGS */
"pushf\n\t"
- "popl %0\n\t"
+ "pop %0\n\t"
: "=a" (a), "=c" (c)
:
: "cc"
@@ -87,9 +87,9 @@
#else
// code from libavcodec:
__asm __volatile
- ("movl %%ebx, %%esi\n\t"
+ ("mov %%"REG_b", %%"REG_S"\n\t"
"cpuid\n\t"
- "xchgl %%ebx, %%esi"
+ "xchg %%"REG_b", %%"REG_S
: "=a" (p[0]), "=S" (p[1]),
"=c" (p[2]), "=d" (p[3])
: "0" (ax));
@@ -456,7 +456,7 @@
gCpuCaps.hasSSE=0;
#endif /* __linux__ */
}
-#else /* ARCH_X86 */
+#else /* ARCH_X86 || ARCH_X86_64 */
#ifdef SYS_DARWIN
#include <sys/sysctl.h>
@@ -536,10 +536,6 @@
mp_msg(MSGT_CPUDETECT,MSGL_INFO,"CPU: Intel Itanium\n");
#endif
-#ifdef ARCH_X86_64
- mp_msg(MSGT_CPUDETECT,MSGL_INFO,"CPU: Advanced Micro Devices 64-bit CPU\n");
-#endif
-
#ifdef ARCH_SPARC
mp_msg(MSGT_CPUDETECT,MSGL_INFO,"CPU: Sun Sparc\n");
#endif
Index: cpudetect.h
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- cpudetect.h 19 Sep 2003 23:52:41 -0000 1.10
+++ cpudetect.h 21 Oct 2004 11:55:19 -0000 1.11
@@ -6,6 +6,32 @@
#define CPUTYPE_I586 5
#define CPUTYPE_I686 6
+#ifdef ARCH_X86_64
+# define REGa rax
+# define REGb rbx
+# define REGSP rsp
+# define REG_a "rax"
+# define REG_b "rbx"
+# define REG_c "rcx"
+# define REG_d "rdx"
+# define REG_S "rsi"
+# define REG_D "rdi"
+# define REG_SP "rsp"
+# define REG_BP "rbp"
+#else
+# define REGa eax
+# define REGb ebx
+# define REGSP esp
+# define REG_a "eax"
+# define REG_b "ebx"
+# define REG_c "ecx"
+# define REG_d "edx"
+# define REG_S "esi"
+# define REG_D "edi"
+# define REG_SP "esp"
+# define REG_BP "ebp"
+#endif
+
typedef struct cpucaps_s {
int cpuType;
int cpuStepping;
- Previous message: [Mplayer-cvslog] CVS: main/libvo vo_quartz.c,1.26,1.27
- Next message: [Mplayer-cvslog] CVS: main/libvo aclib.c, 1.12, 1.13 aclib_template.c, 1.9, 1.10 osd.c, 1.22, 1.23 osd_template.c, 1.21, 1.22
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list