New upstream version 18.11-rc1
[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 endif
72 endif
73
74 # IBM Power CPU flags
75 ifneq ($(filter $(AUTO_CPUFLAGS),__PPC64__),)
76 CPUFLAGS += PPC64
77 endif
78
79 ifneq ($(filter $(AUTO_CPUFLAGS),__PPC32__),)
80 CPUFLAGS += PPC32
81 endif
82
83 ifneq ($(filter $(AUTO_CPUFLAGS),__vector),)
84 CPUFLAGS += ALTIVEC
85 endif
86
87 ifneq ($(filter $(AUTO_CPUFLAGS),__builtin_vsx_xvnmaddadp),)
88 CPUFLAGS += VSX
89 endif
90
91 # ARM flags
92 ifneq ($(filter __ARM_NEON __aarch64__,$(AUTO_CPUFLAGS)),)
93 CPUFLAGS += NEON
94 endif
95
96 ifneq ($(filter $(AUTO_CPUFLAGS),__ARM_FEATURE_CRC32),)
97 CPUFLAGS += CRC32
98 endif
99
100 ifneq ($(filter $(AUTO_CPUFLAGS),__ARM_FEATURE_CRYPTO),)
101 CPUFLAGS += AES
102 CPUFLAGS += PMULL
103 CPUFLAGS += SHA1
104 CPUFLAGS += SHA2
105 endif
106
107 MACHINE_CFLAGS += $(addprefix -DRTE_MACHINE_CPUFLAG_,$(CPUFLAGS))
108
109 # To strip whitespace
110 comma:= ,
111 empty:=
112 space:= $(empty) $(empty)
113 CPUFLAGSTMP1 := $(addprefix RTE_CPUFLAG_,$(CPUFLAGS))
114 CPUFLAGSTMP2 := $(subst $(space),$(comma),$(CPUFLAGSTMP1))
115 CPUFLAGS_LIST := -DRTE_COMPILE_TIME_CPUFLAGS=$(CPUFLAGSTMP2)