From 983cc7da8566fcbe2647ed2d3921e7683bd8d325 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 18 Sep 2018 23:11:55 -0700 Subject: svm: march svm_fifo take 2 Change-Id: Ifa4fceef7edbe43d444790a624957db0817064de Signed-off-by: Florin Coras --- src/vppinfra/cpu.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/vppinfra') diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h index 110815c9f87..c636cf8639c 100644 --- a/src/vppinfra/cpu.h +++ b/src/vppinfra/cpu.h @@ -190,6 +190,35 @@ clib_cpu_march_priority_avx2 () #endif #endif /* included_clib_cpu_h */ +#define CLIB_MARCH_FN_CONSTRUCTOR(fn) \ +static void __clib_constructor \ +CLIB_MARCH_SFX(fn ## _march_constructor) (void) \ +{ \ + if (CLIB_MARCH_FN_PRIORITY() > fn ## _selected_priority) \ + { \ + fn ## _selected = & CLIB_MARCH_SFX (fn ## _ma); \ + fn ## _selected_priority = CLIB_MARCH_FN_PRIORITY(); \ + } \ +} \ + +#ifndef CLIB_MARCH_VARIANT +#define CLIB_MARCH_FN(fn, rtype, _args...) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args); \ + rtype (*fn ## _selected) (_args) = & CLIB_MARCH_SFX (fn ## _ma); \ + int fn ## _selected_priority = 0; \ + static inline rtype CLIB_CPU_OPTIMIZED \ + CLIB_MARCH_SFX (fn ## _ma)(_args) +#else +#define CLIB_MARCH_FN(fn, rtype, _args...) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args); \ + extern int (*fn ## _selected) (_args); \ + extern int fn ## _selected_priority; \ + CLIB_MARCH_FN_CONSTRUCTOR (fn) \ + static rtype CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (fn ## _ma)(_args) +#endif + +#define CLIB_MARCH_FN_SELECT(fn) (* fn ## _selected) + format_function_t format_cpu_uarch; format_function_t format_cpu_model_name; format_function_t format_cpu_flags; -- cgit 1.2.3-korg