23 constexpr static uint32_t processor_type_OEM = 0;
24 constexpr static uint32_t processor_type_Intel_overdrive = 1;
25 constexpr static uint32_t processor_type_dual_processor = 2;
30 uint32_t stepping_id:4 = 0;
31 uint32_t model_id:8 = 0;
32 uint32_t family_id:9 = 0;
33 uint32_t processor_type:2 = 0;
35 uint64_t features = 0;
38 size_t cache_flush_size = 0;
51 hilet leaf0 = get_leaf(0);
52 hilet max_leaf = leaf0.a;
60 size_t brand_index = 0;
62 hilet leaf1 = get_leaf(1);
64 stepping_id = leaf1.a & 0xf;
65 model_id = (leaf1.a >> 4) & 0xf;
66 family_id = (leaf1.a >> 8) & 0xf;
67 processor_type = (leaf1.a >> 12) & 0x3;
69 if (family_id == 0x6 or family_id == 0xf) {
71 model_id |= ((leaf1.a >> 16) & 0xf) << 4;
73 if (family_id == 0xf) {
75 family_id += (leaf1.a >> 20) & 0xff;
78 brand_index = leaf1.b & 0xff;
79 cache_flush_size = ((leaf1.b >> 8) & 0xff) * 8;
80 APIC_id = (leaf1.b >> 24) & 0xff;
88 [[nodiscard]]
bool has_aesni() const noexcept
90 return to_bool(instruction_set & instruction_set_aesni);
93 [[nodiscard]]
bool has_avx() const noexcept
95 return to_bool(instruction_set & instruction_set_avx);
98 [[nodiscard]]
bool has_cmpxchg16b() const noexcept
100 return to_bool(instruction_set & instruction_set_cmpxchg16b);
103 [[nodiscard]]
bool has_clfsh() const noexcept
105 return to_bool(instruction_set & instruction_set_clfsh);
108 [[nodiscard]]
bool has_cmov() const noexcept
110 return to_bool(instruction_set & instruction_set_cmov);
113 [[nodiscard]]
bool has_cx8() const noexcept
115 return to_bool(instruction_set & instruction_set_cx8);
118 [[nodiscard]]
bool has_fma() const noexcept
120 return to_bool(instruction_set & instruction_set_fma);
123 [[nodiscard]]
bool has_f16c() const noexcept
125 return to_bool(instruction_set & instruction_set_f16c);
128 [[nodiscard]]
bool has_fxsr() const noexcept
130 return to_bool(instruction_set & instruction_set_fxsr);
133 [[nodiscard]]
bool has_sse() const noexcept
135 return to_bool(instruction_set & instruction_set_sse);
138 [[nodiscard]]
bool has_sse2() const noexcept
140 return to_bool(instruction_set & instruction_set_sse2);
143 [[nodiscard]]
bool has_sse3() const noexcept
145 return to_bool(instruction_set & instruction_set_sse3);
148 [[nodiscard]]
bool has_ssse3() const noexcept
150 return to_bool(instruction_set & instruction_set_ssse3);
153 [[nodiscard]]
bool has_sse4_1() const noexcept
155 return to_bool(instruction_set & instruction_set_sse4_1);
158 [[nodiscard]]
bool has_sse4_2() const noexcept
160 return to_bool(instruction_set & instruction_set_sse4_2);
163 [[nodiscard]]
bool has_movbe() const noexcept
165 return to_bool(instruction_set & instruction_set_movbe);
168 [[nodiscard]]
bool has_mmx() const noexcept
170 return to_bool(instruction_set & instruction_set_mmx);
173 [[nodiscard]]
bool has_msr() const noexcept
175 return to_bool(instruction_set & instruction_set_msr);
178 [[nodiscard]]
bool has_osxsave() const noexcept
180 return to_bool(instruction_set & instruction_set_osxsave);
183 [[nodiscard]]
bool has_pclmulqdq() const noexcept
185 return to_bool(instruction_set & instruction_set_pclmulqdq);
188 [[nodiscard]]
bool has_popcnt() const noexcept
190 return to_bool(instruction_set & instruction_set_popcnt);
193 [[nodiscard]]
bool has_rdrand() const noexcept
195 return to_bool(instruction_set & instruction_set_rdrand);
198 [[nodiscard]]
bool has_sep() const noexcept
200 return to_bool(instruction_set & instruction_set_sep);
203 [[nodiscard]]
bool has_tsc() const noexcept
205 return to_bool(instruction_set & instruction_set_tsc);
208 [[nodiscard]]
bool has_xsave() const noexcept
210 return to_bool(instruction_set & instruction_set_xsave);
213 [[nodiscard]]
bool has_acpi() const noexcept
215 return to_bool(features & features_acpi);
218 [[nodiscard]]
bool has_apic() const noexcept
220 return to_bool(features & features_apic);
223 [[nodiscard]]
bool has_cnxt_id() const noexcept
225 return to_bool(features & features_cnxt_id);
228 [[nodiscard]]
bool has_dca() const noexcept
230 return to_bool(features & features_dca);
233 [[nodiscard]]
bool has_de() const noexcept
235 return to_bool(features & features_de);
238 [[nodiscard]]
bool has_ds() const noexcept
240 return to_bool(features & features_ds);
243 [[nodiscard]]
bool has_ds_cpl() const noexcept
245 return to_bool(features & features_ds_cpl);
248 [[nodiscard]]
bool has_dtes64() const noexcept
250 return to_bool(features & features_dtes64);
253 [[nodiscard]]
bool has_eist() const noexcept
255 return to_bool(features & features_eist);
258 [[nodiscard]]
bool has_fpu() const noexcept
260 return to_bool(features & features_fpu);
263 [[nodiscard]]
bool has_htt() const noexcept
265 return to_bool(features & features_htt);
268 [[nodiscard]]
bool has_mca() const noexcept
270 return to_bool(features & features_mca);
273 [[nodiscard]]
bool has_mce() const noexcept
275 return to_bool(features & features_mce);
278 [[nodiscard]]
bool has_monitor() const noexcept
280 return to_bool(features & features_monitor);
283 [[nodiscard]]
bool has_mttr() const noexcept
285 return to_bool(features & features_mttr);
288 [[nodiscard]]
bool has_pae() const noexcept
290 return to_bool(features & features_pae);
293 [[nodiscard]]
bool has_pat() const noexcept
295 return to_bool(features & features_pat);
298 [[nodiscard]]
bool has_pbe() const noexcept
300 return to_bool(features & features_pbe);
303 [[nodiscard]]
bool has_pcid() const noexcept
305 return to_bool(features & features_pcid);
308 [[nodiscard]]
bool has_pdcm() const noexcept
310 return to_bool(features & features_pdcm);
313 [[nodiscard]]
bool has_pge() const noexcept
315 return to_bool(features & features_pge);
318 [[nodiscard]]
bool has_pse() const noexcept
320 return to_bool(features & features_pse);
323 [[nodiscard]]
bool has_pse_36() const noexcept
325 return to_bool(features & features_pse_36);
328 [[nodiscard]]
bool has_psn() const noexcept
330 return to_bool(features & features_psm);
333 [[nodiscard]]
bool has_sdbg() const noexcept
335 return to_bool(features & features_sdbg);
338 [[nodiscard]]
bool has_smx() const noexcept
340 return to_bool(features & features_smx);
343 [[nodiscard]]
bool has_ss() const noexcept
345 return to_bool(features & features_ss);
348 [[nodiscard]]
bool has_tm() const noexcept
350 return to_bool(features & features_tm);
353 [[nodiscard]]
bool has_tm2() const noexcept
355 return to_bool(features & features_tm2);
358 [[nodiscard]]
bool has_tsc_deadline() const noexcept
360 return to_bool(features & features_tsc_deadline);
363 [[nodiscard]]
bool has_vme() const noexcept
365 return to_bool(features & features_vme);
368 [[nodiscard]]
bool has_vmx() const noexcept
370 return to_bool(features & features_vmx);
373 [[nodiscard]]
bool has_x2apic() const noexcept
375 return to_bool(features & features_x2apic);
378 [[nodiscard]]
bool has_xtpr() const noexcept
380 return to_bool(features & features_xtpr);
385 constexpr static uint64_t instruction_set_aesni = 0x0000'0000'0000'0001;
386 constexpr static uint64_t instruction_set_avx = 0x0000'0000'0000'0002;
387 constexpr static uint64_t instruction_set_cmpxchg16b = 0x0000'0000'0000'0004;
388 constexpr static uint64_t instruction_set_clfsh = 0x0000'0000'0000'0008;
389 constexpr static uint64_t instruction_set_cmov = 0x0000'0000'0000'0010;
390 constexpr static uint64_t instruction_set_cx8 = 0x0000'0000'0000'0020;
391 constexpr static uint64_t instruction_set_fma = 0x0000'0000'0000'0040;
392 constexpr static uint64_t instruction_set_f16c = 0x0000'0000'0000'0080;
393 constexpr static uint64_t instruction_set_fxsr = 0x0000'0000'0000'0100;
394 constexpr static uint64_t instruction_set_sse = 0x0000'0000'0000'0200;
395 constexpr static uint64_t instruction_set_sse2 = 0x0000'0000'0000'0300;
396 constexpr static uint64_t instruction_set_sse3 = 0x0000'0000'0000'0800;
397 constexpr static uint64_t instruction_set_ssse3 = 0x0000'0000'0000'1000;
398 constexpr static uint64_t instruction_set_sse4_1 = 0x0000'0000'0000'2000;
399 constexpr static uint64_t instruction_set_sse4_2 = 0x0000'0000'0000'4000;
400 constexpr static uint64_t instruction_set_movbe = 0x0000'0000'0000'8000;
401 constexpr static uint64_t instruction_set_mmx = 0x0000'0000'0001'0000;
402 constexpr static uint64_t instruction_set_msr = 0x0000'0000'0002'0000;
403 constexpr static uint64_t instruction_set_osxsave = 0x0000'0000'0004'0000;
404 constexpr static uint64_t instruction_set_pclmulqdq = 0x0000'0000'0008'0000;
405 constexpr static uint64_t instruction_set_popcnt = 0x0000'0000'0010'0000;
406 constexpr static uint64_t instruction_set_rdrand = 0x0000'0000'0020'0000;
407 constexpr static uint64_t instruction_set_sep = 0x0000'0000'0040'0000;
408 constexpr static uint64_t instruction_set_tsc = 0x0000'0000'0080'0000;
409 constexpr static uint64_t instruction_set_xsave = 0x0000'0000'0100'0000;
411 constexpr static uint64_t features_acpi = 0x0000'0000'0000'0001;
412 constexpr static uint64_t features_apic = 0x0000'0000'0000'0002;
413 constexpr static uint64_t features_cnxt_id = 0x0000'0000'0000'0004;
414 constexpr static uint64_t features_dca = 0x0000'0000'0000'0008;
415 constexpr static uint64_t features_de = 0x0000'0000'0000'0010;
416 constexpr static uint64_t features_ds = 0x0000'0000'0000'0020;
417 constexpr static uint64_t features_ds_cpl = 0x0000'0000'0000'0040;
418 constexpr static uint64_t features_dtes64 = 0x0000'0000'0000'0080;
419 constexpr static uint64_t features_eist = 0x0000'0000'0000'0100;
420 constexpr static uint64_t features_fpu = 0x0000'0000'0000'0200;
421 constexpr static uint64_t features_htt = 0x0000'0000'0000'0400;
422 constexpr static uint64_t features_mca = 0x0000'0000'0000'0800;
423 constexpr static uint64_t features_mce = 0x0000'0000'0000'1000;
424 constexpr static uint64_t features_monitor = 0x0000'0000'0000'2000;
425 constexpr static uint64_t features_mttr = 0x0000'0000'0000'4000;
426 constexpr static uint64_t features_pae = 0x0000'0000'0000'8000;
427 constexpr static uint64_t features_pat = 0x0000'0000'0001'0000;
428 constexpr static uint64_t features_pbe = 0x0000'0000'0002'0000;
429 constexpr static uint64_t features_pcid = 0x0000'0000'0004'0000;
430 constexpr static uint64_t features_pdcm = 0x0000'0000'0008'0000;
431 constexpr static uint64_t features_pge = 0x0000'0000'0010'0000;
432 constexpr static uint64_t features_pse = 0x0000'0000'0020'0000;
433 constexpr static uint64_t features_pse_36 = 0x0000'0000'0040'0000;
434 constexpr static uint64_t features_psn = 0x0000'0000'0080'0000;
435 constexpr static uint64_t features_sdbg = 0x0000'0000'0100'0000;
436 constexpr static uint64_t features_smx = 0x0000'0000'0200'0000;
437 constexpr static uint64_t features_ss = 0x0000'0000'0400'0000;
438 constexpr static uint64_t features_tm = 0x0000'0000'0800'0000;
439 constexpr static uint64_t features_tm2 = 0x0000'0000'1000'0000;
440 constexpr static uint64_t features_tsc_deadline = 0x0000'0000'2000'0000;
441 constexpr static uint64_t features_vme = 0x0000'0000'4000'0000;
442 constexpr static uint64_t features_vmx = 0x0000'0000'8000'0000;
443 constexpr static uint64_t features_x2apic = 0x0000'0001'0000'0000;
444 constexpr static uint64_t features_xtpr = 0x0000'0002'0000'0000;
447 uint32_t instruction_set = 0;
448 uint64_t features = 0;
457#if HI_COMPILER == HI_CC_MSVC
459 [[nodiscard]]
static leaf_type get_leaf(uint32_t leaf_id, uint32_t index = 0) noexcept
464 __cpuindex(tmp, char_cast<int>(cpu_id_leaf), char_cast<int>(index));
470#elif HI_COMPILER == HI_CC_GCC || HI_COMPILER == HI_CC_CLANG
472 [[nodiscard]]
static leaf_type get_leaf(uint32_t leaf_id, uint32_t index = 0) noexcept
475 __cpuid_count(leaf_id, index, r.a, r.b, r.c, r.d);
480#error "Unsuported compiler for x64 cpu_id"