xref: /f-stack/dpdk/lib/librte_fib/meson.build (revision 2d9fd380)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2018 Vladimir Medvedkin <[email protected]>
3# Copyright(c) 2019 Intel Corporation
4
5sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
6headers = files('rte_fib.h', 'rte_fib6.h')
7deps += ['rib']
8
9# compile AVX512 version if:
10# we are building 64-bit binary AND binutils can generate proper code
11if dpdk_conf.has('RTE_ARCH_X86_64') and binutils_ok.returncode() == 0
12	# compile AVX512 version if either:
13	# a. we have AVX512F supported in minimum instruction set baseline
14	# b. it's not minimum instruction set, but supported by compiler
15	#
16	# in former case, just add avx512 C file to files list
17	# in latter case, compile c file to static lib, using correct
18	# compiler flags, and then have the .o file from static lib
19	# linked into main lib.
20
21	# check if all required flags already enabled (variant a).
22	acl_avx512_flags = ['__AVX512F__','__AVX512DQ__']
23	acl_avx512_on = true
24	foreach f:acl_avx512_flags
25		if cc.get_define(f, args: machine_args) == ''
26			acl_avx512_on = false
27		endif
28	endforeach
29
30	if acl_avx512_on == true
31		cflags += ['-DCC_DIR24_8_AVX512_SUPPORT']
32		sources += files('dir24_8_avx512.c')
33		# TRIE AVX512 implementation uses avx512bw intrinsics along with
34		# avx512f and avx512dq
35		if cc.get_define('__AVX512BW__', args: machine_args) != ''
36			cflags += ['-DCC_TRIE_AVX512_SUPPORT']
37			sources += files('trie_avx512.c')
38		endif
39	elif cc.has_multi_arguments('-mavx512f', '-mavx512dq')
40		dir24_8_avx512_tmp = static_library('dir24_8_avx512_tmp',
41				'dir24_8_avx512.c',
42				dependencies: static_rte_eal,
43				c_args: cflags + ['-mavx512f', '-mavx512dq'])
44		objs += dir24_8_avx512_tmp.extract_objects('dir24_8_avx512.c')
45		cflags += ['-DCC_DIR24_8_AVX512_SUPPORT']
46		# TRIE AVX512 implementation uses avx512bw intrinsics along with
47		# avx512f and avx512dq
48		if cc.has_argument('-mavx512bw')
49			trie_avx512_tmp = static_library('trie_avx512_tmp',
50				'trie_avx512.c',
51				dependencies: static_rte_eal,
52				c_args: cflags + ['-mavx512f', \
53					'-mavx512dq', '-mavx512bw'])
54			objs += trie_avx512_tmp.extract_objects('trie_avx512.c')
55			cflags += ['-DCC_TRIE_AVX512_SUPPORT']
56		endif
57	endif
58endif
59