| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 VPX_CPU_TRANSMETA, | 28 VPX_CPU_TRANSMETA, |
| 29 VPX_CPU_TRANSMETA_OLD, | 29 VPX_CPU_TRANSMETA_OLD, |
| 30 VPX_CPU_UMC, | 30 VPX_CPU_UMC, |
| 31 VPX_CPU_VIA, | 31 VPX_CPU_VIA, |
| 32 | 32 |
| 33 VPX_CPU_LAST | 33 VPX_CPU_LAST |
| 34 } vpx_cpu_t; | 34 } vpx_cpu_t; |
| 35 | 35 |
| 36 #if defined(__GNUC__) && __GNUC__ || defined(__ANDROID__) | 36 #if defined(__GNUC__) && __GNUC__ || defined(__ANDROID__) |
| 37 #if ARCH_X86_64 | 37 #if ARCH_X86_64 |
| 38 #define cpuid(func,ax,bx,cx,dx)\ | 38 #define cpuid(func, func2, ax, bx, cx, dx)\ |
| 39 __asm__ __volatile__ (\ | 39 __asm__ __volatile__ (\ |
| 40 "cpuid \n\t" \ | 40 "cpuid \n\t" \ |
| 41 : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) \ | 41 : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) \ |
| 42 : "a" (func)); | 42 : "a" (func), "c" (func2)); |
| 43 #else | 43 #else |
| 44 #define cpuid(func,ax,bx,cx,dx)\ | 44 #define cpuid(func, func2, ax, bx, cx, dx)\ |
| 45 __asm__ __volatile__ (\ | 45 __asm__ __volatile__ (\ |
| 46 "mov %%ebx, %%edi \n\t" \ | 46 "mov %%ebx, %%edi \n\t" \ |
| 47 "cpuid \n\t" \ | 47 "cpuid \n\t" \ |
| 48 "xchg %%edi, %%ebx \n\t" \ | 48 "xchg %%edi, %%ebx \n\t" \ |
| 49 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ | 49 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ |
| 50 : "a" (func)); | 50 : "a" (func), "c" (func2)); |
| 51 #endif | 51 #endif |
| 52 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* end __GNUC__ or __ANDROID__
*/ | 52 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* end __GNUC__ or __ANDROID__
*/ |
| 53 #if ARCH_X86_64 | 53 #if ARCH_X86_64 |
| 54 #define cpuid(func,ax,bx,cx,dx)\ | 54 #define cpuid(func, func2, ax, bx, cx, dx)\ |
| 55 asm volatile (\ | 55 asm volatile (\ |
| 56 "xchg %rsi, %rbx \n\t" \ | 56 "xchg %rsi, %rbx \n\t" \ |
| 57 "cpuid \n\t" \ | 57 "cpuid \n\t" \ |
| 58 "movl %ebx, %edi \n\t" \ | 58 "movl %ebx, %edi \n\t" \ |
| 59 "xchg %rsi, %rbx \n\t" \ | 59 "xchg %rsi, %rbx \n\t" \ |
| 60 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ | 60 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ |
| 61 : "a" (func)); | 61 : "a" (func), "c" (func2)); |
| 62 #else | 62 #else |
| 63 #define cpuid(func,ax,bx,cx,dx)\ | 63 #define cpuid(func, func2, ax, bx, cx, dx)\ |
| 64 asm volatile (\ | 64 asm volatile (\ |
| 65 "pushl %ebx \n\t" \ | 65 "pushl %ebx \n\t" \ |
| 66 "cpuid \n\t" \ | 66 "cpuid \n\t" \ |
| 67 "movl %ebx, %edi \n\t" \ | 67 "movl %ebx, %edi \n\t" \ |
| 68 "popl %ebx \n\t" \ | 68 "popl %ebx \n\t" \ |
| 69 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ | 69 : "=a" (ax), "=D" (bx), "=c" (cx), "=d" (dx) \ |
| 70 : "a" (func)); | 70 : "a" (func), "c" (func2)); |
| 71 #endif | 71 #endif |
| 72 #else /* end __SUNPRO__ */ | 72 #else /* end __SUNPRO__ */ |
| 73 #if ARCH_X86_64 | 73 #if ARCH_X86_64 |
| 74 #if defined(_MSC_VER) && _MSC_VER > 1500 |
| 75 void __cpuidex(int CPUInfo[4], int info_type, int ecxvalue); |
| 76 #pragma intrinsic(__cpuidex) |
| 77 #define cpuid(func, func2, a, b, c, d) do {\ |
| 78 int regs[4];\ |
| 79 __cpuidex(regs, func, func2); \ |
| 80 a = regs[0]; b = regs[1]; c = regs[2]; d = regs[3];\ |
| 81 } while(0) |
| 82 #else |
| 74 void __cpuid(int CPUInfo[4], int info_type); | 83 void __cpuid(int CPUInfo[4], int info_type); |
| 75 #pragma intrinsic(__cpuid) | 84 #pragma intrinsic(__cpuid) |
| 76 #define cpuid(func,a,b,c,d) do{\ | 85 #define cpuid(func, func2, a, b, c, d) do {\ |
| 77 int regs[4];\ | 86 int regs[4];\ |
| 78 __cpuid(regs,func); a=regs[0]; b=regs[1]; c=regs[2]; d=regs[3];\ | 87 __cpuid(regs, func); \ |
| 79 } while(0) | 88 a = regs[0]; b = regs[1]; c = regs[2]; d = regs[3];\ |
| 89 } while (0) |
| 90 #endif |
| 80 #else | 91 #else |
| 81 #define cpuid(func,a,b,c,d)\ | 92 #define cpuid(func, func2, a, b, c, d)\ |
| 82 __asm mov eax, func\ | 93 __asm mov eax, func\ |
| 94 __asm mov ecx, func2\ |
| 83 __asm cpuid\ | 95 __asm cpuid\ |
| 84 __asm mov a, eax\ | 96 __asm mov a, eax\ |
| 85 __asm mov b, ebx\ | 97 __asm mov b, ebx\ |
| 86 __asm mov c, ecx\ | 98 __asm mov c, ecx\ |
| 87 __asm mov d, edx | 99 __asm mov d, edx |
| 88 #endif | 100 #endif |
| 89 #endif /* end others */ | 101 #endif /* end others */ |
| 90 | 102 |
| 91 #define HAS_MMX 0x01 | 103 #define HAS_MMX 0x01 |
| 92 #define HAS_SSE 0x02 | 104 #define HAS_SSE 0x02 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 113 | 125 |
| 114 if (env && *env) | 126 if (env && *env) |
| 115 return (int)strtol(env, NULL, 0); | 127 return (int)strtol(env, NULL, 0); |
| 116 | 128 |
| 117 env = getenv("VPX_SIMD_CAPS_MASK"); | 129 env = getenv("VPX_SIMD_CAPS_MASK"); |
| 118 | 130 |
| 119 if (env && *env) | 131 if (env && *env) |
| 120 mask = strtol(env, NULL, 0); | 132 mask = strtol(env, NULL, 0); |
| 121 | 133 |
| 122 /* Ensure that the CPUID instruction supports extended features */ | 134 /* Ensure that the CPUID instruction supports extended features */ |
| 123 cpuid(0, reg_eax, reg_ebx, reg_ecx, reg_edx); | 135 cpuid(0, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); |
| 124 | 136 |
| 125 if (reg_eax < 1) | 137 if (reg_eax < 1) |
| 126 return 0; | 138 return 0; |
| 127 | 139 |
| 128 /* Get the standard feature flags */ | 140 /* Get the standard feature flags */ |
| 129 cpuid(1, reg_eax, reg_ebx, reg_ecx, reg_edx); | 141 cpuid(1, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); |
| 130 | 142 |
| 131 if (reg_edx & BIT(23)) flags |= HAS_MMX; | 143 if (reg_edx & BIT(23)) flags |= HAS_MMX; |
| 132 | 144 |
| 133 if (reg_edx & BIT(25)) flags |= HAS_SSE; /* aka xmm */ | 145 if (reg_edx & BIT(25)) flags |= HAS_SSE; /* aka xmm */ |
| 134 | 146 |
| 135 if (reg_edx & BIT(26)) flags |= HAS_SSE2; /* aka wmt */ | 147 if (reg_edx & BIT(26)) flags |= HAS_SSE2; /* aka wmt */ |
| 136 | 148 |
| 137 if (reg_ecx & BIT(0)) flags |= HAS_SSE3; | 149 if (reg_ecx & BIT(0)) flags |= HAS_SSE3; |
| 138 | 150 |
| 139 if (reg_ecx & BIT(9)) flags |= HAS_SSSE3; | 151 if (reg_ecx & BIT(9)) flags |= HAS_SSSE3; |
| 140 | 152 |
| 141 if (reg_ecx & BIT(19)) flags |= HAS_SSE4_1; | 153 if (reg_ecx & BIT(19)) flags |= HAS_SSE4_1; |
| 142 | 154 |
| 143 if (reg_ecx & BIT(28)) flags |= HAS_AVX; | 155 if (reg_ecx & BIT(28)) flags |= HAS_AVX; |
| 144 | 156 |
| 157 /* Get the leaf 7 feature flags. Needed to check for AVX2 support */ |
| 158 reg_eax = 7; |
| 159 reg_ecx = 0; |
| 160 cpuid(7, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); |
| 161 |
| 145 if (reg_ebx & BIT(5)) flags |= HAS_AVX2; | 162 if (reg_ebx & BIT(5)) flags |= HAS_AVX2; |
| 146 | 163 |
| 147 return flags & mask; | 164 return flags & mask; |
| 148 } | 165 } |
| 149 | 166 |
| 150 vpx_cpu_t vpx_x86_vendor(void); | 167 vpx_cpu_t vpx_x86_vendor(void); |
| 151 | 168 |
| 152 #if ARCH_X86_64 && defined(_MSC_VER) | 169 #if ARCH_X86_64 && defined(_MSC_VER) |
| 153 unsigned __int64 __rdtsc(void); | 170 unsigned __int64 __rdtsc(void); |
| 154 #pragma intrinsic(__rdtsc) | 171 #pragma intrinsic(__rdtsc) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 x87_set_double_precision(void) { | 251 x87_set_double_precision(void) { |
| 235 unsigned short mode = x87_get_control_word(); | 252 unsigned short mode = x87_get_control_word(); |
| 236 x87_set_control_word((mode&~0x300) | 0x200); | 253 x87_set_control_word((mode&~0x300) | 0x200); |
| 237 return mode; | 254 return mode; |
| 238 } | 255 } |
| 239 | 256 |
| 240 | 257 |
| 241 extern void vpx_reset_mmx_state(void); | 258 extern void vpx_reset_mmx_state(void); |
| 242 #endif | 259 #endif |
| 243 | 260 |
| OLD | NEW |