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} == "btver2" 148MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 149. elif ${CPUTYPE} == "btver1" 150MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 151. elif ${CPUTYPE} == "amdfam10" 152MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586 153. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" 154MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 155. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 156 ${CPUTYPE} == "athlon-fx" 157MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 158. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 159 ${CPUTYPE} == "athlon-4" 160MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 161. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 162MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 163. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" 164MACHINE_CPU = 3dnow mmx k6 k5 i586 165. elif ${CPUTYPE} == "k6" 166MACHINE_CPU = mmx k6 k5 i586 167. elif ${CPUTYPE} == "k5" 168MACHINE_CPU = k5 i586 169. elif ${CPUTYPE} == "core-avx2" 170MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 171. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 172MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 173. elif ${CPUTYPE} == "corei7" 174MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 175. elif ${CPUTYPE} == "penryn" 176MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 177. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 178MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 179. elif ${CPUTYPE} == "yonah" || ${CPUTYPE} == "prescott" 180MACHINE_CPU = sse3 sse2 sse i686 mmx i586 181. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || \ 182 ${CPUTYPE} == "pentium-m" 183MACHINE_CPU = sse2 sse i686 mmx i586 184. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 185MACHINE_CPU = sse i686 mmx i586 186. elif ${CPUTYPE} == "pentium2" 187MACHINE_CPU = i686 mmx i586 188. elif ${CPUTYPE} == "pentiumpro" 189MACHINE_CPU = i686 i586 190. elif ${CPUTYPE} == "pentium-mmx" 191MACHINE_CPU = mmx i586 192. elif ${CPUTYPE} == "pentium" 193MACHINE_CPU = i586 194. elif ${CPUTYPE} == "c7" 195MACHINE_CPU = sse3 sse2 sse i686 mmx i586 196. elif ${CPUTYPE} == "c3-2" 197MACHINE_CPU = sse i686 mmx i586 198. elif ${CPUTYPE} == "c3" 199MACHINE_CPU = 3dnow mmx i586 200. elif ${CPUTYPE} == "winchip2" 201MACHINE_CPU = 3dnow mmx 202. elif ${CPUTYPE} == "winchip-c6" 203MACHINE_CPU = mmx 204. endif 205MACHINE_CPU += i486 206. elif ${MACHINE_CPUARCH} == "amd64" 207. if ${CPUTYPE} == "bdver2" || ${CPUTYPE} == "bdver1" 208MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 209. elif ${CPUTYPE} == "btver2" 210MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 211. elif ${CPUTYPE} == "btver1" 212MACHINE_CPU = ssse3 sse4a sse3 213. elif ${CPUTYPE} == "amdfam10" 214MACHINE_CPU = k8 3dnow sse4a sse3 215. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ 216 ${CPUTYPE} == "k8-sse3" 217MACHINE_CPU = k8 3dnow sse3 218. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 219 ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" 220MACHINE_CPU = k8 3dnow 221. elif ${CPUTYPE} == "core-avx2" 222MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 223. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" 224MACHINE_CPU = avx sse42 sse41 ssse3 sse3 225. elif ${CPUTYPE} == "corei7" 226MACHINE_CPU = sse42 sse41 ssse3 sse3 227. elif ${CPUTYPE} == "penryn" 228MACHINE_CPU = sse41 ssse3 sse3 229. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" 230MACHINE_CPU = ssse3 sse3 231. elif ${CPUTYPE} == "nocona" 232MACHINE_CPU = sse3 233. endif 234MACHINE_CPU += amd64 sse2 sse mmx 235. elif ${MACHINE_CPUARCH} == "ia64" 236. if ${CPUTYPE} == "itanium" 237MACHINE_CPU = itanium 238. endif 239. elif ${MACHINE_ARCH} == "powerpc" 240. if ${CPUTYPE} == "e500" 241MACHINE_CPU = booke 242. endif 243. elif ${MACHINE_ARCH} == "sparc64" 244. if ${CPUTYPE} == "v9" 245MACHINE_CPU = v9 246. elif ${CPUTYPE} == "ultrasparc" 247MACHINE_CPU = v9 ultrasparc 248. elif ${CPUTYPE} == "ultrasparc3" 249MACHINE_CPU = v9 ultrasparc ultrasparc3 250. endif 251. endif 252.endif 253 254.if ${MACHINE_CPUARCH} == "mips" 255CFLAGS += -G0 256.endif 257 258# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 259 260.if !defined(NO_CPU_CFLAGS) 261CFLAGS += ${_CPUCFLAGS} 262.endif 263