pkgsrc/devel/cpuflags/files/subr_x86
abs 921a7e1f6d Updated devel/cpuflags to 1.41
Treat all Atoms as '-march=core2 -mtune=pentium'
2009-03-30 21:02:25 +00:00

131 lines
3.6 KiB
Text

# $NetBSD: subr_x86,v 1.13 2009/03/30 21:02:25 abs Exp $
# Apparently the only way to reliably determine the architecture of a recent
# Intel CPU is to use the cpu brand string - as they reused family and
# extended family bitflags... annoying
# Even better, they appear to have reused brand strings between Northwood
# and Prescott pentium4s. Thats just... special.
# AMD, in contrast decided to keep things simple:
# (thanks to Christoph Egger for this list)
# Family 0x6: AMD K7
# Family 0xf: AMD K8
# Family 0x10: AMD Barcelona/Phenom
# Family 0x11: AMD Turion Ultra
map_x86_brand_string()
{
case "$cpu_brand" in
"AMD*")
case "$cpu_family-$cpu_model" in
5-6 | 5-7 ) echo '-march=k6' ;;
5-8 ) echo '-march=k6-2' ;;
5-9 ) echo '-march=k6-3' ;;
6-1 | 6-2 | 6-3 ) echo '-march=athlon' ;;
6-4 | 6-6 | 6-7 | 6-8 | 6-a ) echo '-march=athlon-4' ;;
esac
;;
"VIA Nehemiah"*) echo '-march=c3' ;;
"Genuine Intel(R) CPU T2400"*) echo '-march=core2' ;;
"Genuine Intel(R) CPU T2500"*) echo '-march=core2' ;;
"Intel(R) Atom(TM) CPU "*) echo '-march=core2 -mtune=pentium' ;;#So far
"Intel(R) Celeron(R) CPU E1400"*) echo '-march=core2' ;;
"Intel(R) Celeron(R) CPU 2.40GHz") echo '-march=pentium4' ;;
"Intel(R) Celeron(R) M processor "*) echo '-march=pentium-m' ;;
"Intel(R) Celeron(TM) CPU 1400MHz") echo '-march=pentium3' ;;
"Intel(R) Core 2 "*) echo '-march=core2' ;;
"Intel(R) Core(TM)2 "*) echo '-march=core2' ;;
"Intel(R) Pentium(R) 4 CPU"*)
if [ -n "$cpu_feature_SSE3" ] ; then
echo '-march=prescott'
else
echo '-march=pentium4'
fi ;;
"Intel(R) Pentium(R) M processor "*) echo '-march=pentium-m' ;;
"Intel(R) Xeon(R) CPU 3040"*) echo '-march=core2' ;;
"Intel(R) Xeon(R) CPU 3050"*) echo '-march=core2' ;;
"Intel(R) Xeon(R) CPU E5310"*) echo '-march=core2' ;;
"Intel(r) Xeon(r) CPU E5430"*) echo '-march=core2' ;;
"Pentium(R) Dual-Core CPU E5200"*) echo '-march=core2' ;;
esac
}
flags_fixup_x86arch()
{
arch=$1
features=$2
# Fixup ARCH for x86
#
# The format of table is
# feature:lowend_arch:fix_arch
#
$AWK -v "arch=${arch#-march=}" -v "features=$features" '
BEGIN { split(features,ar); FS=":" }
{ for (af in ar)
{ if ((ar[af] == $1) && (arch == $3)) { print $2; exit;} }
}
' <<EOD
-msse:pentium3:i386
-msse:pentium3:i486
-msse:pentium3:i586
-msse:pentium3:i686
-msse:pentium3:pentium
-msse:pentium3:pentium-mmx
-msse:pentium3:pentiumpro
-msse:pentium3:pentium2
-msse:athlon:k6
-msse:athlon:k6-2
-msse:athlon:k6-3
-msse2:pentium4:i386
-msse2:pentium4:i386
-msse2:pentium4:i486
-msse2:pentium4:i586
-msse2:pentium4:i686
-msse2:pentium4:pentium
-msse2:pentium4:pentium-mmx
-msse2:pentium4:pentiumpro
-msse2:pentium4:pentium2
-msse2:pentium4:pentium3
-msse2:pentium4:pentium3m
-msse2:k8:k6
-msse2:k8:k6-2
-msse2:k8:k6-3
-msse2:k8:athlon
-msse2:k8:athlon-tbird
-msse2:k8:athlon-4
-msse2:k8:athlon-xp
-msse2:k8:athlon-mp
-msse3:prescott:i386
-msse3:prescott:i386
-msse3:prescott:i486
-msse3:prescott:i586
-msse3:prescott:i686
-msse3:prescott:pentium
-msse3:prescott:pentium-mmx
-msse3:prescott:pentiumpro
-msse3:prescott:pentium2
-msse3:prescott:pentium3
-msse3:prescott:pentium3m
-msse3:prescott:pentium-m
-msse3:prescott:pentium4
-msse3:prescott:pentium4m
-msse3:k8:k6
-msse3:k8:k6-2
-msse3:k8:k6-3
-msse3:k8:athlon
-msse3:k8:athlon-tbird
-msse3:k8:athlon-4
-msse3:k8:athlon-xp
-msse3:k8:athlon-mp
-m3dnow:athlon:k6
-m3dnow:athlon:k6-2
-m3dnow:athlon:k6-3
EOD
## in future
#-mssse3:nocona:prescott ...
#-msse4:nehalem:nocona ...
}