3 # Set default CPU compile flags and baseline CPUTYPE for each arch. The
4 # compile flags must support the minimum CPU type for each architecture but
5 # may tune support for more advanced processors.
7 .if !defined(CPUTYPE) || empty(CPUTYPE)
9 . if ${MACHINE_ARCH} == "i386"
11 . elif ${MACHINE_ARCH} == "amd64"
12 MACHINE_CPU = amd64 sse2 sse mmx
13 . elif ${MACHINE_ARCH} == "ia64"
15 . elif ${MACHINE_ARCH} == "powerpc"
17 . elif ${MACHINE_ARCH} == "sparc64"
18 MACHINE_CPU = ultrasparc
19 . elif ${MACHINE_ARCH} == "arm"
21 . elif ${MACHINE_ARCH} == "mips"
26 # Handle aliases (not documented in make.conf to avoid user confusion
27 # between e.g. i586 and pentium)
29 . if ${MACHINE_ARCH} == "i386"
30 . if ${CPUTYPE} == "nocona"
32 . elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2"
34 . elif ${CPUTYPE} == "p4"
36 . elif ${CPUTYPE} == "p4m"
38 . elif ${CPUTYPE} == "p3"
40 . elif ${CPUTYPE} == "p3m"
42 . elif ${CPUTYPE} == "p-m"
44 . elif ${CPUTYPE} == "p2"
46 . elif ${CPUTYPE} == "i686"
48 . elif ${CPUTYPE} == "i586/mmx"
50 . elif ${CPUTYPE} == "i586"
52 . elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \
53 ${CPUTYPE} == "k8-sse3"
55 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
58 . elif ${CPUTYPE} == "k7"
61 . elif ${MACHINE_ARCH} == "amd64"
62 . if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
65 . elif ${MACHINE_ARCH} == "sparc64"
66 . if ${CPUTYPE} == "us"
68 . elif ${CPUTYPE} == "us3"
73 ###############################################################################
74 # Logic to set up correct gcc optimization flag. This must be included
75 # after /etc/make.conf so it can react to the local value of CPUTYPE
76 # defined therein. Consult:
77 # http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
78 # http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html
79 # http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html
80 # http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
81 # http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
82 # http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
84 . if ${MACHINE_ARCH} == "i386"
85 . if ${CPUTYPE} == "crusoe"
86 _CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
87 . elif ${CPUTYPE} == "k5"
88 _CPUCFLAGS = -march=pentium
90 _CPUCFLAGS = -march=${CPUTYPE}
91 . endif # GCC on 'i386'
92 . if ${CPUTYPE} == "crusoe"
93 _ICC_CPUCFLAGS = -tpp6 -xiM
94 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
95 ${CPUTYPE} == "athlon-4"
96 _ICC_CPUCFLAGS = -tpp6 -xiMK
97 . elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
98 _ICC_CPUCFLAGS = -tpp6 -xiM
99 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
100 _ICC_CPUCFLAGS = -tpp6 -xi
101 . elif ${CPUTYPE} == "k5"
102 _ICC_CPUCFLAGS = -tpp5
103 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
104 _ICC_CPUCFLAGS = -tpp7 -xiMKW
105 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
106 ${CPUTYPE} == "pentium-m"
107 _ICC_CPUCFLAGS = -tpp6 -xiMK
108 . elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
109 _ICC_CPUCFLAGS = -tpp6 -xiM
110 . elif ${CPUTYPE} == "pentium-mmx"
111 _ICC_CPUCFLAGS = -tpp5 -xM
112 . elif ${CPUTYPE} == "pentium"
113 _ICC_CPUCFLAGS = -tpp5
116 . endif # ICC on 'i386'
117 . elif ${MACHINE_ARCH} == "amd64"
118 _CPUCFLAGS = -march=${CPUTYPE}
119 . elif ${MACHINE_ARCH} == "arm"
120 . if ${CPUTYPE} == "xscale"
121 #XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
122 #_CPUCFLAGS = -mcpu=xscale
123 _CPUCFLAGS = -march=armv5te -D__XSCALE__
125 _CPUCFLAGS = -mcpu=${CPUTYPE}
127 . elif ${MACHINE_ARCH} == "powerpc"
128 . if ${CPUTYPE} == "e500"
129 _CPUCFLAGS = -Wa,-me500 -msoft-float
131 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
133 . elif ${MACHINE_ARCH} == "mips"
134 . if ${CPUTYPE} == "mips32"
135 _CPUCFLAGS = -march=mips32
136 . elif ${CPUTYPE} == "mips32r2"
137 _CPUCFLAGS = -march=mips32r2
138 . elif ${CPUTYPE} == "mips64"
139 _CPUCFLAGS = -march=mips64
140 . elif ${CPUTYPE} == "mips64r2"
141 _CPUCFLAGS = -march=mips64r2
142 . elif ${CPUTYPE} == "mips4kc"
143 _CPUCFLAGS = -march=4kc
144 . elif ${CPUTYPE} == "mips24kc"
145 _CPUCFLAGS = -march=24kc
147 . elif ${MACHINE_ARCH} == "sparc64"
148 . if ${CPUTYPE} == "v9"
149 _CPUCFLAGS = -mcpu=v9
150 . elif ${CPUTYPE} == "ultrasparc"
151 _CPUCFLAGS = -mcpu=ultrasparc
152 . elif ${CPUTYPE} == "ultrasparc3"
153 _CPUCFLAGS = -mcpu=ultrasparc3
157 # Set up the list of CPU features based on the CPU type. This is an
158 # unordered list to make it easy for client makefiles to test for the
159 # presence of a CPU feature.
161 . if ${MACHINE_ARCH} == "i386"
162 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3"
163 MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 i486 i386
164 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
165 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
166 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
167 ${CPUTYPE} == "athlon-4"
168 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
169 . elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
170 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
171 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
172 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
173 . elif ${CPUTYPE} == "k6"
174 MACHINE_CPU = mmx k6 k5 i586 i486 i386
175 . elif ${CPUTYPE} == "k5"
176 MACHINE_CPU = k5 i586 i486 i386
177 . elif ${CPUTYPE} == "c3"
178 MACHINE_CPU = 3dnow mmx i586 i486 i386
179 . elif ${CPUTYPE} == "c3-2"
180 MACHINE_CPU = sse mmx i586 i486 i386
181 . elif ${CPUTYPE} == "c7"
182 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
183 . elif ${CPUTYPE} == "prescott"
184 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
185 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
186 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
187 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
188 MACHINE_CPU = sse i686 mmx i586 i486 i386
189 . elif ${CPUTYPE} == "pentium2"
190 MACHINE_CPU = i686 mmx i586 i486 i386
191 . elif ${CPUTYPE} == "pentiumpro"
192 MACHINE_CPU = i686 i586 i486 i386
193 . elif ${CPUTYPE} == "pentium-mmx"
194 MACHINE_CPU = mmx i586 i486 i386
195 . elif ${CPUTYPE} == "pentium"
196 MACHINE_CPU = i586 i486 i386
197 . elif ${CPUTYPE} == "i486"
198 MACHINE_CPU = i486 i386
199 . elif ${CPUTYPE} == "i386"
202 . elif ${MACHINE_ARCH} == "amd64"
203 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || ${CPUTYPE} == "k8-sse3"
204 MACHINE_CPU = k8 3dnow sse3
205 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
206 MACHINE_CPU = k8 3dnow
207 . elif ${CPUTYPE} == "nocona"
210 MACHINE_CPU += amd64 sse2 sse mmx
211 . elif ${MACHINE_ARCH} == "ia64"
212 . if ${CPUTYPE} == "itanium"
213 MACHINE_CPU = itanium
215 . elif ${MACHINE_ARCH} == "powerpc"
216 . if ${CPUTYPE} == "e500"
219 . elif ${MACHINE_ARCH} == "sparc64"
220 . if ${CPUTYPE} == "v9"
222 . elif ${CPUTYPE} == "ultrasparc"
223 MACHINE_CPU = v9 ultrasparc
224 . elif ${CPUTYPE} == "ultrasparc3"
225 MACHINE_CPU = v9 ultrasparc ultrasparc3
230 .if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
231 CFLAGS += -mbig-endian
232 LDFLAGS += -mbig-endian
236 .if ${MACHINE_ARCH} == "mips"
237 . if defined(TARGET_BIG_ENDIAN)
246 CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls
249 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
251 .if !defined(NO_CPU_CFLAGS)
253 CFLAGS += ${_ICC_CPUCFLAGS}
255 CFLAGS += ${_CPUCFLAGS}