target.def (target_option.init_struct): New hook.
authorJoseph Myers <joseph@codesourcery.com>
Fri, 15 Oct 2010 19:19:05 +0000 (20:19 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Fri, 15 Oct 2010 19:19:05 +0000 (20:19 +0100)
* target.def (target_option.init_struct): New hook.
* doc/tm.texi.in (TARGET_OPTION_INIT_STRUCT): New @hook.
* doc/tm.texi: Regenerate.
* hooks.c (hook_void_gcc_optionsp): New.
* hooks.h (hook_void_gcc_optionsp): Declare.
* langhooks-def.h (lhd_init_options_struct): Remove.
(LANG_HOOKS_INIT_OPTIONS_STRUCT): Define to
hook_void_gcc_optionsp.
* langhooks.c (lhd_init_options_struct): Remove.
* opts.c (init_options_struct): Also call
targetm.target_option.init_struct.
* config/i386/i386.c (ix86_option_init_struct,
TARGET_OPTION_INIT_STRUCT): New.
(ix86_option_optimization): Move some settings to
ix86_option_init_struct.
* config/pdp11/pdp11.c (pdp11_option_init_struct,
TARGET_OPTION_INIT_STRUCT): New.
(pdp11_option_optimization): Move some settings to
pdp11_option_init_struct.
* config/rs6000/rs6000.c (rs6000_option_optimization): Replace by
rs6000_option_init_struct.  Use options structure pointer.
(TARGET_OPTION_OPTIMIZATION): Replace by
TARGET_OPTION_INIT_STRUCT.
* config/s390/s390.c (s390_option_init_struct,
TARGET_OPTION_INIT_STRUCT): New.
(s390_option_optimization): Don't set
flag_asynchronous_unwind_tables here.
* config/sh/sh.c (sh_option_init_struct,
TARGET_OPTION_INIT_STRUCT): New.
(sh_option_optimization): Don't set flag_finite_math_only here.
* config/spu/spu.c (spu_option_optimization): Replace by
spu_option_optimization.  Use options structure pointer.
(TARGET_OPTION_OPTIMIZATION): Replace by
TARGET_OPTION_INIT_STRUCT.

From-SVN: r165519

15 files changed:
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/pdp11/pdp11.c
gcc/config/rs6000/rs6000.c
gcc/config/s390/s390.c
gcc/config/sh/sh.c
gcc/config/spu/spu.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/hooks.c
gcc/hooks.h
gcc/langhooks-def.h
gcc/langhooks.c
gcc/opts.c
gcc/target.def

index 3c9a6d03db1678713446d2edd78d1d8357fe0566..d702bf0775eeb241713769200391a6309552f18a 100644 (file)
@@ -1,3 +1,40 @@
+2010-10-15  Joseph Myers  <joseph@codesourcery.com>
+
+       * target.def (target_option.init_struct): New hook.
+       * doc/tm.texi.in (TARGET_OPTION_INIT_STRUCT): New @hook.
+       * doc/tm.texi: Regenerate.
+       * hooks.c (hook_void_gcc_optionsp): New.
+       * hooks.h (hook_void_gcc_optionsp): Declare.
+       * langhooks-def.h (lhd_init_options_struct): Remove.
+       (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define to
+       hook_void_gcc_optionsp.
+       * langhooks.c (lhd_init_options_struct): Remove.
+       * opts.c (init_options_struct): Also call
+       targetm.target_option.init_struct.
+       * config/i386/i386.c (ix86_option_init_struct,
+       TARGET_OPTION_INIT_STRUCT): New.
+       (ix86_option_optimization): Move some settings to
+       ix86_option_init_struct.
+       * config/pdp11/pdp11.c (pdp11_option_init_struct,
+       TARGET_OPTION_INIT_STRUCT): New.
+       (pdp11_option_optimization): Move some settings to
+       pdp11_option_init_struct.
+       * config/rs6000/rs6000.c (rs6000_option_optimization): Replace by
+       rs6000_option_init_struct.  Use options structure pointer.
+       (TARGET_OPTION_OPTIMIZATION): Replace by
+       TARGET_OPTION_INIT_STRUCT.
+       * config/s390/s390.c (s390_option_init_struct,
+       TARGET_OPTION_INIT_STRUCT): New.
+       (s390_option_optimization): Don't set
+       flag_asynchronous_unwind_tables here.
+       * config/sh/sh.c (sh_option_init_struct,
+       TARGET_OPTION_INIT_STRUCT): New.
+       (sh_option_optimization): Don't set flag_finite_math_only here.
+       * config/spu/spu.c (spu_option_optimization): Replace by
+       spu_option_optimization.  Use options structure pointer.
+       (TARGET_OPTION_OPTIMIZATION): Replace by
+       TARGET_OPTION_INIT_STRUCT.
+
 2010-10-14  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * doc/md.texi (Standard Names): Add fma@var{m}4 documentation.
index 91e383938901a55e85e3fa3e01990d24176e0d58..4536ef22ea8211b21e0030c50e191c5ecfb45107 100644 (file)
@@ -4537,11 +4537,6 @@ ix86_option_optimization (int level, int size ATTRIBUTE_UNUSED)
     flag_schedule_insns = 0;
 #endif
 
-  if (TARGET_MACHO)
-    /* The Darwin libraries never set errno, so we might as well
-       avoid calling them when that's the only reason we would.  */
-    flag_errno_math = 0;
-
   /* The default values of these switches depend on the TARGET_64BIT
      that is not known at this moment.  Mark these values with 2 and
      let user the to override these.  In case there is no command line
@@ -4554,14 +4549,26 @@ ix86_option_optimization (int level, int size ATTRIBUTE_UNUSED)
   if (level > 1)
     flag_zee = 2;
 
-  flag_pcc_struct_return = 2;
-  flag_asynchronous_unwind_tables = 2;
-  flag_vect_cost_model = 1;
 #ifdef SUBTARGET_OPTIMIZATION_OPTIONS
   SUBTARGET_OPTIMIZATION_OPTIONS;
 #endif
 }
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
+static void
+ix86_option_init_struct (struct gcc_options *opts)
+{
+  if (TARGET_MACHO)
+    /* The Darwin libraries never set errno, so we might as well
+       avoid calling them when that's the only reason we would.  */
+    opts->x_flag_errno_math = 0;
+
+  opts->x_flag_pcc_struct_return = 2;
+  opts->x_flag_asynchronous_unwind_tables = 2;
+  opts->x_flag_vect_cost_model = 1;
+}
+
 /* Decide whether we must probe the stack before any space allocation
    on this target.  It's essentially TARGET_STACK_PROBE except when
    -fstack-check causes the stack to be already probed differently.  */
@@ -33269,6 +33276,8 @@ ix86_autovectorize_vector_sizes (void)
 #define TARGET_OPTION_OVERRIDE ix86_option_override
 #undef TARGET_OPTION_OPTIMIZATION
 #define TARGET_OPTION_OPTIMIZATION ix86_option_optimization
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT ix86_option_init_struct
 
 #undef TARGET_REGISTER_MOVE_COST
 #define TARGET_REGISTER_MOVE_COST ix86_register_move_cost
index 651b0cc6012382ebf3804b0897b0acdf194a3771..e6b41596c13b3d7037aef0da6f6196cc20abd633 100644 (file)
@@ -146,6 +146,7 @@ decode_pdp11_d (const struct real_format *fmt ATTRIBUTE_UNUSED,
 
 static bool pdp11_handle_option (size_t, const char *, int);
 static void pdp11_option_optimization (int, int);
+static void pdp11_option_init_struct (struct gcc_options *);
 static rtx find_addr_reg (rtx); 
 static const char *singlemove_string (rtx *);
 static bool pdp11_assemble_integer (rtx, unsigned int, int);
@@ -189,6 +190,8 @@ static void pdp11_function_arg_advance (CUMULATIVE_ARGS *,
 #define TARGET_HANDLE_OPTION pdp11_handle_option
 #undef TARGET_OPTION_OPTIMIZATION
 #define TARGET_OPTION_OPTIMIZATION pdp11_option_optimization
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT pdp11_option_init_struct
 
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS pdp11_rtx_costs
@@ -235,9 +238,6 @@ pdp11_handle_option (size_t code, const char *arg ATTRIBUTE_UNUSED,
 static void
 pdp11_option_optimization (int level, int size ATTRIBUTE_UNUSED)
 {
-  flag_finite_math_only = 0;
-  flag_trapping_math = 0;
-  flag_signaling_nans = 0;
   if (level >= 3)
     {
       flag_omit_frame_pointer = 1;
@@ -245,6 +245,16 @@ pdp11_option_optimization (int level, int size ATTRIBUTE_UNUSED)
     }
 }
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
+static void
+pdp11_option_init_struct (struct gcc_options *opts)
+{
+  opts->x_flag_finite_math_only = 0;
+  opts->x_flag_trapping_math = 0;
+  opts->x_flag_signaling_nans = 0;
+}
+
 /* Nonzero if OP is a valid second operand for an arithmetic insn.  */
 
 int
index f97730181272dd4ff91c622dab4e5b6a46da6ece..a1baa592fa9b1498db8759e7596d01ec943341e4 100644 (file)
@@ -1136,7 +1136,7 @@ static rtx altivec_expand_vec_set_builtin (tree);
 static rtx altivec_expand_vec_ext_builtin (tree, rtx);
 static int get_element_number (tree, tree);
 static void rs6000_option_override (void);
-static void rs6000_option_optimization (int, int);
+static void rs6000_option_init_struct (struct gcc_options *);
 static void rs6000_option_default_params (void);
 static bool rs6000_handle_option (size_t, const char *, int);
 static void rs6000_parse_tls_size_option (void);
@@ -1602,8 +1602,8 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE rs6000_option_override
 
-#undef TARGET_OPTION_OPTIMIZATION
-#define TARGET_OPTION_OPTIMIZATION rs6000_option_optimization
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct
 
 #undef TARGET_OPTION_DEFAULT_PARAMS
 #define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params
@@ -3681,18 +3681,19 @@ rs6000_parse_tls_size_option (void)
     error ("bad value %qs for -mtls-size switch", rs6000_tls_size_string);
 }
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
 static void
-rs6000_option_optimization (int level ATTRIBUTE_UNUSED,
-                           int size ATTRIBUTE_UNUSED)
+rs6000_option_init_struct (struct gcc_options *opts)
 {
   if (DEFAULT_ABI == ABI_DARWIN)
     /* The Darwin libraries never set errno, so we might as well
        avoid calling them when that's the only reason we would.  */
-    flag_errno_math = 0;
+    opts->x_flag_errno_math = 0;
 
   /* Enable section anchors by default.  */
   if (!TARGET_MACHO)
-    flag_section_anchors = 2;
+    opts->x_flag_section_anchors = 2;
 }
 
 /* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
index 8aabe1175e8260aff5459c15c5a32954bdd46d00..be26fbd6073c2436da1e42768230d1742dbe9239 100644 (file)
@@ -1503,15 +1503,21 @@ s390_option_optimization (int level ATTRIBUTE_UNUSED, int size)
   /* ??? There are apparently still problems with -fcaller-saves.  */
   flag_caller_saves = 0;
 
-  /* By default, always emit DWARF-2 unwind info.  This allows debugging
-     without maintaining a stack frame back-chain.  */
-  flag_asynchronous_unwind_tables = 1;
-
   /* Use MVCLE instructions to decrease code size if requested.  */
   if (size != 0)
     target_flags |= MASK_MVCLE;
 }
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+
+static void
+s390_option_init_struct (struct gcc_options *opts)
+{
+  /* By default, always emit DWARF-2 unwind info.  This allows debugging
+     without maintaining a stack frame back-chain.  */
+  opts->x_flag_asynchronous_unwind_tables = 1;
+}
+
 /* Return true if ARG is the name of a processor.  Set *TYPE and *FLAGS
    to the associated processor_type and processor_flags if so.  */
 
@@ -10507,6 +10513,9 @@ s390_loop_unroll_adjust (unsigned nunroll, struct loop *loop)
 #undef TARGET_OPTION_OPTIMIZATION
 #define TARGET_OPTION_OPTIMIZATION s390_option_optimization
 
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT s390_option_init_struct
+
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO s390_encode_section_info
 
index 53b70ec83e8b8f007dfcb6f3f834d07783cc55f2..41cc8b7a8a681b4ecefb94b7c80a829dc288439c 100644 (file)
@@ -184,6 +184,7 @@ static rtx gen_block_redirect (rtx, int, int);
 static void sh_reorg (void);
 static void sh_option_override (void);
 static void sh_option_optimization (int, int);
+static void sh_option_init_struct (struct gcc_options *);
 static void sh_option_default_params (void);
 static void output_stack_adjust (int, rtx, int, HARD_REG_SET *, bool);
 static rtx frame_insn (rtx);
@@ -343,6 +344,8 @@ static const struct attribute_spec sh_attribute_table[] =
 #define TARGET_OPTION_OVERRIDE sh_option_override
 #undef TARGET_OPTION_OPTIMIZATION
 #define TARGET_OPTION_OPTIMIZATION sh_option_optimization
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT sh_option_init_struct
 #undef TARGET_OPTION_DEFAULT_PARAMS
 #define TARGET_OPTION_DEFAULT_PARAMS sh_option_default_params
 
@@ -725,17 +728,23 @@ sh_option_optimization (int level, int size)
       if (!size)
        target_flags |= MASK_SAVE_ALL_TARGET_REGS;
     }
-  /* Likewise, we can't meaningfully test TARGET_SH2E / TARGET_IEEE
-     here, so leave it to TARGET_OPTION_OVERRIDE to set
-    flag_finite_math_only.  We set it to 2 here so we know if the user
-    explicitly requested this to be on or off.  */
-  flag_finite_math_only = 2;
   /* If flag_schedule_insns is 1, we set it to 2 here so we know if
      the user explicitly requested this to be on or off.  */
   if (flag_schedule_insns > 0)
     flag_schedule_insns = 2;
 }
 
+/* Implement TARGET_OPTION_INIT_STRUCT.  */
+static void
+sh_option_init_struct (struct gcc_options *opts)
+{
+  /* We can't meaningfully test TARGET_SH2E / TARGET_IEEE
+     here, so leave it to TARGET_OPTION_OVERRIDE to set
+     flag_finite_math_only.  We set it to 2 here so we know if the user
+     explicitly requested this to be on or off.  */
+  opts->x_flag_finite_math_only = 2;
+}
+
 /* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
 static void
 sh_option_default_params (void)
index f9e5c82ea7a9385ac76b116f0572f82ca3547b26..254bd652bb08aa33517550752b0609f4d80fdcd4 100644 (file)
@@ -150,7 +150,7 @@ char regs_ever_allocated[FIRST_PSEUDO_REGISTER];
 
 /*  Prototypes and external defs.  */
 static void spu_option_override (void);
-static void spu_option_optimization (int, int);
+static void spu_option_init_struct (struct gcc_options *opts);
 static void spu_option_default_params (void);
 static void spu_init_builtins (void);
 static tree spu_builtin_decl (unsigned, bool);
@@ -480,8 +480,8 @@ static const struct attribute_spec spu_attribute_table[] =
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE spu_option_override
 
-#undef TARGET_OPTION_OPTIMIZATION
-#define TARGET_OPTION_OPTIMIZATION spu_option_optimization
+#undef TARGET_OPTION_INIT_STRUCT
+#define TARGET_OPTION_INIT_STRUCT spu_option_init_struct
 
 #undef TARGET_OPTION_DEFAULT_PARAMS
 #define TARGET_OPTION_DEFAULT_PARAMS spu_option_default_params
@@ -492,10 +492,10 @@ static const struct attribute_spec spu_attribute_table[] =
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 static void
-spu_option_optimization (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED)
+spu_option_init_struct (struct gcc_options *opts)
 {
   /* With so many registers this is better on by default. */
-  flag_rename_registers = 1;
+  opts->x_flag_rename_registers = 1;
 }
 
 /* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
index a268617f7a1b378a6372a6c4f8b7386a996d542a..7c15d95f6beb25b2feed2a5d17e915a00f460150 100644 (file)
@@ -812,6 +812,10 @@ this hook!}  The debugging options are not supposed to alter the
 generated code.
 @end deftypefn
 
+@deftypefn {Target Hook} void TARGET_OPTION_INIT_STRUCT (struct gcc_options *@var{opts})
+Set target-dependent initial values of fields in @var{opts}.
+@end deftypefn
+
 @deftypefn {Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void)
 Set target-dependent default values for @option{--param} settings, using calls to @code{set_default_param_value}.
 @end deftypefn
index 74cf927f3982542bbf2ec1f7080e7308c257367d..938ff6aeba1a5410d57613a0b0bf5d29383c284e 100644 (file)
@@ -812,6 +812,8 @@ this hook!}  The debugging options are not supposed to alter the
 generated code.
 @end deftypefn
 
+@hook TARGET_OPTION_INIT_STRUCT
+
 @hook TARGET_OPTION_DEFAULT_PARAMS
 
 @hook TARGET_HELP
index 9969bce177be9c3aba4d8cb210ec5dd152b8b5a3..19e294fcbd2b9c5508524af614c9a9deed355504 100644 (file)
@@ -360,3 +360,10 @@ void
 hook_void_rtx_int (rtx insn ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
 {
 }
+
+/* Generic hook that takes a struct gcc_options * and returns void.  */
+
+void
+hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
+{
+}
index de18b86423f9e1beb75dc3600b743ee43168f638..5bfa1ad047eea3595f7433d6c5e79b710d2a2284 100644 (file)
@@ -61,6 +61,7 @@ extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
 extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 extern void hook_void_int_int (int, int);
+extern void hook_void_gcc_optionsp (struct gcc_options *);
 
 extern int hook_int_const_tree_0 (const_tree);
 extern int hook_int_const_tree_const_tree_1 (const_tree, const_tree);
index 469cc46cbce0bf4d715db4057f9ff1f15ccc7833..ceff0b92c257c1c14f3f79416aac1eb56c3a93c3 100644 (file)
@@ -65,7 +65,6 @@ extern tree lhd_builtin_function (tree);
 
 /* Declarations of default tree inlining hooks.  */
 extern void lhd_initialize_diagnostics (diagnostic_context *);
-extern void lhd_init_options_struct (struct gcc_options *);
 extern void lhd_init_options (unsigned int,
                              struct cl_decoded_option *);
 extern bool lhd_complain_wrong_lang_p (const struct cl_option *);
@@ -88,7 +87,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 #define LANG_HOOKS_FINISH              lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE          lhd_do_nothing_i
 #define LANG_HOOKS_OPTION_LANG_MASK    hook_uint_void_0
-#define LANG_HOOKS_INIT_OPTIONS_STRUCT lhd_init_options_struct
+#define LANG_HOOKS_INIT_OPTIONS_STRUCT hook_void_gcc_optionsp
 #define LANG_HOOKS_INIT_OPTIONS                lhd_init_options
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lhd_complain_wrong_lang_p
index 2217a248a738eeef5b7a694c98136df83a8c2c6a..76c066bfaa3793ec1044e7ce50fadc3353e32c44 100644 (file)
@@ -337,12 +337,6 @@ lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED)
 {
 }
 
-/* Called to perform language-specific options initialization of OPTS.  */
-void
-lhd_init_options_struct (struct gcc_options *opts ATTRIBUTE_UNUSED)
-{
-}
-
 /* Called to perform language-specific options initialization.  */
 void
 lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
index 6807123062501299f53d0fe62d90d57815f25c2f..81514ba7075bd0180e9bfa1c7e21eee97820e127 100644 (file)
@@ -695,6 +695,9 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
 
   /* Some targets have ABI-specified unwind tables.  */
   opts->x_flag_unwind_tables = targetm.unwind_tables_default;
+
+  /* Some targets have other target-specific initialization.  */
+  targetm.target_option.init_struct (opts);
 }
 
 /* Decode command-line options to an array, like
index f7ad80b7b8ab207e1df869534def45957cf147d5..186950ec2eddb6cdd804ca0eb1243fe9f0ec8f88 100644 (file)
@@ -2356,6 +2356,12 @@ DEFHOOK
  void, (void),
  hook_void_void)
 
+DEFHOOK
+(init_struct,
+"Set target-dependent initial values of fields in @var{opts}.",
+ void, (struct gcc_options *opts),
+ hook_void_gcc_optionsp)
+
 /* Function to determine if one function can inline another function.  */
 #undef HOOK_PREFIX
 #define HOOK_PREFIX "TARGET_"