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"
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"
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
89 . elif ${CPUTYPE} == "core2"
90 _CPUCFLAGS = -march=prescott
92 _CPUCFLAGS = -march=${CPUTYPE}
93 . endif # GCC on 'i386'
94 . if ${CPUTYPE} == "crusoe"
95 _ICC_CPUCFLAGS = -tpp6 -xiM
96 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
97 ${CPUTYPE} == "athlon-4"
98 _ICC_CPUCFLAGS = -tpp6 -xiMK
99 . elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
100 _ICC_CPUCFLAGS = -tpp6 -xiM
101 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
102 _ICC_CPUCFLAGS = -tpp6 -xi
103 . elif ${CPUTYPE} == "k5"
104 _ICC_CPUCFLAGS = -tpp5
105 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
106 _ICC_CPUCFLAGS = -tpp7 -xiMKW
107 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
108 ${CPUTYPE} == "pentium-m"
109 _ICC_CPUCFLAGS = -tpp6 -xiMK
110 . elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
111 _ICC_CPUCFLAGS = -tpp6 -xiM
112 . elif ${CPUTYPE} == "pentium-mmx"
113 _ICC_CPUCFLAGS = -tpp5 -xM
114 . elif ${CPUTYPE} == "pentium"
115 _ICC_CPUCFLAGS = -tpp5
118 . endif # ICC on 'i386'
119 . elif ${MACHINE_ARCH} == "amd64"
120 _CPUCFLAGS = -march=${CPUTYPE}
121 . elif ${MACHINE_ARCH} == "arm"
122 . if ${CPUTYPE} == "xscale"
123 #XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
124 #_CPUCFLAGS = -mcpu=xscale
125 _CPUCFLAGS = -march=armv5te -D__XSCALE__
127 _CPUCFLAGS = -mcpu=${CPUTYPE}
129 . elif ${MACHINE_ARCH} == "powerpc"
130 . if ${CPUTYPE} == "e500"
131 _CPUCFLAGS = -Wa,-me500 -msoft-float
133 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
135 . elif ${MACHINE_ARCH} == "mips"
136 . if ${CPUTYPE} == "mips32"
137 _CPUCFLAGS = -march=mips32
138 . elif ${CPUTYPE} == "mips32r2"
139 _CPUCFLAGS = -march=mips32r2
140 . elif ${CPUTYPE} == "mips64"
141 _CPUCFLAGS = -march=mips64
142 . elif ${CPUTYPE} == "mips64r2"
143 _CPUCFLAGS = -march=mips64r2
144 . elif ${CPUTYPE} == "mips4kc"
145 _CPUCFLAGS = -march=4kc
146 . elif ${CPUTYPE} == "mips24kc"
147 _CPUCFLAGS = -march=24kc
149 . elif ${MACHINE_ARCH} == "sparc64"
150 . if ${CPUTYPE} == "v9"
151 _CPUCFLAGS = -mcpu=v9
152 . elif ${CPUTYPE} == "ultrasparc"
153 _CPUCFLAGS = -mcpu=ultrasparc
154 . elif ${CPUTYPE} == "ultrasparc3"
155 _CPUCFLAGS = -mcpu=ultrasparc3
159 # Set up the list of CPU features based on the CPU type. This is an
160 # unordered list to make it easy for client makefiles to test for the
161 # presence of a CPU feature.
163 . if ${MACHINE_ARCH} == "i386"
164 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3"
165 MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 i486 i386
166 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
167 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
168 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
169 ${CPUTYPE} == "athlon-4"
170 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
171 . elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
172 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
173 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode"
174 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
175 . elif ${CPUTYPE} == "k6"
176 MACHINE_CPU = mmx k6 k5 i586 i486 i386
177 . elif ${CPUTYPE} == "k5"
178 MACHINE_CPU = k5 i586 i486 i386
179 . elif ${CPUTYPE} == "c3"
180 MACHINE_CPU = 3dnow mmx i586 i486 i386
181 . elif ${CPUTYPE} == "c3-2"
182 MACHINE_CPU = sse mmx i586 i486 i386
183 . elif ${CPUTYPE} == "c7"
184 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
185 . elif ${CPUTYPE} == "core2"
186 MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 i486 i386
187 . elif ${CPUTYPE} == "prescott"
188 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
189 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
190 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
191 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
192 MACHINE_CPU = sse i686 mmx i586 i486 i386
193 . elif ${CPUTYPE} == "pentium2"
194 MACHINE_CPU = i686 mmx i586 i486 i386
195 . elif ${CPUTYPE} == "pentiumpro"
196 MACHINE_CPU = i686 i586 i486 i386
197 . elif ${CPUTYPE} == "pentium-mmx"
198 MACHINE_CPU = mmx i586 i486 i386
199 . elif ${CPUTYPE} == "pentium"
200 MACHINE_CPU = i586 i486 i386
201 . elif ${CPUTYPE} == "i486"
202 MACHINE_CPU = i486 i386
203 . elif ${CPUTYPE} == "i386"
206 . elif ${MACHINE_ARCH} == "amd64"
207 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || ${CPUTYPE} == "k8-sse3"
208 MACHINE_CPU = k8 3dnow sse3
209 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
210 MACHINE_CPU = k8 3dnow
211 . elif ${CPUTYPE} == "core2"
212 MACHINE_CPU = ssse3 sse3
213 . elif ${CPUTYPE} == "nocona"
216 MACHINE_CPU += amd64 sse2 sse mmx
217 . elif ${MACHINE_ARCH} == "ia64"
218 . if ${CPUTYPE} == "itanium"
219 MACHINE_CPU = itanium
221 . elif ${MACHINE_ARCH} == "powerpc"
222 . if ${CPUTYPE} == "e500"
225 . elif ${MACHINE_ARCH} == "sparc64"
226 . if ${CPUTYPE} == "v9"
228 . elif ${CPUTYPE} == "ultrasparc"
229 MACHINE_CPU = v9 ultrasparc
230 . elif ${CPUTYPE} == "ultrasparc3"
231 MACHINE_CPU = v9 ultrasparc ultrasparc3
236 .if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
237 CFLAGS += -mbig-endian
238 LDFLAGS += -mbig-endian
242 .if ${MACHINE_ARCH} == "mips"
243 . if defined(TARGET_BIG_ENDIAN)
252 CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls
255 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
257 .if !defined(NO_CPU_CFLAGS)
259 CFLAGS += ${_ICC_CPUCFLAGS}
261 CFLAGS += ${_CPUCFLAGS}