Patchwork [4.7] Avoid global state in cris_handle_option

login
register
mail settings
Submitter Joseph S. Myers
Date March 3, 2011, 2:44 a.m.
Message ID <Pine.LNX.4.64.1103030243070.7166@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/85212/
State New
Headers show

Comments

Joseph S. Myers - March 3, 2011, 2:44 a.m.
This patch, for 4.7 and relative to a tree with
<http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01709.html> applied,
stops the CRIS handle_option hook from using global state.  There was
a macro CRIS_SUBTARGET_HANDLE_OPTION that did not have any parameters
for state pointers, and whose only definition was empty; since the
only definition was empty, I just removed the macro as useless rather
than changing its interface to add more unused parameters.

Tested building cc1 and xgcc for cross to cris-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-02  Joseph Myers  <joseph@codesourcery.com>

	* config/cris/cris.c (cris_handle_option): Access target_flags via
	opts pointer.  Don't assert that global structures are in use.
	Don't call CRIS_SUBTARGET_HANDLE_OPTION.
	* config/cris/cris.h (CRIS_SUBTARGET_HANDLE_OPTION): Don't define.

Patch

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/cris/cris.c gcc-mainline/gcc/config/cris/cris.c
--- gcc-mainline-1/gcc/config/cris/cris.c	2011-02-23 14:14:58.000000000 -0800
+++ gcc-mainline/gcc/config/cris/cris.c	2011-03-02 12:45:53.000000000 -0800
@@ -2340,28 +2340,24 @@  cris_asm_output_case_end (FILE *stream, 
    cris_option_override.  */
 
 static bool
-cris_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+cris_handle_option (struct gcc_options *opts,
+		    struct gcc_options *opts_set ATTRIBUTE_UNUSED,
 		    const struct cl_decoded_option *decoded,
 		    location_t loc ATTRIBUTE_UNUSED)
 {
   size_t code = decoded->opt_index;
-  const char *arg ATTRIBUTE_UNUSED = decoded->arg;
-  int value ATTRIBUTE_UNUSED = decoded->value;
-
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
 
   switch (code)
     {
     case OPT_metrax100:
-      target_flags
+      opts->x_target_flags
 	|= (MASK_SVINTO
 	    + MASK_ETRAX4_ADD
 	    + MASK_ALIGN_BY_32);
       break;
 
     case OPT_mno_etrax100:
-      target_flags
+      opts->x_target_flags
 	&= ~(MASK_SVINTO
 	     + MASK_ETRAX4_ADD
 	     + MASK_ALIGN_BY_32);
@@ -2369,7 +2365,7 @@  cris_handle_option (struct gcc_options *
 
     case OPT_m32_bit:
     case OPT_m32bit:
-      target_flags
+      opts->x_target_flags
 	|= (MASK_STACK_ALIGN
 	    + MASK_CONST_ALIGN
 	    + MASK_DATA_ALIGN
@@ -2378,7 +2374,7 @@  cris_handle_option (struct gcc_options *
 
     case OPT_m16_bit:
     case OPT_m16bit:
-      target_flags
+      opts->x_target_flags
 	|= (MASK_STACK_ALIGN
 	    + MASK_CONST_ALIGN
 	    + MASK_DATA_ALIGN);
@@ -2386,7 +2382,7 @@  cris_handle_option (struct gcc_options *
 
     case OPT_m8_bit:
     case OPT_m8bit:
-      target_flags
+      opts->x_target_flags
 	&= ~(MASK_STACK_ALIGN
 	     + MASK_CONST_ALIGN
 	     + MASK_DATA_ALIGN);
@@ -2396,8 +2392,6 @@  cris_handle_option (struct gcc_options *
       break;
     }
 
-  CRIS_SUBTARGET_HANDLE_OPTION(code, arg, value);
-
   return true;
 }
 
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/cris/cris.h gcc-mainline/gcc/config/cris/cris.h
--- gcc-mainline-1/gcc/config/cris/cris.h	2011-01-26 16:28:19.000000000 -0800
+++ gcc-mainline/gcc/config/cris/cris.h	2011-03-02 12:43:09.000000000 -0800
@@ -309,8 +309,6 @@  extern int cris_cpu_version;
 #define TARGET_HAS_SWAP (cris_cpu_version >= CRIS_CPU_SVINTO)
 #define TARGET_V32 (cris_cpu_version >= CRIS_CPU_V32)
 
-#define CRIS_SUBTARGET_HANDLE_OPTION(x, y, z)
-
 /* Node: Storage Layout */
 
 #define BITS_BIG_ENDIAN 0