bsd.cpu.mk revision 136211
1# $FreeBSD: head/share/mk/bsd.cpu.mk 136211 2004-10-07 09:56:48Z des $
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. if ${MACHINE_ARCH} == "i386"
9_CPUCFLAGS =
10MACHINE_CPU = i486
11. elif ${MACHINE_ARCH} == "alpha"
12_CPUCFLAGS = -mcpu=ev4 -mtune=ev5
13MACHINE_CPU = ev4
14. elif ${MACHINE_ARCH} == "amd64"
15MACHINE_CPU = amd64 sse2 sse
16. elif ${MACHINE_ARCH} == "ia64"
17_CPUCFLAGS =
18MACHINE_CPU = itanium
19. elif ${MACHINE_ARCH} == "sparc64"
20_CPUCFLAGS =
21. elif ${MACHINE_ARCH} == "arm"
22_CPUCFLAGS =
23MACHINE_CPU = arm
24. endif
25.else
26
27# Handle aliases (not documented in make.conf to avoid user confusion
28# between e.g. i586 and pentium)
29
30. if ${MACHINE_ARCH} == "i386"
31.  if ${CPUTYPE} == "pentium4"
32CPUTYPE = p4
33.  elif ${CPUTYPE} == "pentium4m"
34CPUTYPE = p4m
35.  elif ${CPUTYPE} == "pentium3"
36CPUTYPE = p3
37.  elif ${CPUTYPE} == "pentium3m"
38CPUTYPE = p3m
39.  elif ${CPUTYPE} == "pentium-m"
40CPUTYPE = p-m
41.  elif ${CPUTYPE} == "pentiumpro"
42CPUTYPE = i686
43.  elif ${CPUTYPE} == "pentium"
44CPUTYPE = i586
45.  elif ${CPUTYPE} == "opteron"
46CPUTYPE = athlon-mp
47.  elif ${CPUTYPE} == "athlon64"
48CPUTYPE = athlon-xp
49.  elif ${CPUTYPE} == "k7"
50CPUTYPE = athlon
51.  endif
52. endif
53
54# Logic to set up correct gcc optimization flag.  This must be included
55# after /etc/make.conf so it can react to the local value of CPUTYPE
56# defined therein.  Consult:
57#	http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html
58#	http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html
59#	http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
60#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
61#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
62
63. if ${MACHINE_ARCH} == "i386"
64.  if ${CPUTYPE} == "crusoe"
65_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
66_ICC_CPUCFLAGS = -tpp6 -xiM
67.  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
68    ${CPUTYPE} == "athlon-4"
69_CPUCFLAGS = -march=${CPUTYPE}
70_ICC_CPUCFLAGS = -tpp6 -xiMK
71.  elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
72_CPUCFLAGS = -march=${CPUTYPE}
73_ICC_CPUCFLAGS = -tpp6 -xiM
74.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
75_CPUCFLAGS = -march=${CPUTYPE}
76_ICC_CPUCFLAGS = -tpp6 -xi
77.  elif ${CPUTYPE} == "k5"
78_CPUCFLAGS = -march=pentium
79_ICC_CPUCFLAGS = -tpp5
80.  elif ${CPUTYPE} == "p4"
81_CPUCFLAGS = -march=pentium4
82_ICC_CPUCFLAGS = -tpp7 -xiMKW
83.  elif ${CPUTYPE} == "p4m"
84_CPUCFLAGS = -march=pentium4m
85.  elif ${CPUTYPE} == "p3"
86_CPUCFLAGS = -march=pentium3
87_ICC_CPUCFLAGS = -tpp6 -xiMK
88.  elif ${CPUTYPE} == "p3m"
89_CPUCFLAGS = -march=pentium3m
90.  elif ${CPUTYPE} == "p-m"
91_CPUCFLAGS = -march=pentium-m
92.  elif ${CPUTYPE} == "p2"
93_CPUCFLAGS = -march=pentium2
94_ICC_CPUCFLAGS = -tpp6 -xiM
95.  elif ${CPUTYPE} == "i686"
96_CPUCFLAGS = -march=pentiumpro
97_ICC_CPUCFLAGS = -tpp6 -xiM
98.  elif ${CPUTYPE} == "i586/mmx"
99_CPUCFLAGS = -march=pentium-mmx
100_ICC_CPUCFLAGS = -tpp5 -xM
101.  elif ${CPUTYPE} == "i586"
102_CPUCFLAGS = -march=pentium
103_ICC_CPUCFLAGS = -tpp5
104.  elif ${CPUTYPE} == "i486"
105_CPUCFLAGS = -march=i486
106_ICC_CPUCFLAGS =
107.  endif
108. elif ${MACHINE_ARCH} == "alpha"
109.  if ${CPUTYPE} == "ev67"
110_CPUCFLAGS = -mcpu=ev67
111.  elif ${CPUTYPE} == "ev6"
112_CPUCFLAGS = -mcpu=ev6
113.  elif ${CPUTYPE} == "pca56"
114_CPUCFLAGS = -mcpu=pca56
115.  elif ${CPUTYPE} == "ev56"
116_CPUCFLAGS = -mcpu=ev56
117.  elif ${CPUTYPE} == "ev5"
118_CPUCFLAGS = -mcpu=ev5
119.  elif ${CPUTYPE} == "ev45"
120_CPUCFLAGS = -mcpu=ev45
121.  elif ${CPUTYPE} == "ev4"
122_CPUCFLAGS = -mcpu=ev4
123.  endif
124. elif ${MACHINE_ARCH} == "arm"
125.  if ${CPUTYPE} == "strongarm"
126_CPUCFLAGS = -mcpu=strongarm
127.  elif ${CPUTYPE} == "xscale"
128#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
129#_CPUCFLAGS = -mcpu=xscale
130_CPUCFLAGS = -D__XSCALE__
131.  endif
132. endif
133
134# Set up the list of CPU features based on the CPU type.  This is an
135# unordered list to make it easy for client makefiles to test for the
136# presence of a CPU feature.
137
138. if ${MACHINE_ARCH} == "i386"
139.  if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
140    ${CPUTYPE} == "athlon-4"
141MACHINE_CPU = athlon-xp k7 3dnow sse mmx k6 k5 i586 i486 i386
142.  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
143MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
144.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
145MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
146.  elif ${CPUTYPE} == "k6"
147MACHINE_CPU = mmx k6 k5 i586 i486 i386
148.  elif ${CPUTYPE} == "k5"
149MACHINE_CPU = k5 i586 i486 i386
150.  elif ${CPUTYPE} == "p4" || ${CPUTYPE} == "p4m" || ${CPUTYPE} == "p-m"
151MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
152.  elif ${CPUTYPE} == "p3" || ${CPUTYPE} == "p3m"
153MACHINE_CPU = sse i686 mmx i586 i486 i386
154.  elif ${CPUTYPE} == "p2"
155MACHINE_CPU = i686 mmx i586 i486 i386
156.  elif ${CPUTYPE} == "i686"
157MACHINE_CPU = i686 i586 i486 i386
158.  elif ${CPUTYPE} == "i586/mmx"
159MACHINE_CPU = mmx i586 i486 i386
160.  elif ${CPUTYPE} == "i586"
161MACHINE_CPU = i586 i486 i386
162.  elif ${CPUTYPE} == "i486"
163MACHINE_CPU = i486 i386
164.  elif ${CPUTYPE} == "i386"
165MACHINE_CPU = i386
166.  endif
167. elif ${MACHINE_ARCH} == "alpha"
168.  if ${CPUTYPE} == "ev6"
169MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
170.  elif ${CPUTYPE} == "pca56"
171MACHINE_CPU = pca56 ev56 ev5 ev45 ev4
172.  elif ${CPUTYPE} == "ev56"
173MACHINE_CPU = ev56 ev5 ev45 ev4
174.  elif ${CPUTYPE} == "ev5"
175MACHINE_CPU = ev5 ev45 ev4
176.  elif ${CPUTYPE} == "ev45"
177MACHINE_CPU = ev45 ev4
178.  elif ${CPUTYPE} == "ev4"
179MACHINE_CPU = ev4
180.  endif
181. elif ${MACHINE_ARCH} == "amd64"
182MACHINE_CPU = amd64 sse2 sse
183. elif ${MACHINE_ARCH} == "ia64"
184.  if ${CPUTYPE} == "itanium"
185MACHINE_CPU = itanium
186.  endif
187. endif
188.endif
189
190.if ${MACHINE_ARCH} == "alpha"
191_CPUCFLAGS += -mieee
192.endif
193
194# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
195
196.if !defined(NO_CPU_CFLAGS)
197. if ${CC} == "icc"
198CFLAGS += ${_ICC_CPUCFLAGS}
199. else
200CFLAGS += ${_CPUCFLAGS}
201. endif
202.endif
203