1# Set default CPU compile flags and baseline CPUTYPE for each arch. The 2# compile flags must support the minimum CPU type for each architecture but 3# may tune support for more advanced processors. 4 5.if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native" 6 7. if defined(CPUTYPE) && !empty(CPUTYPE) && ${CPUTYPE} == "native" 8_CPUCFLAGS = -march=native 9. else 10_CPUCFLAGS = 11. endif 12 13. if ${MACHINE_ARCH} == "i386" 14MACHINE_CPU = i486 i386 15. elif ${MACHINE_ARCH} == "x86_64" 16MACHINE_CPU = x86_64 sse2 sse mmx 17. endif 18 19.else 20 21_CPUCFLAGS_FIXUP = 22 23# Old CPUTYPE compat shim 24. if ${CPUTYPE} == "i586" \ 25 || ${CPUTYPE} == "k5" 26CPUTYPE = pentium 27. elif ${CPUTYPE} == "i586/mmx" 28CPUTYPE = pentium-mmx 29. elif ${CPUTYPE} == "p2" 30CPUTYPE = pentium2 31. elif ${CPUTYPE} == "pentium3m" \ 32 || ${CPUTYPE} == "p3m" \ 33 || ${CPUTYPE} == "p3" \ 34 || ${CPUTYPE} == "c3-2" 35CPUTYPE = pentium3 36. elif ${CPUTYPE} == "pentium4m" \ 37 || ${CPUTYPE} == "pentium-m" \ 38 || ${CPUTYPE} == "p-m" \ 39 || ${CPUTYPE} == "p4"\ 40 || ${CPUTYPE} == "p4m" 41CPUTYPE = pentium4 42. elif ${CPUTYPE} == "crusoe" 43CPUTYPE = pentiumpro 44_CPUCFLAGS_FIXUP = -falign-functions=0 -falign-jumps=0 -falign-loops=0 45. elif ${CPUTYPE} == "i686" 46CPUTYPE = pentiumpro 47. elif ${CPUTYPE} == "k6-2" 48CPUTYPE = k6-3 49. elif ${CPUTYPE} == "k7" \ 50 || ${CPUTYPE} == "athlon-tbird" 51CPUTYPE = athlon 52. elif ${CPUTYPE} == "athlon-mp" \ 53 || ${CPUTYPE} == "athlon-4" 54CPUTYPE = athlon-xp 55. elif ${CPUTYPE} == "k8" \ 56 || ${CPUTYPE} == "opteron" \ 57 || ${CPUTYPE} == "athlon-fx" 58CPUTYPE = athlon64 59. elif ${CPUTYPE} == "k8-sse3" \ 60 || ${CPUTYPE} == "opteron-sse3" 61CPUTYPE = athlon64-sse3 62. elif ${CPUTYPE} == "amdfam10" 63CPUTYPE = barcelona 64. elif ${CPUTYPE} == "c3" 65CPUTYPE = winchip2 66. elif ${CPUTYPE} == "core" 67CPUTYPE = nocona 68. elif ${CPUTYPE} == "corei7-avx" \ 69 || ${CPUTYPE} == "corei7-avx-i" \ 70 || ${CPUTYPE} == "corei7-avx2" 71CPUTYPE = corei7 72. elif ${CPUTYPE} == "atom" 73CPUTYPE = core2 74. elif ${CPUTYPE} == "bdver2" 75CPUTYPE = bdver1 76. elif ${CPUTYPE} == "btver1" 77CPUTYPE = barcelona 78. endif 79 80############################################################################### 81# Logic to set up correct gcc optimization flag. This must be included 82# after /etc/make.conf so it can react to the local value of CPUTYPE 83# defined therein. Consult: 84# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 85 86_CPUCFLAGS = -march=${CPUTYPE} ${_CPUCFLAGS_FIXUP} 87 88# Set up the list of CPU features based on the CPU type. This is an 89# unordered list to make it easy for client makefiles to test for the 90# presence of a CPU feature. 91 92. if ${MACHINE_ARCH} == "i386" 93. if ${CPUTYPE} == "bdver1" 94MACHINE_CPU = abm 3dnow mmx sse4.2 sse4.1 sse3 sse2 sse \ 95 athlon-xp athlon k7 k6 k5 i586 96. elif ${CPUTYPE} == "barcelona" 97MACHINE_CPU = abm 3dnow mmx sse4a sse3 sse2 sse \ 98 athlon-xp athlon k7 k6 k5 i586 99. elif ${CPUTYPE} == "athlon64-sse3" 100MACHINE_CPU = 3dnow mmx sse3 sse2 sse athlon-xp athlon k7 k6 k5 i586 101. elif ${CPUTYPE} == "athlon64" 102MACHINE_CPU = 3dnow mmx sse2 sse athlon-xp athlon k7 k6 k5 i586 103. elif ${CPUTYPE} == "athlon-xp" 104MACHINE_CPU = 3dnow mmx sse athlon-xp athlon k7 k6 k5 i586 105. elif ${CPUTYPE} == "athlon" 106MACHINE_CPU = 3dnow mmx athlon k7 k6 k5 i586 107. elif ${CPUTYPE} == "k6-3" 108MACHINE_CPU = 3dnow mmx k6 k5 i586 109. elif ${CPUTYPE} == "k6" 110MACHINE_CPU = mmx k6 k5 i586 111. elif ${CPUTYPE} == "geode" 112MACHINE_CPU = 3dnow mmx i686 i586 113. elif ${CPUTYPE} == "corei7" 114MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3 sse2 sse mmx i686 i586 115. elif ${CPUTYPE} == "core2" 116MACHINE_CPU = ssse3 sse3 sse2 sse mmx i686 i586 117. elif ${CPUTYPE} == "nocona" 118MACHINE_CPU = sse3 sse2 sse mmx i686 i586 119. elif ${CPUTYPE} == "prescott" 120MACHINE_CPU = sse3 sse2 sse mmx i686 i586 121. elif ${CPUTYPE} == "pentium4" 122MACHINE_CPU = sse2 sse mmx i686 i586 123. elif ${CPUTYPE} == "pentium3" 124MACHINE_CPU = sse mmx i686 i586 125. elif ${CPUTYPE} == "pentium2" 126MACHINE_CPU = mmx i686 i586 127. elif ${CPUTYPE} == "pentiumpro" 128MACHINE_CPU = i686 i586 129. elif ${CPUTYPE} == "winchip2" 130MACHINE_CPU = 3dnow mmx 131. elif ${CPUTYPE} == "winchip-c6" 132MACHINE_CPU = mmx 133. elif ${CPUTYPE} == "pentium-mmx" 134MACHINE_CPU = mmx i586 135. elif ${CPUTYPE} == "pentium" 136MACHINE_CPU = i586 137. endif 138MACHINE_CPU += i386 i486 139. elif ${MACHINE_ARCH} == "x86_64" 140. if ${CPUTYPE} == "bdver1" 141MACHINE_CPU = k8 abm 3dnow sse4.2 sse4.1 sse3 142. elif ${CPUTYPE} == "barcelona" 143MACHINE_CPU = k8 abm 3dnow sse4a sse3 144. elif ${CPUTYPE} == "athlon64-sse3" 145MACHINE_CPU = k8 3dnow sse3 146. elif ${CPUTYPE} == "athlon64" 147MACHINE_CPU = k8 3dnow 148. elif ${CPUTYPE} == "corei7" 149MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3 150. elif ${CPUTYPE} == "core2" 151MACHINE_CPU = ssse3 sse3 152. elif ${CPUTYPE} == "nocona" 153MACHINE_CPU = sse3 154. endif 155MACHINE_CPU += sse2 sse mmx x86_64 156. endif 157 158.endif 159