24 constexpr static uint32_t processor_type_OEM = 0;
25 constexpr static uint32_t processor_type_Intel_overdrive = 1;
26 constexpr static uint32_t processor_type_dual_processor = 2;
31 uint32_t stepping_id:4 = 0;
32 uint32_t model_id:8 = 0;
33 uint32_t family_id:9 = 0;
34 uint32_t processor_type:2 = 0;
36 uint64_t features = 0;
39 size_t cache_flush_size = 0;
52 hilet leaf0 = get_leaf(0);
53 hilet max_leaf = leaf0.a;
61 size_t brand_index = 0;
63 hilet leaf1 = get_leaf(1);
65 stepping_id = leaf1.a & 0xf;
66 model_id = (leaf1.a >> 4) & 0xf;
67 family_id = (leaf1.a >> 8) & 0xf;
68 processor_type = (leaf1.a >> 12) & 0x3;
70 if (family_id == 0x6 or family_id == 0xf) {
72 model_id |= ((leaf1.a >> 16) & 0xf) << 4;
74 if (family_id == 0xf) {
76 family_id += (leaf1.a >> 20) & 0xff;
79 brand_index = leaf1.b & 0xff;
80 cache_flush_size = ((leaf1.b >> 8) & 0xff) * 8;
81 APIC_id = (leaf1.b >> 24) & 0xff;
89 [[nodiscard]]
bool has_aesni() const noexcept
91 return to_bool(instruction_set & instruction_set_aesni);
94 [[nodiscard]]
bool has_avx() const noexcept
96 return to_bool(instruction_set & instruction_set_avx);
99 [[nodiscard]]
bool has_cmpxchg16b() const noexcept
101 return to_bool(instruction_set & instruction_set_cmpxchg16b);
104 [[nodiscard]]
bool has_clfsh() const noexcept
106 return to_bool(instruction_set & instruction_set_clfsh);
109 [[nodiscard]]
bool has_cmov() const noexcept
111 return to_bool(instruction_set & instruction_set_cmov);
114 [[nodiscard]]
bool has_cx8() const noexcept
116 return to_bool(instruction_set & instruction_set_cx8);
119 [[nodiscard]]
bool has_fma() const noexcept
121 return to_bool(instruction_set & instruction_set_fma);
124 [[nodiscard]]
bool has_f16c() const noexcept
126 return to_bool(instruction_set & instruction_set_f16c);
129 [[nodiscard]]
bool has_fxsr() const noexcept
131 return to_bool(instruction_set & instruction_set_fxsr);
134 [[nodiscard]]
bool has_sse() const noexcept
136 return to_bool(instruction_set & instruction_set_sse);
139 [[nodiscard]]
bool has_sse2() const noexcept
141 return to_bool(instruction_set & instruction_set_sse2);
144 [[nodiscard]]
bool has_sse3() const noexcept
146 return to_bool(instruction_set & instruction_set_sse3);
149 [[nodiscard]]
bool has_ssse3() const noexcept
151 return to_bool(instruction_set & instruction_set_ssse3);
154 [[nodiscard]]
bool has_sse4_1() const noexcept
156 return to_bool(instruction_set & instruction_set_sse4_1);
159 [[nodiscard]]
bool has_sse4_2() const noexcept
161 return to_bool(instruction_set & instruction_set_sse4_2);
164 [[nodiscard]]
bool has_movbe() const noexcept
166 return to_bool(instruction_set & instruction_set_movbe);
169 [[nodiscard]]
bool has_mmx() const noexcept
171 return to_bool(instruction_set & instruction_set_mmx);
174 [[nodiscard]]
bool has_msr() const noexcept
176 return to_bool(instruction_set & instruction_set_msr);
179 [[nodiscard]]
bool has_osxsave() const noexcept
181 return to_bool(instruction_set & instruction_set_osxsave);
184 [[nodiscard]]
bool has_pclmulqdq() const noexcept
186 return to_bool(instruction_set & instruction_set_pclmulqdq);
189 [[nodiscard]]
bool has_popcnt() const noexcept
191 return to_bool(instruction_set & instruction_set_popcnt);
194 [[nodiscard]]
bool has_rdrand() const noexcept
196 return to_bool(instruction_set & instruction_set_rdrand);
199 [[nodiscard]]
bool has_sep() const noexcept
201 return to_bool(instruction_set & instruction_set_sep);
204 [[nodiscard]]
bool has_tsc() const noexcept
206 return to_bool(instruction_set & instruction_set_tsc);
209 [[nodiscard]]
bool has_xsave() const noexcept
211 return to_bool(instruction_set & instruction_set_xsave);
214 [[nodiscard]]
bool has_acpi() const noexcept
216 return to_bool(features & features_acpi);
219 [[nodiscard]]
bool has_apic() const noexcept
221 return to_bool(features & features_apic);
224 [[nodiscard]]
bool has_cnxt_id() const noexcept
226 return to_bool(features & features_cnxt_id);
229 [[nodiscard]]
bool has_dca() const noexcept
231 return to_bool(features & features_dca);
234 [[nodiscard]]
bool has_de() const noexcept
236 return to_bool(features & features_de);
239 [[nodiscard]]
bool has_ds() const noexcept
241 return to_bool(features & features_ds);
244 [[nodiscard]]
bool has_ds_cpl() const noexcept
246 return to_bool(features & features_ds_cpl);
249 [[nodiscard]]
bool has_dtes64() const noexcept
251 return to_bool(features & features_dtes64);
254 [[nodiscard]]
bool has_eist() const noexcept
256 return to_bool(features & features_eist);
259 [[nodiscard]]
bool has_fpu() const noexcept
261 return to_bool(features & features_fpu);
264 [[nodiscard]]
bool has_htt() const noexcept
266 return to_bool(features & features_htt);
269 [[nodiscard]]
bool has_mca() const noexcept
271 return to_bool(features & features_mca);
274 [[nodiscard]]
bool has_mce() const noexcept
276 return to_bool(features & features_mce);
279 [[nodiscard]]
bool has_monitor() const noexcept
281 return to_bool(features & features_monitor);
284 [[nodiscard]]
bool has_mttr() const noexcept
286 return to_bool(features & features_mttr);
289 [[nodiscard]]
bool has_pae() const noexcept
291 return to_bool(features & features_pae);
294 [[nodiscard]]
bool has_pat() const noexcept
296 return to_bool(features & features_pat);
299 [[nodiscard]]
bool has_pbe() const noexcept
301 return to_bool(features & features_pbe);
304 [[nodiscard]]
bool has_pcid() const noexcept
306 return to_bool(features & features_pcid);
309 [[nodiscard]]
bool has_pdcm() const noexcept
311 return to_bool(features & features_pdcm);
314 [[nodiscard]]
bool has_pge() const noexcept
316 return to_bool(features & features_pge);
319 [[nodiscard]]
bool has_pse() const noexcept
321 return to_bool(features & features_pse);
324 [[nodiscard]]
bool has_pse_36() const noexcept
326 return to_bool(features & features_pse_36);
329 [[nodiscard]]
bool has_psn() const noexcept
331 return to_bool(features & features_psm);
334 [[nodiscard]]
bool has_sdbg() const noexcept
336 return to_bool(features & features_sdbg);
339 [[nodiscard]]
bool has_smx() const noexcept
341 return to_bool(features & features_smx);
344 [[nodiscard]]
bool has_ss() const noexcept
346 return to_bool(features & features_ss);
349 [[nodiscard]]
bool has_tm() const noexcept
351 return to_bool(features & features_tm);
354 [[nodiscard]]
bool has_tm2() const noexcept
356 return to_bool(features & features_tm2);
359 [[nodiscard]]
bool has_tsc_deadline() const noexcept
361 return to_bool(features & features_tsc_deadline);
364 [[nodiscard]]
bool has_vme() const noexcept
366 return to_bool(features & features_vme);
369 [[nodiscard]]
bool has_vmx() const noexcept
371 return to_bool(features & features_vmx);
374 [[nodiscard]]
bool has_x2apic() const noexcept
376 return to_bool(features & features_x2apic);
379 [[nodiscard]]
bool has_xtpr() const noexcept
381 return to_bool(features & features_xtpr);
386 constexpr static uint64_t instruction_set_aesni = 0x0000'0000'0000'0001;
387 constexpr static uint64_t instruction_set_avx = 0x0000'0000'0000'0002;
388 constexpr static uint64_t instruction_set_cmpxchg16b = 0x0000'0000'0000'0004;
389 constexpr static uint64_t instruction_set_clfsh = 0x0000'0000'0000'0008;
390 constexpr static uint64_t instruction_set_cmov = 0x0000'0000'0000'0010;
391 constexpr static uint64_t instruction_set_cx8 = 0x0000'0000'0000'0020;
392 constexpr static uint64_t instruction_set_fma = 0x0000'0000'0000'0040;
393 constexpr static uint64_t instruction_set_f16c = 0x0000'0000'0000'0080;
394 constexpr static uint64_t instruction_set_fxsr = 0x0000'0000'0000'0100;
395 constexpr static uint64_t instruction_set_sse = 0x0000'0000'0000'0200;
396 constexpr static uint64_t instruction_set_sse2 = 0x0000'0000'0000'0300;
397 constexpr static uint64_t instruction_set_sse3 = 0x0000'0000'0000'0800;
398 constexpr static uint64_t instruction_set_ssse3 = 0x0000'0000'0000'1000;
399 constexpr static uint64_t instruction_set_sse4_1 = 0x0000'0000'0000'2000;
400 constexpr static uint64_t instruction_set_sse4_2 = 0x0000'0000'0000'4000;
401 constexpr static uint64_t instruction_set_movbe = 0x0000'0000'0000'8000;
402 constexpr static uint64_t instruction_set_mmx = 0x0000'0000'0001'0000;
403 constexpr static uint64_t instruction_set_msr = 0x0000'0000'0002'0000;
404 constexpr static uint64_t instruction_set_osxsave = 0x0000'0000'0004'0000;
405 constexpr static uint64_t instruction_set_pclmulqdq = 0x0000'0000'0008'0000;
406 constexpr static uint64_t instruction_set_popcnt = 0x0000'0000'0010'0000;
407 constexpr static uint64_t instruction_set_rdrand = 0x0000'0000'0020'0000;
408 constexpr static uint64_t instruction_set_sep = 0x0000'0000'0040'0000;
409 constexpr static uint64_t instruction_set_tsc = 0x0000'0000'0080'0000;
410 constexpr static uint64_t instruction_set_xsave = 0x0000'0000'0100'0000;
412 constexpr static uint64_t features_acpi = 0x0000'0000'0000'0001;
413 constexpr static uint64_t features_apic = 0x0000'0000'0000'0002;
414 constexpr static uint64_t features_cnxt_id = 0x0000'0000'0000'0004;
415 constexpr static uint64_t features_dca = 0x0000'0000'0000'0008;
416 constexpr static uint64_t features_de = 0x0000'0000'0000'0010;
417 constexpr static uint64_t features_ds = 0x0000'0000'0000'0020;
418 constexpr static uint64_t features_ds_cpl = 0x0000'0000'0000'0040;
419 constexpr static uint64_t features_dtes64 = 0x0000'0000'0000'0080;
420 constexpr static uint64_t features_eist = 0x0000'0000'0000'0100;
421 constexpr static uint64_t features_fpu = 0x0000'0000'0000'0200;
422 constexpr static uint64_t features_htt = 0x0000'0000'0000'0400;
423 constexpr static uint64_t features_mca = 0x0000'0000'0000'0800;
424 constexpr static uint64_t features_mce = 0x0000'0000'0000'1000;
425 constexpr static uint64_t features_monitor = 0x0000'0000'0000'2000;
426 constexpr static uint64_t features_mttr = 0x0000'0000'0000'4000;
427 constexpr static uint64_t features_pae = 0x0000'0000'0000'8000;
428 constexpr static uint64_t features_pat = 0x0000'0000'0001'0000;
429 constexpr static uint64_t features_pbe = 0x0000'0000'0002'0000;
430 constexpr static uint64_t features_pcid = 0x0000'0000'0004'0000;
431 constexpr static uint64_t features_pdcm = 0x0000'0000'0008'0000;
432 constexpr static uint64_t features_pge = 0x0000'0000'0010'0000;
433 constexpr static uint64_t features_pse = 0x0000'0000'0020'0000;
434 constexpr static uint64_t features_pse_36 = 0x0000'0000'0040'0000;
435 constexpr static uint64_t features_psn = 0x0000'0000'0080'0000;
436 constexpr static uint64_t features_sdbg = 0x0000'0000'0100'0000;
437 constexpr static uint64_t features_smx = 0x0000'0000'0200'0000;
438 constexpr static uint64_t features_ss = 0x0000'0000'0400'0000;
439 constexpr static uint64_t features_tm = 0x0000'0000'0800'0000;
440 constexpr static uint64_t features_tm2 = 0x0000'0000'1000'0000;
441 constexpr static uint64_t features_tsc_deadline = 0x0000'0000'2000'0000;
442 constexpr static uint64_t features_vme = 0x0000'0000'4000'0000;
443 constexpr static uint64_t features_vmx = 0x0000'0000'8000'0000;
444 constexpr static uint64_t features_x2apic = 0x0000'0001'0000'0000;
445 constexpr static uint64_t features_xtpr = 0x0000'0002'0000'0000;
448 uint32_t instruction_set = 0;
449 uint64_t features = 0;
458#if HI_COMPILER == HI_CC_MSVC
460 [[nodiscard]]
static leaf_type get_leaf(uint32_t leaf_id, uint32_t index = 0) noexcept
465 __cpuindex(tmp, char_cast<int>(cpu_id_leaf), char_cast<int>(index));
471#elif HI_COMPILER == HI_CC_GCC || HI_COMPILER == HI_CC_CLANG
473 [[nodiscard]]
static leaf_type get_leaf(uint32_t leaf_id, uint32_t index = 0) noexcept
476 __cpuid_count(leaf_id, index, r.a, r.b, r.c, r.d);
481#error "Unsuported compiler for x64 cpu_id"