summaryrefslogtreecommitdiff
path: root/config.guess
diff options
context:
space:
mode:
authorTorbjorn Granlund <torbjorng@google.com>2015-06-15 18:03:10 +0200
committerTorbjorn Granlund <torbjorng@google.com>2015-06-15 18:03:10 +0200
commita12ff8f642b6cf4ef6bbf046ffdfa7deb6eb89ff (patch)
treee500ee2207c41d8194e6ef803c5f675b6c4b0ba0 /config.guess
parent29f2b51a0a70c172a6a05ad8994e922c230ba5c3 (diff)
downloadgmp-a12ff8f642b6cf4ef6bbf046ffdfa7deb6eb89ff.tar.gz
Rewrite code for AVX handling to deal with broken cpuid states.
Diffstat (limited to 'config.guess')
-rwxr-xr-xconfig.guess112
1 files changed, 59 insertions, 53 deletions
diff --git a/config.guess b/config.guess
index 1f37b3f50..fc4c54188 100755
--- a/config.guess
+++ b/config.guess
@@ -766,25 +766,23 @@ int
main ()
{
char vendor_string[13];
- char dummy_string[12];
+ char feature_string[12];
long fms;
- int family, model, stepping;
+ int family, model;
const char *modelstr, *suffix;
- int cpu_64bit = 0;
+ int cpu_64bit = 0, cpu_avx = 0;
int cpuid_64bit, cpuid_avx, cpuid_osxsave;
CPUID (vendor_string, 0);
vendor_string[12] = 0;
- fms = CPUID (dummy_string, 1);
+ fms = CPUID (feature_string, 1);
family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff);
model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0);
- stepping = fms & 0xf;
- cpuid_avx = (dummy_string[11] >> 4) & 1;
- cpuid_osxsave = (dummy_string[11] >> 3) & 1;
- suffix = cpuid_avx > cpuid_osxsave ? "noavx" : "";
+ cpuid_avx = (feature_string[11] >> 4) & 1;
+ cpuid_osxsave = (feature_string[11] >> 3) & 1;
modelstr = "$guess_cpu";
@@ -800,48 +798,48 @@ main ()
else if (model >= 4) modelstr = "pentiummmx";
break;
case 6:
- if (model <= 1) modelstr = "pentiumpro";
- else if (model <= 6) modelstr = "pentium2";
- else if (model <= 8) modelstr = "pentium3";
- else if (model <= 9) modelstr = "pentiumm";
- else if (model <= 0x0c) modelstr = "pentium3";
- else if (model <= 0x0e) modelstr = "pentiumm";
- else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2";
- else if (model == 0x1a) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Gainestown */
- else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */
- else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */
- else if (model == 0x1e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Lynnfield/Jasper */
- else if (model == 0x25) cpu_64bit = 1, modelstr = "westmere"; /* WSM Clarkdale/Arrandale */
- else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */
- else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */
- else if (model == 0x2a) cpu_64bit = 1, modelstr = "sandybridge";/* SB */
- else if (model == 0x2c) cpu_64bit = 1, modelstr = "westmere"; /* WSM Gulftown */
- else if (model == 0x2d) cpu_64bit = 1, modelstr = "sandybridge";/* SBC-EP */
- else if (model == 0x2e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Beckton */
- else if (model == 0x2f) cpu_64bit = 1, modelstr = "westmere"; /* WSM Eagleton */
- else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */
- else if (model == 0x37) cpu_64bit = 1, modelstr = "silvermont"; /* Atom Silvermont */
- else if (model == 0x3a) cpu_64bit = 1, modelstr = "ivybridge"; /* IBR */
- else if (model == 0x3c) cpu_64bit = 1, modelstr = "haswell"; /* Haswell client */
- else if (model == 0x3d) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell */
- else if (model == 0x3e) cpu_64bit = 1, modelstr = "ivybridge"; /* Ivytown */
- else if (model == 0x3f) cpu_64bit = 1, modelstr = "haswell"; /* Haswell server */
- else if (model == 0x45) cpu_64bit = 1, modelstr = "haswell"; /* Haswell ULT */
- else if (model == 0x46) cpu_64bit = 1, modelstr = "haswell"; /* Crystal Well */
- else if (model == 0x47) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell */
- else if (model == 0x4a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */
- else if (model == 0x4c) cpu_64bit = 1, modelstr = "silvermont"; /* Airmont */
- else if (model == 0x4d) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont/Avoton */
- else if (model == 0x4f) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell server */
- else if (model == 0x56) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell microserver */
- else cpu_64bit = 1, modelstr = "nehalem"; /* default */
+ if (model <= 1) modelstr = "pentiumpro";
+ else if (model <= 6) modelstr = "pentium2";
+ else if (model <= 8) modelstr = "pentium3";
+ else if (model <= 9) modelstr = "pentiumm";
+ else if (model <= 0x0c) modelstr = "pentium3";
+ else if (model <= 0x0e) modelstr = "pentiumm";
+ else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2";
+ else if (model == 0x1a) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Gainestown */
+ else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */
+ else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */
+ else if (model == 0x1e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Lynnfield/Jasper */
+ else if (model == 0x25) cpu_64bit = 1, modelstr = "westmere"; /* WSM Clarkdale/Arrandale */
+ else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */
+ else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */
+ else if (model == 0x2a) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SB */
+ else if (model == 0x2c) cpu_64bit = 1, modelstr = "westmere"; /* WSM Gulftown */
+ else if (model == 0x2d) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SBC-EP */
+ else if (model == 0x2e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Beckton */
+ else if (model == 0x2f) cpu_64bit = 1, modelstr = "westmere"; /* WSM Eagleton */
+ else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */
+ else if (model == 0x37) cpu_64bit = 1, modelstr = "silvermont"; /* Atom Silvermont */
+ else if (model == 0x3a) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* IBR */
+ else if (model == 0x3c) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell client */
+ else if (model == 0x3d) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */
+ else if (model == 0x3e) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* Ivytown */
+ else if (model == 0x3f) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell server */
+ else if (model == 0x45) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell ULT */
+ else if (model == 0x46) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Crystal Well */
+ else if (model == 0x47) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */
+ else if (model == 0x4a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */
+ else if (model == 0x4c) cpu_64bit = 1, modelstr = "silvermont"; /* Airmont */
+ else if (model == 0x4d) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont/Avoton */
+ else if (model == 0x4f) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell server */
+ else if (model == 0x56) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell microserver */
+ else cpu_64bit = 1, modelstr = "nehalem"; /* default */
if (strcmp (modelstr, "haswell") == 0)
{
/* Some Haswells lack BMI2. Let them appear as Sandybridges for
now. */
- CPUID (dummy_string, 7);
- if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
+ CPUID (feature_string, 7);
+ if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
modelstr = "sandybridge";
}
@@ -885,7 +883,7 @@ main ()
cpu_64bit = 1, modelstr = "bobcat";
break;
case 21: /* Bulldozer */
- cpu_64bit = 1;
+ cpu_64bit = 1, cpu_avx = 1;
if (model <= 1)
modelstr = "bulldozer";
else if (model < 0x20) /* really 2, [0x10-0x20) */
@@ -896,7 +894,7 @@ main ()
modelstr = "excavator";
break;
case 22: /* Jaguar, an improved bobcat */
- cpu_64bit = 1, modelstr = "jaguar";
+ cpu_64bit = 1, cpu_avx = 1, modelstr = "jaguar";
break;
}
}
@@ -916,15 +914,23 @@ main ()
}
}
- CPUID (dummy_string, 0x80000001);
- cpuid_64bit = (dummy_string[7] >> 5) & 1;
+ CPUID (feature_string, 0x80000001);
+ cpuid_64bit = (feature_string[7] >> 5) & 1;
+
+ suffix = "";
- /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
- cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
- This is of course wrong, but it can happen in some emulators, so this
- workaround allows for successful 64-bit builds. */
if (cpuid_64bit && ! cpu_64bit)
+ /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
+ cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
+ This is of course wrong, but it can happen in some virtualisers and
+ emulators, so this workaround allows for successful 64-bit builds. */
modelstr = "x86_64";
+ else if (cpu_avx && ! (cpuid_avx && cpuid_osxsave))
+ /* For CPUs nominally capable of executing AVX, append "noavx" when not
+ both the AVX and OSXSAVE cpuid bits are set. We tolerate weirdness
+ here, as some virtualisers set a broken cpuid state here, while other
+ virtualisers allow users to set a broken state. */
+ suffix = "noavx";
printf ("%s%s", modelstr, suffix);
return 0;