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
3 // found in the LICENSE file.
11 #include "base/base_export.h"
12 #include "build/build_config.h"
16 #if defined(ARCH_CPU_X86_FAMILY)
19 // Compute the CPU family and model based on the vendor and CPUID signature.
20 // Returns in order: family, model, extended family, extended model.
21 BASE_EXPORT std::tuple<int, int, int, int> ComputeX86FamilyAndModel(
22 const std::string& vendor,
25 } // namespace internal
26 #endif // defined(ARCH_CPU_X86_FAMILY)
28 // Query information about the processor.
29 class BASE_EXPORT CPU final {
33 enum IntelMicroArchitecture {
43 MAX_INTEL_MICRO_ARCHITECTURE
46 // Accessors for CPU information.
47 const std::string& vendor_name() const { return cpu_vendor_; }
48 int signature() const { return signature_; }
49 int stepping() const { return stepping_; }
50 int model() const { return model_; }
51 int family() const { return family_; }
52 int type() const { return type_; }
53 int extended_model() const { return ext_model_; }
54 int extended_family() const { return ext_family_; }
55 bool has_mmx() const { return has_mmx_; }
56 bool has_sse() const { return has_sse_; }
57 bool has_sse2() const { return has_sse2_; }
58 bool has_sse3() const { return has_sse3_; }
59 bool has_ssse3() const { return has_ssse3_; }
60 bool has_sse41() const { return has_sse41_; }
61 bool has_sse42() const { return has_sse42_; }
62 bool has_popcnt() const { return has_popcnt_; }
63 bool has_avx() const { return has_avx_; }
64 bool has_avx2() const { return has_avx2_; }
65 bool has_aesni() const { return has_aesni_; }
66 bool has_non_stop_time_stamp_counter() const {
67 return has_non_stop_time_stamp_counter_;
69 bool is_running_in_vm() const { return is_running_in_vm_; }
71 IntelMicroArchitecture GetIntelMicroArchitecture() const;
72 const std::string& cpu_brand() const { return cpu_brand_; }
75 // Query the processor for CPUID information.
78 int signature_; // raw form of type, family, model, and stepping
79 int type_; // process type
80 int family_; // family of the processor
81 int model_; // model of processor
82 int stepping_; // processor revision number
96 bool has_non_stop_time_stamp_counter_;
97 bool is_running_in_vm_;
98 std::string cpu_vendor_;
99 std::string cpu_brand_;
104 #endif // BASE_CPU_H_