1 /* Get CPU type and Features for x86 processors. 2 Copyright (C) 2012-2021 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 BUILTIN_VENDOR_MAX = VENDOR_OTHER, 37 VENDOR_MAX 38 }; 39 40 /* Any new types or subtypes have to be inserted at the end. */ 41 42 enum processor_types 43 { 44 INTEL_BONNELL = 1, 45 INTEL_CORE2, 46 INTEL_COREI7, 47 AMDFAM10H, 48 AMDFAM15H, 49 INTEL_SILVERMONT, 50 INTEL_KNL, 51 AMD_BTVER1, 52 AMD_BTVER2, 53 AMDFAM17H, 54 INTEL_KNM, 55 INTEL_GOLDMONT, 56 INTEL_GOLDMONT_PLUS, 57 INTEL_TREMONT, 58 AMDFAM19H, 59 CPU_TYPE_MAX, 60 BUILTIN_CPU_TYPE_MAX = CPU_TYPE_MAX 61 }; 62 63 enum processor_subtypes 64 { 65 INTEL_COREI7_NEHALEM = 1, 66 INTEL_COREI7_WESTMERE, 67 INTEL_COREI7_SANDYBRIDGE, 68 AMDFAM10H_BARCELONA, 69 AMDFAM10H_SHANGHAI, 70 AMDFAM10H_ISTANBUL, 71 AMDFAM15H_BDVER1, 72 AMDFAM15H_BDVER2, 73 AMDFAM15H_BDVER3, 74 AMDFAM15H_BDVER4, 75 AMDFAM17H_ZNVER1, 76 INTEL_COREI7_IVYBRIDGE, 77 INTEL_COREI7_HASWELL, 78 INTEL_COREI7_BROADWELL, 79 INTEL_COREI7_SKYLAKE, 80 INTEL_COREI7_SKYLAKE_AVX512, 81 INTEL_COREI7_CANNONLAKE, 82 INTEL_COREI7_ICELAKE_CLIENT, 83 INTEL_COREI7_ICELAKE_SERVER, 84 AMDFAM17H_ZNVER2, 85 INTEL_COREI7_CASCADELAKE, 86 INTEL_COREI7_TIGERLAKE, 87 INTEL_COREI7_COOPERLAKE, 88 INTEL_COREI7_SAPPHIRERAPIDS, 89 INTEL_COREI7_ALDERLAKE, 90 AMDFAM19H_ZNVER3, 91 INTEL_COREI7_ROCKETLAKE, 92 CPU_SUBTYPE_MAX 93 }; 94 95 /* Priority of i386 features, greater value is higher priority. This is 96 used to decide the order in which function dispatch must happen. For 97 instance, a version specialized for SSE4.2 should be checked for dispatch 98 before a version for SSE3, as SSE4.2 implies SSE3. */ 99 enum feature_priority 100 { 101 P_NONE = 0, 102 P_MMX, 103 P_SSE, 104 P_SSE2, 105 P_SSE3, 106 P_SSSE3, 107 P_PROC_SSSE3, 108 P_SSE4_A, 109 P_PROC_SSE4_A, 110 P_SSE4_1, 111 P_SSE4_2, 112 P_PROC_SSE4_2, 113 P_POPCNT, 114 P_AES, 115 P_PCLMUL, 116 P_AVX, 117 P_PROC_AVX, 118 P_BMI, 119 P_PROC_BMI, 120 P_FMA4, 121 P_XOP, 122 P_PROC_XOP, 123 P_FMA, 124 P_PROC_FMA, 125 P_BMI2, 126 P_AVX2, 127 P_PROC_AVX2, 128 P_AVX512F, 129 P_PROC_AVX512F, 130 P_PROC_DYNAMIC 131 }; 132 133 /* ISA Features supported. New features have to be inserted at the end. */ 134 135 enum processor_features 136 { 137 FEATURE_CMOV = 0, 138 FEATURE_MMX, 139 FEATURE_POPCNT, 140 FEATURE_SSE, 141 FEATURE_SSE2, 142 FEATURE_SSE3, 143 FEATURE_SSSE3, 144 FEATURE_SSE4_1, 145 FEATURE_SSE4_2, 146 FEATURE_AVX, 147 FEATURE_AVX2, 148 FEATURE_SSE4_A, 149 FEATURE_FMA4, 150 FEATURE_XOP, 151 FEATURE_FMA, 152 FEATURE_AVX512F, 153 FEATURE_BMI, 154 FEATURE_BMI2, 155 FEATURE_AES, 156 FEATURE_PCLMUL, 157 FEATURE_AVX512VL, 158 FEATURE_AVX512BW, 159 FEATURE_AVX512DQ, 160 FEATURE_AVX512CD, 161 FEATURE_AVX512ER, 162 FEATURE_AVX512PF, 163 FEATURE_AVX512VBMI, 164 FEATURE_AVX512IFMA, 165 FEATURE_AVX5124VNNIW, 166 FEATURE_AVX5124FMAPS, 167 FEATURE_AVX512VPOPCNTDQ, 168 FEATURE_AVX512VBMI2, 169 FEATURE_GFNI, 170 FEATURE_VPCLMULQDQ, 171 FEATURE_AVX512VNNI, 172 FEATURE_AVX512BITALG, 173 FEATURE_AVX512BF16, 174 FEATURE_AVX512VP2INTERSECT, 175 FEATURE_3DNOW, 176 FEATURE_3DNOWP, 177 FEATURE_ADX, 178 FEATURE_ABM, 179 FEATURE_CLDEMOTE, 180 FEATURE_CLFLUSHOPT, 181 FEATURE_CLWB, 182 FEATURE_CLZERO, 183 FEATURE_CMPXCHG16B, 184 FEATURE_CMPXCHG8B, 185 FEATURE_ENQCMD, 186 FEATURE_F16C, 187 FEATURE_FSGSBASE, 188 FEATURE_FXSAVE, 189 FEATURE_HLE, 190 FEATURE_IBT, 191 FEATURE_LAHF_LM, 192 FEATURE_LM, 193 FEATURE_LWP, 194 FEATURE_LZCNT, 195 FEATURE_MOVBE, 196 FEATURE_MOVDIR64B, 197 FEATURE_MOVDIRI, 198 FEATURE_MWAITX, 199 FEATURE_OSXSAVE, 200 FEATURE_PCONFIG, 201 FEATURE_PKU, 202 FEATURE_PREFETCHWT1, 203 FEATURE_PRFCHW, 204 FEATURE_PTWRITE, 205 FEATURE_RDPID, 206 FEATURE_RDRND, 207 FEATURE_RDSEED, 208 FEATURE_RTM, 209 FEATURE_SERIALIZE, 210 FEATURE_SGX, 211 FEATURE_SHA, 212 FEATURE_SHSTK, 213 FEATURE_TBM, 214 FEATURE_TSXLDTRK, 215 FEATURE_VAES, 216 FEATURE_WAITPKG, 217 FEATURE_WBNOINVD, 218 FEATURE_XSAVE, 219 FEATURE_XSAVEC, 220 FEATURE_XSAVEOPT, 221 FEATURE_XSAVES, 222 FEATURE_AMX_TILE, 223 FEATURE_AMX_INT8, 224 FEATURE_AMX_BF16, 225 FEATURE_UINTR, 226 FEATURE_HRESET, 227 FEATURE_KL, 228 FEATURE_AESKLE, 229 FEATURE_WIDEKL, 230 FEATURE_AVXVNNI, 231 CPU_FEATURE_MAX 232 }; 233 234 /* Size of __cpu_features2 array in libgcc/config/i386/cpuinfo.c. */ 235 #define SIZE_OF_CPU_FEATURES ((CPU_FEATURE_MAX - 1) / 32) 236 237 /* These are the values for vendor types, cpu types and subtypes. Cpu 238 types and subtypes should be subtracted by the corresponding start 239 value. */ 240 241 #define M_CPU_TYPE_START (BUILTIN_VENDOR_MAX) 242 #define M_CPU_SUBTYPE_START \ 243 (M_CPU_TYPE_START + BUILTIN_CPU_TYPE_MAX) 244 #define M_VENDOR(a) (a) 245 #define M_CPU_TYPE(a) (M_CPU_TYPE_START + a) 246 #define M_CPU_SUBTYPE(a) (M_CPU_SUBTYPE_START + a) 247