bsd.cpu.mk revision 263882
151889Sache# $FreeBSD: stable/10/share/mk/bsd.cpu.mk 263882 2014-03-28 20:12:30Z jkim $ 288313Sache 351889Sache# Set default CPU compile flags and baseline CPUTYPE for each arch. The 451889Sache# compile flags must support the minimum CPU type for each architecture but 551889Sache# may tune support for more advanced processors. 651889Sache 751889Sache.if !defined(CPUTYPE) || empty(CPUTYPE) 888313Sache_CPUCFLAGS = 951889Sache. if ${MACHINE_CPUARCH} == "i386" 1087108SacheMACHINE_CPU = i486 1188313Sache. elif ${MACHINE_CPUARCH} == "amd64" 1287108SacheMACHINE_CPU = amd64 sse2 sse mmx 1387108Sache. elif ${MACHINE_CPUARCH} == "ia64" 1451889SacheMACHINE_CPU = itanium 1587108Sache. elif ${MACHINE_CPUARCH} == "powerpc" 1687108SacheMACHINE_CPU = aim 1788313Sache. elif ${MACHINE_CPUARCH} == "sparc64" 1887108SacheMACHINE_CPU = ultrasparc 1988313Sache. elif ${MACHINE_CPUARCH} == "arm" 2088313SacheMACHINE_CPU = arm 2187108Sache. elif ${MACHINE_CPUARCH} == "mips" 2287108SacheMACHINE_CPU = mips 2388313Sache. endif 2451889Sache.else 2551889Sache 2651889Sache# Handle aliases (not documented in make.conf to avoid user confusion 2751889Sache# between e.g. i586 and pentium) 2888313Sache 2988313Sache. if ${MACHINE_CPUARCH} == "i386" 3088313Sache. if ${CPUTYPE} == "barcelona" 3188313SacheCPUTYPE = amdfam10 3288313Sache. elif ${CPUTYPE} == "k7" 3388313SacheCPUTYPE = athlon 3451889Sache. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" 3551889SacheCPUTYPE = corei7 3651889Sache. elif ${CPUTYPE} == "core" 3788313SacheCPUTYPE = prescott 3888313Sache. elif ${CPUTYPE} == "p4" 3988313SacheCPUTYPE = pentium4 4088313Sache. elif ${CPUTYPE} == "p4m" 4188313SacheCPUTYPE = pentium4m 4288313Sache. elif ${CPUTYPE} == "p3" 4351889SacheCPUTYPE = pentium3 4451889Sache. elif ${CPUTYPE} == "p3m" 4551889SacheCPUTYPE = pentium3m 4651889Sache. elif ${CPUTYPE} == "p-m" 47CPUTYPE = pentium-m 48. elif ${CPUTYPE} == "p2" 49CPUTYPE = pentium2 50. elif ${CPUTYPE} == "i686" 51CPUTYPE = pentiumpro 52. elif ${CPUTYPE} == "i586/mmx" 53CPUTYPE = pentium-mmx 54. elif ${CPUTYPE} == "i586" 55CPUTYPE = pentium 56. endif 57. elif ${MACHINE_CPUARCH} == "amd64" 58. if ${CPUTYPE} == "barcelona" 59CPUTYPE = amdfam10 60. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" 61CPUTYPE = corei7 62. elif ${CPUTYPE} == "prescott" 63CPUTYPE = nocona 64. endif 65. elif ${MACHINE_ARCH} == "sparc64" 66. if ${CPUTYPE} == "us" 67CPUTYPE = ultrasparc 68. elif ${CPUTYPE} == "us3" 69CPUTYPE = ultrasparc3 70. endif 71. endif 72 73############################################################################### 74# Logic to set up correct gcc optimization flag. This must be included 75# after /etc/make.conf so it can react to the local value of CPUTYPE 76# defined therein. Consult: 77# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 78# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 79# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 80# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 81# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 82# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 83 84. if ${MACHINE_CPUARCH} == "i386" 85. if ${CPUTYPE} == "crusoe" 86_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 87. elif ${CPUTYPE} == "k5" 88_CPUCFLAGS = -march=pentium 89. elif ${CPUTYPE} == "c7" 90_CPUCFLAGS = -march=c3-2 91. else 92_CPUCFLAGS = -march=${CPUTYPE} 93. endif 94. elif ${MACHINE_CPUARCH} == "amd64" 95_CPUCFLAGS = -march=${CPUTYPE} 96. elif ${MACHINE_CPUARCH} == "arm" 97. if ${CPUTYPE} == "xscale" 98#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 99#_CPUCFLAGS = -mcpu=xscale 100_CPUCFLAGS = -march=armv5te -D__XSCALE__ 101. elif ${CPUTYPE} == "armv6" 102_CPUCFLAGS = -march=${CPUTYPE} -DARM_ARCH_6=1 103. elif ${CPUTYPE} == "cortexa" 104_CPUCFLAGS = -DARM_ARCH_6=1 -mfpu=vfp 105. else 106_CPUCFLAGS = -mcpu=${CPUTYPE} 107. endif 108. elif ${MACHINE_ARCH} == "powerpc" 109. if ${CPUTYPE} == "e500" 110_CPUCFLAGS = -Wa,-me500 -msoft-float 111. else 112_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 113. endif 114. elif ${MACHINE_ARCH} == "powerpc64" 115_CPUCFLAGS = -mcpu=${CPUTYPE} 116. elif ${MACHINE_CPUARCH} == "mips" 117. if ${CPUTYPE} == "mips32" 118_CPUCFLAGS = -march=mips32 119. elif ${CPUTYPE} == "mips32r2" 120_CPUCFLAGS = -march=mips32r2 121. elif ${CPUTYPE} == "mips64" 122_CPUCFLAGS = -march=mips64 123. elif ${CPUTYPE} == "mips64r2" 124_CPUCFLAGS = -march=mips64r2 125. elif ${CPUTYPE} == "mips4kc" 126_CPUCFLAGS = -march=4kc 127. elif ${CPUTYPE} == "mips24kc" 128_CPUCFLAGS = -march=24kc 129. endif 130. elif ${MACHINE_ARCH} == "sparc64" 131. if ${CPUTYPE} == "v9" 132_CPUCFLAGS = -mcpu=v9 133. elif ${CPUTYPE} == "ultrasparc" 134_CPUCFLAGS = -mcpu=ultrasparc 135. elif ${CPUTYPE} == "ultrasparc3" 136_CPUCFLAGS = -mcpu=ultrasparc3 137. endif 138. endif 139 140# Set up the list of CPU features based on the CPU type. This is an 141# unordered list to make it easy for client makefiles to test for the 142# presence of a CPU feature. 143 144. if ${MACHINE_CPUARCH} == "i386" 145. if ${CPUTYPE} == "bdver3" || ${CPUTYPE} == "bdver2" || \ 146 ${CPUTYPE} == "bdver1" 147MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 148. elif ${CPUTYPE} == "btver2" 149MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 150. elif ${CPUTYPE} == "btver1" 151MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 152. elif ${CPUTYPE} == "amdfam10" 153MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586 154. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" 155MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 156. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 157 ${CPUTYPE} == "athlon-fx" 158MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 159. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 160 ${CPUTYPE} == "athlon-4" 161MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 162. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 163MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 164. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" 165MACHINE_CPU = 3dnow mmx k6 k5 i586 166. elif ${CPUTYPE} == "k6" 167MACHINE_CPU = mmx k6 k5 i586 168. elif ${CPUTYPE} == "k5" 169MACHINE_CPU = k5 i586 170. elif ${CPUTYPE} == "core-avx2" 171MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 172. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 173MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 174. elif ${CPUTYPE} == "slm" || ${CPUTYPE} == "corei7" 175MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 176. elif ${CPUTYPE} == "penryn" 177MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 178. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 179MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 180. elif ${CPUTYPE} == "yonah" || ${CPUTYPE} == "prescott" 181MACHINE_CPU = sse3 sse2 sse i686 mmx i586 182. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || \ 183 ${CPUTYPE} == "pentium-m" 184MACHINE_CPU = sse2 sse i686 mmx i586 185. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 186MACHINE_CPU = sse i686 mmx i586 187. elif ${CPUTYPE} == "pentium2" 188MACHINE_CPU = i686 mmx i586 189. elif ${CPUTYPE} == "pentiumpro" 190MACHINE_CPU = i686 i586 191. elif ${CPUTYPE} == "pentium-mmx" 192MACHINE_CPU = mmx i586 193. elif ${CPUTYPE} == "pentium" 194MACHINE_CPU = i586 195. elif ${CPUTYPE} == "c7" 196MACHINE_CPU = sse3 sse2 sse i686 mmx i586 197. elif ${CPUTYPE} == "c3-2" 198MACHINE_CPU = sse i686 mmx i586 199. elif ${CPUTYPE} == "c3" 200MACHINE_CPU = 3dnow mmx i586 201. elif ${CPUTYPE} == "winchip2" 202MACHINE_CPU = 3dnow mmx 203. elif ${CPUTYPE} == "winchip-c6" 204MACHINE_CPU = mmx 205. endif 206MACHINE_CPU += i486 207. elif ${MACHINE_CPUARCH} == "amd64" 208. if ${CPUTYPE} == "bdver3" || ${CPUTYPE} == "bdver2" || \ 209 ${CPUTYPE} == "bdver1" 210MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 211. elif ${CPUTYPE} == "btver2" 212MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 213. elif ${CPUTYPE} == "btver1" 214MACHINE_CPU = ssse3 sse4a sse3 215. elif ${CPUTYPE} == "amdfam10" 216MACHINE_CPU = k8 3dnow sse4a sse3 217. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ 218 ${CPUTYPE} == "k8-sse3" 219MACHINE_CPU = k8 3dnow sse3 220. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 221 ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" 222MACHINE_CPU = k8 3dnow 223. elif ${CPUTYPE} == "core-avx2" 224MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 225. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 226MACHINE_CPU = avx sse42 sse41 ssse3 sse3 227. elif ${CPUTYPE} == "slm" || ${CPUTYPE} == "corei7" 228MACHINE_CPU = sse42 sse41 ssse3 sse3 229. elif ${CPUTYPE} == "penryn" 230MACHINE_CPU = sse41 ssse3 sse3 231. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 232MACHINE_CPU = ssse3 sse3 233. elif ${CPUTYPE} == "nocona" 234MACHINE_CPU = sse3 235. endif 236MACHINE_CPU += amd64 sse2 sse mmx 237. elif ${MACHINE_CPUARCH} == "ia64" 238. if ${CPUTYPE} == "itanium" 239MACHINE_CPU = itanium 240. endif 241. elif ${MACHINE_ARCH} == "powerpc" 242. if ${CPUTYPE} == "e500" 243MACHINE_CPU = booke 244. endif 245. elif ${MACHINE_ARCH} == "sparc64" 246. if ${CPUTYPE} == "v9" 247MACHINE_CPU = v9 248. elif ${CPUTYPE} == "ultrasparc" 249MACHINE_CPU = v9 ultrasparc 250. elif ${CPUTYPE} == "ultrasparc3" 251MACHINE_CPU = v9 ultrasparc ultrasparc3 252. endif 253. endif 254.endif 255 256.if ${MACHINE_CPUARCH} == "mips" 257CFLAGS += -G0 258.endif 259 260# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 261 262.if !defined(NO_CPU_CFLAGS) 263CFLAGS += ${_CPUCFLAGS} 264.endif 265