bsd.cpu.mk revision 127258
172878Skris# $FreeBSD: head/share/mk/bsd.cpu.mk 127258 2004-03-21 04:57:24Z marcel $
272878Skris
3100772Sjhb# Set default CPU compile flags and baseline CPUTYPE for each arch.  The
4100772Sjhb# compile flags must support the minimum CPU type for each architecture but
5100772Sjhb# may tune support for more advanced processors.
672878Skris
7101232Sru.if !defined(CPUTYPE) || empty(CPUTYPE)
8100773Sjhb. if ${MACHINE_ARCH} == "i386"
9125252Sjhb_CPUCFLAGS =
10113374SobrienMACHINE_CPU = i486
11100773Sjhb. elif ${MACHINE_ARCH} == "alpha"
12100772Sjhb_CPUCFLAGS = -mcpu=ev4 -mtune=ev5
13103560SjhbMACHINE_CPU = ev4
14126657Sbde. elif ${MACHINE_ARCH} == "amd64"
15115175SpeterMACHINE_CPU = amd64 sse2 sse
16100773Sjhb. elif ${MACHINE_ARCH} == "ia64"
17100772Sjhb_CPUCFLAGS =
18103560SjhbMACHINE_CPU = itanium
19100773Sjhb. elif ${MACHINE_ARCH} == "sparc64"
20100772Sjhb_CPUCFLAGS =
21100773Sjhb. endif
22100772Sjhb.else
2372878Skris
2472878Skris# Handle aliases (not documented in make.conf to avoid user confusion
2572878Skris# between e.g. i586 and pentium)
2672878Skris
27100773Sjhb. if ${MACHINE_ARCH} == "i386"
28100773Sjhb.  if ${CPUTYPE} == "pentiumpro"
2972878SkrisCPUTYPE = i686
30100773Sjhb.  elif ${CPUTYPE} == "pentium"
3172878SkrisCPUTYPE = i586
32103045Smux.  elif ${CPUTYPE} == "k7"
33103045SmuxCPUTYPE = athlon
34100773Sjhb.  endif
3572878Skris. endif
3672878Skris
3796421Sobrien# Logic to set up correct gcc optimization flag.  This must be included
3872878Skris# after /etc/make.conf so it can react to the local value of CPUTYPE
3996421Sobrien# defined therein.  Consult:
4096421Sobrien#	http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html
41127258Smarcel#	http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html
42127258Smarcel#	http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
4396421Sobrien#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
44127258Smarcel#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
4572878Skris
4672878Skris. if ${MACHINE_ARCH} == "i386"
47125254Sbde.  if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
48126938Strhodes    ${CPUTYPE} == "athlon-4"
49126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK
50112768Sobrien_CPUCFLAGS = -march=${CPUTYPE}
51126890Strhodes.  elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
52126890Strhodes_CPUCFLAGS = -march=${CPUTYPE}
53126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM
54112768Sobrien.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
55112768Sobrien_CPUCFLAGS = -march=${CPUTYPE}
56126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xi
5772878Skris.  elif ${CPUTYPE} == "k5"
58126890Strhodes_ICC_CPUCFLAGS = -tpp5
5974146Skris_CPUCFLAGS = -march=pentium
6073145Skris.  elif ${CPUTYPE} == "p4"
61126890Strhodes_ICC_CPUCFLAGS = -tpp7 -xiMKW
62117514Smux_CPUCFLAGS = -march=pentium4
6373145Skris.  elif ${CPUTYPE} == "p3"
64126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK
65103045Smux_CPUCFLAGS = -march=pentium3
6673145Skris.  elif ${CPUTYPE} == "p2"
67126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM
68103045Smux_CPUCFLAGS = -march=pentium2
6972878Skris.  elif ${CPUTYPE} == "i686"
70126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM
7174146Skris_CPUCFLAGS = -march=pentiumpro
7273145Skris.  elif ${CPUTYPE} == "i586/mmx"
73126890Strhodes_ICC_CPUCFLAGS = -tpp5 -xM
7498159Ssobomax_CPUCFLAGS = -march=pentium-mmx
7572878Skris.  elif ${CPUTYPE} == "i586"
76126890Strhodes_ICC_CPUCFLAGS = -tpp5
7774146Skris_CPUCFLAGS = -march=pentium
7872878Skris.  elif ${CPUTYPE} == "i486"
79126890Strhodes_ICC_CPUCFLAGS =
8094987Sru_CPUCFLAGS = -march=i486
8172878Skris.  endif
8272878Skris. elif ${MACHINE_ARCH} == "alpha"
83103048Skris.  if ${CPUTYPE} == "ev67"
84103048Skris_CPUCFLAGS = -mcpu=ev67
85103048Skris.  elif ${CPUTYPE} == "ev6"
8674146Skris_CPUCFLAGS = -mcpu=ev6
8772878Skris.  elif ${CPUTYPE} == "pca56"
8874146Skris_CPUCFLAGS = -mcpu=pca56
8972878Skris.  elif ${CPUTYPE} == "ev56"
9074146Skris_CPUCFLAGS = -mcpu=ev56
9172878Skris.  elif ${CPUTYPE} == "ev5"
9274146Skris_CPUCFLAGS = -mcpu=ev5
9372878Skris.  elif ${CPUTYPE} == "ev45"
94103048Skris_CPUCFLAGS = -mcpu=ev45
9572878Skris.  elif ${CPUTYPE} == "ev4"
9674146Skris_CPUCFLAGS = -mcpu=ev4
9772878Skris.  endif
9872878Skris. endif
9972878Skris
10072878Skris# Set up the list of CPU features based on the CPU type.  This is an
10172878Skris# unordered list to make it easy for client makefiles to test for the
10272878Skris# presence of a CPU feature.
10372878Skris
104126657Sbde. if ${MACHINE_ARCH} == "i386"
105126657Sbde.  if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
106125254Sbde    ${CPUTYPE} == "athlon-4"
107112768SobrienMACHINE_CPU = athlon-xp k7 3dnow sse mmx k6 k5 i586 i486 i386
108126657Sbde.  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
109112768SobrienMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
110126657Sbde.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
111103045SmuxMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
112103562Sjhb.  elif ${CPUTYPE} == "k6"
11374069SsobomaxMACHINE_CPU = mmx k6 k5 i586 i486 i386
114103562Sjhb.  elif ${CPUTYPE} == "k5"
11572878SkrisMACHINE_CPU = k5 i586 i486 i386
116103562Sjhb.  elif ${CPUTYPE} == "p4"
117103045SmuxMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
118103562Sjhb.  elif ${CPUTYPE} == "p3"
11973145SkrisMACHINE_CPU = sse i686 mmx i586 i486 i386
120103562Sjhb.  elif ${CPUTYPE} == "p2"
12174553SkrisMACHINE_CPU = i686 mmx i586 i486 i386
122103562Sjhb.  elif ${CPUTYPE} == "i686"
12372878SkrisMACHINE_CPU = i686 i586 i486 i386
124103562Sjhb.  elif ${CPUTYPE} == "i586/mmx"
12573145SkrisMACHINE_CPU = mmx i586 i486 i386
126103562Sjhb.  elif ${CPUTYPE} == "i586"
12772878SkrisMACHINE_CPU = i586 i486 i386
128103562Sjhb.  elif ${CPUTYPE} == "i486"
12972878SkrisMACHINE_CPU = i486 i386
130103562Sjhb.  elif ${CPUTYPE} == "i386"
13172878SkrisMACHINE_CPU = i386
132103562Sjhb.  endif
133103562Sjhb. elif ${MACHINE_ARCH} == "alpha"
134103562Sjhb.  if ${CPUTYPE} == "ev6"
13572878SkrisMACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
136103562Sjhb.  elif ${CPUTYPE} == "pca56"
13772878SkrisMACHINE_CPU = pca56 ev56 ev5 ev45 ev4
138103562Sjhb.  elif ${CPUTYPE} == "ev56"
13972878SkrisMACHINE_CPU = ev56 ev5 ev45 ev4
140103562Sjhb.  elif ${CPUTYPE} == "ev5"
14172878SkrisMACHINE_CPU = ev5 ev45 ev4
142103562Sjhb.  elif ${CPUTYPE} == "ev45"
14372878SkrisMACHINE_CPU = ev45 ev4
144103562Sjhb.  elif ${CPUTYPE} == "ev4"
14572878SkrisMACHINE_CPU = ev4
146103562Sjhb.  endif
147115175Speter. elif ${MACHINE_ARCH} == "amd64"
148115175SpeterMACHINE_CPU = amd64 sse2 sse
149103562Sjhb. elif ${MACHINE_ARCH} == "ia64"
150103562Sjhb.  if ${CPUTYPE} == "itanium"
15172878SkrisMACHINE_CPU = itanium
152103562Sjhb.  endif
15372878Skris. endif
15472878Skris.endif
155103561Sjhb
156112769Sobrien.if ${MACHINE_ARCH} == "alpha"
157112769Sobrien_CPUCFLAGS += -mieee
158112769Sobrien.endif
159112769Sobrien
160124347Sru# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
161103561Sjhb
162103561Sjhb.if !defined(NO_CPU_CFLAGS)
163126890Strhodes. if ${CC} == "icc"
164126890StrhodesCFLAGS += ${_ICC_CPUCFLAGS}
165126890Strhodes. else
166103561SjhbCFLAGS += ${_CPUCFLAGS}
167126890Strhodes. endif
168103561Sjhb.endif
169