diff options
author | Tamar Christina <tamar.christina@arm.com> | 2018-10-01 13:06:53 +0000 |
---|---|---|
committer | Tamar Christina <tnfchris@gcc.gnu.org> | 2018-10-01 13:06:53 +0000 |
commit | 03ced4ab9f729cc4d5854439f136d84d1343b32d (patch) | |
tree | a8052683671f592c9b2edb6f58685170c945b8bd /gcc/common | |
parent | c98f502f0ab9e51357665d7afcad724feee6088b (diff) | |
download | gcc-03ced4ab9f729cc4d5854439f136d84d1343b32d.zip gcc-03ced4ab9f729cc4d5854439f136d84d1343b32d.tar.gz gcc-03ced4ab9f729cc4d5854439f136d84d1343b32d.tar.bz2 |
Allow back-ends to be able to do custom validations on params.
This patch adds the ability for backends to add custom constrains to the param
values by defining a new hook option_validate_param.
This hook is invoked on every set_param_value which allows the back-end to
ensure that the parameters are always within it's desired state.
gcc/
* params.c (set_param_value):
Add index of parameter being validated.
* common/common-target.def (option_validate_param): New.
* common/common-targhooks.h (default_option_validate_param): New.
* common/common-targhooks.c (default_option_validate_param): New.
* doc/tm.texi.in (TARGET_OPTION_VALIDATE_PARAM): New.
* doc/tm.texi: Regenerate.
From-SVN: r264755
Diffstat (limited to 'gcc/common')
-rw-r--r-- | gcc/common/common-target.def | 7 | ||||
-rw-r--r-- | gcc/common/common-targhooks.c | 9 | ||||
-rw-r--r-- | gcc/common/common-targhooks.h | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/gcc/common/common-target.def b/gcc/common/common-target.def index 019b1e7..8a268b6 100644 --- a/gcc/common/common-target.def +++ b/gcc/common/common-target.def @@ -56,6 +56,13 @@ DEFHOOK void, (void), hook_void_void) +DEFHOOK +(option_validate_param, +"Validate target-dependent value for @option{--param} settings, using\ + calls to @code{set_param_value}.", + 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 1b1a015..990c495 100644 --- a/gcc/common/common-targhooks.c +++ b/gcc/common/common-targhooks.c @@ -86,6 +86,15 @@ 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 4bdf8ef..b021ff0 100644 --- a/gcc/common/common-targhooks.h +++ b/gcc/common/common-targhooks.h @@ -30,6 +30,8 @@ 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 |