Commit d78182cc by Tom de Vries Committed by Tom de Vries

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.

From-SVN: r228755
parent 7fd103ef
2015-10-13 Tom de Vries <tom@codesourcery.com> 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 PR tree-optimization/67476
* omp-low.c (expand_omp_for_generic): Handle original loop tree. * omp-low.c (expand_omp_for_generic): Handle original loop tree.
...@@ -890,7 +890,7 @@ RTL_BASE_H = coretypes.h rtl.h rtl.def $(MACHMODE_H) reg-notes.def \ ...@@ -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 FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h
RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h
READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.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 \ BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \
gtm-builtins.def sanitizer.def cilkplus.def cilk-builtins.def gtm-builtins.def sanitizer.def cilkplus.def cilk-builtins.def
INTERNAL_FN_DEF = internal-fn.def INTERNAL_FN_DEF = internal-fn.def
...@@ -3260,8 +3260,8 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ ...@@ -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 \ 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) \ $(EXCEPT_H) tree-ssa-sccvn.h real.h output.h $(IPA_UTILS_H) \
$(C_PRAGMA_H) $(CPPLIB_H) $(FUNCTION_H) \ $(C_PRAGMA_H) $(CPPLIB_H) $(FUNCTION_H) \
cppdefault.h flags.h $(MD5_H) params.def params.h prefix.h tree-inline.h \ cppdefault.h flags.h $(MD5_H) params.def params.h params-enum.h \
$(GIMPLE_PRETTY_PRINT_H) realmpfr.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) \ $(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 \ 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 \ fold-const.h tree-cfg.h tree-into-ssa.h tree-ssanames.h print-tree.h \
......
...@@ -2128,12 +2128,19 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set, ...@@ -2128,12 +2128,19 @@ handle_param (struct gcc_options *opts, struct gcc_options *opts_set,
arg); arg);
else else
{ {
*equal = '\0';
enum compiler_param index;
if (!find_param (arg, &index))
error_at (loc, "invalid --param name %qs", arg);
else
{
if (!param_string_value_p (index, equal + 1, &value))
value = integral_argument (equal + 1); value = integral_argument (equal + 1);
if (value == -1) if (value == -1)
error_at (loc, "invalid --param value %qs", equal + 1); error_at (loc, "invalid --param value %qs", equal + 1);
else else
{
*equal = '\0';
set_param_value (arg, value, set_param_value (arg, value,
opts->x_param_values, opts_set->x_param_values); opts->x_param_values, opts_set->x_param_values);
} }
......
/* 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
...@@ -19,5 +19,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -19,5 +19,8 @@ along with GCC; see the file COPYING3. If not see
#define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \ #define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \
enumerator, enumerator,
#define DEFPARAMENUM5(enumerator, option, nocmsgid, default, \
v0, v1, v2, v3, v4) enumerator,
#include "params.def" #include "params.def"
#undef DEFPARAM #undef DEFPARAM
#undef DEFPARAMENUM5
...@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h" #include "coretypes.h"
#include "common/common-target.h" #include "common/common-target.h"
#include "params.h" #include "params.h"
#include "params-enum.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
/* An array containing the compiler parameters and their current /* An array containing the compiler parameters and their current
...@@ -37,12 +38,23 @@ static size_t num_compiler_params; ...@@ -37,12 +38,23 @@ static size_t num_compiler_params;
default values determined. */ default values determined. */
static bool params_finished; 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[] = { static const param_info lang_independent_params[] = {
#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \ #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" #include "params.def"
#undef DEFPARAM #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. */ /* Add the N PARAMS to the current list of compiler parameters. */
...@@ -114,6 +126,45 @@ set_param_value_internal (compiler_param num, int value, ...@@ -114,6 +126,45 @@ set_param_value_internal (compiler_param num, int value,
params_set[i] = true; 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 /* Set the VALUE associated with the parameter given by NAME in PARAMS
and PARAMS_SET. */ and PARAMS_SET. */
...@@ -126,10 +177,15 @@ set_param_value (const char *name, int value, ...@@ -126,10 +177,15 @@ set_param_value (const char *name, int value,
/* Make sure nobody tries to set a parameter to an invalid value. */ /* Make sure nobody tries to set a parameter to an invalid value. */
gcc_assert (value != INVALID_PARAM_VAL); gcc_assert (value != INVALID_PARAM_VAL);
/* Scan the parameter table to find a matching entry. */ enum compiler_param index;
for (i = 0; i < num_compiler_params; ++i) if (!find_param (name, &index))
if (strcmp (compiler_params[i].option, name) == 0)
{ {
/* 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) if (value < compiler_params[i].min_value)
error ("minimum value of parameter %qs is %u", error ("minimum value of parameter %qs is %u",
compiler_params[i].option, compiler_params[i].option,
...@@ -142,11 +198,6 @@ set_param_value (const char *name, int value, ...@@ -142,11 +198,6 @@ set_param_value (const char *name, int value,
else else
set_param_value_internal ((compiler_param) i, value, set_param_value_internal ((compiler_param) i, value,
params, params_set, true); params, params_set, true);
return;
}
/* If we didn't find this parameter, issue an error message. */
error ("invalid parameter %qs", name);
} }
/* Set the value of the parameter given by NUM to VALUE in PARAMS and /* Set the value of the parameter given by NUM to VALUE in PARAMS and
......
...@@ -55,6 +55,9 @@ struct param_info ...@@ -55,6 +55,9 @@ struct param_info
/* A short description of the option. */ /* A short description of the option. */
const char *const help; const char *const help;
/* The optional names corresponding to the values. */
const char **value_names;
}; };
/* An array containing the compiler parameters and their current /* An array containing the compiler parameters and their current
...@@ -85,6 +88,9 @@ enum compiler_param ...@@ -85,6 +88,9 @@ enum compiler_param
LAST_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. */ /* The value of the parameter given by ENUM. Not an lvalue. */
#define PARAM_VALUE(ENUM) \ #define PARAM_VALUE(ENUM) \
((int) global_options.x_param_values[(int) ENUM]) ((int) global_options.x_param_values[(int) ENUM])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment