Rewrite bsd.cpu.gcc50.mk (new cpus types; i386 removed)
[dragonfly.git] / share / mk / bsd.cpu.gcc50.mk
1 # Set default CPU compile flags and baseline CPUTYPE for each arch.  The
2 # compile flags must support the minimum CPU type for each architecture but
3 # may tune support for more advanced processors.
4
5 generic_x86_64= x86_64 mmx sse sse2
6
7 .if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native"
8
9 . if defined(CPUTYPE) && ${CPUTYPE:Mnative}
10 _CPUCFLAGS=     -march=native
11 . else
12 _CPUCFLAGS=
13 . endif
14
15 MACHINE_CPU=    ${generic_${MACHINE_ARCH}}
16
17 .else
18
19 ###############################################################################
20 # Logic to set up correct gcc optimization flag.  This must be included
21 # after /etc/make.conf so it can react to the local value of CPUTYPE
22 # defined therein.  Consult:
23 #       https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/x86-Options.html
24 ###############################################################################
25
26 # Some GCC cpu-types have aliases, rename them to a single identifier
27 # If the value for cpu-type is not recognized, throw it away and use -native
28
29 . if ${CPUTYPE} == "k8" \
30   || ${CPUTYPE} == "opteron" \
31   || ${CPUTYPE} == "athlon-fx"
32 CT2=    athlon64
33 . elif ${CPUTYPE} == "k8-sse3" \
34     || ${CPUTYPE} == "opteron-sse3"
35 CT2=    athlon64-sse3
36 . elif ${CPUTYPE} == "amdfam10"
37 CT2=    barcelona
38 . else
39 CT2=    ${CPUTYPE}
40 . endif
41
42 known_x86_64=   athlon64 \
43                 athlon64-sse3 \
44                 barcelona \
45                 bdver1 bdver2 bdver3 bdver4 \
46                 bonnell \
47                 broadwell \
48                 btver1 btver2 \
49                 core2 \
50                 haswell \
51                 ivybridge \
52                 knl \
53                 nocona \
54                 nehalem \
55                 sandybridge \
56                 silvermont \
57                 skylake \
58                 skylake-avx512 \
59                 westmere \
60                 znver1
61
62 . if defined(known_${MACHINE_ARCH}) && \
63      !empty(known_${MACHINE_ARCH}:M${CT2})              # CID: Check CPUTYPE
64
65 # Set up the list of CPU features based on the CPU type.  This is an
66 # unordered list to make it easy for client makefiles to test for the
67 # presence of a CPU feature.
68
69 .  if ${MACHINE_ARCH} == "x86_64"
70 C_nocona=       ${generic_x86_64} sse3
71 C_core2=        ${C_nocona} ssse3
72 C_nehalem=      ${C_core2} sse41 sse42 popcnt
73 C_westmere=     ${C_nehalem} aes pclmul
74 C_sandybridge=  ${C_westmere} avx
75 C_ivybridge=    ${C_sandybridge} fsgsbase rdrnd f16c
76 C_haswell=      ${C_ivybridge} movbe avx2 fma bmi bmi2
77 C_broadwell=    ${C_haswell} rdseed adcx prefetchw
78 C_skylake=      ${C_broadwell} xsavec xsaves clflushop
79 C_knl=          ${C_broadwell} avx512f avx512pf avx512er avx512cd
80 C_bonnell=      ${C_core2} movbe
81 C_silvermont=   ${C_westmere} movbe rdrnd
82 C_skylakeavx512=${C_skylake} pku avx512f avx512vl avx512bw avx512dq avx512cd
83 C_athlon64=     ${generic_x86_64} 3dnow
84 C_athlon64sse3= ${C_athlon64} sse3
85 C_barcelona=    ${C_athlon64sse3} sse4a abm
86 C_bdver1=       ${C_core2} sse4a sse41 sse42 abm fma4 avx xop lwp aes \
87                 pclmul cx16
88 C_bdver2=       ${C_bdver1} bmi f16c fma tbm
89 C_bdver3=       ${C_bdver2} fsgsbase
90 C_bdver4=       ${C_bdver3} bmi2 avx2 movbe
91 C_znver1=       ${C_core2} bmi bmi2 f16c fma fsgsbase avx avx2 adcx rdseed \
92                 mwaitx sha clzero aes pclmul cx16 movbe sse4a sse41 sse42 \
93                 abm xsavec xsaves clflushop popcnt
94 C_btver1=       ${C_barcelona} cx16
95 C_btver2=       ${C_btver1} movbe f16c bmi avx pclmul aes sse41 sse42
96
97 .  endif        # end of x86_64 feature list
98
99 _CPUCFLAGS=     -march=${CT2}
100 MACHINE_CPU=    ${C_${CT2:S|-||}}
101
102 . else                                                  # CID: Check CPUTYPE
103
104 # CPUTYPE was defined and was not empty, but the value does not match known
105 # CPU types of the defined MACHINE_ARCH.  Set -march to native and define
106 # generic features based on MACHINE_ARCH
107
108 _CPUCFLAGS=     -march=native
109 MACHINE_CPU=    ${generic_${MACHINE_ARCH}}
110
111 . endif                                                 # CID: Check CPUTYPE
112
113 .endif