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