]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/mk/bsd.cpu.mk
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / mk / bsd.cpu.mk
1 # $FreeBSD$
2
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.
6
7 .if !defined(CPUTYPE) || empty(CPUTYPE)
8 _CPUCFLAGS =
9 . if ${MACHINE_CPUARCH} == "i386"
10 MACHINE_CPU = i486
11 . elif ${MACHINE_CPUARCH} == "amd64"
12 MACHINE_CPU = amd64 sse2 sse mmx
13 . elif ${MACHINE_CPUARCH} == "ia64"
14 MACHINE_CPU = itanium
15 . elif ${MACHINE_CPUARCH} == "powerpc"
16 MACHINE_CPU = aim
17 . elif ${MACHINE_CPUARCH} == "sparc64"
18 MACHINE_CPU = ultrasparc
19 . elif ${MACHINE_CPUARCH} == "arm"
20 MACHINE_CPU = arm
21 . elif ${MACHINE_CPUARCH} == "mips"
22 MACHINE_CPU = mips
23 . endif
24 .else
25
26 # Handle aliases (not documented in make.conf to avoid user confusion
27 # between e.g. i586 and pentium)
28
29 . if ${MACHINE_CPUARCH} == "i386"
30 .  if ${CPUTYPE} == "nocona"
31 CPUTYPE = prescott
32 .  elif ${CPUTYPE} == "core"
33 CPUTYPE = prescott
34 .  elif ${CPUTYPE} == "p4"
35 CPUTYPE = pentium4
36 .  elif ${CPUTYPE} == "p4m"
37 CPUTYPE = pentium4m
38 .  elif ${CPUTYPE} == "p3"
39 CPUTYPE = pentium3
40 .  elif ${CPUTYPE} == "p3m"
41 CPUTYPE = pentium3m
42 .  elif ${CPUTYPE} == "p-m"
43 CPUTYPE = pentium-m
44 .  elif ${CPUTYPE} == "p2"
45 CPUTYPE = pentium2
46 .  elif ${CPUTYPE} == "i686"
47 CPUTYPE = pentiumpro
48 .  elif ${CPUTYPE} == "i586/mmx"
49 CPUTYPE = pentium-mmx
50 .  elif ${CPUTYPE} == "i586"
51 CPUTYPE = pentium
52 .  elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \
53      ${CPUTYPE} == "k8-sse3"
54 CPUTYPE = prescott
55 .  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
56      ${CPUTYPE} == "k8"
57 CPUTYPE = athlon-mp
58 .  elif ${CPUTYPE} == "k7"
59 CPUTYPE = athlon
60 .  endif
61 . elif ${MACHINE_CPUARCH} == "amd64"
62 .  if ${CPUTYPE} == "prescott"
63 CPUTYPE = nocona
64 .  endif
65 . elif ${MACHINE_ARCH} == "sparc64"
66 .  if ${CPUTYPE} == "us"
67 CPUTYPE = ultrasparc
68 .  elif ${CPUTYPE} == "us3"
69 CPUTYPE = ultrasparc3
70 .  endif
71 . endif
72
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
83
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
91 .  else
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__
101 .  else
102 _CPUCFLAGS = -mcpu=${CPUTYPE}
103 .  endif
104 . elif ${MACHINE_ARCH} == "powerpc"
105 .  if ${CPUTYPE} == "e500"
106 _CPUCFLAGS = -Wa,-me500 -msoft-float
107 .  else
108 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
109 .  endif
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
125 .  endif
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
133 .  endif
134 . endif
135
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.
139
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"
181 MACHINE_CPU = i386
182 .  endif
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"
191 MACHINE_CPU = sse3
192 .  endif
193 MACHINE_CPU += amd64 sse2 sse mmx
194 . elif ${MACHINE_CPUARCH} == "ia64"
195 .  if ${CPUTYPE} == "itanium"
196 MACHINE_CPU = itanium
197 .  endif
198 . elif ${MACHINE_ARCH} == "powerpc"
199 .  if ${CPUTYPE} == "e500"
200 MACHINE_CPU = booke
201 .  endif
202 . elif ${MACHINE_ARCH} == "sparc64"
203 .  if ${CPUTYPE} == "v9"
204 MACHINE_CPU = v9
205 .  elif ${CPUTYPE} == "ultrasparc"
206 MACHINE_CPU = v9 ultrasparc
207 .  elif ${CPUTYPE} == "ultrasparc3"
208 MACHINE_CPU = v9 ultrasparc ultrasparc3
209 .  endif
210 . endif
211 .endif
212
213 .if ${MACHINE_CPUARCH} == "mips"
214 CFLAGS += -G0
215 .endif
216
217 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
218
219 .if !defined(NO_CPU_CFLAGS)
220 CFLAGS += ${_CPUCFLAGS}
221 .endif