xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/common/hwc_cpus.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos    Contributed by Oracle.
34f645668Schristos 
44f645668Schristos    This file is part of GNU Binutils.
54f645668Schristos 
64f645668Schristos    This program is free software; you can redistribute it and/or modify
74f645668Schristos    it under the terms of the GNU General Public License as published by
84f645668Schristos    the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos    any later version.
104f645668Schristos 
114f645668Schristos    This program is distributed in the hope that it will be useful,
124f645668Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144f645668Schristos    GNU General Public License for more details.
154f645668Schristos 
164f645668Schristos    You should have received a copy of the GNU General Public License
174f645668Schristos    along with this program; if not, write to the Free Software
184f645668Schristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos    MA 02110-1301, USA.  */
204f645668Schristos 
214f645668Schristos /* Hardware counter profiling: cpu types */
224f645668Schristos 
234f645668Schristos #ifndef __HWC_CPUS_H
244f645668Schristos #define __HWC_CPUS_H
254f645668Schristos 
26*cb63e24eSchristos typedef struct
27*cb63e24eSchristos {
28*cb63e24eSchristos   int cpu_cnt;
29*cb63e24eSchristos   int cpu_clk_freq;
30*cb63e24eSchristos   int cpu_model;
31*cb63e24eSchristos   int cpu_family;
32*cb63e24eSchristos   int cpu_vendor;
33*cb63e24eSchristos   char *cpu_vendorstr;
34*cb63e24eSchristos   char *cpu_modelstr;
35*cb63e24eSchristos } cpu_info_t;
36*cb63e24eSchristos 
37*cb63e24eSchristos extern cpu_info_t *read_cpuinfo();
38*cb63e24eSchristos 
394f645668Schristos #define MAX_PICS    20 /* Max # of HW ctrs that can be enabled simultaneously */
404f645668Schristos 
414f645668Schristos   /* type for specifying CPU register number */
424f645668Schristos   typedef int regno_t;
434f645668Schristos #define REGNO_ANY       ((regno_t)-1)
444f645668Schristos #define REGNO_INVALID   ((regno_t)-2)
454f645668Schristos 
464f645668Schristos   /* --- Utilities for use with regno_t and reg_list[] --- */
474f645668Schristos #define REG_LIST_IS_EMPTY(reg_list) (!(reg_list) || (reg_list)[0] == REGNO_ANY)
484f645668Schristos #define REG_LIST_EOL(regno)         ((regno)==REGNO_ANY)
494f645668Schristos #define REG_LIST_SINGLE_VALID_ENTRY(reg_list) \
504f645668Schristos   (((reg_list) && (reg_list)[1] == REGNO_ANY && \
514f645668Schristos       (reg_list)[0] != REGNO_ANY ) ? (reg_list)[0] : REGNO_ANY)
524f645668Schristos 
534f645668Schristos   /* enum for specifying unknown or uninitialized CPU */
544f645668Schristos   enum
554f645668Schristos   {
564f645668Schristos     CPUVER_GENERIC = 0,
574f645668Schristos     CPUVER_UNDEFINED = -1
584f645668Schristos   };
594f645668Schristos 
604f645668Schristos   // Note: changing an values below may make older HWC experiments unreadable.
614f645668Schristos   // --- Sun/Oracle SPARC ---
624f645668Schristos #define CPC_ULTRA1              1000
634f645668Schristos #define CPC_ULTRA2              1001
644f645668Schristos #define CPC_ULTRA3              1002
654f645668Schristos #define CPC_ULTRA3_PLUS         1003
664f645668Schristos #define CPC_ULTRA3_I            1004
674f645668Schristos #define CPC_ULTRA4_PLUS         1005 /* Panther */
684f645668Schristos #define CPC_ULTRA4              1017 /* Jaguar */
694f645668Schristos #define CPC_ULTRA_T1            1100 /* Niagara1 */
704f645668Schristos #define CPC_ULTRA_T2            1101 /* Niagara2 */
714f645668Schristos #define CPC_ULTRA_T2P           1102
724f645668Schristos #define CPC_ULTRA_T3            1103
734f645668Schristos #define CPC_SPARC_T4            1104
744f645668Schristos #define CPC_SPARC_T5            1110
754f645668Schristos #define CPC_SPARC_T6            1120
764f645668Schristos // #define CPC_SPARC_T7         1130 // use CPC_SPARC_M7
774f645668Schristos #define CPC_SPARC_M4            1204 /* Obsolete */
784f645668Schristos #define CPC_SPARC_M5            1210
794f645668Schristos #define CPC_SPARC_M6            1220
804f645668Schristos #define CPC_SPARC_M7            1230
814f645668Schristos #define CPC_SPARC_M8            1240
824f645668Schristos 
834f645668Schristos   // --- Intel ---
844f645668Schristos   // Pentium
854f645668Schristos #define CPC_PENTIUM             2000
864f645668Schristos #define CPC_PENTIUM_MMX         2001
874f645668Schristos #define CPC_PENTIUM_PRO         2002
884f645668Schristos #define CPC_PENTIUM_PRO_MMX     2003
894f645668Schristos #define CPC_PENTIUM_4           2017
904f645668Schristos #define CPC_PENTIUM_4_HT        2027
914f645668Schristos 
924f645668Schristos   // Core Microarchitecture (Merom/Menryn)
934f645668Schristos #define CPC_INTEL_CORE2         2028
944f645668Schristos #define CPC_INTEL_NEHALEM       2040
954f645668Schristos #define CPC_INTEL_WESTMERE      2042
964f645668Schristos #define CPC_INTEL_SANDYBRIDGE   2045
974f645668Schristos #define CPC_INTEL_IVYBRIDGE     2047
984f645668Schristos #define CPC_INTEL_ATOM          2050 /* Atom*/
994f645668Schristos #define CPC_INTEL_HASWELL       2060
1004f645668Schristos #define CPC_INTEL_BROADWELL     2070
1014f645668Schristos #define CPC_INTEL_SKYLAKE       2080
1024f645668Schristos #define CPC_INTEL_UNKNOWN       2499
1034f645668Schristos #define CPC_AMD_K8C             2500 /* Opteron, Athlon... */
1044f645668Schristos #define CPC_AMD_FAM_10H         2501 /* Barcelona, Shanghai... */
1054f645668Schristos #define CPC_AMD_FAM_11H         2502 /* Griffin... */
1064f645668Schristos #define CPC_AMD_FAM_15H         2503
107*cb63e24eSchristos #define CPC_AMD_Authentic       2504
108*cb63e24eSchristos 
1094f645668Schristos #define CPC_KPROF               3003 // OBSOLETE (To support 12.3 and earlier)
1104f645668Schristos #define CPC_FOX                 3004 /* pseudo-chip */
1114f645668Schristos 
1124f645668Schristos   // --- Fujitsu ---
1134f645668Schristos #define CPC_SPARC64_III     3000
1144f645668Schristos #define CPC_SPARC64_V       3002
1154f645668Schristos #define CPC_SPARC64_VI      4003 /* OPL-C */
1164f645668Schristos #define CPC_SPARC64_VII     4004 /* Jupiter */
1174f645668Schristos #define CPC_SPARC64_X       4006 /* Athena */
1184f645668Schristos #define CPC_SPARC64_XII     4010 /* Athena++ */
1194f645668Schristos 
1204f645668Schristos // aarch64. Constants from arch/arm64/include/asm/cputype.h
1214f645668Schristos enum {
1224f645668Schristos     ARM_CPU_IMP_ARM     = 0x41,
1234f645668Schristos     ARM_CPU_IMP_BRCM    = 0x42,
1244f645668Schristos     ARM_CPU_IMP_CAVIUM  = 0x43,
1254f645668Schristos     ARM_CPU_IMP_APM     = 0x50,
1264f645668Schristos     ARM_CPU_IMP_QCOM    = 0x51
1274f645668Schristos };
1284f645668Schristos 
1294f645668Schristos #define	AARCH64_VENDORSTR_ARM	"ARM"
1304f645668Schristos 
1314f645668Schristos   /* strings below must match those returned by cpc_getcpuver() */
1324f645668Schristos   typedef struct
1334f645668Schristos   {
1344f645668Schristos     int cpc2_cpuver;
1354f645668Schristos     const char * cpc2_cciname;
1364f645668Schristos   } libcpc2_cpu_lookup_t;
1374f645668Schristos #define LIBCPC2_CPU_LOOKUP_LIST \
1384f645668Schristos   {CPC_AMD_K8C               , "AMD Opteron & Athlon64"}, \
1394f645668Schristos   {CPC_AMD_FAM_10H           , "AMD Family 10h"}, \
1404f645668Schristos   {CPC_AMD_FAM_11H           , "AMD Family 11h"}, \
1414f645668Schristos   {CPC_AMD_FAM_15H           , "AMD Family 15h Model 01h"}, \
1424f645668Schristos   {CPC_AMD_FAM_15H           , "AMD Family 15h Model 02h"},/*future*/ \
1434f645668Schristos   {CPC_AMD_FAM_15H           , "AMD Family 15h Model 03h"},/*future*/ \
1444f645668Schristos   {CPC_PENTIUM_4_HT          , "Pentium 4 with HyperThreading"}, \
1454f645668Schristos   {CPC_PENTIUM_4             , "Pentium 4"}, \
1464f645668Schristos   {CPC_PENTIUM_PRO_MMX       , "Pentium Pro with MMX, Pentium II"}, \
1474f645668Schristos   {CPC_PENTIUM_PRO           , "Pentium Pro, Pentium II"}, \
1484f645668Schristos   {CPC_PENTIUM_MMX           , "Pentium with MMX"}, \
1494f645668Schristos   {CPC_PENTIUM               , "Pentium"}, \
1504f645668Schristos   {CPC_INTEL_CORE2           , "Core Microarchitecture"}, \
1514f645668Schristos     /* Merom:  F6M15: Clovertown, Kentsfield, Conroe, Merom, Woodcrest */ \
1524f645668Schristos     /* Merom:  F6M22: Merom Conroe */ \
1534f645668Schristos     /* Penryn: F6M23: Yorkfield, Wolfdale, Penryn, Harpertown */ \
1544f645668Schristos     /* Penryn: F6M29: Dunnington */ \
1554f645668Schristos   {CPC_INTEL_NEHALEM         , "Intel Arch PerfMon v3 on Family 6 Model 26"},/*Bloomfield, Nehalem EP*/ \
1564f645668Schristos   {CPC_INTEL_NEHALEM         , "Intel Arch PerfMon v3 on Family 6 Model 30"},/*Clarksfield, Lynnfield, Jasper Forest*/ \
1574f645668Schristos   {CPC_INTEL_NEHALEM         , "Intel Arch PerfMon v3 on Family 6 Model 31"},/*(TBD)*/ \
1584f645668Schristos   {CPC_INTEL_NEHALEM         , "Intel Arch PerfMon v3 on Family 6 Model 46"},/*Nehalem EX*/ \
1594f645668Schristos   {CPC_INTEL_WESTMERE        , "Intel Arch PerfMon v3 on Family 6 Model 37"},/*Arrandale, Clarskdale*/ \
1604f645668Schristos   {CPC_INTEL_WESTMERE        , "Intel Arch PerfMon v3 on Family 6 Model 44"},/*Gulftown, Westmere EP*/ \
1614f645668Schristos   {CPC_INTEL_WESTMERE        , "Intel Arch PerfMon v3 on Family 6 Model 47"},/*Westmere EX*/ \
1624f645668Schristos   {CPC_INTEL_SANDYBRIDGE     , "Intel Arch PerfMon v3 on Family 6 Model 42"},/*Sandy Bridge*/ \
1634f645668Schristos   {CPC_INTEL_SANDYBRIDGE     , "Intel Arch PerfMon v3 on Family 6 Model 45"},/*Sandy Bridge E, SandyBridge-EN, SandyBridge EP*/ \
1644f645668Schristos   {CPC_INTEL_IVYBRIDGE       , "Intel Arch PerfMon v3 on Family 6 Model 58"},/*Ivy Bridge*/ \
1654f645668Schristos   {CPC_INTEL_IVYBRIDGE       , "Intel Arch PerfMon v3 on Family 6 Model 62"},/*(TBD)*/ \
1664f645668Schristos   {CPC_INTEL_ATOM            , "Intel Arch PerfMon v3 on Family 6 Model 28"},/*Atom*/ \
1674f645668Schristos   {CPC_INTEL_HASWELL         , "Intel Arch PerfMon v3 on Family 6 Model 60"},/*Haswell*/ \
1684f645668Schristos   {CPC_INTEL_HASWELL         , "Intel Arch PerfMon v3 on Family 6 Model 63"},/*Haswell*/ \
1694f645668Schristos   {CPC_INTEL_HASWELL         , "Intel Arch PerfMon v3 on Family 6 Model 69"},/*Haswell*/ \
1704f645668Schristos   {CPC_INTEL_HASWELL         , "Intel Arch PerfMon v3 on Family 6 Model 70"},/*Haswell*/ \
1714f645668Schristos   {CPC_INTEL_BROADWELL       , "Intel Arch PerfMon v3 on Family 6 Model 61"},/*Broadwell*/ \
1724f645668Schristos   {CPC_INTEL_BROADWELL       , "Intel Arch PerfMon v3 on Family 6 Model 71"},/*Broadwell*/ \
1734f645668Schristos   {CPC_INTEL_BROADWELL       , "Intel Arch PerfMon v3 on Family 6 Model 79"},/*Broadwell*/ \
1744f645668Schristos   {CPC_INTEL_BROADWELL       , "Intel Arch PerfMon v3 on Family 6 Model 86"},/*Broadwell*/ \
1754f645668Schristos   {CPC_INTEL_SKYLAKE         , "Intel Arch PerfMon v4 on Family 6 Model 78"},/*Skylake*/ \
1764f645668Schristos   {CPC_INTEL_SKYLAKE         , "Intel Arch PerfMon v4 on Family 6 Model 85"},/*Skylake*/ \
1774f645668Schristos   {CPC_INTEL_SKYLAKE         , "Intel Arch PerfMon v4 on Family 6 Model 94"},/*Skylake*/ \
1784f645668Schristos   {CPC_INTEL_UNKNOWN         , "Intel Arch PerfMon"},/*Not yet in table*/ \
1794f645668Schristos   {CPC_SPARC64_III           , "SPARC64 III"/*?*/}, \
1804f645668Schristos   {CPC_SPARC64_V             , "SPARC64 V"/*?*/}, \
1814f645668Schristos   {CPC_SPARC64_VI            , "SPARC64 VI"}, \
1824f645668Schristos   {CPC_SPARC64_VII           , "SPARC64 VI & VII"}, \
1834f645668Schristos   {CPC_SPARC64_X             , "SPARC64 X"}, \
1844f645668Schristos   {CPC_SPARC64_XII           , "SPARC64 XII"}, \
1854f645668Schristos   {CPC_ULTRA_T1              , "UltraSPARC T1"}, \
1864f645668Schristos   {CPC_ULTRA_T2              , "UltraSPARC T2"}, \
1874f645668Schristos   {CPC_ULTRA_T2P             , "UltraSPARC T2+"}, \
1884f645668Schristos   {CPC_ULTRA_T3              , "SPARC T3"},  \
1894f645668Schristos   {CPC_SPARC_T4              , "SPARC T4"},  \
1904f645668Schristos   {CPC_SPARC_M4              , "SPARC M4"},  \
1914f645668Schristos   {CPC_SPARC_T5              , "SPARC T5"},  \
1924f645668Schristos   {CPC_SPARC_M5              , "SPARC M5"},  \
1934f645668Schristos   {CPC_SPARC_T6              , "SPARC T6"},  \
1944f645668Schristos   {CPC_SPARC_M6              , "SPARC M6"},  \
1954f645668Schristos   {CPC_SPARC_M7              , "SPARC T7"},  \
1964f645668Schristos   {CPC_SPARC_M7              , "SPARC 3e40"},  \
1974f645668Schristos   {CPC_SPARC_M7              , "SPARC M7"},  \
1984f645668Schristos   {CPC_SPARC_M8              , "SPARC 3e50"},  \
1994f645668Schristos   {CPC_ULTRA4_PLUS           , "UltraSPARC IV+"}, \
2004f645668Schristos   {CPC_ULTRA4                , "UltraSPARC IV"}, \
2014f645668Schristos   {CPC_ULTRA3_I              , "UltraSPARC IIIi"}, \
2024f645668Schristos   {CPC_ULTRA3_I              , "UltraSPARC IIIi & IIIi+"}, \
2034f645668Schristos   {CPC_ULTRA3_PLUS           , "UltraSPARC III+"}, \
2044f645668Schristos   {CPC_ULTRA3_PLUS           , "UltraSPARC III+ & IV"}, \
2054f645668Schristos   {CPC_ULTRA3                , "UltraSPARC III"}, \
2064f645668Schristos   {CPC_ULTRA2                , "UltraSPARC I&II"}, \
2074f645668Schristos   {CPC_ULTRA1                , "UltraSPARC I&II"}, \
2084f645668Schristos   {ARM_CPU_IMP_APM           , AARCH64_VENDORSTR_ARM}, \
209*cb63e24eSchristos   {CPC_AMD_Authentic         , "AuthenticAMD"}, \
2104f645668Schristos   {0, NULL}
2114f645668Schristos   /* init like this:
2124f645668Schristos      static libcpc2_cpu_lookup_t cpu_table[]={LIBCPC2_CPU_LOOKUP_LIST};
2134f645668Schristos    */
2144f645668Schristos #endif
215