bsd.cpu.gcc47.mk: Add default cpu extensions
[dragonfly.git] / share / mk / bsd.cpu.gcc47.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 .if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native"
6
7 . if defined(CPUTYPE) && !empty(CPUTYPE) && ${CPUTYPE} == "native"
8 _CPUCFLAGS = -march=native
9 . else
10 _CPUCFLAGS =
11 . endif
12
13 . if ${MACHINE_ARCH} == "i386"
14 MACHINE_CPU = i486 i386
15 . elif ${MACHINE_ARCH} == "x86_64"
16 MACHINE_CPU = x86_64 sse2 sse mmx
17 . endif
18
19 .else
20
21 _CPUCFLAGS_FIXUP =
22
23 # Old CPUTYPE compat shim
24 . if ${CPUTYPE} == "i586" \
25   || ${CPUTYPE} == "k5"
26 CPUTYPE = pentium
27 . elif ${CPUTYPE} == "i586/mmx"
28 CPUTYPE = pentium-mmx
29 . elif ${CPUTYPE} == "p2"
30 CPUTYPE = pentium2
31 . elif ${CPUTYPE} == "pentium3m" \
32     || ${CPUTYPE} == "p3m" \
33     || ${CPUTYPE} == "p3" \
34     || ${CPUTYPE} == "c3-2"
35 CPUTYPE = pentium3
36 . elif ${CPUTYPE} == "pentium4m" \
37     || ${CPUTYPE} == "pentium-m" \
38     || ${CPUTYPE} == "p-m" \
39     || ${CPUTYPE} == "p4"\
40     || ${CPUTYPE} == "p4m"
41 CPUTYPE = pentium4
42 . elif ${CPUTYPE} == "crusoe"
43 CPUTYPE = pentiumpro
44 _CPUCFLAGS_FIXUP = -falign-functions=0 -falign-jumps=0 -falign-loops=0
45 . elif ${CPUTYPE} == "i686"
46 CPUTYPE = pentiumpro
47 . elif ${CPUTYPE} == "k6-2"
48 CPUTYPE = k6-3
49 . elif ${CPUTYPE} == "k7" \
50     || ${CPUTYPE} == "athlon-tbird"
51 CPUTYPE = athlon
52 . elif ${CPUTYPE} == "athlon-mp" \
53     || ${CPUTYPE} == "athlon-4"
54 CPUTYPE = athlon-xp
55 . elif ${CPUTYPE} == "k8" \
56     || ${CPUTYPE} == "opteron" \
57     || ${CPUTYPE} == "athlon-fx"
58 CPUTYPE = athlon64
59 . elif ${CPUTYPE} == "k8-sse3" \
60     || ${CPUTYPE} == "opteron-sse3"
61 CPUTYPE = athlon64-sse3
62 . elif ${CPUTYPE} == "amdfam10"
63 CPUTYPE = barcelona
64 . elif ${CPUTYPE} == "c3"
65 CPUTYPE = winchip2
66 . elif ${CPUTYPE} == "core"
67 CPUTYPE = nocona
68 . elif ${CPUTYPE} == "corei7-avx" \
69     || ${CPUTYPE} == "corei7-avx-i" \
70     || ${CPUTYPE} == "corei7-avx2"
71 CPUTYPE = corei7
72 . elif ${CPUTYPE} == "atom"
73 CPUTYPE = core2
74 . elif ${CPUTYPE} == "bdver2"
75 CPUTYPE = bdver1
76 . elif ${CPUTYPE} == "btver1"
77 CPUTYPE = barcelona
78 . endif
79
80 ###############################################################################
81 # Logic to set up correct gcc optimization flag.  This must be included
82 # after /etc/make.conf so it can react to the local value of CPUTYPE
83 # defined therein.  Consult:
84 #       http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
85
86 _CPUCFLAGS = -march=${CPUTYPE} ${_CPUCFLAGS_FIXUP}
87
88 # Set up the list of CPU features based on the CPU type.  This is an
89 # unordered list to make it easy for client makefiles to test for the
90 # presence of a CPU feature.
91
92 . if ${MACHINE_ARCH} == "i386"
93 .  if ${CPUTYPE} == "bdver1"
94 MACHINE_CPU = abm 3dnow mmx sse4.2 sse4.1 sse3 sse2 sse \
95         athlon-xp athlon k7 k6 k5 i586
96 .  elif ${CPUTYPE} == "barcelona"
97 MACHINE_CPU = abm 3dnow mmx sse4a sse3 sse2 sse \
98         athlon-xp athlon k7 k6 k5 i586
99 .  elif ${CPUTYPE} == "athlon64-sse3"
100 MACHINE_CPU = 3dnow mmx sse3 sse2 sse athlon-xp athlon k7 k6 k5 i586
101 .  elif ${CPUTYPE} == "athlon64"
102 MACHINE_CPU = 3dnow mmx sse2 sse athlon-xp athlon k7 k6 k5 i586
103 .  elif ${CPUTYPE} == "athlon-xp"
104 MACHINE_CPU = 3dnow mmx sse athlon-xp athlon k7 k6 k5 i586
105 .  elif ${CPUTYPE} == "athlon"
106 MACHINE_CPU = 3dnow mmx athlon k7 k6 k5 i586
107 .  elif ${CPUTYPE} == "k6-3"
108 MACHINE_CPU = 3dnow mmx k6 k5 i586
109 .  elif ${CPUTYPE} == "k6"
110 MACHINE_CPU = mmx k6 k5 i586
111 .  elif ${CPUTYPE} == "geode"
112 MACHINE_CPU = 3dnow mmx i686 i586
113 .  elif ${CPUTYPE} == "corei7"
114 MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3 sse2 sse mmx i686 i586
115 .  elif ${CPUTYPE} == "core2"
116 MACHINE_CPU = ssse3 sse3 sse2 sse mmx i686 i586
117 .  elif ${CPUTYPE} == "nocona"
118 MACHINE_CPU = sse3 sse2 sse mmx i686 i586
119 .  elif ${CPUTYPE} == "prescott"
120 MACHINE_CPU = sse3 sse2 sse mmx i686 i586
121 .  elif ${CPUTYPE} == "pentium4"
122 MACHINE_CPU = sse2 sse mmx i686 i586
123 .  elif ${CPUTYPE} == "pentium3"
124 MACHINE_CPU = sse mmx i686 i586
125 .  elif ${CPUTYPE} == "pentium2"
126 MACHINE_CPU = mmx i686 i586
127 .  elif ${CPUTYPE} == "pentiumpro"
128 MACHINE_CPU = i686 i586
129 .  elif ${CPUTYPE} == "winchip2"
130 MACHINE_CPU = 3dnow mmx
131 .  elif ${CPUTYPE} == "winchip-c6"
132 MACHINE_CPU = mmx
133 .  elif ${CPUTYPE} == "pentium-mmx"
134 MACHINE_CPU = mmx i586
135 .  elif ${CPUTYPE} == "pentium"
136 MACHINE_CPU = i586
137 .  endif
138 MACHINE_CPU += i386 i486
139 . elif ${MACHINE_ARCH} == "x86_64"
140 .  if ${CPUTYPE} == "bdver1"
141 MACHINE_CPU = k8 abm 3dnow sse4.2 sse4.1 sse3
142 .  elif ${CPUTYPE} == "barcelona"
143 MACHINE_CPU = k8 abm 3dnow sse4a sse3
144 .  elif ${CPUTYPE} == "athlon64-sse3"
145 MACHINE_CPU = k8 3dnow sse3
146 .  elif ${CPUTYPE} == "athlon64"
147 MACHINE_CPU = k8 3dnow
148 .  elif ${CPUTYPE} == "corei7"
149 MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3
150 .  elif ${CPUTYPE} == "core2"
151 MACHINE_CPU = ssse3 sse3
152 .  elif ${CPUTYPE} == "nocona"
153 MACHINE_CPU = sse3
154 .  endif
155 MACHINE_CPU += sse2 sse mmx x86_64
156 . endif
157
158 .endif