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 19 matching lines...) Expand all Loading... |
30 ext_family_(0), | 30 ext_family_(0), |
31 has_mmx_(false), | 31 has_mmx_(false), |
32 has_sse_(false), | 32 has_sse_(false), |
33 has_sse2_(false), | 33 has_sse2_(false), |
34 has_sse3_(false), | 34 has_sse3_(false), |
35 has_ssse3_(false), | 35 has_ssse3_(false), |
36 has_sse41_(false), | 36 has_sse41_(false), |
37 has_sse42_(false), | 37 has_sse42_(false), |
38 has_avx_(false), | 38 has_avx_(false), |
39 has_avx_hardware_(false), | 39 has_avx_hardware_(false), |
| 40 has_aesni_(false), |
40 has_non_stop_time_stamp_counter_(false), | 41 has_non_stop_time_stamp_counter_(false), |
41 cpu_vendor_("unknown") { | 42 cpu_vendor_("unknown") { |
42 Initialize(); | 43 Initialize(); |
43 } | 44 } |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 #if defined(ARCH_CPU_X86_FAMILY) | 48 #if defined(ARCH_CPU_X86_FAMILY) |
48 #ifndef _MSC_VER | 49 #ifndef _MSC_VER |
49 | 50 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 (cpu_info[2] & 0x10000000) != 0; | 125 (cpu_info[2] & 0x10000000) != 0; |
125 // AVX instructions will generate an illegal instruction exception unless | 126 // AVX instructions will generate an illegal instruction exception unless |
126 // a) they are supported by the CPU, | 127 // a) they are supported by the CPU, |
127 // b) XSAVE is supported by the CPU and | 128 // b) XSAVE is supported by the CPU and |
128 // c) XSAVE is enabled by the kernel. | 129 // c) XSAVE is enabled by the kernel. |
129 // See http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled | 130 // See http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled |
130 has_avx_ = | 131 has_avx_ = |
131 has_avx_hardware_ && | 132 has_avx_hardware_ && |
132 (cpu_info[2] & 0x08000000) != 0 /* OSXSAVE */ && | 133 (cpu_info[2] & 0x08000000) != 0 /* OSXSAVE */ && |
133 (_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */; | 134 (_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */; |
| 135 has_aesni_ = (cpu_info[2] & 0x02000000) != 0; |
134 } | 136 } |
135 | 137 |
136 // Get the brand string of the cpu. | 138 // Get the brand string of the cpu. |
137 __cpuid(cpu_info, 0x80000000); | 139 __cpuid(cpu_info, 0x80000000); |
138 const int parameter_end = 0x80000004; | 140 const int parameter_end = 0x80000004; |
139 int max_parameter = cpu_info[0]; | 141 int max_parameter = cpu_info[0]; |
140 | 142 |
141 if (cpu_info[0] >= parameter_end) { | 143 if (cpu_info[0] >= parameter_end) { |
142 char* cpu_string_ptr = cpu_string; | 144 char* cpu_string_ptr = cpu_string; |
143 | 145 |
(...skipping 26 matching lines...) Expand all Loading... |
170 if (has_sse42()) return SSE42; | 172 if (has_sse42()) return SSE42; |
171 if (has_sse41()) return SSE41; | 173 if (has_sse41()) return SSE41; |
172 if (has_ssse3()) return SSSE3; | 174 if (has_ssse3()) return SSSE3; |
173 if (has_sse3()) return SSE3; | 175 if (has_sse3()) return SSE3; |
174 if (has_sse2()) return SSE2; | 176 if (has_sse2()) return SSE2; |
175 if (has_sse()) return SSE; | 177 if (has_sse()) return SSE; |
176 return PENTIUM; | 178 return PENTIUM; |
177 } | 179 } |
178 | 180 |
179 } // namespace base | 181 } // namespace base |
OLD | NEW |