Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | #ifndef CPUINFO_H |
| 3 | #define CPUINFO_H |
| 4 | |
| 5 | #ifndef __cplusplus |
| 6 | #include <stdbool.h> |
| 7 | #endif |
| 8 | |
Hao Lu | 3617d5b | 2017-10-23 15:16:50 -0700 | [diff] [blame] | 9 | #ifdef __APPLE__ |
| 10 | #include <TargetConditionals.h> |
| 11 | #endif |
| 12 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | |
| 15 | /* Identify architecture and define corresponding macro */ |
| 16 | |
| 17 | #if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) |
| 18 | #define CPUINFO_ARCH_X86 1 |
| 19 | #endif |
| 20 | |
| 21 | #if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) |
| 22 | #define CPUINFO_ARCH_X86_64 1 |
| 23 | #endif |
| 24 | |
| 25 | #if defined(__arm__) || defined(_M_ARM) |
| 26 | #define CPUINFO_ARCH_ARM 1 |
| 27 | #endif |
| 28 | |
| 29 | #if defined(__aarch64__) || defined(_M_ARM64) |
| 30 | #define CPUINFO_ARCH_ARM64 1 |
| 31 | #endif |
| 32 | |
| 33 | #if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) |
| 34 | #define CPUINFO_ARCH_PPC64 1 |
| 35 | #endif |
| 36 | |
| 37 | #if defined(__pnacl__) |
| 38 | #define CPUINFO_ARCH_PNACL 1 |
| 39 | #endif |
| 40 | |
| 41 | #if defined(EMSCRIPTEN) |
| 42 | #define CPUINFO_ARCH_ASMJS 1 |
| 43 | #endif |
| 44 | |
| 45 | #if CPUINFO_ARCH_X86 && defined(_MSC_VER) |
| 46 | #define CPUINFO_ABI __cdecl |
| 47 | #elif CPUINFO_ARCH_X86 && defined(__GNUC__) |
| 48 | #define CPUINFO_ABI __attribute__((__cdecl__)) |
| 49 | #else |
| 50 | #define CPUINFO_ABI |
| 51 | #endif |
| 52 | |
| 53 | /* Define other architecture-specific macros as 0 */ |
| 54 | |
| 55 | #ifndef CPUINFO_ARCH_X86 |
| 56 | #define CPUINFO_ARCH_X86 0 |
| 57 | #endif |
| 58 | |
| 59 | #ifndef CPUINFO_ARCH_X86_64 |
| 60 | #define CPUINFO_ARCH_X86_64 0 |
| 61 | #endif |
| 62 | |
| 63 | #ifndef CPUINFO_ARCH_ARM |
| 64 | #define CPUINFO_ARCH_ARM 0 |
| 65 | #endif |
| 66 | |
| 67 | #ifndef CPUINFO_ARCH_ARM64 |
| 68 | #define CPUINFO_ARCH_ARM64 0 |
| 69 | #endif |
| 70 | |
| 71 | #ifndef CPUINFO_ARCH_PPC64 |
| 72 | #define CPUINFO_ARCH_PPC64 0 |
| 73 | #endif |
| 74 | |
| 75 | #ifndef CPUINFO_ARCH_PNACL |
| 76 | #define CPUINFO_ARCH_PNACL 0 |
| 77 | #endif |
| 78 | |
| 79 | #ifndef CPUINFO_ARCH_ASMJS |
| 80 | #define CPUINFO_ARCH_ASMJS 0 |
| 81 | #endif |
| 82 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 83 | #define CPUINFO_CACHE_UNIFIED 0x00000001 |
| 84 | #define CPUINFO_CACHE_INCLUSIVE 0x00000002 |
| 85 | #define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004 |
| 86 | |
| 87 | struct cpuinfo_cache { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 88 | /** Cache size in bytes */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 89 | uint32_t size; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 90 | /** Number of ways of associativity */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 91 | uint32_t associativity; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 92 | /** Number of sets */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 93 | uint32_t sets; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 94 | /** Number of partitions */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 95 | uint32_t partitions; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 96 | /** Line size in bytes */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 97 | uint32_t line_size; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 98 | /** |
| 99 | * Binary characteristics of the cache (unified cache, inclusive cache, cache with complex indexing). |
| 100 | * |
| 101 | * @see CPUINFO_CACHE_UNIFIED, CPUINFO_CACHE_INCLUSIVE, CPUINFO_CACHE_COMPLEX_INDEXING |
| 102 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 103 | uint32_t flags; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 104 | /** Index of the first logical processor that shares this cache */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 105 | uint32_t processor_start; |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 106 | /** Number of logical processors that share this cache */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 107 | uint32_t processor_count; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | struct cpuinfo_trace_cache { |
| 111 | uint32_t uops; |
| 112 | uint32_t associativity; |
| 113 | }; |
| 114 | |
| 115 | #define CPUINFO_PAGE_SIZE_4KB 0x1000 |
| 116 | #define CPUINFO_PAGE_SIZE_1MB 0x100000 |
| 117 | #define CPUINFO_PAGE_SIZE_2MB 0x200000 |
| 118 | #define CPUINFO_PAGE_SIZE_4MB 0x400000 |
| 119 | #define CPUINFO_PAGE_SIZE_16MB 0x1000000 |
| 120 | #define CPUINFO_PAGE_SIZE_1GB 0x40000000 |
| 121 | |
| 122 | struct cpuinfo_tlb { |
| 123 | uint32_t entries; |
| 124 | uint32_t associativity; |
| 125 | uint64_t pages; |
| 126 | }; |
| 127 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 128 | /** Vendor of processor core design */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 129 | enum cpuinfo_vendor { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 130 | /** Processor vendor is not known to the library, or the library failed to get vendor information from the OS. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 131 | cpuinfo_vendor_unknown = 0, |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 132 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 133 | /* Active vendors of modern CPUs */ |
| 134 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 135 | /** |
| 136 | * Intel Corporation. Vendor of x86, x86-64, IA64, and ARM processor microarchitectures. |
| 137 | * |
| 138 | * Sold its ARM design subsidiary in 2006. The last ARM processor design was released in 2004. |
| 139 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 140 | cpuinfo_vendor_intel = 1, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 141 | /** Advanced Micro Devices, Inc. Vendor of x86 and x86-64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 142 | cpuinfo_vendor_amd = 2, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 143 | /** ARM Holdings plc. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 144 | cpuinfo_vendor_arm = 3, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 145 | /** Qualcomm Incorporated. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 146 | cpuinfo_vendor_qualcomm = 4, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 147 | /** Apple Inc. Vendor of ARM and ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 148 | cpuinfo_vendor_apple = 5, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 149 | /** Samsung Electronics Co., Ltd. Vendir if ARM64 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 150 | cpuinfo_vendor_samsung = 6, |
Marat Dukhan | 93982f2 | 2017-10-20 13:10:23 -0700 | [diff] [blame] | 151 | /** Nvidia Corporation. Vendor of ARM64-compatible processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 152 | cpuinfo_vendor_nvidia = 7, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 153 | /** MIPS Technologies, Inc. Vendor of MIPS processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 154 | cpuinfo_vendor_mips = 8, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 155 | /** International Business Machines Corporation. Vendor of PowerPC processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 156 | cpuinfo_vendor_ibm = 9, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 157 | /** Ingenic Semiconductor. Vendor of MIPS processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 158 | cpuinfo_vendor_ingenic = 10, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 159 | /** |
| 160 | * VIA Technologies, Inc. Vendor of x86 and x86-64 processor microarchitectures. |
| 161 | * |
| 162 | * Processors are designed by Centaur Technology, a subsidiary of VIA Technologies. |
| 163 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 164 | cpuinfo_vendor_via = 11, |
Marat Dukhan | 92dae31 | 2017-05-09 14:10:17 +0000 | [diff] [blame] | 165 | /** Cavium, Inc. Vendor of ARM64 processor microarchitectures. */ |
| 166 | cpuinfo_vendor_cavium = 12, |
Marat Dukhan | 1ae7ff8 | 2018-05-13 19:30:58 -0700 | [diff] [blame] | 167 | /** Broadcom, Inc. Vendor of ARM processor microarchitectures. */ |
| 168 | cpuinfo_vendor_broadcom = 13, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 169 | /** Applied Micro Circuits Corporation (APM). Vendor of ARM64 processor microarchitectures. */ |
| 170 | cpuinfo_vendor_apm = 14, |
Marat Dukhan | b73f61a | 2018-09-02 23:57:56 +0300 | [diff] [blame^] | 171 | /** |
| 172 | * Huawei Technologies Co., Ltd. Vendor of ARM64 processor microarchitectures. |
| 173 | * |
| 174 | * Processors are designed by HiSilicon, a subsidiary of Huawei. |
| 175 | */ |
| 176 | cpuinfo_vendor_huawei = 15, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 177 | |
| 178 | /* Active vendors of embedded CPUs */ |
| 179 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 180 | /** Texas Instruments Inc. Vendor of ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 181 | cpuinfo_vendor_texas_instruments = 30, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 182 | /** Marvell Technology Group Ltd. Vendor of ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 183 | cpuinfo_vendor_marvell = 31, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 184 | /** RDC Semiconductor Co., Ltd. Vendor of x86 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 185 | cpuinfo_vendor_rdc = 32, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 186 | /** DM&P Electronics Inc. Vendor of x86 processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 187 | cpuinfo_vendor_dmp = 33, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 188 | /** Motorola, Inc. Vendor of PowerPC and ARM processor microarchitectures. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 189 | cpuinfo_vendor_motorola = 34, |
| 190 | |
| 191 | /* Defunct CPU vendors */ |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 192 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 193 | /** |
| 194 | * Transmeta Corporation. Vendor of x86 processor microarchitectures. |
| 195 | * |
| 196 | * Now defunct. The last processor design was released in 2004. |
| 197 | * Transmeta processors implemented VLIW ISA and used binary translation to execute x86 code. |
| 198 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 199 | cpuinfo_vendor_transmeta = 50, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 200 | /** |
| 201 | * Cyrix Corporation. Vendor of x86 processor microarchitectures. |
| 202 | * |
| 203 | * Now defunct. The last processor design was released in 1996. |
| 204 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 205 | cpuinfo_vendor_cyrix = 51, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 206 | /** |
| 207 | * Rise Technology. Vendor of x86 processor microarchitectures. |
| 208 | * |
| 209 | * Now defunct. The last processor design was released in 1999. |
| 210 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 211 | cpuinfo_vendor_rise = 52, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 212 | /** |
| 213 | * National Semiconductor. Vendor of x86 processor microarchitectures. |
| 214 | * |
| 215 | * Sold its x86 design subsidiary in 1999. The last processor design was released in 1998. |
| 216 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 217 | cpuinfo_vendor_nsc = 53, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 218 | /** |
| 219 | * Silicon Integrated Systems. Vendor of x86 processor microarchitectures. |
| 220 | * |
| 221 | * Sold its x86 design subsidiary in 2001. The last processor design was released in 2001. |
| 222 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 223 | cpuinfo_vendor_sis = 54, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 224 | /** |
| 225 | * NexGen. Vendor of x86 processor microarchitectures. |
| 226 | * |
| 227 | * Now defunct. The last processor design was released in 1994. |
| 228 | * NexGen designed the first x86 microarchitecture which decomposed x86 instructions into simple microoperations. |
| 229 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 230 | cpuinfo_vendor_nexgen = 55, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 231 | /** |
| 232 | * United Microelectronics Corporation. Vendor of x86 processor microarchitectures. |
| 233 | * |
| 234 | * Ceased x86 in the early 1990s. The last processor design was released in 1991. |
| 235 | * Designed U5C and U5D processors. Both are 486 level. |
| 236 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 237 | cpuinfo_vendor_umc = 56, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 238 | /** |
| 239 | * Digital Equipment Corporation. Vendor of ARM processor microarchitecture. |
| 240 | * |
| 241 | * Sold its ARM designs in 1997. The last processor design was released in 1997. |
| 242 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 243 | cpuinfo_vendor_dec = 57, |
| 244 | }; |
| 245 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 246 | /** |
| 247 | * Processor microarchitecture |
| 248 | * |
| 249 | * Processors with different microarchitectures often have different instruction performance characteristics, |
| 250 | * and may have dramatically different pipeline organization. |
| 251 | */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 252 | enum cpuinfo_uarch { |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 253 | /** Microarchitecture is unknown, or the library failed to get information about the microarchitecture from OS */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 254 | cpuinfo_uarch_unknown = 0, |
| 255 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 256 | /** Pentium and Pentium MMX microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 257 | cpuinfo_uarch_p5 = 0x00100100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 258 | /** Intel Quark microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 259 | cpuinfo_uarch_quark = 0x00100101, |
| 260 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 261 | /** Pentium Pro, Pentium II, and Pentium III. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 262 | cpuinfo_uarch_p6 = 0x00100200, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 263 | /** Pentium M. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 264 | cpuinfo_uarch_dothan = 0x00100201, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 265 | /** Intel Core microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 266 | cpuinfo_uarch_yonah = 0x00100202, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 267 | /** Intel Core 2 microarchitecture on 65 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 268 | cpuinfo_uarch_conroe = 0x00100203, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 269 | /** Intel Core 2 microarchitecture on 45 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 270 | cpuinfo_uarch_penryn = 0x00100204, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 271 | /** Intel Nehalem and Westmere microarchitectures (Core i3/i5/i7 1st gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 272 | cpuinfo_uarch_nehalem = 0x00100205, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 273 | /** Intel Sandy Bridge microarchitecture (Core i3/i5/i7 2nd gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 274 | cpuinfo_uarch_sandy_bridge = 0x00100206, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 275 | /** Intel Ivy Bridge microarchitecture (Core i3/i5/i7 3rd gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 276 | cpuinfo_uarch_ivy_bridge = 0x00100207, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 277 | /** Intel Haswell microarchitecture (Core i3/i5/i7 4th gen). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 278 | cpuinfo_uarch_haswell = 0x00100208, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 279 | /** Intel Broadwell microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 280 | cpuinfo_uarch_broadwell = 0x00100209, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 281 | /** Intel Sky Lake microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 282 | cpuinfo_uarch_sky_lake = 0x0010020A, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 283 | /** Intel Kaby Lake microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 284 | cpuinfo_uarch_kaby_lake = 0x0010020B, |
| 285 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 286 | /** Pentium 4 with Willamette, Northwood, or Foster cores. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 287 | cpuinfo_uarch_willamette = 0x00100300, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 288 | /** Pentium 4 with Prescott and later cores. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 289 | cpuinfo_uarch_prescott = 0x00100301, |
| 290 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 291 | /** Intel Atom on 45 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 292 | cpuinfo_uarch_bonnell = 0x00100400, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 293 | /** Intel Atom on 32 nm process. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 294 | cpuinfo_uarch_saltwell = 0x00100401, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 295 | /** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 296 | cpuinfo_uarch_silvermont = 0x00100402, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 297 | /** Intel Airmont microarchitecture (14 nm out-of-order Atom). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 298 | cpuinfo_uarch_airmont = 0x00100403, |
| 299 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 300 | /** Intel Knights Ferry HPC boards. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 301 | cpuinfo_uarch_knights_ferry = 0x00100500, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 302 | /** Intel Knights Corner HPC boards (aka Xeon Phi). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 303 | cpuinfo_uarch_knights_corner = 0x00100501, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 304 | /** Intel Knights Landing microarchitecture (second-gen MIC). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 305 | cpuinfo_uarch_knights_landing = 0x00100502, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 306 | /** Intel Knights Hill microarchitecture (third-gen MIC). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 307 | cpuinfo_uarch_knights_hill = 0x00100503, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 308 | /** Intel Knights Mill Xeon Phi. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 309 | cpuinfo_uarch_knights_mill = 0x00100504, |
| 310 | |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 311 | /** Intel/Marvell XScale series. */ |
| 312 | cpuinfo_uarch_xscale = 0x00100600, |
| 313 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 314 | /** AMD K5. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 315 | cpuinfo_uarch_k5 = 0x00200100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 316 | /** AMD K6 and alike. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 317 | cpuinfo_uarch_k6 = 0x00200101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 318 | /** AMD Athlon and Duron. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 319 | cpuinfo_uarch_k7 = 0x00200102, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 320 | /** AMD Athlon 64, Opteron 64. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 321 | cpuinfo_uarch_k8 = 0x00200103, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 322 | /** AMD Family 10h (Barcelona, Istambul, Magny-Cours). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 323 | cpuinfo_uarch_k10 = 0x00200104, |
| 324 | /** |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 325 | * AMD Bulldozer microarchitecture |
| 326 | * Zambezi FX-series CPUs, Zurich, Valencia and Interlagos Opteron CPUs. |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 327 | */ |
| 328 | cpuinfo_uarch_bulldozer = 0x00200105, |
| 329 | /** |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 330 | * AMD Piledriver microarchitecture |
| 331 | * Vishera FX-series CPUs, Trinity and Richland APUs, Delhi, Seoul, Abu Dhabi Opteron CPUs. |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 332 | */ |
| 333 | cpuinfo_uarch_piledriver = 0x00200106, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 334 | /** AMD Steamroller microarchitecture (Kaveri APUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 335 | cpuinfo_uarch_steamroller = 0x00200107, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 336 | /** AMD Excavator microarchitecture (Carizzo APUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 337 | cpuinfo_uarch_excavator = 0x00200108, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 338 | /** AMD Zen microarchitecture (Ryzen CPUs). */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 339 | cpuinfo_uarch_zen = 0x00200109, |
| 340 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 341 | /** NSC Geode and AMD Geode GX and LX. */ |
Marat Dukhan | e25187d | 2017-04-16 05:03:07 -0400 | [diff] [blame] | 342 | cpuinfo_uarch_geode = 0x00200200, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 343 | /** AMD Bobcat mobile microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 344 | cpuinfo_uarch_bobcat = 0x00200201, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 345 | /** AMD Jaguar mobile microarchitecture. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 346 | cpuinfo_uarch_jaguar = 0x00200202, |
Marat Dukhan | 818e199 | 2018-02-24 15:39:18 +0100 | [diff] [blame] | 347 | /** AMD Puma mobile microarchitecture. */ |
| 348 | cpuinfo_uarch_puma = 0x00200203, |
Marat Dukhan | b92e2ed | 2017-09-26 19:26:41 -0700 | [diff] [blame] | 349 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 350 | /** ARM7 series. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 351 | cpuinfo_uarch_arm7 = 0x00300100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 352 | /** ARM9 series. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 353 | cpuinfo_uarch_arm9 = 0x00300101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 354 | /** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 355 | cpuinfo_uarch_arm11 = 0x00300102, |
| 356 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 357 | /** ARM Cortex-A5. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 358 | cpuinfo_uarch_cortex_a5 = 0x00300205, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 359 | /** ARM Cortex-A7. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 360 | cpuinfo_uarch_cortex_a7 = 0x00300207, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 361 | /** ARM Cortex-A8. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 362 | cpuinfo_uarch_cortex_a8 = 0x00300208, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 363 | /** ARM Cortex-A9. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 364 | cpuinfo_uarch_cortex_a9 = 0x00300209, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 365 | /** ARM Cortex-A12. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 366 | cpuinfo_uarch_cortex_a12 = 0x00300212, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 367 | /** ARM Cortex-A15. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 368 | cpuinfo_uarch_cortex_a15 = 0x00300215, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 369 | /** ARM Cortex-A17. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 370 | cpuinfo_uarch_cortex_a17 = 0x00300217, |
| 371 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 372 | /** ARM Cortex-A32. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 373 | cpuinfo_uarch_cortex_a32 = 0x00300332, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 374 | /** ARM Cortex-A35. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 375 | cpuinfo_uarch_cortex_a35 = 0x00300335, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 376 | /** ARM Cortex-A53. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 377 | cpuinfo_uarch_cortex_a53 = 0x00300353, |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 378 | /** ARM Cortex-A55. */ |
| 379 | cpuinfo_uarch_cortex_a55 = 0x00300355, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 380 | /** ARM Cortex-A57. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 381 | cpuinfo_uarch_cortex_a57 = 0x00300357, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 382 | /** ARM Cortex-A72. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 383 | cpuinfo_uarch_cortex_a72 = 0x00300372, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 384 | /** ARM Cortex-A73. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 385 | cpuinfo_uarch_cortex_a73 = 0x00300373, |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 386 | /** ARM Cortex-A75. */ |
| 387 | cpuinfo_uarch_cortex_a75 = 0x00300375, |
Marat Dukhan | b73f61a | 2018-09-02 23:57:56 +0300 | [diff] [blame^] | 388 | /** ARM Cortex-A76. */ |
| 389 | cpuinfo_uarch_cortex_a76 = 0x00300376, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 390 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 391 | /** Qualcomm Scorpion. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 392 | cpuinfo_uarch_scorpion = 0x00400100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 393 | /** Qualcomm Krait. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 394 | cpuinfo_uarch_krait = 0x00400101, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 395 | /** Qualcomm Kryo. */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 396 | cpuinfo_uarch_kryo = 0x00400102, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 397 | /** Qualcomm Falkor. */ |
| 398 | cpuinfo_uarch_falkor = 0x00400103, |
| 399 | /** Qualcomm Saphira. */ |
| 400 | cpuinfo_uarch_saphira = 0x00400104, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 401 | |
Marat Dukhan | 93982f2 | 2017-10-20 13:10:23 -0700 | [diff] [blame] | 402 | /** Nvidia Denver. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 403 | cpuinfo_uarch_denver = 0x00500100, |
Marat Dukhan | 1e6c8c9 | 2018-05-13 20:24:07 -0700 | [diff] [blame] | 404 | /** Nvidia Denver 2. */ |
| 405 | cpuinfo_uarch_denver2 = 0x00500101, |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 406 | |
Marat Dukhan | dcf096d | 2018-03-07 11:09:16 -0800 | [diff] [blame] | 407 | /** Samsung Mongoose M1 (Exynos 8890 big cores). */ |
Marat Dukhan | a750f2a | 2018-03-07 11:07:48 -0800 | [diff] [blame] | 408 | cpuinfo_uarch_mongoose_m1 = 0x00600100, |
Marat Dukhan | dcf096d | 2018-03-07 11:09:16 -0800 | [diff] [blame] | 409 | /** Samsung Mongoose M2 (Exynos 8895 big cores). */ |
Marat Dukhan | a750f2a | 2018-03-07 11:07:48 -0800 | [diff] [blame] | 410 | cpuinfo_uarch_mongoose_m2 = 0x00600101, |
Marat Dukhan | 10eae00 | 2018-03-29 18:36:31 -0700 | [diff] [blame] | 411 | /** Samsung Meerkat M3 (Exynos 9810 big cores). */ |
| 412 | cpuinfo_uarch_meerkat_m3 = 0x00600102, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 413 | |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 414 | /** Apple A6 and A6X processors. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 415 | cpuinfo_uarch_swift = 0x00700100, |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 416 | /** Apple A7 processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 417 | cpuinfo_uarch_cyclone = 0x00700101, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 418 | /** Apple A8 and A8X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 419 | cpuinfo_uarch_typhoon = 0x00700102, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 420 | /** Apple A9 and A9X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 421 | cpuinfo_uarch_twister = 0x00700103, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 422 | /** Apple A10 and A10X processor. */ |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 423 | cpuinfo_uarch_hurricane = 0x00700104, |
Hao Lu | 922070c | 2017-10-18 16:29:02 -0700 | [diff] [blame] | 424 | /** Apple A11 processor (big cores). */ |
| 425 | cpuinfo_uarch_monsoon = 0x00700105, |
| 426 | /** Apple A11 processor (little cores). */ |
| 427 | cpuinfo_uarch_mistral = 0x00700106, |
Marat Dukhan | 92dae31 | 2017-05-09 14:10:17 +0000 | [diff] [blame] | 428 | |
| 429 | /** Cavium ThunderX. */ |
| 430 | cpuinfo_uarch_thunderx = 0x00800100, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 431 | /** Cavium ThunderX2 (originally Broadcom Vulkan). */ |
| 432 | cpuinfo_uarch_thunderx2 = 0x00800200, |
Marat Dukhan | 8871832 | 2017-08-24 10:12:20 -0700 | [diff] [blame] | 433 | |
| 434 | /** Marvell PJ4. */ |
| 435 | cpuinfo_uarch_pj4 = 0x00900100, |
Marat Dukhan | 1ae7ff8 | 2018-05-13 19:30:58 -0700 | [diff] [blame] | 436 | |
| 437 | /** Broadcom Brahma B15. */ |
| 438 | cpuinfo_uarch_brahma_b15 = 0x00A00100, |
| 439 | /** Broadcom Brahma B53. */ |
| 440 | cpuinfo_uarch_brahma_b53 = 0x00A00101, |
Marat Dukhan | 029030c | 2018-05-13 20:10:22 -0700 | [diff] [blame] | 441 | |
| 442 | /** Applied Micro X-Gene. */ |
| 443 | cpuinfo_uarch_xgene = 0x00B00100, |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 444 | }; |
| 445 | |
| 446 | struct cpuinfo_processor { |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 447 | /** SMT (hyperthread) ID within a core */ |
| 448 | uint32_t smt_id; |
| 449 | /** Core containing this logical processor */ |
| 450 | const struct cpuinfo_core* core; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 451 | /** Cluster of cores containing this logical processor */ |
| 452 | const struct cpuinfo_cluster* cluster; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 453 | /** Physical package containing this logical processor */ |
| 454 | const struct cpuinfo_package* package; |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 455 | #if defined(__linux__) |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 456 | /** |
| 457 | * Linux-specific ID for the logical processor: |
| 458 | * - Linux kernel exposes information about this logical processor in /sys/devices/system/cpu/cpu<linux_id>/ |
| 459 | * - Bit <linux_id> in the cpu_set_t identifies this logical processor |
| 460 | */ |
Marat Dukhan | 15e1df9 | 2017-09-13 11:10:10 -0700 | [diff] [blame] | 461 | int linux_id; |
| 462 | #endif |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 463 | #if defined(_WIN32) |
| 464 | /** Windows-specific ID for the group containing the logical processor. */ |
| 465 | uint16_t windows_group_id; |
| 466 | /** |
| 467 | * Windows-specific ID of the logical processor within its group: |
| 468 | * - Bit <windows_processor_id> in the KAFFINITY mask identifies this logical processor within its group. |
| 469 | */ |
| 470 | uint16_t windows_processor_id; |
| 471 | #endif |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 472 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 473 | /** APIC ID (unique x86-specific ID of the logical processor) */ |
| 474 | uint32_t apic_id; |
| 475 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 476 | struct { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 477 | /** Level 1 instruction cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 478 | const struct cpuinfo_cache* l1i; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 479 | /** Level 1 data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 480 | const struct cpuinfo_cache* l1d; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 481 | /** Level 2 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 482 | const struct cpuinfo_cache* l2; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 483 | /** Level 3 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 484 | const struct cpuinfo_cache* l3; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 485 | /** Level 4 unified or data cache */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 486 | const struct cpuinfo_cache* l4; |
| 487 | } cache; |
| 488 | }; |
| 489 | |
| 490 | struct cpuinfo_core { |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 491 | /** Index of the first logical processor on this core. */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 492 | uint32_t processor_start; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 493 | /** Number of logical processors on this core */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 494 | uint32_t processor_count; |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 495 | /** Core ID within a package */ |
| 496 | uint32_t core_id; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 497 | /** Cluster containing this core */ |
| 498 | const struct cpuinfo_cluster* cluster; |
| 499 | /** Physical package containing this core. */ |
Marat Dukhan | 2d37dc4 | 2017-09-25 01:32:37 -0700 | [diff] [blame] | 500 | const struct cpuinfo_package* package; |
| 501 | /** Vendor of the CPU microarchitecture for this core */ |
| 502 | enum cpuinfo_vendor vendor; |
| 503 | /** CPU microarchitecture for this core */ |
| 504 | enum cpuinfo_uarch uarch; |
| 505 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 506 | /** Value of CPUID leaf 1 EAX register for this core */ |
| 507 | uint32_t cpuid; |
| 508 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 509 | /** Value of Main ID Register (MIDR) for this core */ |
| 510 | uint32_t midr; |
| 511 | #endif |
Marat Dukhan | 28538f4 | 2018-03-10 14:28:14 -0800 | [diff] [blame] | 512 | /** Clock rate (non-Turbo) of the core, in Hz */ |
| 513 | uint64_t frequency; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 514 | }; |
| 515 | |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 516 | struct cpuinfo_cluster { |
| 517 | /** Index of the first logical processor in the cluster */ |
| 518 | uint32_t processor_start; |
| 519 | /** Number of logical processors in the cluster */ |
| 520 | uint32_t processor_count; |
| 521 | /** Index of the first core in the cluster */ |
| 522 | uint32_t core_start; |
| 523 | /** Number of cores on the cluster */ |
| 524 | uint32_t core_count; |
| 525 | /** Cluster ID within a package */ |
| 526 | uint32_t cluster_id; |
| 527 | /** Physical package containing the cluster */ |
| 528 | const struct cpuinfo_package* package; |
| 529 | /** CPU microarchitecture vendor of the cores in the cluster */ |
| 530 | enum cpuinfo_vendor vendor; |
| 531 | /** CPU microarchitecture of the cores in the cluster */ |
| 532 | enum cpuinfo_uarch uarch; |
| 533 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 534 | /** Value of CPUID leaf 1 EAX register of the cores in the cluster */ |
| 535 | uint32_t cpuid; |
| 536 | #elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 537 | /** Value of Main ID Register (MIDR) of the cores in the cluster */ |
| 538 | uint32_t midr; |
| 539 | #endif |
| 540 | /** Clock rate (non-Turbo) of the cores in the cluster, in Hz */ |
| 541 | uint64_t frequency; |
| 542 | }; |
| 543 | |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 544 | #define CPUINFO_PACKAGE_NAME_MAX 48 |
Marat Dukhan | c40c731 | 2017-09-21 16:08:18 -0700 | [diff] [blame] | 545 | #define CPUINFO_GPU_NAME_MAX 64 |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 546 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 547 | struct cpuinfo_package { |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 548 | /** SoC or processor chip model name */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 549 | char name[CPUINFO_PACKAGE_NAME_MAX]; |
Hao Lu | 3617d5b | 2017-10-23 15:16:50 -0700 | [diff] [blame] | 550 | #if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE) |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 551 | /** Integrated GPU model name */ |
| 552 | char gpu_name[CPUINFO_GPU_NAME_MAX]; |
| 553 | #endif |
| 554 | /** Index of the first logical processor on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 555 | uint32_t processor_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 556 | /** Number of logical processors on this physical package */ |
Marat Dukhan | ab3a127 | 2017-08-25 23:20:07 -0700 | [diff] [blame] | 557 | uint32_t processor_count; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 558 | /** Index of the first core on this physical package */ |
Marat Dukhan | fb4fbe0 | 2017-09-13 00:51:05 -0700 | [diff] [blame] | 559 | uint32_t core_start; |
Marat Dukhan | 8f79efb | 2017-09-25 11:17:21 -0700 | [diff] [blame] | 560 | /** Number of cores on this physical package */ |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 561 | uint32_t core_count; |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 562 | /** Index of the first cluster of cores on this physical package */ |
| 563 | uint32_t cluster_start; |
| 564 | /** Number of clusters of cores on this physical package */ |
| 565 | uint32_t cluster_count; |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 566 | }; |
| 567 | |
| 568 | #ifdef __cplusplus |
| 569 | extern "C" { |
| 570 | #endif |
| 571 | |
Marat Dukhan | 5355651 | 2018-02-25 09:01:27 +0100 | [diff] [blame] | 572 | bool CPUINFO_ABI cpuinfo_initialize(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 573 | |
| 574 | void CPUINFO_ABI cpuinfo_deinitialize(void); |
| 575 | |
| 576 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 577 | /* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions instead. */ |
| 578 | struct cpuinfo_x86_isa { |
| 579 | #if CPUINFO_ARCH_X86 |
| 580 | bool rdtsc; |
| 581 | #endif |
| 582 | bool rdtscp; |
| 583 | bool rdpid; |
| 584 | bool sysenter; |
| 585 | #if CPUINFO_ARCH_X86 |
| 586 | bool syscall; |
| 587 | #endif |
| 588 | bool msr; |
| 589 | bool clzero; |
| 590 | bool clflush; |
| 591 | bool clflushopt; |
| 592 | bool mwait; |
| 593 | bool mwaitx; |
| 594 | #if CPUINFO_ARCH_X86 |
| 595 | bool emmx; |
| 596 | #endif |
| 597 | bool fxsave; |
| 598 | bool xsave; |
| 599 | #if CPUINFO_ARCH_X86 |
| 600 | bool fpu; |
| 601 | bool mmx; |
| 602 | bool mmx_plus; |
| 603 | #endif |
| 604 | bool three_d_now; |
| 605 | bool three_d_now_plus; |
| 606 | #if CPUINFO_ARCH_X86 |
| 607 | bool three_d_now_geode; |
| 608 | #endif |
| 609 | bool prefetch; |
| 610 | bool prefetchw; |
| 611 | bool prefetchwt1; |
| 612 | #if CPUINFO_ARCH_X86 |
| 613 | bool daz; |
| 614 | bool sse; |
| 615 | bool sse2; |
| 616 | #endif |
| 617 | bool sse3; |
| 618 | bool ssse3; |
| 619 | bool sse4_1; |
| 620 | bool sse4_2; |
| 621 | bool sse4a; |
| 622 | bool misaligned_sse; |
| 623 | bool avx; |
| 624 | bool fma3; |
| 625 | bool fma4; |
| 626 | bool xop; |
| 627 | bool f16c; |
| 628 | bool avx2; |
| 629 | bool avx512f; |
| 630 | bool avx512pf; |
| 631 | bool avx512er; |
| 632 | bool avx512cd; |
| 633 | bool avx512dq; |
| 634 | bool avx512bw; |
| 635 | bool avx512vl; |
| 636 | bool avx512ifma; |
| 637 | bool avx512vbmi; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 638 | bool avx512vbmi2; |
| 639 | bool avx512bitalg; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 640 | bool avx512vpopcntdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 641 | bool avx512vnni; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 642 | bool avx512_4vnniw; |
| 643 | bool avx512_4fmaps; |
| 644 | bool hle; |
| 645 | bool rtm; |
| 646 | bool xtest; |
| 647 | bool mpx; |
| 648 | #if CPUINFO_ARCH_X86 |
| 649 | bool cmov; |
| 650 | bool cmpxchg8b; |
| 651 | #endif |
| 652 | bool cmpxchg16b; |
| 653 | bool clwb; |
| 654 | bool movbe; |
| 655 | #if CPUINFO_ARCH_X86_64 |
| 656 | bool lahf_sahf; |
| 657 | #endif |
| 658 | bool fs_gs_base; |
| 659 | bool lzcnt; |
| 660 | bool popcnt; |
| 661 | bool tbm; |
| 662 | bool bmi; |
| 663 | bool bmi2; |
| 664 | bool adx; |
| 665 | bool aes; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 666 | bool vaes; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 667 | bool pclmulqdq; |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 668 | bool vpclmulqdq; |
| 669 | bool gfni; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 670 | bool rdrand; |
| 671 | bool rdseed; |
| 672 | bool sha; |
| 673 | bool rng; |
| 674 | bool ace; |
| 675 | bool ace2; |
| 676 | bool phe; |
| 677 | bool pmm; |
| 678 | bool lwp; |
| 679 | }; |
| 680 | |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 681 | extern struct cpuinfo_x86_isa cpuinfo_isa; |
| 682 | #endif |
| 683 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 684 | static inline bool cpuinfo_has_x86_rdtsc(void) { |
| 685 | #if CPUINFO_ARCH_X86_64 |
| 686 | return true; |
| 687 | #elif CPUINFO_ARCH_X86 |
| 688 | #if defined(__ANDROID__) |
| 689 | return true; |
| 690 | #else |
| 691 | return cpuinfo_isa.rdtsc; |
| 692 | #endif |
| 693 | #else |
| 694 | return false; |
| 695 | #endif |
| 696 | } |
| 697 | |
| 698 | static inline bool cpuinfo_has_x86_rdtscp(void) { |
| 699 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 700 | return cpuinfo_isa.rdtscp; |
| 701 | #else |
| 702 | return false; |
| 703 | #endif |
| 704 | } |
| 705 | |
| 706 | static inline bool cpuinfo_has_x86_rdpid(void) { |
| 707 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 708 | return cpuinfo_isa.rdpid; |
| 709 | #else |
| 710 | return false; |
| 711 | #endif |
| 712 | } |
| 713 | |
| 714 | static inline bool cpuinfo_has_x86_clzero(void) { |
| 715 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 716 | return cpuinfo_isa.clzero; |
| 717 | #else |
| 718 | return false; |
| 719 | #endif |
| 720 | } |
| 721 | |
| 722 | static inline bool cpuinfo_has_x86_mwait(void) { |
| 723 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 724 | return cpuinfo_isa.mwait; |
| 725 | #else |
| 726 | return false; |
| 727 | #endif |
| 728 | } |
| 729 | |
| 730 | static inline bool cpuinfo_has_x86_mwaitx(void) { |
| 731 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 732 | return cpuinfo_isa.mwaitx; |
| 733 | #else |
| 734 | return false; |
| 735 | #endif |
| 736 | } |
| 737 | |
| 738 | static inline bool cpuinfo_has_x86_fxsave(void) { |
| 739 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 740 | return cpuinfo_isa.fxsave; |
| 741 | #else |
| 742 | return false; |
| 743 | #endif |
| 744 | } |
| 745 | |
| 746 | static inline bool cpuinfo_has_x86_xsave(void) { |
| 747 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 748 | return cpuinfo_isa.xsave; |
| 749 | #else |
| 750 | return false; |
| 751 | #endif |
| 752 | } |
| 753 | |
| 754 | static inline bool cpuinfo_has_x86_fpu(void) { |
| 755 | #if CPUINFO_ARCH_X86_64 |
| 756 | return true; |
| 757 | #elif CPUINFO_ARCH_X86 |
| 758 | #if defined(__ANDROID__) |
| 759 | return true; |
| 760 | #else |
| 761 | return cpuinfo_isa.fpu; |
| 762 | #endif |
| 763 | #else |
| 764 | return false; |
| 765 | #endif |
| 766 | } |
| 767 | |
| 768 | static inline bool cpuinfo_has_x86_mmx(void) { |
| 769 | #if CPUINFO_ARCH_X86_64 |
| 770 | return true; |
| 771 | #elif CPUINFO_ARCH_X86 |
| 772 | #if defined(__ANDROID__) |
| 773 | return true; |
| 774 | #else |
| 775 | return cpuinfo_isa.mmx; |
| 776 | #endif |
| 777 | #else |
| 778 | return false; |
| 779 | #endif |
| 780 | } |
| 781 | |
| 782 | static inline bool cpuinfo_has_x86_mmx_plus(void) { |
| 783 | #if CPUINFO_ARCH_X86_64 |
| 784 | return true; |
| 785 | #elif CPUINFO_ARCH_X86 |
| 786 | #if defined(__ANDROID__) |
| 787 | return true; |
| 788 | #else |
| 789 | return cpuinfo_isa.mmx_plus; |
| 790 | #endif |
| 791 | #else |
| 792 | return false; |
| 793 | #endif |
| 794 | } |
| 795 | |
| 796 | static inline bool cpuinfo_has_x86_3dnow(void) { |
| 797 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 798 | return cpuinfo_isa.three_d_now; |
| 799 | #else |
| 800 | return false; |
| 801 | #endif |
| 802 | } |
| 803 | |
| 804 | static inline bool cpuinfo_has_x86_3dnow_plus(void) { |
| 805 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 806 | return cpuinfo_isa.three_d_now_plus; |
| 807 | #else |
| 808 | return false; |
| 809 | #endif |
| 810 | } |
| 811 | |
| 812 | static inline bool cpuinfo_has_x86_3dnow_geode(void) { |
| 813 | #if CPUINFO_ARCH_X86_64 |
| 814 | return false; |
| 815 | #elif CPUINFO_ARCH_X86 |
| 816 | #if defined(__ANDROID__) |
| 817 | return false; |
| 818 | #else |
| 819 | return cpuinfo_isa.three_d_now_geode; |
| 820 | #endif |
| 821 | #else |
| 822 | return false; |
| 823 | #endif |
| 824 | } |
| 825 | |
| 826 | static inline bool cpuinfo_has_x86_prefetch(void) { |
| 827 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 828 | return cpuinfo_isa.prefetch; |
| 829 | #else |
| 830 | return false; |
| 831 | #endif |
| 832 | } |
| 833 | |
| 834 | static inline bool cpuinfo_has_x86_prefetchw(void) { |
| 835 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 836 | return cpuinfo_isa.prefetchw; |
| 837 | #else |
| 838 | return false; |
| 839 | #endif |
| 840 | } |
| 841 | |
| 842 | static inline bool cpuinfo_has_x86_prefetchwt1(void) { |
| 843 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 844 | return cpuinfo_isa.prefetchwt1; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 845 | #else |
| 846 | return false; |
| 847 | #endif |
| 848 | } |
| 849 | |
| 850 | static inline bool cpuinfo_has_x86_daz(void) { |
| 851 | #if CPUINFO_ARCH_X86_64 |
| 852 | return true; |
| 853 | #elif CPUINFO_ARCH_X86 |
| 854 | #if defined(__ANDROID__) |
| 855 | return true; |
| 856 | #else |
| 857 | return cpuinfo_isa.daz; |
| 858 | #endif |
| 859 | #else |
| 860 | return false; |
| 861 | #endif |
| 862 | } |
| 863 | |
Marat Dukhan | 9da4c91 | 2017-09-26 10:53:28 -0700 | [diff] [blame] | 864 | static inline bool cpuinfo_has_x86_sse(void) { |
| 865 | #if CPUINFO_ARCH_X86_64 |
| 866 | return true; |
| 867 | #elif CPUINFO_ARCH_X86 |
| 868 | #if defined(__ANDROID__) |
| 869 | return true; |
| 870 | #else |
| 871 | return cpuinfo_isa.sse; |
| 872 | #endif |
| 873 | #else |
| 874 | return false; |
| 875 | #endif |
| 876 | } |
| 877 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 878 | static inline bool cpuinfo_has_x86_sse2(void) { |
| 879 | #if CPUINFO_ARCH_X86_64 |
| 880 | return true; |
| 881 | #elif CPUINFO_ARCH_X86 |
| 882 | #if defined(__ANDROID__) |
| 883 | return true; |
| 884 | #else |
| 885 | return cpuinfo_isa.sse2; |
| 886 | #endif |
| 887 | #else |
| 888 | return false; |
| 889 | #endif |
| 890 | } |
| 891 | |
| 892 | static inline bool cpuinfo_has_x86_sse3(void) { |
| 893 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 894 | #if defined(__ANDROID__) |
| 895 | return true; |
| 896 | #else |
| 897 | return cpuinfo_isa.sse3; |
| 898 | #endif |
| 899 | #else |
| 900 | return false; |
| 901 | #endif |
| 902 | } |
| 903 | |
| 904 | static inline bool cpuinfo_has_x86_ssse3(void) { |
| 905 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 906 | #if defined(__ANDROID__) |
| 907 | return true; |
| 908 | #else |
| 909 | return cpuinfo_isa.ssse3; |
| 910 | #endif |
| 911 | #else |
| 912 | return false; |
| 913 | #endif |
| 914 | } |
| 915 | |
| 916 | static inline bool cpuinfo_has_x86_sse4_1(void) { |
| 917 | #if CPUINFO_ARCH_X86_64 |
| 918 | #if defined(__ANDROID__) |
| 919 | return true; |
| 920 | #else |
| 921 | return cpuinfo_isa.sse4_1; |
| 922 | #endif |
| 923 | #elif CPUINFO_ARCH_X86 |
| 924 | return cpuinfo_isa.sse4_1; |
| 925 | #else |
| 926 | return false; |
| 927 | #endif |
| 928 | } |
| 929 | |
| 930 | static inline bool cpuinfo_has_x86_sse4_2(void) { |
| 931 | #if CPUINFO_ARCH_X86_64 |
| 932 | #if defined(__ANDROID__) |
| 933 | return true; |
| 934 | #else |
| 935 | return cpuinfo_isa.sse4_2; |
| 936 | #endif |
| 937 | #elif CPUINFO_ARCH_X86 |
| 938 | return cpuinfo_isa.sse4_2; |
| 939 | #else |
| 940 | return false; |
| 941 | #endif |
| 942 | } |
| 943 | |
| 944 | static inline bool cpuinfo_has_x86_sse4a(void) { |
| 945 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 946 | return cpuinfo_isa.sse4a; |
| 947 | #else |
| 948 | return false; |
| 949 | #endif |
| 950 | } |
| 951 | |
| 952 | static inline bool cpuinfo_has_x86_misaligned_sse(void) { |
| 953 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 954 | return cpuinfo_isa.misaligned_sse; |
| 955 | #else |
| 956 | return false; |
| 957 | #endif |
| 958 | } |
| 959 | |
| 960 | static inline bool cpuinfo_has_x86_avx(void) { |
| 961 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 962 | return cpuinfo_isa.avx; |
| 963 | #else |
| 964 | return false; |
| 965 | #endif |
| 966 | } |
| 967 | |
| 968 | static inline bool cpuinfo_has_x86_fma3(void) { |
| 969 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 970 | return cpuinfo_isa.fma3; |
| 971 | #else |
| 972 | return false; |
| 973 | #endif |
| 974 | } |
| 975 | |
| 976 | static inline bool cpuinfo_has_x86_fma4(void) { |
| 977 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 978 | return cpuinfo_isa.fma4; |
| 979 | #else |
| 980 | return false; |
| 981 | #endif |
| 982 | } |
| 983 | |
| 984 | static inline bool cpuinfo_has_x86_xop(void) { |
| 985 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 986 | return cpuinfo_isa.xop; |
| 987 | #else |
| 988 | return false; |
| 989 | #endif |
| 990 | } |
| 991 | |
| 992 | static inline bool cpuinfo_has_x86_f16c(void) { |
| 993 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 994 | return cpuinfo_isa.f16c; |
| 995 | #else |
| 996 | return false; |
| 997 | #endif |
| 998 | } |
| 999 | |
| 1000 | static inline bool cpuinfo_has_x86_avx2(void) { |
| 1001 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1002 | return cpuinfo_isa.avx2; |
| 1003 | #else |
| 1004 | return false; |
| 1005 | #endif |
| 1006 | } |
| 1007 | |
| 1008 | static inline bool cpuinfo_has_x86_avx512f(void) { |
| 1009 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1010 | return cpuinfo_isa.avx512f; |
| 1011 | #else |
| 1012 | return false; |
| 1013 | #endif |
| 1014 | } |
| 1015 | |
| 1016 | static inline bool cpuinfo_has_x86_avx512pf(void) { |
| 1017 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1018 | return cpuinfo_isa.avx512pf; |
| 1019 | #else |
| 1020 | return false; |
| 1021 | #endif |
| 1022 | } |
| 1023 | |
| 1024 | static inline bool cpuinfo_has_x86_avx512er(void) { |
| 1025 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1026 | return cpuinfo_isa.avx512er; |
| 1027 | #else |
| 1028 | return false; |
| 1029 | #endif |
| 1030 | } |
| 1031 | |
| 1032 | static inline bool cpuinfo_has_x86_avx512cd(void) { |
| 1033 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1034 | return cpuinfo_isa.avx512cd; |
| 1035 | #else |
| 1036 | return false; |
| 1037 | #endif |
| 1038 | } |
| 1039 | |
| 1040 | static inline bool cpuinfo_has_x86_avx512dq(void) { |
| 1041 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1042 | return cpuinfo_isa.avx512dq; |
| 1043 | #else |
| 1044 | return false; |
| 1045 | #endif |
| 1046 | } |
| 1047 | |
| 1048 | static inline bool cpuinfo_has_x86_avx512bw(void) { |
| 1049 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1050 | return cpuinfo_isa.avx512bw; |
| 1051 | #else |
| 1052 | return false; |
| 1053 | #endif |
| 1054 | } |
| 1055 | |
| 1056 | static inline bool cpuinfo_has_x86_avx512vl(void) { |
| 1057 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1058 | return cpuinfo_isa.avx512vl; |
| 1059 | #else |
| 1060 | return false; |
| 1061 | #endif |
| 1062 | } |
| 1063 | |
| 1064 | static inline bool cpuinfo_has_x86_avx512ifma(void) { |
| 1065 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1066 | return cpuinfo_isa.avx512ifma; |
| 1067 | #else |
| 1068 | return false; |
| 1069 | #endif |
| 1070 | } |
| 1071 | |
| 1072 | static inline bool cpuinfo_has_x86_avx512vbmi(void) { |
| 1073 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1074 | return cpuinfo_isa.avx512vbmi; |
| 1075 | #else |
| 1076 | return false; |
| 1077 | #endif |
| 1078 | } |
| 1079 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1080 | static inline bool cpuinfo_has_x86_avx512vbmi2(void) { |
| 1081 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1082 | return cpuinfo_isa.avx512vbmi2; |
| 1083 | #else |
| 1084 | return false; |
| 1085 | #endif |
| 1086 | } |
| 1087 | |
| 1088 | static inline bool cpuinfo_has_x86_avx512bitalg(void) { |
| 1089 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1090 | return cpuinfo_isa.avx512bitalg; |
| 1091 | #else |
| 1092 | return false; |
| 1093 | #endif |
| 1094 | } |
| 1095 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1096 | static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) { |
| 1097 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1098 | return cpuinfo_isa.avx512vpopcntdq; |
| 1099 | #else |
| 1100 | return false; |
| 1101 | #endif |
| 1102 | } |
| 1103 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1104 | static inline bool cpuinfo_has_x86_avx512vnni(void) { |
Marat Dukhan | 6b33b23 | 2017-10-13 09:36:52 -0700 | [diff] [blame] | 1105 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1106 | return cpuinfo_isa.avx512vnni; |
| 1107 | #else |
| 1108 | return false; |
| 1109 | #endif |
| 1110 | } |
| 1111 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1112 | static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { |
| 1113 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1114 | return cpuinfo_isa.avx512_4vnniw; |
| 1115 | #else |
| 1116 | return false; |
| 1117 | #endif |
| 1118 | } |
| 1119 | |
| 1120 | static inline bool cpuinfo_has_x86_avx512_4fmaps(void) { |
| 1121 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1122 | return cpuinfo_isa.avx512_4fmaps; |
| 1123 | #else |
| 1124 | return false; |
| 1125 | #endif |
| 1126 | } |
| 1127 | |
Marat Dukhan | 9e32e8d | 2017-09-26 11:02:37 -0700 | [diff] [blame] | 1128 | static inline bool cpuinfo_has_x86_hle(void) { |
| 1129 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1130 | return cpuinfo_isa.hle; |
| 1131 | #else |
| 1132 | return false; |
| 1133 | #endif |
| 1134 | } |
| 1135 | |
| 1136 | static inline bool cpuinfo_has_x86_rtm(void) { |
| 1137 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1138 | return cpuinfo_isa.rtm; |
| 1139 | #else |
| 1140 | return false; |
| 1141 | #endif |
| 1142 | } |
| 1143 | |
| 1144 | static inline bool cpuinfo_has_x86_xtest(void) { |
| 1145 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1146 | return cpuinfo_isa.xtest; |
| 1147 | #else |
| 1148 | return false; |
| 1149 | #endif |
| 1150 | } |
| 1151 | |
| 1152 | static inline bool cpuinfo_has_x86_mpx(void) { |
| 1153 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1154 | return cpuinfo_isa.mpx; |
| 1155 | #else |
| 1156 | return false; |
| 1157 | #endif |
| 1158 | } |
| 1159 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1160 | static inline bool cpuinfo_has_x86_cmov(void) { |
| 1161 | #if CPUINFO_ARCH_X86_64 |
| 1162 | return true; |
| 1163 | #elif CPUINFO_ARCH_X86 |
| 1164 | return cpuinfo_isa.cmov; |
| 1165 | #else |
| 1166 | return false; |
| 1167 | #endif |
| 1168 | } |
| 1169 | |
| 1170 | static inline bool cpuinfo_has_x86_cmpxchg8b(void) { |
| 1171 | #if CPUINFO_ARCH_X86_64 |
| 1172 | return true; |
| 1173 | #elif CPUINFO_ARCH_X86 |
| 1174 | return cpuinfo_isa.cmpxchg8b; |
| 1175 | #else |
| 1176 | return false; |
| 1177 | #endif |
| 1178 | } |
| 1179 | |
| 1180 | static inline bool cpuinfo_has_x86_cmpxchg16b(void) { |
| 1181 | #if CPUINFO_ARCH_X86_64 |
| 1182 | return cpuinfo_isa.cmpxchg16b; |
| 1183 | #else |
| 1184 | return false; |
| 1185 | #endif |
| 1186 | } |
| 1187 | |
| 1188 | static inline bool cpuinfo_has_x86_clwb(void) { |
| 1189 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1190 | return cpuinfo_isa.clwb; |
| 1191 | #else |
| 1192 | return false; |
| 1193 | #endif |
| 1194 | } |
| 1195 | |
| 1196 | static inline bool cpuinfo_has_x86_movbe(void) { |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1197 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1198 | return cpuinfo_isa.movbe; |
| 1199 | #else |
| 1200 | return false; |
| 1201 | #endif |
| 1202 | } |
| 1203 | |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1204 | static inline bool cpuinfo_has_x86_lahf_sahf(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1205 | #if CPUINFO_ARCH_X86 |
| 1206 | return true; |
| 1207 | #elif CPUINFO_ARCH_X86_64 |
| 1208 | return cpuinfo_isa.lahf_sahf; |
| 1209 | #else |
| 1210 | return false; |
| 1211 | #endif |
| 1212 | } |
| 1213 | |
| 1214 | static inline bool cpuinfo_has_x86_lzcnt(void) { |
| 1215 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1216 | return cpuinfo_isa.lzcnt; |
| 1217 | #else |
| 1218 | return false; |
| 1219 | #endif |
| 1220 | } |
| 1221 | |
| 1222 | static inline bool cpuinfo_has_x86_popcnt(void) { |
| 1223 | #if CPUINFO_ARCH_X86_64 |
| 1224 | #if defined(__ANDROID__) |
| 1225 | return true; |
| 1226 | #else |
| 1227 | return cpuinfo_isa.popcnt; |
| 1228 | #endif |
| 1229 | #elif CPUINFO_ARCH_X86 |
| 1230 | return cpuinfo_isa.popcnt; |
| 1231 | #else |
| 1232 | return false; |
| 1233 | #endif |
| 1234 | } |
| 1235 | |
| 1236 | static inline bool cpuinfo_has_x86_tbm(void) { |
| 1237 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1238 | return cpuinfo_isa.tbm; |
| 1239 | #else |
| 1240 | return false; |
| 1241 | #endif |
| 1242 | } |
| 1243 | |
| 1244 | static inline bool cpuinfo_has_x86_bmi(void) { |
| 1245 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1246 | return cpuinfo_isa.bmi; |
| 1247 | #else |
| 1248 | return false; |
| 1249 | #endif |
| 1250 | } |
| 1251 | |
| 1252 | static inline bool cpuinfo_has_x86_bmi2(void) { |
| 1253 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1254 | return cpuinfo_isa.bmi2; |
| 1255 | #else |
| 1256 | return false; |
| 1257 | #endif |
| 1258 | } |
| 1259 | |
| 1260 | static inline bool cpuinfo_has_x86_adx(void) { |
| 1261 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1262 | return cpuinfo_isa.adx; |
| 1263 | #else |
| 1264 | return false; |
| 1265 | #endif |
| 1266 | } |
| 1267 | |
| 1268 | static inline bool cpuinfo_has_x86_aes(void) { |
| 1269 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1270 | return cpuinfo_isa.aes; |
| 1271 | #else |
| 1272 | return false; |
| 1273 | #endif |
| 1274 | } |
| 1275 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1276 | static inline bool cpuinfo_has_x86_vaes(void) { |
| 1277 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1278 | return cpuinfo_isa.vaes; |
| 1279 | #else |
| 1280 | return false; |
| 1281 | #endif |
| 1282 | } |
| 1283 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1284 | static inline bool cpuinfo_has_x86_pclmulqdq(void) { |
| 1285 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1286 | return cpuinfo_isa.pclmulqdq; |
| 1287 | #else |
| 1288 | return false; |
| 1289 | #endif |
| 1290 | } |
| 1291 | |
Marat Dukhan | 861d21a | 2017-10-13 07:10:25 -0700 | [diff] [blame] | 1292 | static inline bool cpuinfo_has_x86_vpclmulqdq(void) { |
| 1293 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1294 | return cpuinfo_isa.vpclmulqdq; |
| 1295 | #else |
| 1296 | return false; |
| 1297 | #endif |
| 1298 | } |
| 1299 | |
| 1300 | static inline bool cpuinfo_has_x86_gfni(void) { |
| 1301 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1302 | return cpuinfo_isa.gfni; |
| 1303 | #else |
| 1304 | return false; |
| 1305 | #endif |
| 1306 | } |
| 1307 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1308 | static inline bool cpuinfo_has_x86_rdrand(void) { |
| 1309 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1310 | return cpuinfo_isa.rdrand; |
| 1311 | #else |
| 1312 | return false; |
| 1313 | #endif |
| 1314 | } |
| 1315 | |
| 1316 | static inline bool cpuinfo_has_x86_rdseed(void) { |
| 1317 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1318 | return cpuinfo_isa.rdseed; |
| 1319 | #else |
| 1320 | return false; |
| 1321 | #endif |
| 1322 | } |
| 1323 | |
| 1324 | static inline bool cpuinfo_has_x86_sha(void) { |
| 1325 | #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 |
| 1326 | return cpuinfo_isa.sha; |
| 1327 | #else |
| 1328 | return false; |
| 1329 | #endif |
| 1330 | } |
| 1331 | |
Marat Dukhan | ab42e7e | 2017-05-09 13:19:39 +0000 | [diff] [blame] | 1332 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1333 | /* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions instead. */ |
| 1334 | struct cpuinfo_arm_isa { |
| 1335 | #if CPUINFO_ARCH_ARM |
| 1336 | bool thumb; |
| 1337 | bool thumb2; |
| 1338 | bool thumbee; |
| 1339 | bool jazelle; |
| 1340 | bool armv5e; |
| 1341 | bool armv6; |
| 1342 | bool armv6k; |
| 1343 | bool armv7; |
| 1344 | bool armv7mp; |
| 1345 | bool idiv; |
| 1346 | |
| 1347 | bool vfpv2; |
| 1348 | bool vfpv3; |
| 1349 | bool d32; |
| 1350 | bool fp16; |
| 1351 | bool fma; |
| 1352 | |
| 1353 | bool wmmx; |
| 1354 | bool wmmx2; |
| 1355 | bool neon; |
| 1356 | #endif |
| 1357 | #if CPUINFO_ARCH_ARM64 |
| 1358 | bool atomics; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1359 | #endif |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1360 | bool rdm; |
| 1361 | bool fp16arith; |
| 1362 | bool jscvt; |
| 1363 | bool fcma; |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1364 | |
| 1365 | bool aes; |
| 1366 | bool sha1; |
| 1367 | bool sha2; |
| 1368 | bool pmull; |
| 1369 | bool crc32; |
| 1370 | }; |
| 1371 | |
Marat Dukhan | 3c98276 | 2017-05-08 06:16:45 +0000 | [diff] [blame] | 1372 | extern struct cpuinfo_arm_isa cpuinfo_isa; |
| 1373 | #endif |
| 1374 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1375 | static inline bool cpuinfo_has_arm_thumb(void) { |
| 1376 | #if CPUINFO_ARCH_ARM |
| 1377 | return cpuinfo_isa.thumb; |
| 1378 | #else |
| 1379 | return false; |
| 1380 | #endif |
| 1381 | } |
| 1382 | |
| 1383 | static inline bool cpuinfo_has_arm_thumb2(void) { |
| 1384 | #if CPUINFO_ARCH_ARM |
| 1385 | return cpuinfo_isa.thumb2; |
| 1386 | #else |
| 1387 | return false; |
| 1388 | #endif |
| 1389 | } |
| 1390 | |
| 1391 | static inline bool cpuinfo_has_arm_v5e(void) { |
| 1392 | #if CPUINFO_ARCH_ARM |
| 1393 | return cpuinfo_isa.armv5e; |
| 1394 | #else |
| 1395 | return false; |
| 1396 | #endif |
| 1397 | } |
| 1398 | |
| 1399 | static inline bool cpuinfo_has_arm_v6(void) { |
| 1400 | #if CPUINFO_ARCH_ARM |
| 1401 | return cpuinfo_isa.armv6; |
| 1402 | #else |
| 1403 | return false; |
| 1404 | #endif |
| 1405 | } |
| 1406 | |
| 1407 | static inline bool cpuinfo_has_arm_v6k(void) { |
| 1408 | #if CPUINFO_ARCH_ARM |
| 1409 | return cpuinfo_isa.armv6k; |
| 1410 | #else |
| 1411 | return false; |
| 1412 | #endif |
| 1413 | } |
| 1414 | |
| 1415 | static inline bool cpuinfo_has_arm_v7(void) { |
| 1416 | #if CPUINFO_ARCH_ARM |
| 1417 | return cpuinfo_isa.armv7; |
| 1418 | #else |
| 1419 | return false; |
| 1420 | #endif |
| 1421 | } |
| 1422 | |
| 1423 | static inline bool cpuinfo_has_arm_v7mp(void) { |
| 1424 | #if CPUINFO_ARCH_ARM |
| 1425 | return cpuinfo_isa.armv7mp; |
| 1426 | #else |
| 1427 | return false; |
| 1428 | #endif |
| 1429 | } |
| 1430 | |
| 1431 | static inline bool cpuinfo_has_arm_idiv(void) { |
| 1432 | #if CPUINFO_ARCH_ARM64 |
| 1433 | return true; |
| 1434 | #elif CPUINFO_ARCH_ARM |
| 1435 | return cpuinfo_isa.idiv; |
| 1436 | #else |
| 1437 | return false; |
| 1438 | #endif |
| 1439 | } |
| 1440 | |
| 1441 | static inline bool cpuinfo_has_arm_vfpv2(void) { |
| 1442 | #if CPUINFO_ARCH_ARM |
| 1443 | return cpuinfo_isa.vfpv2; |
| 1444 | #else |
| 1445 | return false; |
| 1446 | #endif |
| 1447 | } |
| 1448 | |
| 1449 | static inline bool cpuinfo_has_arm_vfpv3(void) { |
| 1450 | #if CPUINFO_ARCH_ARM64 |
| 1451 | return true; |
| 1452 | #elif CPUINFO_ARCH_ARM |
| 1453 | return cpuinfo_isa.vfpv3; |
| 1454 | #else |
| 1455 | return false; |
| 1456 | #endif |
| 1457 | } |
| 1458 | |
| 1459 | static inline bool cpuinfo_has_arm_vfpv3_d32(void) { |
| 1460 | #if CPUINFO_ARCH_ARM64 |
| 1461 | return true; |
| 1462 | #elif CPUINFO_ARCH_ARM |
| 1463 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32; |
| 1464 | #else |
| 1465 | return false; |
| 1466 | #endif |
| 1467 | } |
| 1468 | |
| 1469 | static inline bool cpuinfo_has_arm_vfpv3_fp16(void) { |
| 1470 | #if CPUINFO_ARCH_ARM64 |
| 1471 | return true; |
| 1472 | #elif CPUINFO_ARCH_ARM |
| 1473 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16; |
| 1474 | #else |
| 1475 | return false; |
| 1476 | #endif |
| 1477 | } |
| 1478 | |
| 1479 | static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) { |
| 1480 | #if CPUINFO_ARCH_ARM64 |
| 1481 | return true; |
| 1482 | #elif CPUINFO_ARCH_ARM |
| 1483 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32; |
| 1484 | #else |
| 1485 | return false; |
| 1486 | #endif |
| 1487 | } |
| 1488 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1489 | static inline bool cpuinfo_has_arm_vfpv4(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1490 | #if CPUINFO_ARCH_ARM64 |
| 1491 | return true; |
| 1492 | #elif CPUINFO_ARCH_ARM |
| 1493 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma; |
| 1494 | #else |
| 1495 | return false; |
| 1496 | #endif |
| 1497 | } |
| 1498 | |
Marat Dukhan | 6022f80 | 2017-09-26 11:56:36 -0700 | [diff] [blame] | 1499 | static inline bool cpuinfo_has_arm_vfpv4_d32(void) { |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1500 | #if CPUINFO_ARCH_ARM64 |
| 1501 | return true; |
| 1502 | #elif CPUINFO_ARCH_ARM |
| 1503 | return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32; |
| 1504 | #else |
| 1505 | return false; |
| 1506 | #endif |
| 1507 | } |
| 1508 | |
| 1509 | static inline bool cpuinfo_has_arm_wmmx(void) { |
| 1510 | #if CPUINFO_ARCH_ARM |
| 1511 | return cpuinfo_isa.wmmx; |
| 1512 | #else |
| 1513 | return false; |
| 1514 | #endif |
| 1515 | } |
| 1516 | |
| 1517 | static inline bool cpuinfo_has_arm_wmmx2(void) { |
| 1518 | #if CPUINFO_ARCH_ARM |
| 1519 | return cpuinfo_isa.wmmx2; |
| 1520 | #else |
| 1521 | return false; |
| 1522 | #endif |
| 1523 | } |
| 1524 | |
| 1525 | static inline bool cpuinfo_has_arm_neon(void) { |
| 1526 | #if CPUINFO_ARCH_ARM64 |
| 1527 | return true; |
| 1528 | #elif CPUINFO_ARCH_ARM |
| 1529 | return cpuinfo_isa.neon; |
| 1530 | #else |
| 1531 | return false; |
| 1532 | #endif |
| 1533 | } |
| 1534 | |
| 1535 | static inline bool cpuinfo_has_arm_neon_fp16(void) { |
| 1536 | #if CPUINFO_ARCH_ARM64 |
| 1537 | return true; |
| 1538 | #elif CPUINFO_ARCH_ARM |
| 1539 | return cpuinfo_isa.neon && cpuinfo_isa.fp16; |
| 1540 | #else |
| 1541 | return false; |
| 1542 | #endif |
| 1543 | } |
| 1544 | |
| 1545 | static inline bool cpuinfo_has_arm_neon_fma(void) { |
| 1546 | #if CPUINFO_ARCH_ARM64 |
| 1547 | return true; |
| 1548 | #elif CPUINFO_ARCH_ARM |
| 1549 | return cpuinfo_isa.neon && cpuinfo_isa.fma; |
| 1550 | #else |
| 1551 | return false; |
| 1552 | #endif |
| 1553 | } |
| 1554 | |
| 1555 | static inline bool cpuinfo_has_arm_atomics(void) { |
| 1556 | #if CPUINFO_ARCH_ARM64 |
| 1557 | return cpuinfo_isa.atomics; |
| 1558 | #else |
| 1559 | return false; |
| 1560 | #endif |
| 1561 | } |
| 1562 | |
| 1563 | static inline bool cpuinfo_has_arm_neon_rdm(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1564 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1565 | return cpuinfo_isa.rdm; |
| 1566 | #else |
| 1567 | return false; |
| 1568 | #endif |
| 1569 | } |
| 1570 | |
Marat Dukhan | de2f71e | 2018-06-11 13:30:21 -0700 | [diff] [blame] | 1571 | static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { |
| 1572 | #if CPUINFO_ARCH_ARM |
| 1573 | return cpuinfo_isa.neon && cpuinfo_isa.fp16arith; |
| 1574 | #elif CPUINFO_ARCH_ARM64 |
| 1575 | return cpuinfo_isa.fp16arith; |
| 1576 | #else |
| 1577 | return false; |
| 1578 | #endif |
| 1579 | } |
| 1580 | |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1581 | static inline bool cpuinfo_has_arm_fp16_arith(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1582 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1583 | return cpuinfo_isa.fp16arith; |
| 1584 | #else |
| 1585 | return false; |
| 1586 | #endif |
| 1587 | } |
| 1588 | |
| 1589 | static inline bool cpuinfo_has_arm_jscvt(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1590 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1591 | return cpuinfo_isa.jscvt; |
| 1592 | #else |
| 1593 | return false; |
| 1594 | #endif |
| 1595 | } |
| 1596 | |
| 1597 | static inline bool cpuinfo_has_arm_fcma(void) { |
Marat Dukhan | 7abab75 | 2018-04-19 22:03:52 -0700 | [diff] [blame] | 1598 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
Marat Dukhan | f720d10 | 2017-09-26 10:33:47 -0700 | [diff] [blame] | 1599 | return cpuinfo_isa.fcma; |
| 1600 | #else |
| 1601 | return false; |
| 1602 | #endif |
| 1603 | } |
| 1604 | |
| 1605 | static inline bool cpuinfo_has_arm_aes(void) { |
| 1606 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1607 | return cpuinfo_isa.aes; |
| 1608 | #else |
| 1609 | return false; |
| 1610 | #endif |
| 1611 | } |
| 1612 | |
| 1613 | static inline bool cpuinfo_has_arm_sha1(void) { |
| 1614 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1615 | return cpuinfo_isa.sha1; |
| 1616 | #else |
| 1617 | return false; |
| 1618 | #endif |
| 1619 | } |
| 1620 | |
| 1621 | static inline bool cpuinfo_has_arm_sha2(void) { |
| 1622 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1623 | return cpuinfo_isa.sha2; |
| 1624 | #else |
| 1625 | return false; |
| 1626 | #endif |
| 1627 | } |
| 1628 | |
| 1629 | static inline bool cpuinfo_has_arm_pmull(void) { |
| 1630 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1631 | return cpuinfo_isa.pmull; |
| 1632 | #else |
| 1633 | return false; |
| 1634 | #endif |
| 1635 | } |
| 1636 | |
| 1637 | static inline bool cpuinfo_has_arm_crc32(void) { |
| 1638 | #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 |
| 1639 | return cpuinfo_isa.crc32; |
| 1640 | #else |
| 1641 | return false; |
| 1642 | #endif |
| 1643 | } |
| 1644 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1645 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); |
| 1646 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1647 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1648 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1649 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); |
| 1650 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); |
| 1651 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void); |
| 1652 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void); |
| 1653 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 1654 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1655 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); |
| 1656 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1657 | const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1658 | const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1659 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); |
| 1660 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); |
| 1661 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index); |
| 1662 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index); |
| 1663 | const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index); |
Marat Dukhan | 3045d4f | 2017-03-04 01:51:42 -0500 | [diff] [blame] | 1664 | |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1665 | uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); |
| 1666 | uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); |
Marat Dukhan | 4d376c3 | 2018-03-18 11:36:39 -0700 | [diff] [blame] | 1667 | uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); |
Marat Dukhan | 7b5e4d5 | 2018-03-15 23:42:50 -0700 | [diff] [blame] | 1668 | uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1669 | uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); |
| 1670 | uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); |
| 1671 | uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); |
| 1672 | uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); |
| 1673 | uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); |
Marat Dukhan | 8ecad1a | 2017-05-08 07:21:57 +0000 | [diff] [blame] | 1674 | |
Marat Dukhan | 3040197 | 2017-09-26 18:35:52 -0700 | [diff] [blame] | 1675 | const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); |
| 1676 | const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1677 | |
| 1678 | #ifdef __cplusplus |
| 1679 | } /* extern "C" */ |
| 1680 | #endif |
| 1681 | |
| 1682 | #endif /* CPUINFO_H */ |