OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/cpu.h" | 5 #include "base/cpu.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 ext_model_(0), | 27 ext_model_(0), |
28 ext_family_(0), | 28 ext_family_(0), |
29 has_mmx_(false), | 29 has_mmx_(false), |
30 has_sse_(false), | 30 has_sse_(false), |
31 has_sse2_(false), | 31 has_sse2_(false), |
32 has_sse3_(false), | 32 has_sse3_(false), |
33 has_ssse3_(false), | 33 has_ssse3_(false), |
34 has_sse41_(false), | 34 has_sse41_(false), |
35 has_sse42_(false), | 35 has_sse42_(false), |
36 has_non_stop_time_stamp_counter_(false), | 36 has_non_stop_time_stamp_counter_(false), |
| 37 has_aesni_(false), |
37 cpu_vendor_("unknown") { | 38 cpu_vendor_("unknown") { |
38 Initialize(); | 39 Initialize(); |
39 } | 40 } |
40 | 41 |
41 #if defined(ARCH_CPU_X86_FAMILY) | 42 #if defined(ARCH_CPU_X86_FAMILY) |
42 #ifndef _MSC_VER | 43 #ifndef _MSC_VER |
43 | 44 |
44 #if defined(__pic__) && defined(__i386__) | 45 #if defined(__pic__) && defined(__i386__) |
45 | 46 |
46 void __cpuid(int cpu_info[4], int info_type) { | 47 void __cpuid(int cpu_info[4], int info_type) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Interpret CPU feature information. | 107 // Interpret CPU feature information. |
107 if (num_ids > 0) { | 108 if (num_ids > 0) { |
108 __cpuid(cpu_info, 1); | 109 __cpuid(cpu_info, 1); |
109 signature_ = cpu_info[0]; | 110 signature_ = cpu_info[0]; |
110 stepping_ = cpu_info[0] & 0xf; | 111 stepping_ = cpu_info[0] & 0xf; |
111 model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0); | 112 model_ = ((cpu_info[0] >> 4) & 0xf) + ((cpu_info[0] >> 12) & 0xf0); |
112 family_ = (cpu_info[0] >> 8) & 0xf; | 113 family_ = (cpu_info[0] >> 8) & 0xf; |
113 type_ = (cpu_info[0] >> 12) & 0x3; | 114 type_ = (cpu_info[0] >> 12) & 0x3; |
114 ext_model_ = (cpu_info[0] >> 16) & 0xf; | 115 ext_model_ = (cpu_info[0] >> 16) & 0xf; |
115 ext_family_ = (cpu_info[0] >> 20) & 0xff; | 116 ext_family_ = (cpu_info[0] >> 20) & 0xff; |
116 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; | 117 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; |
117 has_sse_ = (cpu_info[3] & 0x02000000) != 0; | 118 has_sse_ = (cpu_info[3] & 0x02000000) != 0; |
118 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; | 119 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; |
119 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; | 120 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; |
120 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; | 121 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; |
121 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; | 122 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; |
122 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; | 123 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; |
123 has_avx_ = (cpu_info[2] & 0x10000000) != 0; | 124 has_avx_ = (cpu_info[2] & 0x10000000) != 0; |
| 125 has_aesni_ = (cpu_info[2] & 0x02000000) != 0; |
124 } | 126 } |
125 | 127 |
126 // Get the brand string of the cpu. | 128 // Get the brand string of the cpu. |
127 __cpuid(cpu_info, 0x80000000); | 129 __cpuid(cpu_info, 0x80000000); |
128 const int parameter_end = 0x80000004; | 130 const int parameter_end = 0x80000004; |
129 int max_parameter = cpu_info[0]; | 131 int max_parameter = cpu_info[0]; |
130 | 132 |
131 if (cpu_info[0] >= parameter_end) { | 133 if (cpu_info[0] >= parameter_end) { |
132 char* cpu_string_ptr = cpu_string; | 134 char* cpu_string_ptr = cpu_string; |
133 | 135 |
(...skipping 26 matching lines...) Expand all Loading... |
160 if (has_sse42()) return SSE42; | 162 if (has_sse42()) return SSE42; |
161 if (has_sse41()) return SSE41; | 163 if (has_sse41()) return SSE41; |
162 if (has_ssse3()) return SSSE3; | 164 if (has_ssse3()) return SSSE3; |
163 if (has_sse3()) return SSE3; | 165 if (has_sse3()) return SSE3; |
164 if (has_sse2()) return SSE2; | 166 if (has_sse2()) return SSE2; |
165 if (has_sse()) return SSE; | 167 if (has_sse()) return SSE; |
166 return PENTIUM; | 168 return PENTIUM; |
167 } | 169 } |
168 | 170 |
169 } // namespace base | 171 } // namespace base |
OLD | NEW |