New upstream version 18.11-rc2
[deb_dpdk.git] / mk / rte.cpuflags.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
3
4 # this makefile is called from the generic rte.vars.mk and is
5 # used to set the RTE_CPUFLAG_* environment variables giving details
6 # of what instruction sets the target cpu supports.
7
8 AUTO_CPUFLAGS := $(shell $(CC) $(MACHINE_CFLAGS) $(WERROR_FLAGS) $(EXTRA_CFLAGS) -dM -E - < /dev/null)
9
10 # adding flags to CPUFLAGS
11
12 ifneq ($(filter $(AUTO_CPUFLAGS),__SSE__),)
13 CPUFLAGS += SSE
14 endif
15
16 ifneq ($(filter $(AUTO_CPUFLAGS),__SSE2__),)
17 CPUFLAGS += SSE2
18 endif
19
20 ifneq ($(filter $(AUTO_CPUFLAGS),__SSE3__),)
21 CPUFLAGS += SSE3
22 endif
23
24 ifneq ($(filter $(AUTO_CPUFLAGS),__SSSE3__),)
25 CPUFLAGS += SSSE3
26 endif
27
28 ifneq ($(filter $(AUTO_CPUFLAGS),__SSE4_1__),)
29 CPUFLAGS += SSE4_1
30 endif
31
32 ifneq ($(filter $(AUTO_CPUFLAGS),__SSE4_2__),)
33 CPUFLAGS += SSE4_2
34 endif
35
36 ifneq ($(filter $(AUTO_CPUFLAGS),__AES__),)
37 CPUFLAGS += AES
38 endif
39
40 ifneq ($(filter $(AUTO_CPUFLAGS),__PCLMUL__),)
41 CPUFLAGS += PCLMULQDQ
42 endif
43
44 ifneq ($(filter $(AUTO_CPUFLAGS),__AVX__),)
45 ifeq ($(CONFIG_RTE_ENABLE_AVX),y)
46 CPUFLAGS += AVX
47 endif
48 endif
49
50 ifneq ($(filter $(AUTO_CPUFLAGS),__RDRND__),)
51 CPUFLAGS += RDRAND
52 endif
53
54 ifneq ($(filter $(AUTO_CPUFLAGS),__FSGSBASE__),)
55 CPUFLAGS += FSGSBASE
56 endif
57
58 ifneq ($(filter $(AUTO_CPUFLAGS),__F16C__),)
59 CPUFLAGS += F16C
60 endif
61
62 ifneq ($(filter $(AUTO_CPUFLAGS),__AVX2__),)
63 ifeq ($(CONFIG_RTE_ENABLE_AVX),y)
64 CPUFLAGS += AVX2
65 endif
66 endif
67
68 ifneq ($(filter $(AUTO_CPUFLAGS),__AVX512F__),)
69 ifeq ($(CONFIG_RTE_ENABLE_AVX512),y)
70 CPUFLAGS += AVX512F
71 else
72 # disable AVX512F support of gcc as a workaround for Bug 97
73 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
74 MACHINE_CFLAGS += -mno-avx512f
75 endif
76 endif
77 endif
78
79 # IBM Power CPU flags
80 ifneq ($(filter $(AUTO_CPUFLAGS),__PPC64__),)
81 CPUFLAGS += PPC64
82 endif
83
84 ifneq ($(filter $(AUTO_CPUFLAGS),__PPC32__),)
85 CPUFLAGS += PPC32
86 endif
87
88 ifneq ($(filter $(AUTO_CPUFLAGS),__vector),)
89 CPUFLAGS += ALTIVEC
90 endif
91
92 ifneq ($(filter $(AUTO_CPUFLAGS),__builtin_vsx_xvnmaddadp),)
93 CPUFLAGS += VSX
94 endif
95
96 # ARM flags
97 ifneq ($(filter __ARM_NEON __aarch64__,$(AUTO_CPUFLAGS)),)
98 CPUFLAGS += NEON
99 endif
100
101 ifneq ($(filter $(AUTO_CPUFLAGS),__ARM_FEATURE_CRC32),)
102 CPUFLAGS += CRC32
103 endif
104
105 ifneq ($(filter $(AUTO_CPUFLAGS),__ARM_FEATURE_CRYPTO),)
106 CPUFLAGS += AES
107 CPUFLAGS += PMULL
108 CPUFLAGS += SHA1
109 CPUFLAGS += SHA2
110 endif
111
112 MACHINE_CFLAGS += $(addprefix -DRTE_MACHINE_CPUFLAG_,$(CPUFLAGS))
113
114 # To strip whitespace
115 comma:= ,
116 empty:=
117 space:= $(empty) $(empty)
118 CPUFLAGSTMP1 := $(addprefix RTE_CPUFLAG_,$(CPUFLAGS))
119 CPUFLAGSTMP2 := $(subst $(space),$(comma),$(CPUFLAGSTMP1))
120 CPUFLAGS_LIST := -DRTE_COMPILE_TIME_CPUFLAGS=$(CPUFLAGSTMP2)