diff mbox

Rs6000 infrastructure cleanup (switches), revised patch #2d

Message ID 20121001231123.GA8464@ibm-tiger.the-meissners.org
State New
Headers show

Commit Message

Michael Meissner Oct. 1, 2012, 11:11 p.m. UTC
2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000.c (rs6000_option_override_internal): If
	-mcpu=<xxx> is not specified and the compiler is not configured
	using --with-cpu=<xxx>, use the bits from the TARGET_DEFAULT to
	set the initial options.

I reworked the patch to allow TARGET_DEFAULT bits to be set if there is no
-mcpu=<xxx> and the compiler was not configured using --with-cpu=<xxx>, so that
we don't first clear all of the ISA bits, set them from the cpu, and then merge
back in the TARGET_DEFAULT bits.

Somebody asked about what is set, when this function gets called.  The
target_flags variable is set with the initial settings (TARGET_DEFAULT) and
then all of the switches that the user sets or resets are then applied.  The
target_flags_explicit variable is only set if the user explicitly used that
switch.

So for instance, if the user passed -mpopcntb -mno-vsx on Linux 64-bit systems,
target_flags would be 0x150001 (MASK_PPC_GFXOPT | MASK_POWERPC64 | MASK_64BIT |
MASK_POPCNTB) and target_flags_explicit would be 0x2010000 (MASK_POPCNTB |
MASK_VSX).

Comments

David Edelsohn Oct. 2, 2012, 5:44 p.m. UTC | #1
On Mon, Oct 1, 2012 at 7:11 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         * config/rs6000/rs6000.c (rs6000_option_override_internal): If
>         -mcpu=<xxx> is not specified and the compiler is not configured
>         using --with-cpu=<xxx>, use the bits from the TARGET_DEFAULT to
>         set the initial options.
>
> I reworked the patch to allow TARGET_DEFAULT bits to be set if there is no
> -mcpu=<xxx> and the compiler was not configured using --with-cpu=<xxx>, so that
> we don't first clear all of the ISA bits, set them from the cpu, and then merge
> back in the TARGET_DEFAULT bits.

This version of the patch is good.

Thanks, David
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 191942)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -2446,21 +2446,34 @@  rs6000_option_override_internal (bool gl
       rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index;
       have_cpu = true;
     }
+  else if (implicit_cpu)
+    {
+      rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (implicit_cpu);
+      have_cpu = true;
+    }
   else
     {
-      const char *default_cpu =
-        (implicit_cpu ? implicit_cpu
-         : (TARGET_POWERPC64 ? "powerpc64" : "powerpc"));
-
+      const char *default_cpu = (TARGET_POWERPC64 ? "powerpc64" : "powerpc");
       rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (default_cpu);
-      have_cpu = implicit_cpu != 0;
+      have_cpu = false;
     }
 
   gcc_assert (cpu_index >= 0);
 
-  target_flags &= ~set_masks;
-  target_flags |= (processor_target_table[cpu_index].target_enable
-		   & set_masks);
+  /* If we have a cpu, either through an explicit -mcpu=<xxx> or if the
+     compiler was configured with --with-cpu=<xxx>, replace all of the ISA bits
+     with those from the cpu, except for options that were explicitly set.  If
+     we don't have a cpu, do not override the target bits set in
+     TARGET_DEFAULT.  */
+  if (have_cpu)
+    {
+      target_flags &= ~set_masks;
+      target_flags |= (processor_target_table[cpu_index].target_enable
+		       & set_masks);
+    }
+  else
+    target_flags |= (processor_target_table[cpu_index].target_enable
+		     & ~target_flags_explicit);
 
   if (rs6000_tune_index >= 0)
     tune_index = rs6000_tune_index;