16 #ifndef included_clib_cpu_h 17 #define included_clib_cpu_h 28 #if __x86_64__ && CLIB_DEBUG == 0 29 #define foreach_march_variant(macro, x) \ 30 macro(avx2, x, "arch=core-avx2") 32 #define foreach_march_variant(macro, x) 36 #if __GNUC__ > 4 && !__clang__ 37 #define CLIB_CPU_OPTIMIZED __attribute__ ((optimize ("tree-vectorize"))) 39 #define CLIB_CPU_OPTIMIZED 43 #define CLIB_MULTIARCH_ARCH_CHECK(arch, fn, tgt) \ 44 if (clib_cpu_supports_ ## arch()) \ 45 return & fn ## _ ##arch; 47 #define CLIB_MULTIARCH_SELECT_FN(fn,...) \ 48 __VA_ARGS__ void * fn ## _multiarch_select(void) \ 50 foreach_march_variant(CLIB_MULTIARCH_ARCH_CHECK, fn) \ 57 #define foreach_x86_64_flags \ 59 _ (ssse3, 1, ecx, 9) \ 60 _ (sse41, 1, ecx, 19) \ 61 _ (sse42, 1, ecx, 20) \ 64 _ (avx512f, 7, ebx, 16) \ 71 if ((
u32) __get_cpuid_max (0x80000000 & lev, 0) < lev)
74 __cpuid_count (lev, 0, *eax, *ebx, *ecx, *edx);
76 __cpuid (lev, *eax, *ebx, *ecx, *edx);
81 #define _(flag, func, reg, bit) \ 83 clib_cpu_supports_ ## flag() \ 85 u32 __attribute__((unused)) eax, ebx = 0, ecx = 0, edx = 0; \ 86 clib_get_cpuid (func, &eax, &ebx, &ecx, &edx); \ 88 return ((reg & (1 << bit)) != 0); \ foreach_x86_64_flags format_function_t format_cpu_uarch
format_function_t format_cpu_flags
static int clib_get_cpuid(const u32 lev, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
#define foreach_x86_64_flags
format_function_t format_cpu_model_name