This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 8/9] Remove option_default_params and option_validate_param hooks.


On 11/11/19 3:36 PM, Richard Biener wrote:
as a followup I notice that the targets *_default_params () functions should
be merged into the default-options structs they have (did you check the
defaults are still applied and user-overridable?)

Apparently, the *_default_params target hook is not called right now. So that
I decided to directly transform all usages of that to default-options structs.
I built all the affected cross compilers and checked --help=param -Q, where
I can see the overwritten default. Moreover, a param value can be properly
adjusted with a user option.

I'm running tests on x86_64-linux-gnu and ppc64-linux-gnu right now to check
affect of the attached patch.

Martin
>From c5cf7c135d93cfa07373e6469708b0f42f419ad5 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 12 Nov 2019 09:41:31 +0100
Subject: [PATCH 8/9] Remove option_default_params and option_validate_param
 hooks.

gcc/ChangeLog:

2019-11-12  Martin Liska  <mliska@suse.cz>

	* common/common-target.def: Remove option_validate_param and
	option_default_params.
	* common/common-targhooks.c (default_option_validate_param):
	Remove.
	* common/common-targhooks.h (default_option_validate_param):
	Remove.
	* common/config/aarch64/aarch64-common.c (TARGET_OPTION_DEFAULT_PARAMS):
	Remove usage of this.
	(TARGET_OPTION_VALIDATE_PARAM): Likewise.
	(aarch64_option_validate_param): Likewise.
	(aarch64_option_default_params): Likewise
	* common/config/bpf/bpf-common.c (bpf_option_default_params): Likewise.
	(TARGET_OPTION_DEFAULT_PARAMS): Likewise.
	* common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise.
	(TARGET_OPTION_DEFAULT_PARAMS): Likewise.
	* common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise.
	(TARGET_OPTION_DEFAULT_PARAMS): Likewise.
	* common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise.
	(TARGET_OPTION_DEFAULT_PARAMS): Likewise.
	* common/config/sh/sh-common.c (sh_option_default_params): Likewise.
	(TARGET_OPTION_DEFAULT_PARAMS): Likewise.
	* config/aarch64/aarch64.c (aarch64_override_options_internal): Validate
	guard_size here.
	* doc/tm.texi: Remove option_default_params and option_validate_param.
	* doc/tm.texi.in: Likewise.
---
 gcc/common/common-target.def                  | 12 -----
 gcc/common/common-targhooks.c                 |  9 ----
 gcc/common/common-targhooks.h                 |  2 -
 gcc/common/config/aarch64/aarch64-common.c    | 47 ++-----------------
 gcc/common/config/bpf/bpf-common.c            | 13 -----
 gcc/common/config/ia64/ia64-common.c          | 25 ++++------
 .../config/powerpcspe/powerpcspe-common.c     | 14 +-----
 gcc/common/config/rs6000/rs6000-common.c      | 15 ++----
 gcc/common/config/sh/sh-common.c              | 10 +---
 gcc/config/aarch64/aarch64.c                  | 12 ++---
 gcc/doc/tm.texi                               |  8 ----
 gcc/doc/tm.texi.in                            |  4 --
 12 files changed, 22 insertions(+), 149 deletions(-)

diff --git a/gcc/common/common-target.def b/gcc/common/common-target.def
index 48096720e44..de5e1c2265e 100644
--- a/gcc/common/common-target.def
+++ b/gcc/common/common-target.def
@@ -49,18 +49,6 @@ DEFHOOKPOD
  "",
  const struct default_options *, empty_optimization_table)
 
-DEFHOOK
-(option_default_params,
-"Set target-dependent default values for @option{--param} settings.",
- void, (void),
- hook_void_void)
-
-DEFHOOK
-(option_validate_param,
-"Validate target-dependent value for @option{--param} settings.",
- bool, (int, int),
- default_option_validate_param)
-
 /* The initial value of target_flags.  */
 DEFHOOKPOD
 (default_target_flags,
diff --git a/gcc/common/common-targhooks.c b/gcc/common/common-targhooks.c
index 9ed7822cab4..41626bad5d8 100644
--- a/gcc/common/common-targhooks.c
+++ b/gcc/common/common-targhooks.c
@@ -86,15 +86,6 @@ default_get_valid_option_values (int, const char *)
   return vec<const char *> ();
 }
 
-/* Default version of TARGET_OPTION_VALIDATE_PARAM.  */
-
-bool
-default_option_validate_param (const int value ATTRIBUTE_UNUSED,
-			       const int param ATTRIBUTE_UNUSED)
-{
-  return true;
-}
-
 const struct default_options empty_optimization_table[] =
   {
     { OPT_LEVELS_NONE, 0, NULL, 0 }
diff --git a/gcc/common/common-targhooks.h b/gcc/common/common-targhooks.h
index 18cfb5ab802..af0bffe0e8c 100644
--- a/gcc/common/common-targhooks.h
+++ b/gcc/common/common-targhooks.h
@@ -30,8 +30,6 @@ extern bool default_target_handle_option (struct gcc_options *,
 					  location_t);
 extern vec<const char *> default_get_valid_option_values (int, const char *);
 
-extern bool default_option_validate_param (const int, const int);
-
 extern const struct default_options empty_optimization_table[];
 
 #endif
diff --git a/gcc/common/config/aarch64/aarch64-common.c b/gcc/common/config/aarch64/aarch64-common.c
index b4ba6708af1..7e966f8fe5d 100644
--- a/gcc/common/config/aarch64/aarch64-common.c
+++ b/gcc/common/config/aarch64/aarch64-common.c
@@ -41,10 +41,6 @@
 
 #undef	TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE aarch_option_optimization_table
-#undef TARGET_OPTION_DEFAULT_PARAMS
-#define TARGET_OPTION_DEFAULT_PARAMS aarch64_option_default_params
-#undef TARGET_OPTION_VALIDATE_PARAM
-#define TARGET_OPTION_VALIDATE_PARAM aarch64_option_validate_param
 #undef TARGET_OPTION_INIT_STRUCT
 #define TARGET_OPTION_INIT_STRUCT aarch64_option_init_struct
 
@@ -63,49 +59,12 @@ static const struct default_options aarch_option_optimization_table[] =
     { OPT_LEVELS_ALL, OPT_fasynchronous_unwind_tables, NULL, 1 },
     { OPT_LEVELS_ALL, OPT_funwind_tables, NULL, 1},
 #endif
+    { OPT_LEVELS_ALL, OPT__param_stack_clash_protection_guard_size_, NULL,
+      DEFAULT_STK_CLASH_GUARD_SIZE == 0 ? 16 : DEFAULT_STK_CLASH_GUARD_SIZE },
+
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
-/* Implement target validation TARGET_OPTION_DEFAULT_PARAM.  */
-
-static bool
-aarch64_option_validate_param (const int value, const int param)
-{
-  /* Check that both parameters are the same.  */
-  if (param == param_stack_clash_protection_guard_size)
-    {
-      if (value != 12 && value != 16)
-	{
-	  error ("only values 12 (4 KB) and 16 (64 KB) are supported for guard "
-		 "size.  Given value %d (%llu KB) is out of range",
-		 value, (1ULL << value) / 1024ULL);
-	  return false;
-	}
-    }
-
-  return true;
-}
-
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-
-static void
-aarch64_option_default_params (void)
-{
-  /* We assume the guard page is 64k.  */
-  int index = (int) param_stack_clash_protection_guard_size;
-  param_stack_clash_protection_guard_size
-    = (DEFAULT_STK_CLASH_GUARD_SIZE == 0 ? 16 : DEFAULT_STK_CLASH_GUARD_SIZE);
-
-  int guard_size = param_stack_clash_protection_guard_size;
-
-  /* Set the interval parameter to be the same as the guard size.  This way the
-     mid-end code does the right thing for us.  */
-  param_stack_clash_protection_probe_interval = guard_size;
-
-  /* Validate the options.  */
-  aarch64_option_validate_param (guard_size, index);
-}
-
 /* Implement TARGET_HANDLE_OPTION.
    This function handles the target specific options for CPU/target selection.
 
diff --git a/gcc/common/config/bpf/bpf-common.c b/gcc/common/config/bpf/bpf-common.c
index 0d04f21b8f9..bd73933bf86 100644
--- a/gcc/common/config/bpf/bpf-common.c
+++ b/gcc/common/config/bpf/bpf-common.c
@@ -39,17 +39,4 @@ static const struct default_options bpf_option_optimization_table[] =
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE bpf_option_optimization_table
 
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-
-static void
-bpf_option_default_params (void)
-{
-  /* XXX large-stack-frame = 512 bytes */
-  /* XXX max-unrolled-insns */
-  /* XXX max-unroll-times */
-}
-
-#undef TARGET_OPTION_DEFAULT_PARAMS
-#define TARGET_OPTION_DEFAULT_PARAMS bpf_option_default_params
-
 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
diff --git a/gcc/common/config/ia64/ia64-common.c b/gcc/common/config/ia64/ia64-common.c
index a9ff29563a3..899cbb92db6 100644
--- a/gcc/common/config/ia64/ia64-common.c
+++ b/gcc/common/config/ia64/ia64-common.c
@@ -35,6 +35,14 @@ static const struct default_options ia64_option_optimization_table[] =
 #ifdef SUBTARGET_OPTIMIZATION_OPTIONS
     SUBTARGET_OPTIMIZATION_OPTIONS,
 #endif
+
+    /* Let the scheduler form additional regions.  */
+    { OPT_LEVELS_ALL, OPT__param_max_sched_extend_regions_iters_, NULL, 2 },
+      /* Set the default values for cache-related parameters.  */
+    { OPT_LEVELS_ALL, OPT__param_simultaneous_prefetches_, NULL, 6 },
+    { OPT_LEVELS_ALL, OPT__param_l1_cache_line_size_ , NULL, 32},
+    { OPT_LEVELS_ALL, OPT__param_sched_mem_true_dep_cost_, NULL, 4 },
+
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
@@ -81,25 +89,8 @@ ia64_except_unwind_info (struct gcc_options *opts)
   return UI_TARGET;
 }
 
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-
-static void
-ia64_option_default_params (void)
-{
-  /* Let the scheduler form additional regions.  */
-  param_max_sched_extend_regions_iters = 2;
-
-  /* Set the default values for cache-related parameters.  */
-  param_simultaneous_prefetches = 6;
-  param_l1_cache_line_size = 32;
-
-  param_sched_mem_true_dep_cost = 4;
-}
-
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE ia64_option_optimization_table
-#undef TARGET_OPTION_DEFAULT_PARAMS
-#define TARGET_OPTION_DEFAULT_PARAMS ia64_option_default_params
 
 #undef TARGET_EXCEPT_UNWIND_INFO
 #define TARGET_EXCEPT_UNWIND_INFO  ia64_except_unwind_info
diff --git a/gcc/common/config/powerpcspe/powerpcspe-common.c b/gcc/common/config/powerpcspe/powerpcspe-common.c
index 8976425b434..2ec5d9a0d88 100644
--- a/gcc/common/config/powerpcspe/powerpcspe-common.c
+++ b/gcc/common/config/powerpcspe/powerpcspe-common.c
@@ -32,6 +32,8 @@ static const struct default_options rs6000_option_optimization_table[] =
   {
     /* Enable -fsched-pressure for first pass instruction scheduling.  */
     { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 },
+    /* Double growth factor to counter reduced min jump length.  */
+    { OPT_LEVELS_ALL, OPT__param_max_grow_copy_bb_insns_, NULL, 16 },
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
@@ -50,15 +52,6 @@ rs6000_option_init_struct (struct gcc_options *opts)
     opts->x_flag_section_anchors = 1;
 }
 
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-
-static void
-rs6000_option_default_params (void)
-{
-  /* Double growth factor to counter reduced min jump length.  */
-  param_max_grow_copy_bb_insns = 16;
-}
-
 /* If not otherwise specified by a target, make 'long double' equivalent to
    'double'.  */
 
@@ -319,9 +312,6 @@ rs6000_supports_split_stack (bool report,
 #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
-
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
 
diff --git a/gcc/common/config/rs6000/rs6000-common.c b/gcc/common/config/rs6000/rs6000-common.c
index 250eca7ecf9..eb0328dee63 100644
--- a/gcc/common/config/rs6000/rs6000-common.c
+++ b/gcc/common/config/rs6000/rs6000-common.c
@@ -42,6 +42,9 @@ static const struct default_options rs6000_option_optimization_table[] =
        turn them off.  */
     { OPT_LEVELS_ALL, OPT_fweb, NULL, 0 },
     { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 },
+
+    /* Double growth factor to counter reduced min jump length.  */
+    { OPT_LEVELS_ALL, OPT__param_max_grow_copy_bb_insns_, NULL, 16 },
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
@@ -69,15 +72,6 @@ rs6000_option_init_struct (struct gcc_options *opts)
 #endif
 }
 
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-
-static void
-rs6000_option_default_params (void)
-{
-  /* Double growth factor to counter reduced min jump length.  */
-  param_max_grow_copy_bb_insns = 16;
-}
-
 /* If not otherwise specified by a target, make 'long double' equivalent to
    'double'.  */
 
@@ -271,9 +265,6 @@ rs6000_supports_split_stack (bool report,
 #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
-
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table
 
diff --git a/gcc/common/config/sh/sh-common.c b/gcc/common/config/sh/sh-common.c
index 104b1b4a304..f195753c70b 100644
--- a/gcc/common/config/sh/sh-common.c
+++ b/gcc/common/config/sh/sh-common.c
@@ -31,6 +31,7 @@ static const struct default_options sh_option_optimization_table[] =
   {
     { OPT_LEVELS_SIZE, OPT_mdiv_, SH_DIV_STR_FOR_SIZE, 1 },
     { OPT_LEVELS_0_ONLY, OPT_mdiv_, "", 1 },
+    { OPT_LEVELS_ALL, OPT__param_simultaneous_prefetches_, NULL, 2 },
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
@@ -144,17 +145,8 @@ sh_handle_option (struct gcc_options *opts,
     }
 }
 
-/* Implement TARGET_OPTION_DEFAULT_PARAMS.  */
-static void
-sh_option_default_params (void)
-{
-  param_simultaneous_prefetches = 2;
-}
-
 #undef TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE sh_option_optimization_table
-#undef TARGET_OPTION_DEFAULT_PARAMS
-#define TARGET_OPTION_DEFAULT_PARAMS sh_option_default_params
 #undef TARGET_DEFAULT_TARGET_FLAGS
 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
 #undef TARGET_HANDLE_OPTION
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 78e6bc0475e..d2a3c7ef90a 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -13340,16 +13340,14 @@ aarch64_override_options_internal (struct gcc_options *opts)
 		       param_sched_pressure_algorithm,
 		       SCHED_PRESSURE_MODEL);
 
-  /* If the user hasn't changed it via configure then set the default to 64 KB
-     for the backend.  */
-  SET_OPTION_IF_UNSET (opts, &global_options_set,
-		       param_stack_clash_protection_guard_size,
-		       (DEFAULT_STK_CLASH_GUARD_SIZE == 0
-			? 16 : DEFAULT_STK_CLASH_GUARD_SIZE));
-
   /* Validate the guard size.  */
   int guard_size = param_stack_clash_protection_guard_size;
 
+  if (guard_size != 12 && guard_size != 16)
+    error ("only values 12 (4 KB) and 16 (64 KB) are supported for guard "
+	   "size.  Given value %d (%llu KB) is out of range",
+	   guard_size, (1ULL << guard_size) / 1024ULL);
+
   /* Enforce that interval is the same size as size so the mid-end does the
      right thing.  */
   SET_OPTION_IF_UNSET (opts, &global_options_set,
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f6bc31bef65..11c236e1c65 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -758,14 +758,6 @@ options are changed via @code{#pragma GCC optimize} or by using the
 Set target-dependent initial values of fields in @var{opts}.
 @end deftypefn
 
-@deftypefn {Common Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void)
-Set target-dependent default values for @option{--param} settings.
-@end deftypefn
-
-@deftypefn {Common Target Hook} bool TARGET_OPTION_VALIDATE_PARAM (int, @var{int})
-Validate target-dependent value for @option{--param} settings.
-@end deftypefn
-
 @defmac SWITCHABLE_TARGET
 Some targets need to switch between substantially different subtargets
 during compilation.  For example, the MIPS target has one subtarget for
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 2739e9ceec5..b8c41b5a7aa 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -736,10 +736,6 @@ options are changed via @code{#pragma GCC optimize} or by using the
 
 @hook TARGET_OPTION_INIT_STRUCT
 
-@hook TARGET_OPTION_DEFAULT_PARAMS
-
-@hook TARGET_OPTION_VALIDATE_PARAM
-
 @defmac SWITCHABLE_TARGET
 Some targets need to switch between substantially different subtargets
 during compilation.  For example, the MIPS target has one subtarget for
-- 
2.24.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]