xref: /dragonfly/share/mk/bsd.cpu.gcc47.mk (revision 74444d28dbd69fa261277551351cd01e932a8469)
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
5generic_x86_64=     x86_64 mmx sse sse2
6generic_i386=       i386
7
8.if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native"
9
10. if defined(CPUTYPE) && ${CPUTYPE:Mnative}
11_CPUCFLAGS=         -march=native
12. else
13_CPUCFLAGS=
14. endif
15
16MACHINE_CPU=        ${generic_${MACHINE_ARCH}}
17
18.else
19
20###############################################################################
21# Logic to set up correct gcc optimization flag.  This must be included
22# after /etc/make.conf so it can react to the local value of CPUTYPE
23# defined therein.  Consult:
24# https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/i386-and-x86-64-Options.html
25###############################################################################
26
27# Some GCC cpu-types have aliases, rename them to a single identifier
28# If the value for cpu-type is not recognized, throw it away and use -native
29
30. if ${CPUTYPE} == "k8" \
31  || ${CPUTYPE} == "opteron" \
32  || ${CPUTYPE} == "athlon-fx"
33CT2=      athlon64
34. elif ${CPUTYPE} == "k8-sse3" \
35    || ${CPUTYPE} == "opteron-sse3"
36CT2=      athlon64-sse3
37. elif ${CPUTYPE} == "amdfam10"
38CT2=      barcelona
39. else
40CT2=      ${CPUTYPE}
41. endif
42
43known_x86_64=       athlon64 \
44                    athlon64-sse3 \
45                    atom \
46                    barcelona \
47                    bdver1 \
48                    bdver2 \
49                    btver1 \
50                    core-avx-i \
51                    core2 \
52                    corei7 \
53                    corei7-avx \
54                    i386 \
55                    nocona \
56                    znver1
57
58known_i386=         i386
59
60. if defined(known_${MACHINE_ARCH}) && \
61     !empty(known_${MACHINE_ARCH}:M${CT2})                  # CID: Check CPUTYPE
62
63# Set up the list of CPU features based on the CPU type.  This is an
64# unordered list to make it easy for client makefiles to test for the
65# presence of a CPU feature.
66
67.  if ${MACHINE_ARCH} == "x86_64"
68C_i386=             ${generic_i386}
69C_nocona= ${generic_x86_64} sse3
70C_core2=  ${C_nocona} ssse3
71C_corei7= ${C_core2} sse41 sse42
72C_corei7avx=        ${C_corei7} avx aes pclmul
73C_atom=             ${C_core2}
74C_athlon64=         ${generic_x86_64} 3dnow
75C_athlon64sse3=     ${C_athlon64} sse3
76C_barcelona=        ${C_athlon64sse3} sse4a abm
77C_bdver1= ${C_corei7avx} sse4a abm fma4 xop lwp cx16
78C_bdver2= ${C_bdver1} bmi f16c fma tbm
79C_btver1= ${C_barcelona} cx16
80C_coreavxi=         ${C_corei7avx} fsgsbase rdrnd f16c
81C_znver1= ${C_corei7avx} bmi bmi2 f16c fma fsgsbase avx2 adcx rdseed \
82                    mwaitx sha clzero cx16 movbe sse4a abm xsavec xsaves \
83                    clflushop popcnt
84
85.  endif  # end of x86_64 feature list
86
87# i386 used for 32-bit BIOS-based boot loaders
88
89.  if ${MACHINE_ARCH} == "i386"
90C_i386=             ${generic_i386}
91.  endif  # end of i386 feature list
92
93_CPUCFLAGS=         -march=${CT2}
94MACHINE_CPU=        ${C_${CT2:S|-||}}
95
96. else                                                                # CID: Check CPUTYPE
97
98# CPUTYPE was defined and was not empty, but the value does not match known
99# CPU types of the defined MACHINE_ARCH.  Set -march to native and define
100# generic features based on MACHINE_ARCH
101
102_CPUCFLAGS=         -march=native
103MACHINE_CPU=        ${generic_${MACHINE_ARCH}}
104
105. endif                                                               # CID: Check CPUTYPE
106
107.endif
108