michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_CPU_H_ michael@0: #define BASE_CPU_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: michael@0: namespace base { michael@0: michael@0: // Query information about the processor. michael@0: class BASE_EXPORT CPU { michael@0: public: michael@0: // Constructor michael@0: CPU(); michael@0: michael@0: enum IntelMicroArchitecture { michael@0: PENTIUM, michael@0: SSE, michael@0: SSE2, michael@0: SSE3, michael@0: SSSE3, michael@0: SSE41, michael@0: SSE42, michael@0: AVX, michael@0: MAX_INTEL_MICRO_ARCHITECTURE michael@0: }; michael@0: michael@0: // Accessors for CPU information. michael@0: const std::string& vendor_name() const { return cpu_vendor_; } michael@0: int signature() const { return signature_; } michael@0: int stepping() const { return stepping_; } michael@0: int model() const { return model_; } michael@0: int family() const { return family_; } michael@0: int type() const { return type_; } michael@0: int extended_model() const { return ext_model_; } michael@0: int extended_family() const { return ext_family_; } michael@0: bool has_mmx() const { return has_mmx_; } michael@0: bool has_sse() const { return has_sse_; } michael@0: bool has_sse2() const { return has_sse2_; } michael@0: bool has_sse3() const { return has_sse3_; } michael@0: bool has_ssse3() const { return has_ssse3_; } michael@0: bool has_sse41() const { return has_sse41_; } michael@0: bool has_sse42() const { return has_sse42_; } michael@0: bool has_avx() const { return has_avx_; } michael@0: bool has_non_stop_time_stamp_counter() const { michael@0: return has_non_stop_time_stamp_counter_; michael@0: } michael@0: IntelMicroArchitecture GetIntelMicroArchitecture() const; michael@0: const std::string& cpu_brand() const { return cpu_brand_; } michael@0: michael@0: private: michael@0: // Query the processor for CPUID information. michael@0: void Initialize(); michael@0: michael@0: int signature_; // raw form of type, family, model, and stepping michael@0: int type_; // process type michael@0: int family_; // family of the processor michael@0: int model_; // model of processor michael@0: int stepping_; // processor revision number michael@0: int ext_model_; michael@0: int ext_family_; michael@0: bool has_mmx_; michael@0: bool has_sse_; michael@0: bool has_sse2_; michael@0: bool has_sse3_; michael@0: bool has_ssse3_; michael@0: bool has_sse41_; michael@0: bool has_sse42_; michael@0: bool has_avx_; michael@0: bool has_non_stop_time_stamp_counter_; michael@0: std::string cpu_vendor_; michael@0: std::string cpu_brand_; michael@0: }; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_CPU_H_