1# $FreeBSD$ 2 3# Set default CPU compile flags and baseline CPUTYPE for each arch. The 4# compile flags must support the minimum CPU type for each architecture but 5# may tune support for more advanced processors. 6 7.if !defined(CPUTYPE) || empty(CPUTYPE) 8_CPUCFLAGS = 9. if ${MACHINE_CPUARCH} == "i386" 10MACHINE_CPU = i486 11. elif ${MACHINE_CPUARCH} == "amd64" 12MACHINE_CPU = amd64 sse2 sse mmx 13. elif ${MACHINE_CPUARCH} == "ia64" 14MACHINE_CPU = itanium 15. elif ${MACHINE_CPUARCH} == "powerpc" 16MACHINE_CPU = aim 17. elif ${MACHINE_CPUARCH} == "sparc64" 18MACHINE_CPU = ultrasparc 19. elif ${MACHINE_CPUARCH} == "arm" 20MACHINE_CPU = arm 21. elif ${MACHINE_CPUARCH} == "mips" 22MACHINE_CPU = mips 23. endif 24.else 25 26# Handle aliases (not documented in make.conf to avoid user confusion 27# between e.g. i586 and pentium) 28 29. if ${MACHINE_CPUARCH} == "i386" 30. if ${CPUTYPE} == "barcelona" 31CPUTYPE = amdfam10 32. elif ${CPUTYPE} == "k7" 33CPUTYPE = athlon 34. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" 35CPUTYPE = corei7 36. elif ${CPUTYPE} == "core" 37CPUTYPE = prescott 38. elif ${CPUTYPE} == "p4" 39CPUTYPE = pentium4 40. elif ${CPUTYPE} == "p4m" 41CPUTYPE = pentium4m 42. elif ${CPUTYPE} == "p3" 43CPUTYPE = pentium3 44. elif ${CPUTYPE} == "p3m" 45CPUTYPE = pentium3m 46. 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} == "bdver2" || ${CPUTYPE} == "bdver1" 146MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 147. elif ${CPUTYPE} == "btver1" 148MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 149. elif ${CPUTYPE} == "amdfam10" 150MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586 151. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" 152MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 153. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 154 ${CPUTYPE} == "athlon-fx" 155MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 156. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 157 ${CPUTYPE} == "athlon-4" 158MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 159. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 160MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 161. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" 162MACHINE_CPU = 3dnow mmx k6 k5 i586 163. elif ${CPUTYPE} == "k6" 164MACHINE_CPU = mmx k6 k5 i586 165. elif ${CPUTYPE} == "k5" 166MACHINE_CPU = k5 i586 167. elif ${CPUTYPE} == "core-avx2" 168MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 169. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 170MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 171. elif ${CPUTYPE} == "corei7" 172MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 173. elif ${CPUTYPE} == "penryn" 174MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 175. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 176MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 177. elif ${CPUTYPE} == "yonah" || ${CPUTYPE} == "prescott" 178MACHINE_CPU = sse3 sse2 sse i686 mmx i586 179. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || \ 180 ${CPUTYPE} == "pentium-m" 181MACHINE_CPU = sse2 sse i686 mmx i586 182. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 183MACHINE_CPU = sse i686 mmx i586 184. elif ${CPUTYPE} == "pentium2" 185MACHINE_CPU = i686 mmx i586 186. elif ${CPUTYPE} == "pentiumpro" 187MACHINE_CPU = i686 i586 188. elif ${CPUTYPE} == "pentium-mmx" 189MACHINE_CPU = mmx i586 190. elif ${CPUTYPE} == "pentium" 191MACHINE_CPU = i586 192. elif ${CPUTYPE} == "c7" 193MACHINE_CPU = sse3 sse2 sse i686 mmx i586 194. elif ${CPUTYPE} == "c3-2" 195MACHINE_CPU = sse i686 mmx i586 196. elif ${CPUTYPE} == "c3" 197MACHINE_CPU = 3dnow mmx i586 198. elif ${CPUTYPE} == "winchip2" 199MACHINE_CPU = 3dnow mmx 200. elif ${CPUTYPE} == "winchip-c6" 201MACHINE_CPU = mmx 202. endif 203MACHINE_CPU += i486 204. elif ${MACHINE_CPUARCH} == "amd64" 205. if ${CPUTYPE} == "bdver2" || ${CPUTYPE} == "bdver1" 206MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 207. elif ${CPUTYPE} == "btver1" 208MACHINE_CPU = ssse3 sse4a sse3 209. elif ${CPUTYPE} == "amdfam10" 210MACHINE_CPU = k8 3dnow sse4a sse3 211. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ 212 ${CPUTYPE} == "k8-sse3" 213MACHINE_CPU = k8 3dnow sse3 214. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 215 ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" 216MACHINE_CPU = k8 3dnow 217. elif ${CPUTYPE} == "core-avx2" 218MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 219. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 220MACHINE_CPU = avx sse42 sse41 ssse3 sse3 221. elif ${CPUTYPE} == "corei7" 222MACHINE_CPU = sse42 sse41 ssse3 sse3 223. elif ${CPUTYPE} == "penryn" 224MACHINE_CPU = sse41 ssse3 sse3 225. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 226MACHINE_CPU = ssse3 sse3 227. elif ${CPUTYPE} == "nocona" 228MACHINE_CPU = sse3 229. endif 230MACHINE_CPU += amd64 sse2 sse mmx 231. elif ${MACHINE_CPUARCH} == "ia64" 232. if ${CPUTYPE} == "itanium" 233MACHINE_CPU = itanium 234. endif 235. elif ${MACHINE_ARCH} == "powerpc" 236. if ${CPUTYPE} == "e500" 237MACHINE_CPU = booke 238. endif 239. elif ${MACHINE_ARCH} == "sparc64" 240. if ${CPUTYPE} == "v9" 241MACHINE_CPU = v9 242. elif ${CPUTYPE} == "ultrasparc" 243MACHINE_CPU = v9 ultrasparc 244. elif ${CPUTYPE} == "ultrasparc3" 245MACHINE_CPU = v9 ultrasparc ultrasparc3 246. endif 247. endif 248.endif 249 250.if ${MACHINE_CPUARCH} == "mips" 251CFLAGS += -G0 252.endif 253 254# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 255 256.if !defined(NO_CPU_CFLAGS) 257CFLAGS += ${_CPUCFLAGS} 258.endif 259