Patchwork Rs6000 infrastructure cleanup (switches), revised patch #2f

login
register
mail settings
Submitter Michael Meissner
Date Oct. 18, 2012, 11:06 p.m.
Message ID <20121018230650.GA28111@ibm-tiger.the-meissners.org>
Download mbox | patch
Permalink /patch/192475/
State New
Headers show

Comments

Michael Meissner - Oct. 18, 2012, 11:06 p.m.
On Thu, Oct 18, 2012 at 05:35:39PM -0400, Michael Meissner wrote:
> On Thu, Oct 18, 2012 at 09:08:34PM +0200, Dominique Dhumieres wrote:
> > > 2012-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
> > > 
> > > 	* config/rs6000/rs6000.opt (rs6000_isa_flags): New flag word to
> > > 	replace target_flags that gives us 63 possible switches.
> > > 	(x_rs6000_isa_flags): Save area for rs6000_isa_flags.
> > > 	(x_rs6000_isa_flags_explicit): Save area for
> > > ...
> > 
> > Bootstrap failed on powerpc-apple-darwin9 with
> 
> Just to let you know, I'm iterating on a patch right now.  There were 3 bugs
> with my checkin:
> 
> 1) The libobjc/encoding.c issue that Eric ran into.  The file encoding.c
>    includes compiler tm.h files, and then redefines stuff so that it doesn't
>    need the target option structure.  I have a bandaid to redefine TARGET_VSX,
>    TARGET_ALTIVEC, and TARGET_64BIT, but this file really cries out for an
>    Objective C user to reengineer and rewrite it so that it doesn't have to
>    include compiler internal files.
> 
> 2) The redefinition problem that Dominique found.  This was caused by moving
>    POWERPC_MASKS from rs6000.c to rs6000-cpus.def, where it more logically
>    belongs.  I think the right solution is to move the #ifdef to
>    rs6000-cpus.def instead of keeping it in rs6000.c.
> 
> 3) I forgot to update the -mdebug=reg support so it prints out the current
>    options once I swtiched from using target_flags to rs6000_isa_flags.  I
>    discovered this today, when doing some future work (that needs new
>    options).
> 
> I'll send out the patch if my bootstrap finishes.

The patch builds in 32-bit on my powerpc64-linux system (which showed up Eric's
problem).  I can't test the patch for Dominique's problem, since it needs a
non-linux system to show up.  I verified the debug problem:

Eric and Dominique could you try it on your respective systems?  Thanks in
advance.

[gcc]
2012-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000-cpus.def (POWERPC_MASKS): Don't assume
	OPTION_MASK_STRICT_ALIGN is defined.
	(MASK_STRICT_ALIGN): If OPTION_MASK_STRICT_ALIGN is not defined,
	define this to 0 for the 3 ports that use it.

	* config/rs6000/rs6000.c (OPTION_MASK_STRICT_ALIGN): Don't do
	check for ports not having -mstrict-align here, move test to
	rs6000-cpus.def.
	(MASK_STRICT_ALIGN): Likewise.
	(rs6000_debug_reg_global): Print out correct target flag words if
	-mdebug=reg.

[libobjc]
2012-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* encoding.c (TARGET_VSX): Provide definitions based on the
	current compilation options, and not based off the target options
	structure.
	(TARGET_ALTIVEC): Likewise.
	(TARGET_64BIT): Likewise.
David Edelsohn - Oct. 19, 2012, 1:41 a.m.
On Thu, Oct 18, 2012 at 7:06 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:

> 2012-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         * config/rs6000/rs6000-cpus.def (POWERPC_MASKS): Don't assume
>         OPTION_MASK_STRICT_ALIGN is defined.
>         (MASK_STRICT_ALIGN): If OPTION_MASK_STRICT_ALIGN is not defined,
>         define this to 0 for the 3 ports that use it.
>
>         * config/rs6000/rs6000.c (OPTION_MASK_STRICT_ALIGN): Don't do
>         check for ports not having -mstrict-align here, move test to
>         rs6000-cpus.def.
>         (MASK_STRICT_ALIGN): Likewise.
>         (rs6000_debug_reg_global): Print out correct target flag words if
>         -mdebug=reg.
>
> [libobjc]
> 2012-10-18  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         * encoding.c (TARGET_VSX): Provide definitions based on the
>         current compilation options, and not based off the target options
>         structure.
>         (TARGET_ALTIVEC): Likewise.
>         (TARGET_64BIT): Likewise.

This is okay if it passes.

Ah, yes, that Objective C issue again...

Thanks, David
Eric Botcazou - Oct. 19, 2012, 9:21 a.m.
> The patch builds in 32-bit on my powerpc64-linux system (which showed up
> Eric's problem).  I can't test the patch for Dominique's problem, since it
> needs a non-linux system to show up.  I verified the debug problem:
> 
> Eric and Dominique could you try it on your respective systems?  Thanks in
> advance.

It works for me, thanks.

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 192545)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -1121,10 +1121,6 @@  static const struct attribute_spec rs600
   { NULL,        0, 0, false, false, false, NULL, false }
 };
 
-#ifndef OPTION_MASK_STRICT_ALIGN
-#define OPTION_MASK_STRICT_ALIGN 0
-#define MASK_STRICT_ALIGN 0
-#endif
 #ifndef TARGET_PROFILE_KERNEL
 #define TARGET_PROFILE_KERNEL 0
 #endif
@@ -1805,10 +1801,11 @@  rs6000_debug_reg_global (void)
     fprintf (stderr, DEBUG_FMT_S, "tune", "<none>");
 
   cl_target_option_save (&cl_opts, &global_options);
-  rs6000_print_isa_options (stderr, 0, "target_flags", target_flags);
+  rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags",
+			    rs6000_isa_flags);
 
-  rs6000_print_isa_options (stderr, 0, "target_flags_explicit",
-			    target_flags_explicit);
+  rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags_explicit",
+			    rs6000_isa_flags_explicit);
 
   rs6000_print_builtin_options (stderr, 0, "rs6000_builtin_mask",
 				rs6000_builtin_mask);
Index: gcc/config/rs6000/rs6000-cpus.def
===================================================================
--- gcc/config/rs6000/rs6000-cpus.def	(revision 192545)
+++ gcc/config/rs6000/rs6000-cpus.def	(working copy)
@@ -46,6 +46,14 @@ 
 
 #define POWERPC_7400_MASK	(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_ALTIVEC)
 
+/* Deal with ports that do not have -mstrict-align.  */
+#ifdef OPTION_MASK_STRICT_ALIGN
+#define OPTION_MASK_STRICT_ALIGN_OPTIONAL OPTION_MASK_STRICT_ALIGN
+#else
+#define OPTION_MASK_STRICT_ALIGN_OPTIONAL 0
+#define MASK_STRICT_ALIGN 0
+#endif
+
 /* Mask of all options to set the default isa flags based on -mcpu=<xxx>.  */
 #define POWERPC_MASKS		(OPTION_MASK_ALTIVEC			\
 				 | OPTION_MASK_CMPB			\
@@ -64,7 +72,7 @@ 
 				 | OPTION_MASK_PPC_GPOPT		\
 				 | OPTION_MASK_RECIP_PRECISION		\
 				 | OPTION_MASK_SOFT_FLOAT		\
-				 | OPTION_MASK_STRICT_ALIGN		\
+				 | OPTION_MASK_STRICT_ALIGN_OPTIONAL	\
 				 | OPTION_MASK_VSX)
 
 #endif
Index: libobjc/encoding.c
===================================================================
--- libobjc/encoding.c	(revision 192545)
+++ libobjc/encoding.c	(working copy)
@@ -112,6 +112,32 @@  static int __attribute__ ((__unused__)) 
 #undef ALTIVEC_VECTOR_MODE
 #define ALTIVEC_VECTOR_MODE(MODE) (0)
 
+/* Replace TARGET_VSX, TARGET_ALTIVEC, and TARGET_64BIT with constants based on
+   the current switches, rather than looking in the options structure.  */
+#ifdef _ARCH_PPC
+#undef TARGET_VSX
+#undef TARGET_ALTIVEC
+#undef TARGET_64BIT
+
+#ifdef __VSX__
+#define TARGET_VSX 1
+#else
+#define TARGET_VSX 0
+#endif
+
+#ifdef __ALTIVEC__
+#define TARGET_ALTIVEC 1
+#else
+#define TARGET_ALTIVEC 0
+#endif
+
+#ifdef _ARCH_PPC64
+#define TARGET_64BIT 1
+#else
+#define TARGET_64BIT 0
+#endif
+#endif
+
 /* Furthermore, some (powerpc) targets also use TARGET_ALIGN_NATURAL
  in their alignment macros. Currently[4.5/6], rs6000.h points this
  to a static variable, initialized by target overrides. This is reset