diff gcc/config/i386/driver-i386.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents 58ad6c70ea60
children b7f97abdc517
line wrap: on
line diff
--- a/gcc/config/i386/driver-i386.c	Sun Feb 07 18:28:00 2010 +0900
+++ b/gcc/config/i386/driver-i386.c	Fri Feb 12 23:39:51 2010 +0900
@@ -46,12 +46,15 @@
   /* At the moment, gcc does not use the information
      about the associativity of the cache.  */
 
-  sprintf (size, "--param l1-cache-size=%u", level1.sizekb);
-  sprintf (line, "--param l1-cache-line-size=%u", level1.line);
+  snprintf (size, sizeof (size),
+	    "--param l1-cache-size=%u ", level1.sizekb);
+  snprintf (line, sizeof (line),
+	    "--param l1-cache-line-size=%u ", level1.line);
 
-  sprintf (size2, "--param l2-cache-size=%u", level2.sizekb);
+  snprintf (size2, sizeof (size2),
+	    "--param l2-cache-size=%u ", level2.sizekb);
 
-  return concat (size, " ", line, " ", size2, " ", NULL);
+  return concat (size, line, size2, NULL);
 }
 
 /* Detect L2 cache parameters using CPUID extended function 0x80000006.  */
@@ -378,9 +381,9 @@
   /* Extended features */
   unsigned int has_lahf_lm = 0, has_sse4a = 0;
   unsigned int has_longmode = 0, has_3dnowp = 0, has_3dnow = 0;
-  unsigned int has_sse4_1 = 0, has_sse4_2 = 0;
+  unsigned int has_movbe = 0, has_sse4_1 = 0, has_sse4_2 = 0;
   unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0;
-  unsigned int has_pclmul = 0;
+  unsigned int has_pclmul = 0, has_abm = 0, has_lwp = 0;
 
   bool arch;
 
@@ -398,9 +401,22 @@
 
   __cpuid (1, eax, ebx, ecx, edx);
 
-  /* We don't care for extended family.  */
   model = (eax >> 4) & 0x0f;
   family = (eax >> 8) & 0x0f;
+  if (vendor == SIG_INTEL)
+    {
+      unsigned int extended_model, extended_family;
+
+      extended_model = (eax >> 12) & 0xf0;
+      extended_family = (eax >> 20) & 0xff;
+      if (family == 0x0f)
+	{
+	  family += extended_family;
+	  model += extended_model;
+	}
+      else if (family == 0x06)
+	model += extended_model;
+    }
 
   has_sse3 = ecx & bit_SSE3;
   has_ssse3 = ecx & bit_SSSE3;
@@ -408,6 +424,7 @@
   has_sse4_2 = ecx & bit_SSE4_2;
   has_avx = ecx & bit_AVX;
   has_cmpxchg16b = ecx & bit_CMPXCHG16B;
+  has_movbe = ecx & bit_MOVBE;
   has_popcnt = ecx & bit_POPCNT;
   has_aes = ecx & bit_AES;
   has_pclmul = ecx & bit_PCLMUL;
@@ -427,6 +444,8 @@
 
       has_lahf_lm = ecx & bit_LAHF_LM;
       has_sse4a = ecx & bit_SSE4a;
+      has_abm = ecx & bit_ABM;
+      has_lwp = ecx & bit_LWP;
 
       has_longmode = edx & bit_LM;
       has_3dnowp = edx & bit_3DNOWP;
@@ -505,8 +524,8 @@
       break;
     case PROCESSOR_PENTIUMPRO:
       if (has_longmode)
-	/* It is Core 2 Duo.  */
-	cpu = "core2";
+	/* It is Core 2 or Atom.  */
+	cpu = (model == 28) ? "atom" : "core2";
       else if (arch)
 	{
 	  if (has_sse3)
@@ -594,53 +613,42 @@
   if (arch)
     {
       if (has_cmpxchg16b)
-	options = concat (options, "-mcx16 ", NULL);
+	options = concat (options, " -mcx16", NULL);
       if (has_lahf_lm)
-	options = concat (options, "-msahf ", NULL);
+	options = concat (options, " -msahf", NULL);
+      if (has_movbe)
+	options = concat (options, " -mmovbe", NULL);
       if (has_aes)
-	options = concat (options, "-maes ", NULL);
+	options = concat (options, " -maes", NULL);
       if (has_pclmul)
-	options = concat (options, "-mpclmul ", NULL);
+	options = concat (options, " -mpclmul", NULL);
       if (has_popcnt)
-	options = concat (options, "-mpopcnt ", NULL);
+	options = concat (options, " -mpopcnt", NULL);
+      if (has_abm)
+	options = concat (options, " -mabm", NULL);
+      if (has_lwp)
+	options = concat (options, " -mlwp", NULL);
+
       if (has_avx)
-	options = concat (options, "-mavx ", NULL);
+	options = concat (options, " -mavx", NULL);
       else if (has_sse4_2)
-	options = concat (options, "-msse4.2 ", NULL);
+	options = concat (options, " -msse4.2", NULL);
       else if (has_sse4_1)
-	options = concat (options, "-msse4.1 ", NULL);
+	options = concat (options, " -msse4.1", NULL);
     }
 
 done:
-  return concat (cache, "-m", argv[0], "=", cpu, " ", options, NULL);
+  return concat (cache, "-m", argv[0], "=", cpu, options, NULL);
 }
 #else
 
-/* If we aren't compiling with GCC we just provide a minimal
-   default value.  */
-
-const char *host_detect_local_cpu (int argc, const char **argv)
-{
-  const char *cpu;
-  bool arch;
-
-  if (argc < 1)
-    return NULL;
-
-  arch = !strcmp (argv[0], "arch");
+/* If we aren't compiling with GCC then the driver will just ignore
+   -march and -mtune "native" target and will leave to the newly
+   built compiler to generate code for its default target.  */
 
-  if (!arch && strcmp (argv[0], "tune"))
-    return NULL;
-  
-  if (arch)
-    {
-      /* FIXME: i386 is wrong for 64bit compiler.  How can we tell if
-	 we are generating 64bit or 32bit code?  */
-      cpu = "i386";
-    }
-  else
-    cpu = "generic";
-
-  return concat ("-m", argv[0], "=", cpu, NULL);
+const char *host_detect_local_cpu (int argc ATTRIBUTE_UNUSED,
+				   const char **argv ATTRIBUTE_UNUSED)
+{
+  return NULL;
 }
 #endif /* __GNUC__ */