bsd.cpu.mk revision 209868
114125Speter# $FreeBSD: head/share/mk/bsd.cpu.mk 209868 2010-07-10 02:32:50Z nwhitehorn $
214125Speter
314125Speter# Set default CPU compile flags and baseline CPUTYPE for each arch.  The
414125Speter# compile flags must support the minimum CPU type for each architecture but
514125Speter# may tune support for more advanced processors.
614125Speter
714125Speter.if !defined(CPUTYPE) || empty(CPUTYPE)
814125Speter_CPUCFLAGS =
914125Speter. if ${MACHINE_ARCH} == "i386"
1014125SpeterMACHINE_CPU = i486
1114125Speter. elif ${MACHINE_ARCH} == "amd64"
1214125SpeterMACHINE_CPU = amd64 sse2 sse mmx
1314125Speter. elif ${MACHINE_ARCH} == "ia64"
1414125SpeterMACHINE_CPU = itanium
1514125Speter. elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
1614125SpeterMACHINE_CPU = aim
1714125Speter. elif ${MACHINE_ARCH} == "sparc64"
1814125Speter. elif ${MACHINE_ARCH} == "arm"
1914125SpeterMACHINE_CPU = arm
2014125Speter. elif ${MACHINE_ARCH} == "mips"
2114125SpeterMACHINE_CPU = mips
2214125Speter. endif
2314125Speter.else
2414125Speter
2514125Speter# Handle aliases (not documented in make.conf to avoid user confusion
2614125Speter# between e.g. i586 and pentium)
2714125Speter
2814125Speter. if ${MACHINE_ARCH} == "i386"
2914125Speter.  if ${CPUTYPE} == "nocona"
3014125SpeterCPUTYPE = prescott
3114125Speter.  elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2"
3214125SpeterCPUTYPE = prescott
3314125Speter.  elif ${CPUTYPE} == "p4"
3430376ScharnierCPUTYPE = pentium4
3530376Scharnier.  elif ${CPUTYPE} == "p4m"
3630376ScharnierCPUTYPE = pentium4m
3714125Speter.  elif ${CPUTYPE} == "p3"
3830376ScharnierCPUTYPE = pentium3
3914125Speter.  elif ${CPUTYPE} == "p3m"
4014125SpeterCPUTYPE = pentium3m
4114125Speter.  elif ${CPUTYPE} == "p-m"
4214125SpeterCPUTYPE = pentium-m
4314125Speter.  elif ${CPUTYPE} == "p2"
4414125SpeterCPUTYPE = pentium2
4514125Speter.  elif ${CPUTYPE} == "i686"
4614125SpeterCPUTYPE = pentiumpro
4714125Speter.  elif ${CPUTYPE} == "i586/mmx"
4814125SpeterCPUTYPE = pentium-mmx
4914125Speter.  elif ${CPUTYPE} == "i586"
5014125SpeterCPUTYPE = pentium
5114125Speter.  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
5214125Speter     ${CPUTYPE} == "k8"
5314125SpeterCPUTYPE = athlon-mp
5414125Speter.  elif ${CPUTYPE} == "k7"
5514125SpeterCPUTYPE = athlon
5614125Speter.  endif
5714125Speter. elif ${MACHINE_ARCH} == "amd64"
5814125Speter.  if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
5914125SpeterCPUTYPE = nocona
6014125Speter.  endif
6114125Speter. endif
6214125Speter
6314125Speter###############################################################################
6414125Speter# Logic to set up correct gcc optimization flag.  This must be included
6514125Speter# after /etc/make.conf so it can react to the local value of CPUTYPE
6614125Speter# defined therein.  Consult:
6714125Speter#	http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
6814125Speter#	http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html
6914125Speter#	http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html
7014125Speter#	http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
7114125Speter#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
7214125Speter#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
7314125Speter
7414125Speter. if ${MACHINE_ARCH} == "i386"
7514125Speter.  if ${CPUTYPE} == "crusoe"
7614125Speter_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
7714125Speter.  elif ${CPUTYPE} == "k5"
7814125Speter_CPUCFLAGS = -march=pentium
7914125Speter.  else
8014125Speter_CPUCFLAGS = -march=${CPUTYPE}
8114125Speter.  endif # GCC on 'i386'
8214125Speter.  if ${CPUTYPE} == "crusoe"
8314125Speter_ICC_CPUCFLAGS = -tpp6 -xiM
8414125Speter.  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
8514125Speter    ${CPUTYPE} == "athlon-4"
8614125Speter_ICC_CPUCFLAGS = -tpp6 -xiMK
8714125Speter.  elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
8814125Speter_ICC_CPUCFLAGS = -tpp6 -xiM
8914125Speter.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
9014125Speter_ICC_CPUCFLAGS = -tpp6 -xi
9114125Speter.  elif ${CPUTYPE} == "k5"
9214125Speter_ICC_CPUCFLAGS = -tpp5
9314125Speter.  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
9414125Speter_ICC_CPUCFLAGS = -tpp7 -xiMKW
9514125Speter.  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
9614125Speter     ${CPUTYPE} == "pentium-m"
9714125Speter_ICC_CPUCFLAGS = -tpp6 -xiMK
9814125Speter.  elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
9914125Speter_ICC_CPUCFLAGS = -tpp6 -xiM
10014125Speter.  elif ${CPUTYPE} == "pentium-mmx"
10114125Speter_ICC_CPUCFLAGS = -tpp5 -xM
10214125Speter.  elif ${CPUTYPE} == "pentium"
10314125Speter_ICC_CPUCFLAGS = -tpp5
10414125Speter.  else
10514125Speter_ICC_CPUCFLAGS =
10614125Speter.  endif # ICC on 'i386'
10714125Speter. elif ${MACHINE_ARCH} == "amd64"
10814125Speter_CPUCFLAGS = -march=${CPUTYPE}
10914125Speter. elif ${MACHINE_ARCH} == "arm"
11014125Speter.  if ${CPUTYPE} == "xscale"
11114125Speter#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
11214125Speter#_CPUCFLAGS = -mcpu=xscale
11314125Speter_CPUCFLAGS = -march=armv5te -D__XSCALE__
11414125Speter.  else
11514125Speter_CPUCFLAGS = -mcpu=${CPUTYPE}
11614125Speter.  endif
11714125Speter. elif ${MACHINE_ARCH} == "powerpc"
11814125Speter.  if ${CPUTYPE} == "e500"
11914125SpeterMACHINE_CPU = booke
12014125Speter_CPUCFLAGS = -Wa,-me500 -msoft-float
12114125Speter.  else
12214125Speter_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
12314125Speter.  endif
12414125Speter. elif ${MACHINE_ARCH} == "powerpc64"
12514125Speter_CPUCFLAGS = -mcpu=${CPUTYPE}
12614125Speter. elif ${MACHINE_ARCH} == "mips"
12714125Speter.  if ${CPUTYPE} == "mips32"
12814125Speter_CPUCFLAGS = -march=mips32
12914125Speter.  elif ${CPUTYPE} == "mips32r2"
13014125Speter_CPUCFLAGS = -march=mips32r2
13114125Speter.  elif ${CPUTYPE} == "mips64"
13214125Speter_CPUCFLAGS = -march=mips64
13314125Speter.  elif ${CPUTYPE} == "mips64r2"
13414125Speter_CPUCFLAGS = -march=mips64r2
13514125Speter.  elif ${CPUTYPE} == "mips4kc"
13614125Speter_CPUCFLAGS = -march=4kc
13714125Speter.  elif ${CPUTYPE} == "mips24kc"
13814125Speter_CPUCFLAGS = -march=24kc
13914125Speter.  endif
14014125Speter. endif
14114125Speter
14214125Speter# Set up the list of CPU features based on the CPU type.  This is an
14314125Speter# unordered list to make it easy for client makefiles to test for the
14414125Speter# presence of a CPU feature.
14514125Speter
14614125Speter. if ${MACHINE_ARCH} == "i386"
14714125Speter.  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
14814125SpeterMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
14914125Speter.  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
15014125Speter    ${CPUTYPE} == "athlon-4"
15130376ScharnierMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
15214125Speter.  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
15314125SpeterMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
15414125Speter.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
15514125SpeterMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
15614125Speter.  elif ${CPUTYPE} == "k6"
15714125SpeterMACHINE_CPU = mmx k6 k5 i586 i486 i386
15821786Salex.  elif ${CPUTYPE} == "k5"
15930376ScharnierMACHINE_CPU = k5 i586 i486 i386
16014125Speter.  elif ${CPUTYPE} == "c3"
16114125SpeterMACHINE_CPU = 3dnow mmx i586 i486 i386
16214125Speter.  elif ${CPUTYPE} == "c3-2"
16314125SpeterMACHINE_CPU = sse mmx i586 i486 i386
16414125Speter.  elif ${CPUTYPE} == "c7"
16514125SpeterMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
16614125Speter.  elif ${CPUTYPE} == "prescott"
16714125SpeterMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
16814125Speter.  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
16914125SpeterMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
17030376Scharnier.  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
17114125SpeterMACHINE_CPU = sse i686 mmx i586 i486 i386
17214125Speter.  elif ${CPUTYPE} == "pentium2"
17314125SpeterMACHINE_CPU = i686 mmx i586 i486 i386
17414125Speter.  elif ${CPUTYPE} == "pentiumpro"
17514125SpeterMACHINE_CPU = i686 i586 i486 i386
17614125Speter.  elif ${CPUTYPE} == "pentium-mmx"
17714125SpeterMACHINE_CPU = mmx i586 i486 i386
17814125Speter.  elif ${CPUTYPE} == "pentium"
17914125SpeterMACHINE_CPU = i586 i486 i386
18014125Speter.  elif ${CPUTYPE} == "i486"
18114125SpeterMACHINE_CPU = i486 i386
18214125Speter.  elif ${CPUTYPE} == "i386"
18314125SpeterMACHINE_CPU = i386
18414125Speter.  endif
18514125Speter. elif ${MACHINE_ARCH} == "amd64"
18614125Speter.  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
18714125SpeterMACHINE_CPU = k8 3dnow
18814125Speter.  elif ${CPUTYPE} == "nocona"
18914125SpeterMACHINE_CPU = sse3
19014125Speter.  endif
19114125SpeterMACHINE_CPU += amd64 sse2 sse mmx
19214125Speter. elif ${MACHINE_ARCH} == "ia64"
19314125Speter.  if ${CPUTYPE} == "itanium"
19414125SpeterMACHINE_CPU = itanium
19514125Speter.  endif
19614125Speter. endif
19714125Speter.endif
19814125Speter
19914125Speter.if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
20014125SpeterCFLAGS += -mbig-endian
20114125SpeterLDFLAGS += -mbig-endian
20214125SpeterLD += -EB
20314125Speter.endif
20414125Speter
20514125Speter.if ${MACHINE_ARCH} == "mips" 
20614125Speter. if defined(TARGET_BIG_ENDIAN)
20714125SpeterCFLAGS += -EB
20814125SpeterLD += -EB
20914125Speter. else
21014125SpeterCFLAGS += -EL
21114125SpeterLD += -EL
21214125Speter. endif
21314125SpeterCFLAGS += -G0
21414125Speter.endif
21514125Speter
21614125Speter# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
21714125Speter
21814125Speter.if !defined(NO_CPU_CFLAGS)
21914125Speter. if ${CC} == "icc"
22014125SpeterCFLAGS += ${_ICC_CPUCFLAGS}
22114125Speter. else
22214125SpeterCFLAGS += ${_CPUCFLAGS}
22314125Speter. endif
22414125Speter.endif
22514125Speter