1 // Copyright 2017 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef CPU_FEATURES_INCLUDE_CPUINFO_X86_H_
16 #define CPU_FEATURES_INCLUDE_CPUINFO_X86_H_
18 #include "cpu_features_macros.h"
20 CPU_FEATURES_START_CPP_NAMESPACE
22 // See https://en.wikipedia.org/wiki/CPUID for a list of x86 cpu features.
51 int avx512vpopcntdq : 1;
52 int avx512_4vnniw : 1;
53 int avx512_4vbmi2 : 1;
57 int cx16 : 1; // aka. CMPXCHG16B
59 // Make sure to update X86FeaturesEnum below if you add a field here.
67 char vendor[13]; // 0 terminated string
70 // Calls cpuid and returns an initialized X86info.
71 // This function is guaranteed to be malloc, memset and memcpy free.
72 X86Info GetX86Info(void);
79 INTEL_ATOM_BNL, // BONNELL
80 INTEL_WSM, // WESTMERE
81 INTEL_SNB, // SANDYBRIDGE
82 INTEL_IVB, // IVYBRIDGE
83 INTEL_ATOM_SMT, // SILVERMONT
85 INTEL_BDW, // BROADWELL
87 INTEL_ATOM_GMT, // GOLDMONT
88 INTEL_KBL, // KABY LAKE
89 INTEL_CFL, // COFFEE LAKE
90 INTEL_CNL, // CANNON LAKE
97 } X86Microarchitecture;
99 // Returns the underlying microarchitecture by looking at X86Info's vendor,
101 X86Microarchitecture GetX86Microarchitecture(const X86Info* info);
103 // Calls cpuid and fills the brand_string.
104 // - brand_string *must* be of size 49 (beware of array decaying).
105 // - brand_string will be zero terminated.
106 // - This function calls memcpy.
107 void FillX86BrandString(char brand_string[49]);
109 ////////////////////////////////////////////////////////////////////////////////
110 // Introspection functions
146 int GetX86FeaturesEnumValue(const X86Features* features, X86FeaturesEnum value);
148 const char* GetX86FeaturesEnumName(X86FeaturesEnum);
150 const char* GetX86MicroarchitectureName(X86Microarchitecture);
152 CPU_FEATURES_END_CPP_NAMESPACE
154 #endif // CPU_FEATURES_INCLUDE_CPUINFO_X86_H_