blob: b3743d4c26dd04abf5c1f935915027a2645a9c3f [file] [log] [blame]
Damjan Marion522e4862016-03-04 12:44:14 +01001/*
2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef included_clib_cpu_h
17#define included_clib_cpu_h
18
Damjan Marion0a78fa12019-01-19 23:45:36 +010019#include <sys/syscall.h>
Damjan Marion1c80e832016-05-11 23:07:18 +020020#include <vppinfra/format.h>
21
Damjan Mariona31698b2021-03-10 14:35:28 +010022#if defined(__x86_64__)
23#define foreach_march_variant \
Damjan Marion98f7f0a2023-04-17 09:38:11 +000024 _ (scalar, "Generic (SIMD disabled)") \
Damjan Mariona31698b2021-03-10 14:35:28 +010025 _ (hsw, "Intel Haswell") \
26 _ (trm, "Intel Tremont") \
27 _ (skx, "Intel Skylake (server) / Cascade Lake") \
Damjan Marion1ca68182023-03-15 11:08:53 +000028 _ (icl, "Intel Ice Lake") \
29 _ (adl, "Intel Alder Lake") \
Sivaprasad Tummala206592b2023-04-17 05:05:15 -070030 _ (spr, "Intel Sapphire Rapids") \
31 _ (znver3, "AMD Milan") \
32 _ (znver4, "AMD Genoa")
Damjan Mariona31698b2021-03-10 14:35:28 +010033#elif defined(__aarch64__)
34#define foreach_march_variant \
35 _ (octeontx2, "Marvell Octeon TX2") \
36 _ (thunderx2t99, "Marvell ThunderX2 T99") \
37 _ (qdf24xx, "Qualcomm CentriqTM 2400") \
38 _ (cortexa72, "ARM Cortex-A72") \
Damjan Marion7bf8f5e2023-09-12 15:08:58 +020039 _ (neoversen1, "ARM Neoverse N1") \
40 _ (neoversen2, "ARM Neoverse N2")
Damjan Marion1c80e832016-05-11 23:07:18 +020041#else
Damjan Mariona31698b2021-03-10 14:35:28 +010042#define foreach_march_variant
Damjan Marion1c80e832016-05-11 23:07:18 +020043#endif
44
Sivaprasad Tummala6a1a8322023-04-17 05:16:11 -070045#define amd_vendor(t1, t2, t3) \
46 ((t1 == 0x68747541) && /* htuA */ \
47 (t2 == 0x444d4163) && /* DMAc */ \
48 (t3 == 0x69746e65)) /* itne */
Damjan Mariona31698b2021-03-10 14:35:28 +010049typedef enum
50{
51 CLIB_MARCH_VARIANT_TYPE = 0,
52#define _(s, n) CLIB_MARCH_VARIANT_TYPE_##s,
53 foreach_march_variant
54#undef _
55 CLIB_MARCH_TYPE_N_VARIANTS
56} clib_march_variant_type_t;
Damjan Marion1c80e832016-05-11 23:07:18 +020057
Damjan Marion812b32d2018-05-28 21:26:47 +020058#ifdef CLIB_MARCH_VARIANT
Damjan Marion04f3db32017-11-10 21:55:45 +010059#define __CLIB_MULTIARCH_FN(a,b) a##_##b
60#define _CLIB_MULTIARCH_FN(a,b) __CLIB_MULTIARCH_FN(a,b)
Damjan Marion812b32d2018-05-28 21:26:47 +020061#define CLIB_MULTIARCH_FN(fn) _CLIB_MULTIARCH_FN(fn,CLIB_MARCH_VARIANT)
Damjan Marion04f3db32017-11-10 21:55:45 +010062#else
63#define CLIB_MULTIARCH_FN(fn) fn
64#endif
Damjan Marion1c80e832016-05-11 23:07:18 +020065
Damjan Marion812b32d2018-05-28 21:26:47 +020066#define CLIB_MARCH_SFX CLIB_MULTIARCH_FN
67
Damjan Marion910d3692019-01-21 11:48:34 +010068typedef struct _clib_march_fn_registration
69{
70 void *function;
71 int priority;
72 struct _clib_march_fn_registration *next;
73 char *name;
74} clib_march_fn_registration;
75
76static_always_inline void *
77clib_march_select_fn_ptr (clib_march_fn_registration * r)
78{
79 void *rv = 0;
80 int last_prio = -1;
81
82 while (r)
83 {
84 if (last_prio < r->priority)
85 {
86 last_prio = r->priority;
87 rv = r->function;
88 }
89 r = r->next;
90 }
91 return rv;
92}
93
Damjan Marion11e0d752021-05-05 20:06:39 +020094#define CLIB_MARCH_FN_POINTER(fn) \
95 (__typeof__ (fn) *) clib_march_select_fn_ptr (fn##_march_fn_registrations);
Damjan Marion910d3692019-01-21 11:48:34 +010096
Mohammed Hawarie7149262022-05-18 10:08:47 +020097#define CLIB_MARCH_FN_VOID_POINTER(fn) \
98 clib_march_select_fn_ptr (fn##_march_fn_registrations);
99
Damjan Marion910d3692019-01-21 11:48:34 +0100100#define _CLIB_MARCH_FN_REGISTRATION(fn) \
101static clib_march_fn_registration \
102CLIB_MARCH_SFX(fn##_march_fn_registration) = \
103{ \
104 .name = CLIB_MARCH_VARIANT_STR \
105}; \
106\
107static void __clib_constructor \
108fn##_march_register () \
109{ \
110 clib_march_fn_registration *r; \
111 r = & CLIB_MARCH_SFX (fn##_march_fn_registration); \
112 r->priority = CLIB_MARCH_FN_PRIORITY(); \
113 r->next = fn##_march_fn_registrations; \
114 r->function = CLIB_MARCH_SFX (fn); \
115 fn##_march_fn_registrations = r; \
116}
117
118#ifdef CLIB_MARCH_VARIANT
119#define CLIB_MARCH_FN_REGISTRATION(fn) \
120extern clib_march_fn_registration *fn##_march_fn_registrations; \
121_CLIB_MARCH_FN_REGISTRATION(fn)
122#else
123#define CLIB_MARCH_FN_REGISTRATION(fn) \
124clib_march_fn_registration *fn##_march_fn_registrations = 0; \
125_CLIB_MARCH_FN_REGISTRATION(fn)
126#endif
Radu Nicolaue1480a22021-01-14 10:25:02 +0000127#define foreach_x86_64_flags \
128 _ (sse3, 1, ecx, 0) \
129 _ (pclmulqdq, 1, ecx, 1) \
130 _ (ssse3, 1, ecx, 9) \
131 _ (sse41, 1, ecx, 19) \
132 _ (sse42, 1, ecx, 20) \
133 _ (avx, 1, ecx, 28) \
134 _ (rdrand, 1, ecx, 30) \
135 _ (avx2, 7, ebx, 5) \
Maros Ondrejicka568ef462022-11-10 14:11:40 +0100136 _ (bmi2, 7, ebx, 8) \
Radu Nicolaue1480a22021-01-14 10:25:02 +0000137 _ (rtm, 7, ebx, 11) \
138 _ (pqm, 7, ebx, 12) \
139 _ (pqe, 7, ebx, 15) \
140 _ (avx512f, 7, ebx, 16) \
141 _ (rdseed, 7, ebx, 18) \
142 _ (x86_aes, 1, ecx, 25) \
143 _ (sha, 7, ebx, 29) \
144 _ (vaes, 7, ecx, 9) \
145 _ (vpclmulqdq, 7, ecx, 10) \
146 _ (avx512_vnni, 7, ecx, 11) \
147 _ (avx512_bitalg, 7, ecx, 12) \
148 _ (avx512_vpopcntdq, 7, ecx, 14) \
149 _ (movdiri, 7, ecx, 27) \
150 _ (movdir64b, 7, ecx, 28) \
Damjan Marion15522282023-03-14 13:34:59 +0100151 _ (enqcmd, 7, ecx, 29) \
Ray Kinsella0d27e3e2021-10-15 12:48:31 +0100152 _ (avx512_fp16, 7, edx, 23) \
Xiaoming Jiang04da3242024-02-22 21:24:20 +0800153 _ (aperfmperf, 0x00000006, ecx, 0) \
Sivaprasad Tummala206592b2023-04-17 05:05:15 -0700154 _ (invariant_tsc, 0x80000007, edx, 8) \
155 _ (monitorx, 0x80000001, ecx, 29)
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100156
157#define foreach_aarch64_flags \
158_ (fp, 0) \
159_ (asimd, 1) \
160_ (evtstrm, 2) \
161_ (aarch64_aes, 3) \
162_ (pmull, 4) \
163_ (sha1, 5) \
164_ (sha2, 6) \
165_ (crc32, 7) \
166_ (atomics, 8) \
167_ (fphp, 9) \
168_ (asimdhp, 10) \
169_ (cpuid, 11) \
170_ (asimdrdm, 12) \
171_ (jscvt, 13) \
172_ (fcma, 14) \
173_ (lrcpc, 15) \
174_ (dcpop, 16) \
175_ (sha3, 17) \
176_ (sm3, 18) \
177_ (sm4, 19) \
178_ (asimddp, 20) \
179_ (sha512, 21) \
180_ (sve, 22)
181
Dave Barach6c89a352022-12-26 14:01:36 -0500182u32 clib_get_current_cpu_id (void);
183u32 clib_get_current_numa_node (void);
Damjan Marion0a78fa12019-01-19 23:45:36 +0100184
Dave Barach6c89a352022-12-26 14:01:36 -0500185typedef int (*clib_cpu_supports_func_t) (void);
Zachary Leaf268d7be2022-05-12 02:26:00 -0500186
Christophe Fontaine33e81952016-12-19 14:41:52 +0100187#if defined(__x86_64__)
188#include "cpuid.h"
189
Damjan Marion1c80e832016-05-11 23:07:18 +0200190static inline int
Dave Barachc3799992016-08-15 11:12:27 -0400191clib_get_cpuid (const u32 lev, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx)
Damjan Marion1c80e832016-05-11 23:07:18 +0200192{
193 if ((u32) __get_cpuid_max (0x80000000 & lev, 0) < lev)
194 return 0;
195 if (lev == 7)
Dave Barachc3799992016-08-15 11:12:27 -0400196 __cpuid_count (lev, 0, *eax, *ebx, *ecx, *edx);
Damjan Marion1c80e832016-05-11 23:07:18 +0200197 else
Dave Barachc3799992016-08-15 11:12:27 -0400198 __cpuid (lev, *eax, *ebx, *ecx, *edx);
Damjan Marion1c80e832016-05-11 23:07:18 +0200199 return 1;
200}
201
Damjan Marion1c80e832016-05-11 23:07:18 +0200202#define _(flag, func, reg, bit) \
203static inline int \
204clib_cpu_supports_ ## flag() \
205{ \
206 u32 __attribute__((unused)) eax, ebx = 0, ecx = 0, edx = 0; \
207 clib_get_cpuid (func, &eax, &ebx, &ecx, &edx); \
208 \
209 return ((reg & (1 << bit)) != 0); \
210}
Dave Barachc3799992016-08-15 11:12:27 -0400211foreach_x86_64_flags
Damjan Marion1c80e832016-05-11 23:07:18 +0200212#undef _
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100213#else /* __x86_64__ */
Christophe Fontaine33e81952016-12-19 14:41:52 +0100214
215#define _(flag, func, reg, bit) \
216static inline int clib_cpu_supports_ ## flag() { return 0; }
217foreach_x86_64_flags
218#undef _
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100219#endif /* __x86_64__ */
220#if defined(__aarch64__)
221#include <sys/auxv.h>
222#define _(flag, bit) \
223static inline int \
224clib_cpu_supports_ ## flag() \
225{ \
226 unsigned long hwcap = getauxval(AT_HWCAP); \
227 return (hwcap & (1 << bit)); \
228}
229 foreach_aarch64_flags
230#undef _
231#else /* ! __x86_64__ && !__aarch64__ */
232#define _(flag, bit) \
233static inline int clib_cpu_supports_ ## flag() { return 0; }
234 foreach_aarch64_flags
235#undef _
236#endif /* __x86_64__, __aarch64__ */
237/*
238 * aes is the only feature with the same name in both flag lists
239 * handle this by prefixing it with the arch name, and handling it
240 * with the custom function below
241 */
242 static inline int
243clib_cpu_supports_aes ()
244{
Zhiyong Yang7f4fd222019-04-19 03:04:41 -0400245#if defined(__x86_64__)
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100246 return clib_cpu_supports_x86_aes ();
247#elif defined (__aarch64__)
248 return clib_cpu_supports_aarch64_aes ();
249#else
250 return 0;
Christophe Fontaine33e81952016-12-19 14:41:52 +0100251#endif
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100252}
253
Damjan Marion812b32d2018-05-28 21:26:47 +0200254static inline int
Damjan Marion98f7f0a2023-04-17 09:38:11 +0000255clib_cpu_march_priority_scalar ()
256{
257 return 1;
258}
259
260static inline int
Damjan Marion15522282023-03-14 13:34:59 +0100261clib_cpu_march_priority_spr ()
262{
263 if (clib_cpu_supports_enqcmd ())
264 return 300;
265 return -1;
266}
267
268static inline int
Damjan Marion162330f2020-04-29 21:28:15 +0200269clib_cpu_march_priority_icl ()
Damjan Marion812b32d2018-05-28 21:26:47 +0200270{
Damjan Marion162330f2020-04-29 21:28:15 +0200271 if (clib_cpu_supports_avx512_bitalg ())
272 return 200;
Damjan Marion812b32d2018-05-28 21:26:47 +0200273 return -1;
274}
275
276static inline int
Damjan Marion15522282023-03-14 13:34:59 +0100277clib_cpu_march_priority_adl ()
278{
279 if (clib_cpu_supports_movdiri () && clib_cpu_supports_avx2 ())
280 return 150;
281 return -1;
282}
283
284static inline int
Damjan Marion162330f2020-04-29 21:28:15 +0200285clib_cpu_march_priority_skx ()
286{
287 if (clib_cpu_supports_avx512f ())
288 return 100;
289 return -1;
290}
291
292static inline int
Radu Nicolaue1480a22021-01-14 10:25:02 +0000293clib_cpu_march_priority_trm ()
294{
295 if (clib_cpu_supports_movdiri ())
Damjan Marion15522282023-03-14 13:34:59 +0100296 return 40;
Radu Nicolaue1480a22021-01-14 10:25:02 +0000297 return -1;
298}
299
300static inline int
Damjan Marion162330f2020-04-29 21:28:15 +0200301clib_cpu_march_priority_hsw ()
Damjan Marion812b32d2018-05-28 21:26:47 +0200302{
303 if (clib_cpu_supports_avx2 ())
Damjan Marion64593152019-03-12 19:59:22 +0100304 return 50;
Damjan Marion812b32d2018-05-28 21:26:47 +0200305 return -1;
306}
307
Sivaprasad Tummala206592b2023-04-17 05:05:15 -0700308static inline int
309clib_cpu_march_priority_znver4 ()
310{
311 if (clib_cpu_supports_avx512_bitalg () && clib_cpu_supports_monitorx ())
312 return 250;
313 return -1;
314}
315
316static inline int
317clib_cpu_march_priority_znver3 ()
318{
319 if (clib_cpu_supports_avx2 () && clib_cpu_supports_monitorx ())
320 return 70;
321 return -1;
322}
323
Ray Kinsella0024e532021-11-26 14:57:35 +0000324#define X86_CPU_ARCH_PERF_FUNC 0xA
325
326static inline int
327clib_get_pmu_counter_count (u8 *fixed, u8 *general)
328{
329#if defined(__x86_64__)
330 u32 __clib_unused eax = 0, ebx = 0, ecx = 0, edx = 0;
331 clib_get_cpuid (X86_CPU_ARCH_PERF_FUNC, &eax, &ebx, &ecx, &edx);
332
333 *general = (eax & 0xFF00) >> 8;
334 *fixed = (edx & 0xF);
335
336 return 1;
337#else
338 return 0;
339#endif
340}
341
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200342typedef struct
Lijian Zhang2e237212018-09-10 17:13:56 +0800343{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200344 struct
345 {
346 u8 implementer;
347 u16 part_num;
348 } aarch64;
349} clib_cpu_info_t;
Lijian Zhang2e237212018-09-10 17:13:56 +0800350
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200351const clib_cpu_info_t *clib_get_cpu_info ();
Lijian Zhang2e237212018-09-10 17:13:56 +0800352
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200353/* ARM */
354#define AARCH64_CPU_IMPLEMENTER_ARM 0x41
355#define AARCH64_CPU_PART_CORTEXA72 0xd08
356#define AARCH64_CPU_PART_NEOVERSEN1 0xd0c
357#define AARCH64_CPU_PART_NEOVERSEN2 0xd49
Lijian Zhang2e237212018-09-10 17:13:56 +0800358
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200359/*cavium */
Nitin Saxenae2f52362020-08-25 19:58:37 +0530360#define AARCH64_CPU_IMPLEMENTER_CAVIUM 0x43
361#define AARCH64_CPU_PART_THUNDERX2 0x0af
362#define AARCH64_CPU_PART_OCTEONTX2T96 0x0b2
363#define AARCH64_CPU_PART_OCTEONTX2T98 0x0b1
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200364
365/* Qualcomm */
366#define AARCH64_CPU_IMPLEMENTER_QUALCOMM 0x51
Lijian Zhang2e237212018-09-10 17:13:56 +0800367#define AARCH64_CPU_PART_QDF24XX 0xc00
Lijian Zhang2e237212018-09-10 17:13:56 +0800368
369static inline int
Nitin Saxenae2f52362020-08-25 19:58:37 +0530370clib_cpu_march_priority_octeontx2 ()
371{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200372 const clib_cpu_info_t *info = clib_get_cpu_info ();
373
374 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_CAVIUM)
375 return -1;
376
377 if (info->aarch64.part_num == AARCH64_CPU_PART_OCTEONTX2T96 ||
378 info->aarch64.part_num == AARCH64_CPU_PART_OCTEONTX2T98)
Nitin Saxenae2f52362020-08-25 19:58:37 +0530379 return 20;
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200380
Nitin Saxenae2f52362020-08-25 19:58:37 +0530381 return -1;
382}
383
384static inline int
Lijian Zhang2e237212018-09-10 17:13:56 +0800385clib_cpu_march_priority_thunderx2t99 ()
386{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200387 const clib_cpu_info_t *info = clib_get_cpu_info ();
388
389 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_CAVIUM)
390 return -1;
391
392 if (info->aarch64.part_num == AARCH64_CPU_PART_THUNDERX2)
Lijian Zhang2e237212018-09-10 17:13:56 +0800393 return 20;
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200394
Lijian Zhang2e237212018-09-10 17:13:56 +0800395 return -1;
396}
397
398static inline int
399clib_cpu_march_priority_qdf24xx ()
400{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200401 const clib_cpu_info_t *info = clib_get_cpu_info ();
402
403 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_QUALCOMM)
404 return -1;
405
406 if (info->aarch64.part_num == AARCH64_CPU_PART_QDF24XX)
Lijian Zhang2e237212018-09-10 17:13:56 +0800407 return 20;
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200408
Lijian Zhang2e237212018-09-10 17:13:56 +0800409 return -1;
410}
411
412static inline int
413clib_cpu_march_priority_cortexa72 ()
414{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200415 const clib_cpu_info_t *info = clib_get_cpu_info ();
416
417 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_ARM)
418 return -1;
419
420 if (info->aarch64.part_num == AARCH64_CPU_PART_CORTEXA72)
Lijian Zhang2e237212018-09-10 17:13:56 +0800421 return 10;
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200422
Lijian Zhang2e237212018-09-10 17:13:56 +0800423 return -1;
424}
425
Lijian.Zhang690ce862020-02-18 19:58:19 +0800426static inline int
427clib_cpu_march_priority_neoversen1 ()
428{
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200429 const clib_cpu_info_t *info = clib_get_cpu_info ();
430
431 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_ARM)
432 return -1;
433
434 if (info->aarch64.part_num == AARCH64_CPU_PART_NEOVERSEN1)
Lijian.Zhang690ce862020-02-18 19:58:19 +0800435 return 10;
Damjan Marion7bf8f5e2023-09-12 15:08:58 +0200436
437 return -1;
438}
439
440static inline int
441clib_cpu_march_priority_neoversen2 ()
442{
443 const clib_cpu_info_t *info = clib_get_cpu_info ();
444
445 if (!info || info->aarch64.implementer != AARCH64_CPU_IMPLEMENTER_ARM)
446 return -1;
447
448 if (info->aarch64.part_num == AARCH64_CPU_PART_NEOVERSEN2)
449 return 10;
450
Lijian.Zhang690ce862020-02-18 19:58:19 +0800451 return -1;
452}
453
Damjan Marion812b32d2018-05-28 21:26:47 +0200454#ifdef CLIB_MARCH_VARIANT
455#define CLIB_MARCH_FN_PRIORITY() CLIB_MARCH_SFX(clib_cpu_march_priority)()
456#else
457#define CLIB_MARCH_FN_PRIORITY() 0
458#endif
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100459#endif /* included_clib_cpu_h */
460
Florin Coras983cc7d2018-09-18 23:11:55 -0700461#define CLIB_MARCH_FN_CONSTRUCTOR(fn) \
462static void __clib_constructor \
463CLIB_MARCH_SFX(fn ## _march_constructor) (void) \
464{ \
465 if (CLIB_MARCH_FN_PRIORITY() > fn ## _selected_priority) \
466 { \
467 fn ## _selected = & CLIB_MARCH_SFX (fn ## _ma); \
468 fn ## _selected_priority = CLIB_MARCH_FN_PRIORITY(); \
469 } \
470} \
471
472#ifndef CLIB_MARCH_VARIANT
Damjan Marion1bb67ab2021-04-30 11:11:08 +0200473#define CLIB_MARCH_FN(fn, rtype, _args...) \
474 static rtype CLIB_MARCH_SFX (fn##_ma) (_args); \
475 rtype (*fn##_selected) (_args) = &CLIB_MARCH_SFX (fn##_ma); \
476 int fn##_selected_priority = 0; \
477 static inline rtype CLIB_MARCH_SFX (fn##_ma) (_args)
Florin Coras983cc7d2018-09-18 23:11:55 -0700478#else
Damjan Marion1bb67ab2021-04-30 11:11:08 +0200479#define CLIB_MARCH_FN(fn, rtype, _args...) \
480 static rtype CLIB_MARCH_SFX (fn##_ma) (_args); \
481 extern rtype (*fn##_selected) (_args); \
482 extern int fn##_selected_priority; \
483 CLIB_MARCH_FN_CONSTRUCTOR (fn) \
484 static rtype CLIB_MARCH_SFX (fn##_ma) (_args)
Florin Coras983cc7d2018-09-18 23:11:55 -0700485#endif
486
487#define CLIB_MARCH_FN_SELECT(fn) (* fn ## _selected)
488
Gabriel Ganne73cb0062017-12-05 14:26:33 +0100489format_function_t format_cpu_uarch;
Damjan Marion522e4862016-03-04 12:44:14 +0100490format_function_t format_cpu_model_name;
Damjan Marion1c80e832016-05-11 23:07:18 +0200491format_function_t format_cpu_flags;
Damjan Marione3e35552021-05-06 17:34:49 +0200492format_function_t format_march_variant;
Damjan Marion522e4862016-03-04 12:44:14 +0100493
Dave Barachc3799992016-08-15 11:12:27 -0400494/*
495 * fd.io coding-style-patch-verification: ON
496 *
497 * Local Variables:
498 * eval: (c-set-style "gnu")
499 * End:
500 */