bsd.cpu.mk revision 212540
172878Skris# $FreeBSD: head/share/mk/bsd.cpu.mk 212540 2010-09-13 07:22:14Z imp $ 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" 18212540Simp. elif ${MACHINE_CPUARCH} == "arm" 19129217ScognetMACHINE_CPU = arm 20212540Simp. elif ${MACHINE_CPUARCH} == "mips" 21177385SimpMACHINE_CPU = mips 22100773Sjhb. endif 23100772Sjhb.else 2472878Skris 2572878Skris# Handle aliases (not documented in make.conf to avoid user confusion 2672878Skris# between e.g. i586 and pentium) 2772878Skris 28212540Simp. if ${MACHINE_CPUARCH} == "i386" 29166071Sdes. if ${CPUTYPE} == "nocona" 30166071SdesCPUTYPE = prescott 31166071Sdes. elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2" 32166071SdesCPUTYPE = prescott 33136607Sobrien. elif ${CPUTYPE} == "p4" 34136606SobrienCPUTYPE = pentium4 35136606Sobrien. elif ${CPUTYPE} == "p4m" 36136606SobrienCPUTYPE = pentium4m 37136606Sobrien. elif ${CPUTYPE} == "p3" 38136606SobrienCPUTYPE = pentium3 39136606Sobrien. elif ${CPUTYPE} == "p3m" 40136606SobrienCPUTYPE = pentium3m 41136606Sobrien. elif ${CPUTYPE} == "p-m" 42136606SobrienCPUTYPE = pentium-m 43136606Sobrien. elif ${CPUTYPE} == "p2" 44136606SobrienCPUTYPE = pentium2 45136606Sobrien. elif ${CPUTYPE} == "i686" 46136606SobrienCPUTYPE = pentiumpro 47136606Sobrien. elif ${CPUTYPE} == "i586/mmx" 48136606SobrienCPUTYPE = pentium-mmx 49136606Sobrien. elif ${CPUTYPE} == "i586" 50136606SobrienCPUTYPE = pentium 51136607Sobrien. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 52136607Sobrien ${CPUTYPE} == "k8" 53133525SobrienCPUTYPE = athlon-mp 54103045Smux. elif ${CPUTYPE} == "k7" 55103045SmuxCPUTYPE = athlon 56100773Sjhb. endif 57212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 58166072Sdes. if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2" 59136607SobrienCPUTYPE = nocona 60136607Sobrien. endif 6172878Skris. endif 6272878Skris 63136606Sobrien############################################################################### 6496421Sobrien# Logic to set up correct gcc optimization flag. This must be included 6572878Skris# after /etc/make.conf so it can react to the local value of CPUTYPE 6696421Sobrien# defined therein. Consult: 67160536Simp# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 68179989Sale# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 69179989Sale# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 70177385Simp# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 7196421Sobrien# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 72179989Sale# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 7372878Skris 74212540Simp. if ${MACHINE_CPUARCH} == "i386" 75127888Sdfr. if ${CPUTYPE} == "crusoe" 76133000Sobrien_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 77136606Sobrien. elif ${CPUTYPE} == "k5" 78136606Sobrien_CPUCFLAGS = -march=pentium 79136606Sobrien. else 80136606Sobrien_CPUCFLAGS = -march=${CPUTYPE} 81136606Sobrien. endif # GCC on 'i386' 82136606Sobrien. if ${CPUTYPE} == "crusoe" 83127888Sdfr_ICC_CPUCFLAGS = -tpp6 -xiM 84127888Sdfr. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 85126938Strhodes ${CPUTYPE} == "athlon-4" 86126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 87126890Strhodes. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 88126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 89112768Sobrien. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 90126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xi 9172878Skris. elif ${CPUTYPE} == "k5" 92126890Strhodes_ICC_CPUCFLAGS = -tpp5 93136606Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 94126890Strhodes_ICC_CPUCFLAGS = -tpp7 -xiMKW 95136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 96136606Sobrien ${CPUTYPE} == "pentium-m" 97126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 98136606Sobrien. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 99126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 100136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 101126890Strhodes_ICC_CPUCFLAGS = -tpp5 -xM 102136606Sobrien. elif ${CPUTYPE} == "pentium" 103126890Strhodes_ICC_CPUCFLAGS = -tpp5 104136606Sobrien. else 105126890Strhodes_ICC_CPUCFLAGS = 106136606Sobrien. endif # ICC on 'i386' 107212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 108136607Sobrien_CPUCFLAGS = -march=${CPUTYPE} 109212540Simp. elif ${MACHINE_CPUARCH} == "arm" 110136606Sobrien. if ${CPUTYPE} == "xscale" 111172706Scognet#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 112172706Scognet#_CPUCFLAGS = -mcpu=xscale 113172706Scognet_CPUCFLAGS = -march=armv5te -D__XSCALE__ 114136606Sobrien. else 115136606Sobrien_CPUCFLAGS = -mcpu=${CPUTYPE} 116135678Scognet. endif 117176776Sraj. elif ${MACHINE_ARCH} == "powerpc" 118176776Sraj. if ${CPUTYPE} == "e500" 119176776SrajMACHINE_CPU = booke 120176776Sraj_CPUCFLAGS = -Wa,-me500 -msoft-float 121188923Snwhitehorn. else 122190681Snwhitehorn_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 123176776Sraj. endif 124209868Snwhitehorn. elif ${MACHINE_ARCH} == "powerpc64" 125209868Snwhitehorn_CPUCFLAGS = -mcpu=${CPUTYPE} 126212540Simp. elif ${MACHINE_CPUARCH} == "mips" 127177385Simp. if ${CPUTYPE} == "mips32" 128177385Simp_CPUCFLAGS = -march=mips32 129177385Simp. elif ${CPUTYPE} == "mips32r2" 130177385Simp_CPUCFLAGS = -march=mips32r2 131177385Simp. elif ${CPUTYPE} == "mips64" 132177385Simp_CPUCFLAGS = -march=mips64 133177385Simp. elif ${CPUTYPE} == "mips64r2" 134177385Simp_CPUCFLAGS = -march=mips64r2 135177385Simp. elif ${CPUTYPE} == "mips4kc" 136177385Simp_CPUCFLAGS = -march=4kc 137177385Simp. elif ${CPUTYPE} == "mips24kc" 138177385Simp_CPUCFLAGS = -march=24kc 139177385Simp. endif 14072878Skris. endif 14172878Skris 14272878Skris# Set up the list of CPU features based on the CPU type. This is an 14372878Skris# unordered list to make it easy for client makefiles to test for the 14472878Skris# presence of a CPU feature. 14572878Skris 146212540Simp. if ${MACHINE_CPUARCH} == "i386" 147136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 148136607SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 149136607Sobrien. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 150125254Sbde ${CPUTYPE} == "athlon-4" 151136606SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 152126657Sbde. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 153112768SobrienMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 154126657Sbde. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 155103045SmuxMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 156103562Sjhb. elif ${CPUTYPE} == "k6" 15774069SsobomaxMACHINE_CPU = mmx k6 k5 i586 i486 i386 158103562Sjhb. elif ${CPUTYPE} == "k5" 15972878SkrisMACHINE_CPU = k5 i586 i486 i386 160160497Sdes. elif ${CPUTYPE} == "c3" 161161259SdesMACHINE_CPU = 3dnow mmx i586 i486 i386 162160497Sdes. elif ${CPUTYPE} == "c3-2" 163160497SdesMACHINE_CPU = sse mmx i586 i486 i386 164176665Sjhb. elif ${CPUTYPE} == "c7" 165176665SjhbMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 166166071Sdes. elif ${CPUTYPE} == "prescott" 167166069SdesMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 168136607Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 169103045SmuxMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 170136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 17173145SkrisMACHINE_CPU = sse i686 mmx i586 i486 i386 172136606Sobrien. elif ${CPUTYPE} == "pentium2" 17374553SkrisMACHINE_CPU = i686 mmx i586 i486 i386 174136606Sobrien. elif ${CPUTYPE} == "pentiumpro" 17572878SkrisMACHINE_CPU = i686 i586 i486 i386 176136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 17773145SkrisMACHINE_CPU = mmx i586 i486 i386 178136606Sobrien. elif ${CPUTYPE} == "pentium" 17972878SkrisMACHINE_CPU = i586 i486 i386 180103562Sjhb. elif ${CPUTYPE} == "i486" 18172878SkrisMACHINE_CPU = i486 i386 182103562Sjhb. elif ${CPUTYPE} == "i386" 18372878SkrisMACHINE_CPU = i386 184103562Sjhb. endif 185212540Simp. elif ${MACHINE_CPUARCH} == "amd64" 186136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 187138685SobrienMACHINE_CPU = k8 3dnow 188166071Sdes. elif ${CPUTYPE} == "nocona" 189138685SobrienMACHINE_CPU = sse3 190136607Sobrien. endif 191138685SobrienMACHINE_CPU += amd64 sse2 sse mmx 192212540Simp. elif ${MACHINE_CPUARCH} == "ia64" 193103562Sjhb. if ${CPUTYPE} == "itanium" 19472878SkrisMACHINE_CPU = itanium 195103562Sjhb. endif 19672878Skris. endif 19772878Skris.endif 198103561Sjhb 199212540Simp.if ${MACHINE_CPUARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 200160534ScognetCFLAGS += -mbig-endian 201160544ScognetLDFLAGS += -mbig-endian 202160535ScognetLD += -EB 203160534Scognet.endif 204160534Scognet 205212540Simp.if ${MACHINE_CPUARCH} == "mips" 206204559SimpCFLAGS += -G0 207177385Simp.endif 208177385Simp 209124347Sru# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 210103561Sjhb 211103561Sjhb.if !defined(NO_CPU_CFLAGS) 212126890Strhodes. if ${CC} == "icc" 213126890StrhodesCFLAGS += ${_ICC_CPUCFLAGS} 214126890Strhodes. else 215103561SjhbCFLAGS += ${_CPUCFLAGS} 216126890Strhodes. endif 217103561Sjhb.endif 218