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" || ${CPUTYPE} == "athlon64" || \
55 . elif ${CPUTYPE} == "k7"
58 . elif ${MACHINE_ARCH} == "amd64"
59 . if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
62 . elif ${MACHINE_ARCH} == "sparc64"
63 . if ${CPUTYPE} == "us"
65 . elif ${CPUTYPE} == "us3"
70 ###############################################################################
71 # Logic to set up correct gcc optimization flag. This must be included
72 # after /etc/make.conf so it can react to the local value of CPUTYPE
73 # defined therein. Consult:
74 # http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
75 # http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html
76 # http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html
77 # http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
78 # http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
79 # http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
81 . if ${MACHINE_ARCH} == "i386"
82 . if ${CPUTYPE} == "crusoe"
83 _CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
84 . elif ${CPUTYPE} == "k5"
85 _CPUCFLAGS = -march=pentium
87 _CPUCFLAGS = -march=${CPUTYPE}
88 . endif # GCC on 'i386'
89 . if ${CPUTYPE} == "crusoe"
90 _ICC_CPUCFLAGS = -tpp6 -xiM
91 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
92 ${CPUTYPE} == "athlon-4"
93 _ICC_CPUCFLAGS = -tpp6 -xiMK
94 . elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
95 _ICC_CPUCFLAGS = -tpp6 -xiM
96 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
97 _ICC_CPUCFLAGS = -tpp6 -xi
98 . elif ${CPUTYPE} == "k5"
99 _ICC_CPUCFLAGS = -tpp5
100 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
101 _ICC_CPUCFLAGS = -tpp7 -xiMKW
102 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
103 ${CPUTYPE} == "pentium-m"
104 _ICC_CPUCFLAGS = -tpp6 -xiMK
105 . elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
106 _ICC_CPUCFLAGS = -tpp6 -xiM
107 . elif ${CPUTYPE} == "pentium-mmx"
108 _ICC_CPUCFLAGS = -tpp5 -xM
109 . elif ${CPUTYPE} == "pentium"
110 _ICC_CPUCFLAGS = -tpp5
113 . endif # ICC on 'i386'
114 . elif ${MACHINE_ARCH} == "amd64"
115 _CPUCFLAGS = -march=${CPUTYPE}
116 . elif ${MACHINE_ARCH} == "arm"
117 . if ${CPUTYPE} == "xscale"
118 #XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
119 #_CPUCFLAGS = -mcpu=xscale
120 _CPUCFLAGS = -march=armv5te -D__XSCALE__
122 _CPUCFLAGS = -mcpu=${CPUTYPE}
124 . elif ${MACHINE_ARCH} == "powerpc"
125 . if ${CPUTYPE} == "e500"
126 _CPUCFLAGS = -Wa,-me500 -msoft-float
128 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
130 . elif ${MACHINE_ARCH} == "mips"
131 . if ${CPUTYPE} == "mips32"
132 _CPUCFLAGS = -march=mips32
133 . elif ${CPUTYPE} == "mips32r2"
134 _CPUCFLAGS = -march=mips32r2
135 . elif ${CPUTYPE} == "mips64"
136 _CPUCFLAGS = -march=mips64
137 . elif ${CPUTYPE} == "mips64r2"
138 _CPUCFLAGS = -march=mips64r2
139 . elif ${CPUTYPE} == "mips4kc"
140 _CPUCFLAGS = -march=4kc
141 . elif ${CPUTYPE} == "mips24kc"
142 _CPUCFLAGS = -march=24kc
144 . elif ${MACHINE_ARCH} == "sparc64"
145 . if ${CPUTYPE} == "v9"
146 _CPUCFLAGS = -mcpu=v9
147 . elif ${CPUTYPE} == "ultrasparc"
148 _CPUCFLAGS = -mcpu=ultrasparc
149 . elif ${CPUTYPE} == "ultrasparc3"
150 _CPUCFLAGS = -mcpu=ultrasparc3
154 # Set up the list of CPU features based on the CPU type. This is an
155 # unordered list to make it easy for client makefiles to test for the
156 # presence of a CPU feature.
158 . if ${MACHINE_ARCH} == "i386"
159 . if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
160 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
161 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
162 ${CPUTYPE} == "athlon-4"
163 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
164 . elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
165 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
166 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
167 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
168 . elif ${CPUTYPE} == "k6"
169 MACHINE_CPU = mmx k6 k5 i586 i486 i386
170 . elif ${CPUTYPE} == "k5"
171 MACHINE_CPU = k5 i586 i486 i386
172 . elif ${CPUTYPE} == "c3"
173 MACHINE_CPU = 3dnow mmx i586 i486 i386
174 . elif ${CPUTYPE} == "c3-2"
175 MACHINE_CPU = sse mmx i586 i486 i386
176 . elif ${CPUTYPE} == "c7"
177 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
178 . elif ${CPUTYPE} == "prescott"
179 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
180 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
181 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
182 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
183 MACHINE_CPU = sse i686 mmx i586 i486 i386
184 . elif ${CPUTYPE} == "pentium2"
185 MACHINE_CPU = i686 mmx i586 i486 i386
186 . elif ${CPUTYPE} == "pentiumpro"
187 MACHINE_CPU = i686 i586 i486 i386
188 . elif ${CPUTYPE} == "pentium-mmx"
189 MACHINE_CPU = mmx i586 i486 i386
190 . elif ${CPUTYPE} == "pentium"
191 MACHINE_CPU = i586 i486 i386
192 . elif ${CPUTYPE} == "i486"
193 MACHINE_CPU = i486 i386
194 . elif ${CPUTYPE} == "i386"
197 . elif ${MACHINE_ARCH} == "amd64"
198 . if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
199 MACHINE_CPU = k8 3dnow
200 . elif ${CPUTYPE} == "nocona"
203 MACHINE_CPU += amd64 sse2 sse mmx
204 . elif ${MACHINE_ARCH} == "ia64"
205 . if ${CPUTYPE} == "itanium"
206 MACHINE_CPU = itanium
208 . elif ${MACHINE_ARCH} == "powerpc"
209 . if ${CPUTYPE} == "e500"
212 . elif ${MACHINE_ARCH} == "sparc64"
213 . if ${CPUTYPE} == "v9"
215 . elif ${CPUTYPE} == "ultrasparc"
216 MACHINE_CPU = v9 ultrasparc
217 . elif ${CPUTYPE} == "ultrasparc3"
218 MACHINE_CPU = v9 ultrasparc ultrasparc3
223 .if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
224 CFLAGS += -mbig-endian
225 LDFLAGS += -mbig-endian
229 .if ${MACHINE_ARCH} == "mips"
230 . if defined(TARGET_BIG_ENDIAN)
239 CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls
242 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
244 .if !defined(NO_CPU_CFLAGS)
246 CFLAGS += ${_ICC_CPUCFLAGS}
248 CFLAGS += ${_CPUCFLAGS}