1 /* Get CPU type and Features for x86 processors. 2 Copyright (C) 2012-2022 Free Software Foundation, Inc. 3 Contributed by Sriraman Tallam (tmsriram@google.com) 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it under 8 the terms of the GNU General Public License as published by the Free 9 Software Foundation; either version 3, or (at your option) any later 10 version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 Under Section 7 of GPL version 3, you are granted additional 18 permissions described in the GCC Runtime Library Exception, version 19 3.1, as published by the Free Software Foundation. 20 21 You should have received a copy of the GNU General Public License and 22 a copy of the GCC Runtime Library Exception along with this program; 23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 <http://www.gnu.org/licenses/>. */ 25 26 /* Processor Vendor and Models. */ 27 28 enum processor_vendor 29 { 30 VENDOR_INTEL = 1, 31 VENDOR_AMD, 32 VENDOR_OTHER, 33 VENDOR_CENTAUR, 34 VENDOR_CYRIX, 35 VENDOR_NSC, 36 37 /* Maximum values must be at the end of this enum. */ 38 VENDOR_MAX, 39 BUILTIN_VENDOR_MAX = VENDOR_OTHER 40 }; 41 42 /* Any new types or subtypes have to be inserted at the end. */ 43 44 enum processor_types 45 { 46 INTEL_BONNELL = 1, 47 INTEL_CORE2, 48 INTEL_COREI7, 49 AMDFAM10H, 50 AMDFAM15H, 51 INTEL_SILVERMONT, 52 INTEL_KNL, 53 AMD_BTVER1, 54 AMD_BTVER2, 55 AMDFAM17H, 56 INTEL_KNM, 57 INTEL_GOLDMONT, 58 INTEL_GOLDMONT_PLUS, 59 INTEL_TREMONT, 60 AMDFAM19H, 61 CPU_TYPE_MAX, 62 BUILTIN_CPU_TYPE_MAX = CPU_TYPE_MAX 63 }; 64 65 enum processor_subtypes 66 { 67 INTEL_COREI7_NEHALEM = 1, 68 INTEL_COREI7_WESTMERE, 69 INTEL_COREI7_SANDYBRIDGE, 70 AMDFAM10H_BARCELONA, 71 AMDFAM10H_SHANGHAI, 72 AMDFAM10H_ISTANBUL, 73 AMDFAM15H_BDVER1, 74 AMDFAM15H_BDVER2, 75 AMDFAM15H_BDVER3, 76 AMDFAM15H_BDVER4, 77 AMDFAM17H_ZNVER1, 78 INTEL_COREI7_IVYBRIDGE, 79 INTEL_COREI7_HASWELL, 80 INTEL_COREI7_BROADWELL, 81 INTEL_COREI7_SKYLAKE, 82 INTEL_COREI7_SKYLAKE_AVX512, 83 INTEL_COREI7_CANNONLAKE, 84 INTEL_COREI7_ICELAKE_CLIENT, 85 INTEL_COREI7_ICELAKE_SERVER, 86 AMDFAM17H_ZNVER2, 87 INTEL_COREI7_CASCADELAKE, 88 INTEL_COREI7_TIGERLAKE, 89 INTEL_COREI7_COOPERLAKE, 90 INTEL_COREI7_SAPPHIRERAPIDS, 91 INTEL_COREI7_ALDERLAKE, 92 AMDFAM19H_ZNVER3, 93 INTEL_COREI7_ROCKETLAKE, 94 AMDFAM19H_ZNVER4, 95 CPU_SUBTYPE_MAX 96 }; 97 98 /* Priority of i386 features, greater value is higher priority. This is 99 used to decide the order in which function dispatch must happen. For 100 instance, a version specialized for SSE4.2 should be checked for dispatch 101 before a version for SSE3, as SSE4.2 implies SSE3. */ 102 enum feature_priority 103 { 104 P_NONE = 0, 105 P_MMX, 106 P_SSE, 107 P_SSE2, 108 P_X86_64_BASELINE, 109 P_SSE3, 110 P_SSSE3, 111 P_PROC_SSSE3, 112 P_SSE4_A, 113 P_PROC_SSE4_A, 114 P_SSE4_1, 115 P_SSE4_2, 116 P_PROC_SSE4_2, 117 P_POPCNT, 118 P_X86_64_V2, 119 P_AES, 120 P_PCLMUL, 121 P_AVX, 122 P_PROC_AVX, 123 P_BMI, 124 P_PROC_BMI, 125 P_FMA4, 126 P_XOP, 127 P_PROC_XOP, 128 P_FMA, 129 P_PROC_FMA, 130 P_BMI2, 131 P_AVX2, 132 P_PROC_AVX2, 133 P_X86_64_V3, 134 P_AVX512F, 135 P_PROC_AVX512F, 136 P_X86_64_V4, 137 P_PROC_DYNAMIC 138 }; 139 140 /* ISA Features supported. New features have to be inserted at the end. */ 141 142 enum processor_features 143 { 144 FEATURE_CMOV = 0, 145 FEATURE_MMX, 146 FEATURE_POPCNT, 147 FEATURE_SSE, 148 FEATURE_SSE2, 149 FEATURE_SSE3, 150 FEATURE_SSSE3, 151 FEATURE_SSE4_1, 152 FEATURE_SSE4_2, 153 FEATURE_AVX, 154 FEATURE_AVX2, 155 FEATURE_SSE4_A, 156 FEATURE_FMA4, 157 FEATURE_XOP, 158 FEATURE_FMA, 159 FEATURE_AVX512F, 160 FEATURE_BMI, 161 FEATURE_BMI2, 162 FEATURE_AES, 163 FEATURE_PCLMUL, 164 FEATURE_AVX512VL, 165 FEATURE_AVX512BW, 166 FEATURE_AVX512DQ, 167 FEATURE_AVX512CD, 168 FEATURE_AVX512ER, 169 FEATURE_AVX512PF, 170 FEATURE_AVX512VBMI, 171 FEATURE_AVX512IFMA, 172 FEATURE_AVX5124VNNIW, 173 FEATURE_AVX5124FMAPS, 174 FEATURE_AVX512VPOPCNTDQ, 175 FEATURE_AVX512VBMI2, 176 FEATURE_GFNI, 177 FEATURE_VPCLMULQDQ, 178 FEATURE_AVX512VNNI, 179 FEATURE_AVX512BITALG, 180 FEATURE_AVX512BF16, 181 FEATURE_AVX512VP2INTERSECT, 182 FEATURE_3DNOW, 183 FEATURE_3DNOWP, 184 FEATURE_ADX, 185 FEATURE_ABM, 186 FEATURE_CLDEMOTE, 187 FEATURE_CLFLUSHOPT, 188 FEATURE_CLWB, 189 FEATURE_CLZERO, 190 FEATURE_CMPXCHG16B, 191 FEATURE_CMPXCHG8B, 192 FEATURE_ENQCMD, 193 FEATURE_F16C, 194 FEATURE_FSGSBASE, 195 FEATURE_FXSAVE, 196 FEATURE_HLE, 197 FEATURE_IBT, 198 FEATURE_LAHF_LM, 199 FEATURE_LM, 200 FEATURE_LWP, 201 FEATURE_LZCNT, 202 FEATURE_MOVBE, 203 FEATURE_MOVDIR64B, 204 FEATURE_MOVDIRI, 205 FEATURE_MWAITX, 206 FEATURE_OSXSAVE, 207 FEATURE_PCONFIG, 208 FEATURE_PKU, 209 FEATURE_PREFETCHWT1, 210 FEATURE_PRFCHW, 211 FEATURE_PTWRITE, 212 FEATURE_RDPID, 213 FEATURE_RDRND, 214 FEATURE_RDSEED, 215 FEATURE_RTM, 216 FEATURE_SERIALIZE, 217 FEATURE_SGX, 218 FEATURE_SHA, 219 FEATURE_SHSTK, 220 FEATURE_TBM, 221 FEATURE_TSXLDTRK, 222 FEATURE_VAES, 223 FEATURE_WAITPKG, 224 FEATURE_WBNOINVD, 225 FEATURE_XSAVE, 226 FEATURE_XSAVEC, 227 FEATURE_XSAVEOPT, 228 FEATURE_XSAVES, 229 FEATURE_AMX_TILE, 230 FEATURE_AMX_INT8, 231 FEATURE_AMX_BF16, 232 FEATURE_UINTR, 233 FEATURE_HRESET, 234 FEATURE_KL, 235 FEATURE_AESKLE, 236 FEATURE_WIDEKL, 237 FEATURE_AVXVNNI, 238 FEATURE_AVX512FP16, 239 FEATURE_X86_64_BASELINE, 240 FEATURE_X86_64_V2, 241 FEATURE_X86_64_V3, 242 FEATURE_X86_64_V4, 243 CPU_FEATURE_MAX 244 }; 245 246 /* Size of __cpu_features2 array in libgcc/config/i386/cpuinfo.c. */ 247 #define SIZE_OF_CPU_FEATURES ((CPU_FEATURE_MAX - 1) / 32) 248 249 /* These are the values for vendor types, cpu types and subtypes. Cpu 250 types and subtypes should be subtracted by the corresponding start 251 value. */ 252 253 #define M_CPU_TYPE_START (BUILTIN_VENDOR_MAX) 254 #define M_CPU_SUBTYPE_START \ 255 (M_CPU_TYPE_START + BUILTIN_CPU_TYPE_MAX) 256 #define M_VENDOR(a) (a) 257 #define M_CPU_TYPE(a) (M_CPU_TYPE_START + a) 258 #define M_CPU_SUBTYPE(a) (M_CPU_SUBTYPE_START + a) 259