238 |
239 |
239 // The actual cpuid info block |
240 // The actual cpuid info block |
240 static CpuidInfo _cpuid_info; |
241 static CpuidInfo _cpuid_info; |
241 |
242 |
242 // Extractors and predicates |
243 // Extractors and predicates |
243 static bool is_extended_cpu_family() { |
|
244 const uint32_t Extended_Cpu_Family = 0xf; |
|
245 return _cpuid_info.std_cpuid1_eax.bits.family == Extended_Cpu_Family; |
|
246 } |
|
247 static uint32_t extended_cpu_family() { |
244 static uint32_t extended_cpu_family() { |
248 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.family; |
245 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.family; |
249 if (is_extended_cpu_family()) { |
246 result += _cpuid_info.std_cpuid1_eax.bits.ext_family; |
250 result += _cpuid_info.std_cpuid1_eax.bits.ext_family; |
|
251 } |
|
252 return result; |
247 return result; |
253 } |
248 } |
254 static uint32_t extended_cpu_model() { |
249 static uint32_t extended_cpu_model() { |
255 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.model; |
250 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.model; |
256 if (is_extended_cpu_family()) { |
251 result |= _cpuid_info.std_cpuid1_eax.bits.ext_model << 4; |
257 result |= _cpuid_info.std_cpuid1_eax.bits.ext_model << 4; |
|
258 } |
|
259 return result; |
252 return result; |
260 } |
253 } |
261 static uint32_t cpu_stepping() { |
254 static uint32_t cpu_stepping() { |
262 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.stepping; |
255 uint32_t result = _cpuid_info.std_cpuid1_eax.bits.stepping; |
263 return result; |
256 return result; |
291 result |= CPU_SSE3; |
284 result |= CPU_SSE3; |
292 if (_cpuid_info.std_cpuid1_ecx.bits.ssse3 != 0) |
285 if (_cpuid_info.std_cpuid1_ecx.bits.ssse3 != 0) |
293 result |= CPU_SSSE3; |
286 result |= CPU_SSSE3; |
294 if (is_amd() && _cpuid_info.ext_cpuid1_ecx.bits.sse4a != 0) |
287 if (is_amd() && _cpuid_info.ext_cpuid1_ecx.bits.sse4a != 0) |
295 result |= CPU_SSE4A; |
288 result |= CPU_SSE4A; |
|
289 if (_cpuid_info.std_cpuid1_ecx.bits.sse4_1 != 0) |
|
290 result |= CPU_SSE4_1; |
|
291 if (_cpuid_info.std_cpuid1_ecx.bits.sse4_2 != 0) |
|
292 result |= CPU_SSE4_2; |
296 return result; |
293 return result; |
297 } |
294 } |
298 |
295 |
299 static void get_processor_features(); |
296 static void get_processor_features(); |
300 |
297 |
378 static bool supports_mmx() { return (_cpuFeatures & CPU_MMX) != 0; } |
375 static bool supports_mmx() { return (_cpuFeatures & CPU_MMX) != 0; } |
379 static bool supports_sse() { return (_cpuFeatures & CPU_SSE) != 0; } |
376 static bool supports_sse() { return (_cpuFeatures & CPU_SSE) != 0; } |
380 static bool supports_sse2() { return (_cpuFeatures & CPU_SSE2) != 0; } |
377 static bool supports_sse2() { return (_cpuFeatures & CPU_SSE2) != 0; } |
381 static bool supports_sse3() { return (_cpuFeatures & CPU_SSE3) != 0; } |
378 static bool supports_sse3() { return (_cpuFeatures & CPU_SSE3) != 0; } |
382 static bool supports_ssse3() { return (_cpuFeatures & CPU_SSSE3)!= 0; } |
379 static bool supports_ssse3() { return (_cpuFeatures & CPU_SSSE3)!= 0; } |
383 static bool supports_sse4() { return (_cpuFeatures & CPU_SSE4) != 0; } |
380 static bool supports_sse4_1() { return (_cpuFeatures & CPU_SSE4_1) != 0; } |
|
381 static bool supports_sse4_2() { return (_cpuFeatures & CPU_SSE4_2) != 0; } |
384 // |
382 // |
385 // AMD features |
383 // AMD features |
386 // |
384 // |
387 static bool supports_3dnow() { return (_cpuFeatures & CPU_3DNOW) != 0; } |
385 static bool supports_3dnow() { return (_cpuFeatures & CPU_3DNOW) != 0; } |
388 static bool supports_mmx_ext() { return is_amd() && _cpuid_info.ext_cpuid1_edx.bits.mmx_amd != 0; } |
386 static bool supports_mmx_ext() { return is_amd() && _cpuid_info.ext_cpuid1_edx.bits.mmx_amd != 0; } |