diff options
author | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-13 10:08:50 +0000 |
---|---|---|
committer | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-13 10:08:50 +0000 |
commit | df423ec7770de59395c8d98dbd838c36f04cc164 (patch) | |
tree | 89563bd3c31401b7aa9c038829d9746e20a87a34 | |
parent | 1c6a437bd44020c37452b7fb4f565f7e7f94d56b (diff) | |
download | gcc-df423ec7770de59395c8d98dbd838c36f04cc164.tar.gz |
Support DEFPARAMENUM in params.def
2015-10-13 Tom de Vries <tom@codesourcery.com>
* Makefile.in (PARAMS_H, PLUGIN_HEADERS): Add params-enum.h.
* params-enum.h: New file.
* opts.c (handle_param): Handle case that param arg is a string.
* params-list.h: Handle DEFPARAMENUM5 in params.def.
* params.c (find_param): New function, factored out of ...
(set_param_value): ... here.
(param_string_value_p): New function.
* params.h (struct param_info): Add value_names field.
(find_param, param_string_value_p): Declare.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228755 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/Makefile.in | 6 | ||||
-rw-r--r-- | gcc/opts.c | 19 | ||||
-rw-r--r-- | gcc/params-enum.h | 39 | ||||
-rw-r--r-- | gcc/params-list.h | 3 | ||||
-rw-r--r-- | gcc/params.c | 97 | ||||
-rw-r--r-- | gcc/params.h | 6 |
7 files changed, 150 insertions, 32 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4632387b2ac..83e4bfadfd4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,17 @@ 2015-10-13 Tom de Vries <tom@codesourcery.com> + * Makefile.in (PARAMS_H, PLUGIN_HEADERS): Add params-enum.h. + * params-enum.h: New file. + * opts.c (handle_param): Handle case that param arg is a string. + * params-list.h: Handle DEFPARAMENUM5 in params.def. + * params.c (find_param): New function, factored out of ... + (set_param_value): ... here. + (param_string_value_p): New function. + * params.h (struct param_info): Add value_names field. + (find_param, param_string_value_p): Declare. + +2015-10-13 Tom de Vries <tom@codesourcery.com> + PR tree-optimization/67476 * omp-low.c (expand_omp_for_generic): Handle original loop tree. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 7e3aefac3fc..783e4c989ac 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -890,7 +890,7 @@ RTL_BASE_H = coretypes.h rtl.h rtl.def $(MACHMODE_H) reg-notes.def \ FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h -PARAMS_H = params.h params.def +PARAMS_H = params.h params-enum.h params.def BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \ gtm-builtins.def sanitizer.def cilkplus.def cilk-builtins.def INTERNAL_FN_DEF = internal-fn.def @@ -3260,8 +3260,8 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ tree-iterator.h $(PLUGIN_H) $(TREE_SSA_H) langhooks.h incpath.h debug.h \ $(EXCEPT_H) tree-ssa-sccvn.h real.h output.h $(IPA_UTILS_H) \ $(C_PRAGMA_H) $(CPPLIB_H) $(FUNCTION_H) \ - cppdefault.h flags.h $(MD5_H) params.def params.h prefix.h tree-inline.h \ - $(GIMPLE_PRETTY_PRINT_H) realmpfr.h \ + cppdefault.h flags.h $(MD5_H) params.def params.h params-enum.h \ + prefix.h tree-inline.h $(GIMPLE_PRETTY_PRINT_H) realmpfr.h \ $(IPA_PROP_H) $(TARGET_H) $(RTL_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) \ version.h stringpool.h gimplify.h gimple-iterator.h gimple-ssa.h \ fold-const.h tree-cfg.h tree-into-ssa.h tree-ssanames.h print-tree.h \ diff --git a/gcc/opts.c b/gcc/opts.c index 896875b40e4..89b3e793de6 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2128,14 +2128,21 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set, arg); else { - value = integral_argument (equal + 1); - if (value == -1) - error_at (loc, "invalid --param value %qs", equal + 1); + *equal = '\0'; + + enum compiler_param index; + if (!find_param (arg, &index)) + error_at (loc, "invalid --param name %qs", arg); else { - *equal = '\0'; - set_param_value (arg, value, - opts->x_param_values, opts_set->x_param_values); + if (!param_string_value_p (index, equal + 1, &value)) + value = integral_argument (equal + 1); + + if (value == -1) + error_at (loc, "invalid --param value %qs", equal + 1); + else + set_param_value (arg, value, + opts->x_param_values, opts_set->x_param_values); } } diff --git a/gcc/params-enum.h b/gcc/params-enum.h new file mode 100644 index 00000000000..a95e16c21e4 --- /dev/null +++ b/gcc/params-enum.h @@ -0,0 +1,39 @@ +/* params-enums.h - Run-time parameter enums. + Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) +#define DEFPARAMENUMNAME(ENUM) ENUM ## _KIND +#define DEFPARAMENUMVAL(ENUM, V) ENUM ## _KIND_ ## V +#define DEFPARAMENUMTERM(ENUM) ENUM ## _KIND_ ## LAST +#define DEFPARAMENUM5(ENUM, OPTION, HELP, DEFAULT, V0, V1, V2, V3, V4) \ + enum DEFPARAMENUMNAME (ENUM) \ + { \ + DEFPARAMENUMVAL (ENUM, V0), \ + DEFPARAMENUMVAL (ENUM, V1), \ + DEFPARAMENUMVAL (ENUM, V2), \ + DEFPARAMENUMVAL (ENUM, V3), \ + DEFPARAMENUMVAL (ENUM, V4), \ + DEFPARAMENUMTERM (ENUM) \ + }; +#include "params.def" +#undef DEFPARAMENUM5 +#undef DEFPARAMENUMTERM +#undef DEFPARAMENUMVAL +#undef DEFPARAMENUMNAME +#undef DEFPARAM diff --git a/gcc/params-list.h b/gcc/params-list.h index ee33ef52b36..fa768563384 100644 --- a/gcc/params-list.h +++ b/gcc/params-list.h @@ -19,5 +19,8 @@ along with GCC; see the file COPYING3. If not see #define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \ enumerator, +#define DEFPARAMENUM5(enumerator, option, nocmsgid, default, \ + v0, v1, v2, v3, v4) enumerator, #include "params.def" #undef DEFPARAM +#undef DEFPARAMENUM5 diff --git a/gcc/params.c b/gcc/params.c index b0bc80b1d26..d58d81edc88 100644 --- a/gcc/params.c +++ b/gcc/params.c @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "common/common-target.h" #include "params.h" +#include "params-enum.h" #include "diagnostic-core.h" /* An array containing the compiler parameters and their current @@ -37,12 +38,23 @@ static size_t num_compiler_params; default values determined. */ static bool params_finished; +#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) +#define DEFPARAMENUM5(ENUM, OPTION, HELP, DEFAULT, V0, V1, V2, V3, V4) \ + static const char *values_ ## ENUM [] = { #V0, #V1, #V2, #V3, #V4, NULL }; +#include "params.def" +#undef DEFPARAMENUM5 +#undef DEFPARAM + static const param_info lang_independent_params[] = { #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \ - { OPTION, DEFAULT, MIN, MAX, HELP }, + { OPTION, DEFAULT, MIN, MAX, HELP, NULL }, +#define DEFPARAMENUM5(ENUM, OPTION, HELP, DEFAULT, \ + V0, V1, V2, V3, V4) \ + { OPTION, (int)ENUM ## _KIND_ ## DEFAULT, 0, 4, HELP, values_ ## ENUM }, #include "params.def" #undef DEFPARAM - { NULL, 0, 0, 0, NULL } +#undef DEFPARAMENUM5 + { NULL, 0, 0, 0, NULL, NULL } }; /* Add the N PARAMS to the current list of compiler parameters. */ @@ -114,6 +126,45 @@ set_param_value_internal (compiler_param num, int value, params_set[i] = true; } +/* Return true if it can find the matching entry for NAME in the parameter + table, and assign the entry index to INDEX. Return false otherwise. */ + +bool +find_param (const char *name, enum compiler_param *index) +{ + for (size_t i = 0; i < num_compiler_params; ++i) + if (strcmp (compiler_params[i].option, name) == 0) + { + *index = (enum compiler_param) i; + return true; + } + + return false; +} + +/* Return true if param with entry index INDEX should be defined using strings. + If so, return the value corresponding to VALUE_NAME in *VALUE_P. */ + +bool +param_string_value_p (enum compiler_param index, const char *value_name, + int *value_p) +{ + param_info *entry = &compiler_params[(int) index]; + if (entry->value_names == NULL) + return false; + + *value_p = -1; + + for (int i = 0; entry->value_names[i] != NULL; ++i) + if (strcmp (entry->value_names[i], value_name) == 0) + { + *value_p = i; + return true; + } + + return true; +} + /* Set the VALUE associated with the parameter given by NAME in PARAMS and PARAMS_SET. */ @@ -126,27 +177,27 @@ set_param_value (const char *name, int value, /* Make sure nobody tries to set a parameter to an invalid value. */ gcc_assert (value != INVALID_PARAM_VAL); - /* Scan the parameter table to find a matching entry. */ - for (i = 0; i < num_compiler_params; ++i) - if (strcmp (compiler_params[i].option, name) == 0) - { - if (value < compiler_params[i].min_value) - error ("minimum value of parameter %qs is %u", - compiler_params[i].option, - compiler_params[i].min_value); - else if (compiler_params[i].max_value > compiler_params[i].min_value - && value > compiler_params[i].max_value) - error ("maximum value of parameter %qs is %u", - compiler_params[i].option, - compiler_params[i].max_value); - else - set_param_value_internal ((compiler_param) i, value, - params, params_set, true); - return; - } - - /* If we didn't find this parameter, issue an error message. */ - error ("invalid parameter %qs", name); + enum compiler_param index; + if (!find_param (name, &index)) + { + /* If we didn't find this parameter, issue an error message. */ + error ("invalid parameter %qs", name); + return; + } + i = (size_t)index; + + if (value < compiler_params[i].min_value) + error ("minimum value of parameter %qs is %u", + compiler_params[i].option, + compiler_params[i].min_value); + else if (compiler_params[i].max_value > compiler_params[i].min_value + && value > compiler_params[i].max_value) + error ("maximum value of parameter %qs is %u", + compiler_params[i].option, + compiler_params[i].max_value); + else + set_param_value_internal ((compiler_param) i, value, + params, params_set, true); } /* Set the value of the parameter given by NUM to VALUE in PARAMS and diff --git a/gcc/params.h b/gcc/params.h index 9f7618ac1d1..1090d009081 100644 --- a/gcc/params.h +++ b/gcc/params.h @@ -55,6 +55,9 @@ struct param_info /* A short description of the option. */ const char *const help; + + /* The optional names corresponding to the values. */ + const char **value_names; }; /* An array containing the compiler parameters and their current @@ -85,6 +88,9 @@ enum compiler_param LAST_PARAM }; +extern bool find_param (const char *, enum compiler_param *); +extern bool param_string_value_p (enum compiler_param, const char *, int *); + /* The value of the parameter given by ENUM. Not an lvalue. */ #define PARAM_VALUE(ENUM) \ ((int) global_options.x_param_values[(int) ENUM]) |