Mercurial > libavcodec.hg
annotate i386/cputest.c @ 3886:e96794bc2b0a libavcodec
Original Commit: r86 | ods15 | 2006-09-29 21:08:42 +0300 (Fri, 29 Sep 2006) | 2 lines
make put_vector ignore unused codebook entries
author | ods15 |
---|---|
date | Mon, 02 Oct 2006 06:08:48 +0000 |
parents | c537a97eec66 |
children | edacbbf46a19 |
rev | line source |
---|---|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
1 /* |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
2 * CPU detection code, extracted from mmx.h |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
3 * (c)1997-99 by H. Dietz and R. Fisher |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
4 * Converted to C and improved by Fabrice Bellard. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
5 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
6 * This library is free software; you can redistribute it and/or |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
9 * version 2 of the License, or (at your option) any later version. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
10 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
14 * Lesser General Public License for more details. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
15 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
17 * License along with this library; if not, write to the Free Software |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
3279
diff
changeset
|
19 */ |
0 | 20 |
21 #include <stdlib.h> | |
22 #include "../dsputil.h" | |
23 | |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
24 #ifdef ARCH_X86_64 |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
25 # define REG_b "rbx" |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
26 # define REG_S "rsi" |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
27 #else |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
28 # define REG_b "ebx" |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
29 # define REG_S "esi" |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
30 #endif |
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
31 |
22
c31fb57d17a6
Suppressing external gas stuff to improve portability to Win32
nickols_k
parents:
16
diff
changeset
|
32 /* ebx saving is necessary for PIC. gcc seems unable to see it alone */ |
c31fb57d17a6
Suppressing external gas stuff to improve portability to Win32
nickols_k
parents:
16
diff
changeset
|
33 #define cpuid(index,eax,ebx,ecx,edx)\ |
43 | 34 __asm __volatile\ |
2979 | 35 ("mov %%"REG_b", %%"REG_S"\n\t"\ |
22
c31fb57d17a6
Suppressing external gas stuff to improve portability to Win32
nickols_k
parents:
16
diff
changeset
|
36 "cpuid\n\t"\ |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
37 "xchg %%"REG_b", %%"REG_S\ |
22
c31fb57d17a6
Suppressing external gas stuff to improve portability to Win32
nickols_k
parents:
16
diff
changeset
|
38 : "=a" (eax), "=S" (ebx),\ |
c31fb57d17a6
Suppressing external gas stuff to improve portability to Win32
nickols_k
parents:
16
diff
changeset
|
39 "=c" (ecx), "=d" (edx)\ |
43 | 40 : "0" (index)); |
0 | 41 |
42 /* Function to test if multimedia instructions are supported... */ | |
43 int mm_support(void) | |
44 { | |
2377
9214c91cdfb7
detect sse on athlon-xp patch by (matthieu castet <castet >.< matthieu >at< free >.< fr>)
michael
parents:
2300
diff
changeset
|
45 int rval = 0; |
0 | 46 int eax, ebx, ecx, edx; |
2388 | 47 int max_std_level, max_ext_level, std_caps=0, ext_caps=0; |
2300
40542ea560d5
gcc 3.4.3 preversions do not appreciate invalid instruction and operand combinations anymore patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2293
diff
changeset
|
48 long a, c; |
2967 | 49 |
0 | 50 __asm__ __volatile__ ( |
51 /* See if CPUID instruction is supported ... */ | |
52 /* ... Get copies of EFLAGS into eax and ecx */ | |
53 "pushf\n\t" | |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
54 "pop %0\n\t" |
2300
40542ea560d5
gcc 3.4.3 preversions do not appreciate invalid instruction and operand combinations anymore patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2293
diff
changeset
|
55 "mov %0, %1\n\t" |
2967 | 56 |
0 | 57 /* ... Toggle the ID bit in one copy and store */ |
58 /* to the EFLAGS reg */ | |
2300
40542ea560d5
gcc 3.4.3 preversions do not appreciate invalid instruction and operand combinations anymore patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2293
diff
changeset
|
59 "xor $0x200000, %0\n\t" |
0 | 60 "push %0\n\t" |
61 "popf\n\t" | |
2967 | 62 |
0 | 63 /* ... Get the (hopefully modified) EFLAGS */ |
64 "pushf\n\t" | |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2129
diff
changeset
|
65 "pop %0\n\t" |
2300
40542ea560d5
gcc 3.4.3 preversions do not appreciate invalid instruction and operand combinations anymore patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2293
diff
changeset
|
66 : "=a" (a), "=c" (c) |
0 | 67 : |
2967 | 68 : "cc" |
0 | 69 ); |
2967 | 70 |
2300
40542ea560d5
gcc 3.4.3 preversions do not appreciate invalid instruction and operand combinations anymore patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
2293
diff
changeset
|
71 if (a == c) |
0 | 72 return 0; /* CPUID not supported */ |
2388 | 73 |
74 cpuid(0, max_std_level, ebx, ecx, edx); | |
75 | |
76 if(max_std_level >= 1){ | |
77 cpuid(1, eax, ebx, ecx, std_caps); | |
78 if (std_caps & (1<<23)) | |
79 rval |= MM_MMX; | |
2967 | 80 if (std_caps & (1<<25)) |
2388 | 81 rval |= MM_MMXEXT | MM_SSE; |
2967 | 82 if (std_caps & (1<<26)) |
2388 | 83 rval |= MM_SSE2; |
3279
647a677c00a4
Remove unused and unsupported Cyrix's "Extended MMX",
gpoirier
parents:
2979
diff
changeset
|
84 if (ecx & 1) |
647a677c00a4
Remove unused and unsupported Cyrix's "Extended MMX",
gpoirier
parents:
2979
diff
changeset
|
85 rval |= MM_SSE3; |
2388 | 86 } |
0 | 87 |
2388 | 88 cpuid(0x80000000, max_ext_level, ebx, ecx, edx); |
89 | |
90 if(max_ext_level >= 0x80000001){ | |
91 cpuid(0x80000001, eax, ebx, ecx, ext_caps); | |
92 if (ext_caps & (1<<31)) | |
93 rval |= MM_3DNOW; | |
94 if (ext_caps & (1<<30)) | |
95 rval |= MM_3DNOWEXT; | |
96 if (ext_caps & (1<<23)) | |
97 rval |= MM_MMX; | |
3279
647a677c00a4
Remove unused and unsupported Cyrix's "Extended MMX",
gpoirier
parents:
2979
diff
changeset
|
98 if (ext_caps & (1<<22)) |
647a677c00a4
Remove unused and unsupported Cyrix's "Extended MMX",
gpoirier
parents:
2979
diff
changeset
|
99 rval |= MM_MMXEXT; |
2388 | 100 } |
101 | |
102 #if 0 | |
2967 | 103 av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s\n", |
104 (rval&MM_MMX) ? "MMX ":"", | |
105 (rval&MM_MMXEXT) ? "MMX2 ":"", | |
106 (rval&MM_SSE) ? "SSE ":"", | |
107 (rval&MM_SSE2) ? "SSE2 ":"", | |
108 (rval&MM_3DNOW) ? "3DNow ":"", | |
2388 | 109 (rval&MM_3DNOWEXT) ? "3DNowExt ":""); |
110 #endif | |
111 return rval; | |
0 | 112 } |
43 | 113 |
114 #ifdef __TEST__ | |
115 int main ( void ) | |
116 { | |
117 int mm_flags; | |
118 mm_flags = mm_support(); | |
2129 | 119 printf("mm_support = 0x%08X\n",mm_flags); |
43 | 120 return 0; |
121 } | |
122 #endif |