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_CPUARCH} == "i386"
11 . elif ${MACHINE_CPUARCH} == "amd64"
12 MACHINE_CPU = amd64 sse2 sse mmx
13 . elif ${MACHINE_CPUARCH} == "ia64"
15 . elif ${MACHINE_CPUARCH} == "powerpc"
17 . elif ${MACHINE_CPUARCH} == "sparc64"
18 MACHINE_CPU = ultrasparc
19 . elif ${MACHINE_CPUARCH} == "arm"
21 . elif ${MACHINE_CPUARCH} == "mips"
26 # Handle aliases (not documented in make.conf to avoid user confusion
27 # between e.g. i586 and pentium)
29 . if ${MACHINE_CPUARCH} == "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_CPUARCH} == "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_CPUARCH} == "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 . elif ${MACHINE_CPUARCH} == "amd64"
95 _CPUCFLAGS = -march=${CPUTYPE}
96 . elif ${MACHINE_CPUARCH} == "arm"
97 . if ${CPUTYPE} == "xscale"
98 #XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
99 #_CPUCFLAGS = -mcpu=xscale
100 _CPUCFLAGS = -march=armv5te -D__XSCALE__
102 _CPUCFLAGS = -mcpu=${CPUTYPE}
104 . elif ${MACHINE_ARCH} == "powerpc"
105 . if ${CPUTYPE} == "e500"
106 _CPUCFLAGS = -Wa,-me500 -msoft-float
108 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
110 . elif ${MACHINE_ARCH} == "powerpc64"
111 _CPUCFLAGS = -mcpu=${CPUTYPE}
112 . elif ${MACHINE_CPUARCH} == "mips"
113 . if ${CPUTYPE} == "mips32"
114 _CPUCFLAGS = -march=mips32
115 . elif ${CPUTYPE} == "mips32r2"
116 _CPUCFLAGS = -march=mips32r2
117 . elif ${CPUTYPE} == "mips64"
118 _CPUCFLAGS = -march=mips64
119 . elif ${CPUTYPE} == "mips64r2"
120 _CPUCFLAGS = -march=mips64r2
121 . elif ${CPUTYPE} == "mips4kc"
122 _CPUCFLAGS = -march=4kc
123 . elif ${CPUTYPE} == "mips24kc"
124 _CPUCFLAGS = -march=24kc
126 . elif ${MACHINE_ARCH} == "sparc64"
127 . if ${CPUTYPE} == "v9"
128 _CPUCFLAGS = -mcpu=v9
129 . elif ${CPUTYPE} == "ultrasparc"
130 _CPUCFLAGS = -mcpu=ultrasparc
131 . elif ${CPUTYPE} == "ultrasparc3"
132 _CPUCFLAGS = -mcpu=ultrasparc3
136 # Set up the list of CPU features based on the CPU type. This is an
137 # unordered list to make it easy for client makefiles to test for the
138 # presence of a CPU feature.
140 . if ${MACHINE_CPUARCH} == "i386"
141 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3"
142 MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 i486 i386
143 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
144 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
145 . elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
146 ${CPUTYPE} == "athlon-4"
147 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
148 . elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
149 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
150 . elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode"
151 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
152 . elif ${CPUTYPE} == "k6"
153 MACHINE_CPU = mmx k6 k5 i586 i486 i386
154 . elif ${CPUTYPE} == "k5"
155 MACHINE_CPU = k5 i586 i486 i386
156 . elif ${CPUTYPE} == "c3"
157 MACHINE_CPU = 3dnow mmx i586 i486 i386
158 . elif ${CPUTYPE} == "c3-2"
159 MACHINE_CPU = sse mmx i586 i486 i386
160 . elif ${CPUTYPE} == "c7"
161 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
162 . elif ${CPUTYPE} == "core2"
163 MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 i486 i386
164 . elif ${CPUTYPE} == "prescott"
165 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
166 . elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
167 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
168 . elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
169 MACHINE_CPU = sse i686 mmx i586 i486 i386
170 . elif ${CPUTYPE} == "pentium2"
171 MACHINE_CPU = i686 mmx i586 i486 i386
172 . elif ${CPUTYPE} == "pentiumpro"
173 MACHINE_CPU = i686 i586 i486 i386
174 . elif ${CPUTYPE} == "pentium-mmx"
175 MACHINE_CPU = mmx i586 i486 i386
176 . elif ${CPUTYPE} == "pentium"
177 MACHINE_CPU = i586 i486 i386
178 . elif ${CPUTYPE} == "i486"
179 MACHINE_CPU = i486 i386
180 . elif ${CPUTYPE} == "i386"
183 . elif ${MACHINE_CPUARCH} == "amd64"
184 . if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || ${CPUTYPE} == "k8-sse3"
185 MACHINE_CPU = k8 3dnow sse3
186 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
187 MACHINE_CPU = k8 3dnow
188 . elif ${CPUTYPE} == "core2"
189 MACHINE_CPU = ssse3 sse3
190 . elif ${CPUTYPE} == "nocona"
193 MACHINE_CPU += amd64 sse2 sse mmx
194 . elif ${MACHINE_CPUARCH} == "ia64"
195 . if ${CPUTYPE} == "itanium"
196 MACHINE_CPU = itanium
198 . elif ${MACHINE_ARCH} == "powerpc"
199 . if ${CPUTYPE} == "e500"
202 . elif ${MACHINE_ARCH} == "sparc64"
203 . if ${CPUTYPE} == "v9"
205 . elif ${CPUTYPE} == "ultrasparc"
206 MACHINE_CPU = v9 ultrasparc
207 . elif ${CPUTYPE} == "ultrasparc3"
208 MACHINE_CPU = v9 ultrasparc ultrasparc3
213 .if ${MACHINE_CPUARCH} == "mips"
217 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
219 .if !defined(NO_CPU_CFLAGS)
220 CFLAGS += ${_CPUCFLAGS}