1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* Hardware counter profiling: cpu types */
41 extern cpu_info_t
*read_cpuinfo();
47 #define MAX_PICS 20 /* Max # of HW ctrs that can be enabled simultaneously */
49 /* type for specifying CPU register number */
51 #define REGNO_ANY ((regno_t)-1)
52 #define REGNO_INVALID ((regno_t)-2)
54 /* --- Utilities for use with regno_t and reg_list[] --- */
55 #define REG_LIST_IS_EMPTY(reg_list) (!(reg_list) || (reg_list)[0] == REGNO_ANY)
56 #define REG_LIST_EOL(regno) ((regno)==REGNO_ANY)
57 #define REG_LIST_SINGLE_VALID_ENTRY(reg_list) \
58 (((reg_list) && (reg_list)[1] == REGNO_ANY && \
59 (reg_list)[0] != REGNO_ANY ) ? (reg_list)[0] : REGNO_ANY)
61 /* enum for specifying unknown or uninitialized CPU */
68 // Note: changing an values below may make older HWC experiments unreadable.
69 // --- Sun/Oracle SPARC ---
70 #define CPC_ULTRA1 1000
71 #define CPC_ULTRA2 1001
72 #define CPC_ULTRA3 1002
73 #define CPC_ULTRA3_PLUS 1003
74 #define CPC_ULTRA3_I 1004
75 #define CPC_ULTRA4_PLUS 1005 /* Panther */
76 #define CPC_ULTRA4 1017 /* Jaguar */
77 #define CPC_ULTRA_T1 1100 /* Niagara1 */
78 #define CPC_ULTRA_T2 1101 /* Niagara2 */
79 #define CPC_ULTRA_T2P 1102
80 #define CPC_ULTRA_T3 1103
81 #define CPC_SPARC_T4 1104
82 #define CPC_SPARC_T5 1110
83 #define CPC_SPARC_T6 1120
84 // #define CPC_SPARC_T7 1130 // use CPC_SPARC_M7
85 #define CPC_SPARC_M4 1204 /* Obsolete */
86 #define CPC_SPARC_M5 1210
87 #define CPC_SPARC_M6 1220
88 #define CPC_SPARC_M7 1230
89 #define CPC_SPARC_M8 1240
93 #define CPC_PENTIUM 2000
94 #define CPC_PENTIUM_MMX 2001
95 #define CPC_PENTIUM_PRO 2002
96 #define CPC_PENTIUM_PRO_MMX 2003
97 #define CPC_PENTIUM_4 2017
98 #define CPC_PENTIUM_4_HT 2027
100 // Core Microarchitecture (Merom/Menryn)
101 #define CPC_INTEL_CORE2 2028
102 #define CPC_INTEL_NEHALEM 2040
103 #define CPC_INTEL_WESTMERE 2042
104 #define CPC_INTEL_SANDYBRIDGE 2045
105 #define CPC_INTEL_IVYBRIDGE 2047
106 #define CPC_INTEL_ATOM 2050 /* Atom*/
107 #define CPC_INTEL_HASWELL 2060
108 #define CPC_INTEL_BROADWELL 2070
109 #define CPC_INTEL_SKYLAKE 2080
110 #define CPC_INTEL_ICELAKE 2081
111 #define CPC_INTEL_UNKNOWN 2499
112 #define CPC_AMD_K8C 2500 /* Opteron, Athlon... */
113 #define CPC_AMD_FAM_10H 2501 /* Barcelona, Shanghai... */
114 #define CPC_AMD_FAM_11H 2502 /* Griffin... */
115 #define CPC_AMD_FAM_15H 2503
116 #define CPC_AMD_Authentic 2504
117 #define CPC_AMD_FAM_19H_ZEN3 2505
118 #define CPC_AMD_FAM_19H_ZEN4 2506
120 #define CPC_KPROF 3003 // OBSOLETE (To support 12.3 and earlier)
121 #define CPC_FOX 3004 /* pseudo-chip */
124 #define CPC_SPARC64_III 3000
125 #define CPC_SPARC64_V 3002
126 #define CPC_SPARC64_VI 4003 /* OPL-C */
127 #define CPC_SPARC64_VII 4004 /* Jupiter */
128 #define CPC_SPARC64_X 4006 /* Athena */
129 #define CPC_SPARC64_XII 4010 /* Athena++ */
132 #define CPC_ARM_GENERIC 3500
133 #define CPC_ARM64_AMCC 3501 /* Applied Micro Circuits Corporation (ARM) */
134 #define CPC_ARM_NEOVERSE_N1 3502
135 #define CPC_ARM_AMPERE_1 3503
137 #define AMD_FAM_19H_ZEN3_NAME "AMD Family 19h (Zen3)"
138 #define AMD_FAM_19H_ZEN4_NAME "AMD Family 19h (Zen4)"
142 AMD_ZEN_FAMILY
= 0x17,
143 AMD_ZEN3_FAMILY
= 0x19
149 AMD_ZENPLUS_RYZEN
= 0x8,
150 AMD_ZENPLUS_RYZEN2
= 0x18,
151 AMD_ZEN2_RYZEN
= 0x31,
152 AMD_ZEN2_RYZEN2
= 0x71,
153 AMD_ZEN2_RYZEN3
= 0x60,
154 AMD_ZEN3_RYZEN
= 0x1,
155 AMD_ZEN3_RYZEN2
= 0x21,
156 AMD_ZEN3_RYZEN3
= 0x50,
157 AMD_ZEN3_EPYC_TRENTO
= 0x30,
158 AMD_ZEN4_RYZEN
= 0x61,
162 // aarch64. Constants from tools/arch/arm64/include/asm/cputype.h
163 // in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
165 ARM_CPU_IMP_ARM
= 0x41,
166 ARM_CPU_IMP_BRCM
= 0x42,
167 ARM_CPU_IMP_CAVIUM
= 0x43,
168 ARM_CPU_IMP_FUJITSU
= 0x46,
169 ARM_CPU_IMP_NVIDIA
= 0x4E,
170 ARM_CPU_IMP_HISI
= 0x48,
171 ARM_CPU_IMP_APM
= 0x50,
172 ARM_CPU_IMP_QCOM
= 0x51,
173 ARM_CPU_IMP_APPLE
= 0x61,
174 ARM_CPU_IMP_AMPERE
= 0xC0
177 // riscv Constants from arch/riscv/include/asm/vendorid_list.h
179 ANDES_VENDOR_ID
= 0x31e,
180 SIFIVE_VENDOR_ID
= 0x489,
181 THEAD_VENDOR_ID
= 0x5b7
184 #define AARCH64_VENDORSTR_ARM "ARM"
186 /* strings below must match those returned by cpc_getcpuver() */
190 const char * cpc2_cciname
;
191 } libcpc2_cpu_lookup_t
;
192 #define LIBCPC2_CPU_LOOKUP_LIST \
193 {CPC_AMD_K8C , "AMD Opteron & Athlon64"}, \
194 {CPC_AMD_FAM_10H , "AMD Family 10h"}, \
195 {CPC_AMD_FAM_11H , "AMD Family 11h"}, \
196 {CPC_AMD_FAM_15H , "AMD Family 15h Model 01h"}, \
197 {CPC_AMD_FAM_15H , "AMD Family 15h Model 02h"},/*future*/ \
198 {CPC_AMD_FAM_15H , "AMD Family 15h Model 03h"},/*future*/ \
199 {CPC_AMD_FAM_19H_ZEN3 , AMD_FAM_19H_ZEN3_NAME}, \
200 {CPC_AMD_FAM_19H_ZEN4 , AMD_FAM_19H_ZEN4_NAME}, \
201 {CPC_PENTIUM_4_HT , "Pentium 4 with HyperThreading"}, \
202 {CPC_PENTIUM_4 , "Pentium 4"}, \
203 {CPC_PENTIUM_PRO_MMX , "Pentium Pro with MMX, Pentium II"}, \
204 {CPC_PENTIUM_PRO , "Pentium Pro, Pentium II"}, \
205 {CPC_PENTIUM_MMX , "Pentium with MMX"}, \
206 {CPC_PENTIUM , "Pentium"}, \
207 {CPC_INTEL_CORE2 , "Core Microarchitecture"}, \
208 /* Merom: F6M15: Clovertown, Kentsfield, Conroe, Merom, Woodcrest */ \
209 /* Merom: F6M22: Merom Conroe */ \
210 /* Penryn: F6M23: Yorkfield, Wolfdale, Penryn, Harpertown */ \
211 /* Penryn: F6M29: Dunnington */ \
212 {CPC_INTEL_NEHALEM , "Intel Arch PerfMon v3 on Family 6 Model 26"},/*Bloomfield, Nehalem EP*/ \
213 {CPC_INTEL_NEHALEM , "Intel Arch PerfMon v3 on Family 6 Model 30"},/*Clarksfield, Lynnfield, Jasper Forest*/ \
214 {CPC_INTEL_NEHALEM , "Intel Arch PerfMon v3 on Family 6 Model 31"},/*(TBD)*/ \
215 {CPC_INTEL_NEHALEM , "Intel Arch PerfMon v3 on Family 6 Model 46"},/*Nehalem EX*/ \
216 {CPC_INTEL_WESTMERE , "Intel Arch PerfMon v3 on Family 6 Model 37"},/*Arrandale, Clarskdale*/ \
217 {CPC_INTEL_WESTMERE , "Intel Arch PerfMon v3 on Family 6 Model 44"},/*Gulftown, Westmere EP*/ \
218 {CPC_INTEL_WESTMERE , "Intel Arch PerfMon v3 on Family 6 Model 47"},/*Westmere EX*/ \
219 {CPC_INTEL_SANDYBRIDGE , "Intel Arch PerfMon v3 on Family 6 Model 42"},/*Sandy Bridge*/ \
220 {CPC_INTEL_SANDYBRIDGE , "Intel Arch PerfMon v3 on Family 6 Model 45"},/*Sandy Bridge E, SandyBridge-EN, SandyBridge EP*/ \
221 {CPC_INTEL_IVYBRIDGE , "Intel Arch PerfMon v3 on Family 6 Model 58"},/*Ivy Bridge*/ \
222 {CPC_INTEL_IVYBRIDGE , "Intel Arch PerfMon v3 on Family 6 Model 62"},/*(TBD)*/ \
223 {CPC_INTEL_ATOM , "Intel Arch PerfMon v3 on Family 6 Model 28"},/*Atom*/ \
224 {CPC_INTEL_HASWELL , "Intel Arch PerfMon v3 on Family 6 Model 60"},/*Haswell*/ \
225 {CPC_INTEL_HASWELL , "Intel Arch PerfMon v3 on Family 6 Model 63"},/*Haswell*/ \
226 {CPC_INTEL_HASWELL , "Intel Arch PerfMon v3 on Family 6 Model 69"},/*Haswell*/ \
227 {CPC_INTEL_HASWELL , "Intel Arch PerfMon v3 on Family 6 Model 70"},/*Haswell*/ \
228 {CPC_INTEL_BROADWELL , "Intel Arch PerfMon v3 on Family 6 Model 61"},/*Broadwell*/ \
229 {CPC_INTEL_BROADWELL , "Intel Arch PerfMon v3 on Family 6 Model 71"},/*Broadwell*/ \
230 {CPC_INTEL_BROADWELL , "Intel Arch PerfMon v3 on Family 6 Model 79"},/*Broadwell*/ \
231 {CPC_INTEL_BROADWELL , "Intel Arch PerfMon v3 on Family 6 Model 86"},/*Broadwell*/ \
232 {CPC_INTEL_SKYLAKE , "Intel Arch PerfMon v4 on Family 6 Model 78"},/*Skylake*/ \
233 {CPC_INTEL_SKYLAKE , "Intel Arch PerfMon v4 on Family 6 Model 85"},/*Skylake*/ \
234 {CPC_INTEL_SKYLAKE , "Intel Arch PerfMon v4 on Family 6 Model 94"},/*Skylake*/ \
235 {CPC_INTEL_UNKNOWN , "Intel Arch PerfMon"},/*Not yet in table*/ \
236 {CPC_SPARC64_III , "SPARC64 III"/*?*/}, \
237 {CPC_SPARC64_V , "SPARC64 V"/*?*/}, \
238 {CPC_SPARC64_VI , "SPARC64 VI"}, \
239 {CPC_SPARC64_VII , "SPARC64 VI & VII"}, \
240 {CPC_SPARC64_X , "SPARC64 X"}, \
241 {CPC_SPARC64_XII , "SPARC64 XII"}, \
242 {CPC_ULTRA_T1 , "UltraSPARC T1"}, \
243 {CPC_ULTRA_T2 , "UltraSPARC T2"}, \
244 {CPC_ULTRA_T2P , "UltraSPARC T2+"}, \
245 {CPC_ULTRA_T3 , "SPARC T3"}, \
246 {CPC_SPARC_T4 , "SPARC T4"}, \
247 {CPC_SPARC_M4 , "SPARC M4"}, \
248 {CPC_SPARC_T5 , "SPARC T5"}, \
249 {CPC_SPARC_M5 , "SPARC M5"}, \
250 {CPC_SPARC_T6 , "SPARC T6"}, \
251 {CPC_SPARC_M6 , "SPARC M6"}, \
252 {CPC_SPARC_M7 , "SPARC T7"}, \
253 {CPC_SPARC_M7 , "SPARC 3e40"}, \
254 {CPC_SPARC_M7 , "SPARC M7"}, \
255 {CPC_SPARC_M8 , "SPARC 3e50"}, \
256 {CPC_ULTRA4_PLUS , "UltraSPARC IV+"}, \
257 {CPC_ULTRA4 , "UltraSPARC IV"}, \
258 {CPC_ULTRA3_I , "UltraSPARC IIIi"}, \
259 {CPC_ULTRA3_I , "UltraSPARC IIIi & IIIi+"}, \
260 {CPC_ULTRA3_PLUS , "UltraSPARC III+"}, \
261 {CPC_ULTRA3_PLUS , "UltraSPARC III+ & IV"}, \
262 {CPC_ULTRA3 , "UltraSPARC III"}, \
263 {CPC_ULTRA2 , "UltraSPARC I&II"}, \
264 {CPC_ULTRA1 , "UltraSPARC I&II"}, \
265 {ARM_CPU_IMP_APM , AARCH64_VENDORSTR_ARM}, \
266 {CPC_AMD_Authentic , "AuthenticAMD"}, \
269 static libcpc2_cpu_lookup_t cpu_table[]={LIBCPC2_CPU_LOOKUP_LIST};