bsd.cpu.mk revision 219640
172878Skris# $FreeBSD: head/share/mk/bsd.cpu.mk 219640 2011-03-14 13:36:51Z mm $ 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) 8136606Sobrien_CPUCFLAGS = 9212540Simp. if ${MACHINE_CPUARCH} == "i386" 10113374SobrienMACHINE_CPU = i486 11212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 12206973SdelphijMACHINE_CPU = amd64 sse2 sse mmx 13212540Simp. elif ${MACHINE_CPUARCH} == "ia64" 14103560SjhbMACHINE_CPU = itanium 15212540Simp. elif ${MACHINE_CPUARCH} == "powerpc" 16176776SrajMACHINE_CPU = aim 17212540Simp. elif ${MACHINE_CPUARCH} == "sparc64" 18216820SmariusMACHINE_CPU = ultrasparc 19212540Simp. elif ${MACHINE_CPUARCH} == "arm" 20129217ScognetMACHINE_CPU = arm 21212540Simp. elif ${MACHINE_CPUARCH} == "mips" 22177385SimpMACHINE_CPU = mips 23100773Sjhb. endif 24100772Sjhb.else 2572878Skris 2672878Skris# Handle aliases (not documented in make.conf to avoid user confusion 2772878Skris# between e.g. i586 and pentium) 2872878Skris 29212540Simp. if ${MACHINE_CPUARCH} == "i386" 30166071Sdes. if ${CPUTYPE} == "nocona" 31166071SdesCPUTYPE = prescott 32219640Smm. elif ${CPUTYPE} == "core" 33166071SdesCPUTYPE = prescott 34136607Sobrien. elif ${CPUTYPE} == "p4" 35136606SobrienCPUTYPE = pentium4 36136606Sobrien. elif ${CPUTYPE} == "p4m" 37136606SobrienCPUTYPE = pentium4m 38136606Sobrien. elif ${CPUTYPE} == "p3" 39136606SobrienCPUTYPE = pentium3 40136606Sobrien. elif ${CPUTYPE} == "p3m" 41136606SobrienCPUTYPE = pentium3m 42136606Sobrien. elif ${CPUTYPE} == "p-m" 43136606SobrienCPUTYPE = pentium-m 44136606Sobrien. elif ${CPUTYPE} == "p2" 45136606SobrienCPUTYPE = pentium2 46136606Sobrien. elif ${CPUTYPE} == "i686" 47136606SobrienCPUTYPE = pentiumpro 48136606Sobrien. elif ${CPUTYPE} == "i586/mmx" 49136606SobrienCPUTYPE = pentium-mmx 50136606Sobrien. elif ${CPUTYPE} == "i586" 51136606SobrienCPUTYPE = pentium 52218896Smm. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ 53218896Smm ${CPUTYPE} == "k8-sse3" 54218896SmmCPUTYPE = prescott 55136607Sobrien. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 56136607Sobrien ${CPUTYPE} == "k8" 57133525SobrienCPUTYPE = athlon-mp 58103045Smux. elif ${CPUTYPE} == "k7" 59103045SmuxCPUTYPE = athlon 60100773Sjhb. endif 61212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 62219376Smm. if ${CPUTYPE} == "prescott" 63136607SobrienCPUTYPE = nocona 64136607Sobrien. endif 65216820Smarius. elif ${MACHINE_ARCH} == "sparc64" 66216820Smarius. if ${CPUTYPE} == "us" 67216820SmariusCPUTYPE = ultrasparc 68216820Smarius. elif ${CPUTYPE} == "us3" 69216820SmariusCPUTYPE = ultrasparc3 70216820Smarius. endif 7172878Skris. endif 7272878Skris 73136606Sobrien############################################################################### 7496421Sobrien# Logic to set up correct gcc optimization flag. This must be included 7572878Skris# after /etc/make.conf so it can react to the local value of CPUTYPE 7696421Sobrien# defined therein. Consult: 77160536Simp# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 78179989Sale# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 79179989Sale# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 80177385Simp# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 8196421Sobrien# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 82179989Sale# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 8372878Skris 84212540Simp. if ${MACHINE_CPUARCH} == "i386" 85127888Sdfr. if ${CPUTYPE} == "crusoe" 86133000Sobrien_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 87136606Sobrien. elif ${CPUTYPE} == "k5" 88136606Sobrien_CPUCFLAGS = -march=pentium 89219640Smm. elif ${CPUTYPE} == "core2" 90219640Smm_CPUCFLAGS = -march=prescott 91136606Sobrien. else 92136606Sobrien_CPUCFLAGS = -march=${CPUTYPE} 93136606Sobrien. endif # GCC on 'i386' 94136606Sobrien. if ${CPUTYPE} == "crusoe" 95127888Sdfr_ICC_CPUCFLAGS = -tpp6 -xiM 96127888Sdfr. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 97126938Strhodes ${CPUTYPE} == "athlon-4" 98126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 99126890Strhodes. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 100126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 101112768Sobrien. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 102126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xi 10372878Skris. elif ${CPUTYPE} == "k5" 104126890Strhodes_ICC_CPUCFLAGS = -tpp5 105136606Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 106126890Strhodes_ICC_CPUCFLAGS = -tpp7 -xiMKW 107136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 108136606Sobrien ${CPUTYPE} == "pentium-m" 109126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 110136606Sobrien. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 111126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 112136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 113126890Strhodes_ICC_CPUCFLAGS = -tpp5 -xM 114136606Sobrien. elif ${CPUTYPE} == "pentium" 115126890Strhodes_ICC_CPUCFLAGS = -tpp5 116136606Sobrien. else 117126890Strhodes_ICC_CPUCFLAGS = 118136606Sobrien. endif # ICC on 'i386' 119212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 120136607Sobrien_CPUCFLAGS = -march=${CPUTYPE} 121212540Simp. elif ${MACHINE_CPUARCH} == "arm" 122136606Sobrien. if ${CPUTYPE} == "xscale" 123172706Scognet#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 124172706Scognet#_CPUCFLAGS = -mcpu=xscale 125172706Scognet_CPUCFLAGS = -march=armv5te -D__XSCALE__ 126136606Sobrien. else 127136606Sobrien_CPUCFLAGS = -mcpu=${CPUTYPE} 128135678Scognet. endif 129215274Simp. elif ${MACHINE_ARCH} == "powerpc" 130176776Sraj. if ${CPUTYPE} == "e500" 131176776Sraj_CPUCFLAGS = -Wa,-me500 -msoft-float 132188923Snwhitehorn. else 133190681Snwhitehorn_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 134176776Sraj. endif 135209868Snwhitehorn. elif ${MACHINE_ARCH} == "powerpc64" 136209868Snwhitehorn_CPUCFLAGS = -mcpu=${CPUTYPE} 137212540Simp. elif ${MACHINE_CPUARCH} == "mips" 138177385Simp. if ${CPUTYPE} == "mips32" 139177385Simp_CPUCFLAGS = -march=mips32 140177385Simp. elif ${CPUTYPE} == "mips32r2" 141177385Simp_CPUCFLAGS = -march=mips32r2 142177385Simp. elif ${CPUTYPE} == "mips64" 143177385Simp_CPUCFLAGS = -march=mips64 144177385Simp. elif ${CPUTYPE} == "mips64r2" 145177385Simp_CPUCFLAGS = -march=mips64r2 146177385Simp. elif ${CPUTYPE} == "mips4kc" 147177385Simp_CPUCFLAGS = -march=4kc 148177385Simp. elif ${CPUTYPE} == "mips24kc" 149177385Simp_CPUCFLAGS = -march=24kc 150177385Simp. endif 151216820Smarius. elif ${MACHINE_ARCH} == "sparc64" 152216820Smarius. if ${CPUTYPE} == "v9" 153216820Smarius_CPUCFLAGS = -mcpu=v9 154216820Smarius. elif ${CPUTYPE} == "ultrasparc" 155216820Smarius_CPUCFLAGS = -mcpu=ultrasparc 156216820Smarius. elif ${CPUTYPE} == "ultrasparc3" 157216820Smarius_CPUCFLAGS = -mcpu=ultrasparc3 158216820Smarius. endif 15972878Skris. endif 16072878Skris 16172878Skris# Set up the list of CPU features based on the CPU type. This is an 16272878Skris# unordered list to make it easy for client makefiles to test for the 16372878Skris# presence of a CPU feature. 16472878Skris 165212540Simp. if ${MACHINE_CPUARCH} == "i386" 166218896Smm. if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" 167218896SmmMACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 i486 i386 168218896Smm. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 169136607SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 170136607Sobrien. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 171125254Sbde ${CPUTYPE} == "athlon-4" 172136606SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 173126657Sbde. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 174112768SobrienMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 175219376Smm. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" 176103045SmuxMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 177103562Sjhb. elif ${CPUTYPE} == "k6" 17874069SsobomaxMACHINE_CPU = mmx k6 k5 i586 i486 i386 179103562Sjhb. elif ${CPUTYPE} == "k5" 18072878SkrisMACHINE_CPU = k5 i586 i486 i386 181160497Sdes. elif ${CPUTYPE} == "c3" 182161259SdesMACHINE_CPU = 3dnow mmx i586 i486 i386 183160497Sdes. elif ${CPUTYPE} == "c3-2" 184160497SdesMACHINE_CPU = sse mmx i586 i486 i386 185176665Sjhb. elif ${CPUTYPE} == "c7" 186176665SjhbMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 187219640Smm. elif ${CPUTYPE} == "core2" 188219640SmmMACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 i486 i386 189166071Sdes. elif ${CPUTYPE} == "prescott" 190166069SdesMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 191136607Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 192103045SmuxMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 193136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 19473145SkrisMACHINE_CPU = sse i686 mmx i586 i486 i386 195136606Sobrien. elif ${CPUTYPE} == "pentium2" 19674553SkrisMACHINE_CPU = i686 mmx i586 i486 i386 197136606Sobrien. elif ${CPUTYPE} == "pentiumpro" 19872878SkrisMACHINE_CPU = i686 i586 i486 i386 199136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 20073145SkrisMACHINE_CPU = mmx i586 i486 i386 201136606Sobrien. elif ${CPUTYPE} == "pentium" 20272878SkrisMACHINE_CPU = i586 i486 i386 203103562Sjhb. elif ${CPUTYPE} == "i486" 20472878SkrisMACHINE_CPU = i486 i386 205103562Sjhb. elif ${CPUTYPE} == "i386" 20672878SkrisMACHINE_CPU = i386 207103562Sjhb. endif 208212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 209218896Smm. if ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || ${CPUTYPE} == "k8-sse3" 210218896SmmMACHINE_CPU = k8 3dnow sse3 211218896Smm. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 212138685SobrienMACHINE_CPU = k8 3dnow 213219640Smm. elif ${CPUTYPE} == "core2" 214219640SmmMACHINE_CPU = ssse3 sse3 215219640Smm. elif ${CPUTYPE} == "nocona" 216138685SobrienMACHINE_CPU = sse3 217136607Sobrien. endif 218138685SobrienMACHINE_CPU += amd64 sse2 sse mmx 219212540Simp. elif ${MACHINE_CPUARCH} == "ia64" 220103562Sjhb. if ${CPUTYPE} == "itanium" 22172878SkrisMACHINE_CPU = itanium 222103562Sjhb. endif 223216820Smarius. elif ${MACHINE_ARCH} == "powerpc" 224216820Smarius. if ${CPUTYPE} == "e500" 225216820SmariusMACHINE_CPU = booke 226216820Smarius. endif 227216820Smarius. elif ${MACHINE_ARCH} == "sparc64" 228216820Smarius. if ${CPUTYPE} == "v9" 229216820SmariusMACHINE_CPU = v9 230216820Smarius. elif ${CPUTYPE} == "ultrasparc" 231216820SmariusMACHINE_CPU = v9 ultrasparc 232216820Smarius. elif ${CPUTYPE} == "ultrasparc3" 233216820SmariusMACHINE_CPU = v9 ultrasparc ultrasparc3 234216820Smarius. endif 23572878Skris. endif 23672878Skris.endif 237103561Sjhb 238216820Smarius.if ${MACHINE_CPUARCH} == "mips" 239204559SimpCFLAGS += -G0 240177385Simp.endif 241177385Simp 242124347Sru# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 243103561Sjhb 244103561Sjhb.if !defined(NO_CPU_CFLAGS) 245126890Strhodes. if ${CC} == "icc" 246126890StrhodesCFLAGS += ${_ICC_CPUCFLAGS} 247126890Strhodes. else 248103561SjhbCFLAGS += ${_CPUCFLAGS} 249126890Strhodes. endif 250103561Sjhb.endif 251