aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-10-14 11:22:43 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-10-14 11:22:43 +0100
commit48476d13b2878a02ffcb38df139594a2477989f1 (patch)
tree9b340b8d6c331d28e231ef93373d6e4219525626
parent4af476d7f2d3571c981b629995d3b3f1f8ffd3ab (diff)
downloadgcc-48476d13b2878a02ffcb38df139594a2477989f1.zip
gcc-48476d13b2878a02ffcb38df139594a2477989f1.tar.gz
gcc-48476d13b2878a02ffcb38df139594a2477989f1.tar.bz2
params.c (params_finished): New.
* params.c (params_finished): New. (add_params): Assert !params_finished. (finish_params): New. (set_param_value_internal): Take params and params_set parameters. Assert params_finished. (set_param_value, maybe_set_param_value): Take params and params_set parameters. Update calls to set_param_value_internal. (set_default_param_value): Assert !params_finished. Don't use set_param_value_internal. (default_param_value, init_param_values): New. * params.h (struct param_info): Change value to default_value. Remove set. (set_param_value, maybe_set_param_value): Add params and params_set parameters. (PARAM_VALUE): Get parameters from global_options. (PARAM_SET_P): Remove. (finish_params, default_param_value, init_param_values): New. * common.opt (param_values): New Variable. * config/arm/arm.c (arm_option_override): Pass extra arguments to maybe_set_param_value. * config/i386/i386.c (ix86_option_override_internal): Pass extra arguments to maybe_set_param_value. * config/picochip/picochip.c (picochip_option_override): Pass extra arguments to maybe_set_param_value. * config/rs6000/rs6000.c (rs6000_option_override_internal): Pass extra arguments to maybe_set_param_value. * config/s390/s390.c (s390_option_override): Use maybe_set_param_value instead of set_param_value. Pass extra arguments to maybe_set_param_value. * config/sparc/sparc.c (sparc_option_override): Pass extra arguments to maybe_set_param_value. * config/spu/spu.c (spu_option_override): Pass extra arguments to maybe_set_param_value. * opts.c (handle_param): Take opts and opts_set parameters. Update call to set_param_value. (initial_min_crossjump_insns, initial_max_fields_for_field_sensitive, initial_loop_invariant_max_bbs_in_loop): Remove. (init_options_once): Don't set them. (init_options_struct): Initialize parameters structures. (default_options_optimization): Use default_param_value when restoring defaults. Update calls to maybe_set_param_value. (finish_options): Update calls to maybe_set_param_value. (common_handle_option): Update calls to handle_param and set_param_value. * toplev.c (DEFPARAM): Update definition for changes to param_info. (general_init): Call finish_params. From-SVN: r165460
-rw-r--r--gcc/ChangeLog51
-rw-r--r--gcc/common.opt3
-rw-r--r--gcc/config/arm/arm.c4
-rw-r--r--gcc/config/i386/i386.c16
-rw-r--r--gcc/config/picochip/picochip.c8
-rw-r--r--gcc/config/rs6000/rs6000.c16
-rw-r--r--gcc/config/s390/s390.c44
-rw-r--r--gcc/config/sparc/sparc.c8
-rw-r--r--gcc/config/spu/spu.c4
-rw-r--r--gcc/opts.c60
-rw-r--r--gcc/params.c76
-rw-r--r--gcc/params.h36
-rw-r--r--gcc/toplev.c5
13 files changed, 248 insertions, 83 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 470849b..771de10 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,54 @@
+2010-10-14 Joseph Myers <joseph@codesourcery.com>
+
+ * params.c (params_finished): New.
+ (add_params): Assert !params_finished.
+ (finish_params): New.
+ (set_param_value_internal): Take params and params_set
+ parameters. Assert params_finished.
+ (set_param_value, maybe_set_param_value): Take params and
+ params_set parameters. Update calls to set_param_value_internal.
+ (set_default_param_value): Assert !params_finished. Don't use
+ set_param_value_internal.
+ (default_param_value, init_param_values): New.
+ * params.h (struct param_info): Change value to default_value.
+ Remove set.
+ (set_param_value, maybe_set_param_value): Add params and
+ params_set parameters.
+ (PARAM_VALUE): Get parameters from global_options.
+ (PARAM_SET_P): Remove.
+ (finish_params, default_param_value, init_param_values): New.
+ * common.opt (param_values): New Variable.
+ * config/arm/arm.c (arm_option_override): Pass extra arguments to
+ maybe_set_param_value.
+ * config/i386/i386.c (ix86_option_override_internal): Pass extra
+ arguments to maybe_set_param_value.
+ * config/picochip/picochip.c (picochip_option_override): Pass
+ extra arguments to maybe_set_param_value.
+ * config/rs6000/rs6000.c (rs6000_option_override_internal): Pass
+ extra arguments to maybe_set_param_value.
+ * config/s390/s390.c (s390_option_override): Use
+ maybe_set_param_value instead of set_param_value. Pass extra
+ arguments to maybe_set_param_value.
+ * config/sparc/sparc.c (sparc_option_override): Pass extra
+ arguments to maybe_set_param_value.
+ * config/spu/spu.c (spu_option_override): Pass extra arguments to
+ maybe_set_param_value.
+ * opts.c (handle_param): Take opts and opts_set parameters.
+ Update call to set_param_value.
+ (initial_min_crossjump_insns,
+ initial_max_fields_for_field_sensitive,
+ initial_loop_invariant_max_bbs_in_loop): Remove.
+ (init_options_once): Don't set them.
+ (init_options_struct): Initialize parameters structures.
+ (default_options_optimization): Use default_param_value when
+ restoring defaults. Update calls to maybe_set_param_value.
+ (finish_options): Update calls to maybe_set_param_value.
+ (common_handle_option): Update calls to handle_param and
+ set_param_value.
+ * toplev.c (DEFPARAM): Update definition for changes to
+ param_info.
+ (general_init): Call finish_params.
+
2010-10-14 Nick Clifton <nickc@redhat.com>
* config/mn10300/mn10300.h (CONSTANT_ALIGNMENT): Define.
diff --git a/gcc/common.opt b/gcc/common.opt
index b0e40c1..8fe796f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -55,6 +55,9 @@ enum ira_region flag_ira_region = IRA_REGION_MIXED
Variable
bool flag_warn_unused_result = false
+Variable
+int *param_values
+
###
Driver
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 855f39e..5307948 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1958,7 +1958,9 @@ arm_option_override (void)
but measurable, size reduction for PIC code. Therefore, we decrease
the bar for unrestricted expression hoisting to the cost of PIC address
calculation, which is 2 instructions. */
- maybe_set_param_value (PARAM_GCSE_UNRESTRICTED_COST, 2);
+ maybe_set_param_value (PARAM_GCSE_UNRESTRICTED_COST, 2,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* Register global variables with the garbage collector. */
arm_add_gc_roots ();
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 0987b45..91e3839 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3633,10 +3633,18 @@ ix86_option_override_internal (bool main_args_p)
flag_schedule_insns_after_reload = flag_schedule_insns = 0;
maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
- ix86_cost->simultaneous_prefetches);
- maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE, ix86_cost->prefetch_block);
- maybe_set_param_value (PARAM_L1_CACHE_SIZE, ix86_cost->l1_cache_size);
- maybe_set_param_value (PARAM_L2_CACHE_SIZE, ix86_cost->l2_cache_size);
+ ix86_cost->simultaneous_prefetches,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE, ix86_cost->prefetch_block,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L1_CACHE_SIZE, ix86_cost->l1_cache_size,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L2_CACHE_SIZE, ix86_cost->l2_cache_size,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
if (flag_prefetch_loop_arrays < 0
diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
index f494b95..37771db 100644
--- a/gcc/config/picochip/picochip.c
+++ b/gcc/config/picochip/picochip.c
@@ -354,8 +354,12 @@ picochip_option_override (void)
that could potentially increase stack size.*/
if (flag_conserve_stack)
{
- maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 0);
- maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 0);
+ maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 0,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 0,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
}
/* Turn off the elimination of unused types. The elaborator
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d7377a5..f008c2d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -3159,11 +3159,19 @@ rs6000_option_override_internal (const char *default_cpu)
}
maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
- rs6000_cost->simultaneous_prefetches);
- maybe_set_param_value (PARAM_L1_CACHE_SIZE, rs6000_cost->l1_cache_size);
+ rs6000_cost->simultaneous_prefetches,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L1_CACHE_SIZE, rs6000_cost->l1_cache_size,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
- rs6000_cost->cache_line_size);
- maybe_set_param_value (PARAM_L2_CACHE_SIZE, rs6000_cost->l2_cache_size);
+ rs6000_cost->cache_line_size,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L2_CACHE_SIZE, rs6000_cost->l2_cache_size,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
can be optimized to ap = __builtin_next_arg (0). */
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 04fcee2..8aabe11 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -1687,22 +1687,42 @@ s390_option_override (void)
if (s390_tune == PROCESSOR_2097_Z10
|| s390_tune == PROCESSOR_2817_Z196)
{
- maybe_set_param_value (PARAM_MAX_UNROLLED_INSNS, 100);
- maybe_set_param_value (PARAM_MAX_UNROLL_TIMES, 32);
- maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS, 2000);
- maybe_set_param_value (PARAM_MAX_COMPLETELY_PEEL_TIMES, 64);
- }
-
- set_param_value ("max-pending-list-length", 256);
+ maybe_set_param_value (PARAM_MAX_UNROLLED_INSNS, 100,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_MAX_UNROLL_TIMES, 32,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS, 2000,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_MAX_COMPLETELY_PEEL_TIMES, 64,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ }
+
+ maybe_set_param_value (PARAM_MAX_PENDING_LIST_LENGTH, 256,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* values for loop prefetching */
- set_param_value ("l1-cache-line-size", 256);
- maybe_set_param_value (PARAM_L1_CACHE_SIZE, 128);
+ maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE, 256,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_L1_CACHE_SIZE, 128,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* s390 has more than 2 levels and the size is much larger. Since
we are always running virtualized assume that we only get a small
part of the caches above l1. */
- maybe_set_param_value (PARAM_L2_CACHE_SIZE, 1500);
- maybe_set_param_value (PARAM_PREFETCH_MIN_INSN_TO_MEM_RATIO, 2);
- maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 6);
+ maybe_set_param_value (PARAM_L2_CACHE_SIZE, 1500,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_PREFETCH_MIN_INSN_TO_MEM_RATIO, 2,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
+ maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 6,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
/* This cannot reside in s390_option_optimization since HAVE_prefetch
requires the arch flags to be evaluated already. Since prefetching
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 6807301..0cd3c81 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -922,13 +922,17 @@ sparc_option_override (void)
|| sparc_cpu == PROCESSOR_NIAGARA2)
? 2
: (sparc_cpu == PROCESSOR_ULTRASPARC3
- ? 8 : 3)));
+ ? 8 : 3)),
+ global_options.x_param_values,
+ global_options_set.x_param_values);
maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
((sparc_cpu == PROCESSOR_ULTRASPARC
|| sparc_cpu == PROCESSOR_ULTRASPARC3
|| sparc_cpu == PROCESSOR_NIAGARA
|| sparc_cpu == PROCESSOR_NIAGARA2)
- ? 64 : 32));
+ ? 64 : 32),
+ global_options.x_param_values,
+ global_options_set.x_param_values);
}
/* Miscellaneous utilities. */
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 9bc78e8..f9e5c82 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -514,7 +514,9 @@ spu_option_override (void)
/* Small loops will be unpeeled at -O3. For SPU it is more important
to keep code small by default. */
if (!flag_unroll_loops && !flag_peel_loops)
- maybe_set_param_value (PARAM_MAX_COMPLETELY_PEEL_TIMES, 1);
+ maybe_set_param_value (PARAM_MAX_COMPLETELY_PEEL_TIMES, 1,
+ global_options.x_param_values,
+ global_options_set.x_param_values);
flag_omit_frame_pointer = 1;
diff --git a/gcc/opts.c b/gcc/opts.c
index 38f2faa..6807123 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -362,7 +362,8 @@ static bool common_handle_option (struct gcc_options *opts,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers);
-static void handle_param (const char *);
+static void handle_param (struct gcc_options *opts,
+ struct gcc_options *opts_set, const char *carg);
static char *write_langs (unsigned int lang_mask);
static void complain_wrong_lang (const struct cl_decoded_option *,
unsigned int lang_mask);
@@ -652,11 +653,6 @@ read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
/* Language mask determined at initialization. */
static unsigned int initial_lang_mask;
-/* Initial values of parameters we reset. */
-static int initial_min_crossjump_insns;
-static int initial_max_fields_for_field_sensitive;
-static int initial_loop_invariant_max_bbs_in_loop;
-
/* Initialize global options-related settings at start-up. */
void
@@ -666,14 +662,6 @@ init_options_once (void)
initial_lang_mask = lang_hooks.option_lang_mask ();
lang_hooks.initialize_diagnostics (global_dc);
-
- /* Save initial values of parameters we reset. */
- initial_min_crossjump_insns
- = PARAM_VALUE (PARAM_MIN_CROSSJUMP_INSNS);
- initial_max_fields_for_field_sensitive
- = PARAM_VALUE (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE);
- initial_loop_invariant_max_bbs_in_loop
- = PARAM_VALUE (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP);
}
/* Initialize OPTS and OPTS_SET before using them in parsing options. */
@@ -681,9 +669,15 @@ init_options_once (void)
void
init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
{
+ size_t num_params = get_num_compiler_params ();
+
*opts = global_options_init;
memset (opts_set, 0, sizeof (*opts_set));
+ opts->x_param_values = XNEWVEC (int, num_params);
+ opts_set->x_param_values = XCNEWVEC (int, num_params);
+ init_param_values (opts->x_param_values);
+
/* Use priority coloring if cover classes is not defined for the
target. */
if (targetm.ira_cover_classes == NULL)
@@ -853,12 +847,16 @@ default_options_optimization (struct gcc_options *opts,
flag_ipa_sra = opt2;
/* Track fields in field-sensitive alias analysis. */
- maybe_set_param_value (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE,
- opt2 ? 100 : initial_max_fields_for_field_sensitive);
+ maybe_set_param_value
+ (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE,
+ opt2 ? 100 : default_param_value (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE),
+ opts->x_param_values, opts_set->x_param_values);
/* For -O1 only do loop invariant motion for very small loops. */
- maybe_set_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP,
- opt2 ? initial_loop_invariant_max_bbs_in_loop : 1000);
+ maybe_set_param_value
+ (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP,
+ opt2 ? default_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) : 1000,
+ opts->x_param_values, opts_set->x_param_values);
/* -O3 optimizations. */
opt3 = (optimize >= 3);
@@ -891,11 +889,13 @@ default_options_optimization (struct gcc_options *opts,
optimize = 2;
/* We want to crossjump as much as possible. */
- maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS, 1);
+ maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS, 1,
+ opts->x_param_values, opts_set->x_param_values);
}
else
maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS,
- initial_min_crossjump_insns);
+ default_param_value (PARAM_MIN_CROSSJUMP_INSNS),
+ opts->x_param_values, opts_set->x_param_values);
/* -Ofast adds optimizations to -O3. */
if (ofast)
@@ -1115,8 +1115,10 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set)
if (flag_conserve_stack)
{
- maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 100);
- maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40);
+ maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 100,
+ opts->x_param_values, opts_set->x_param_values);
+ maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40,
+ opts->x_param_values, opts_set->x_param_values);
}
if (flag_wpa || flag_ltrans)
{
@@ -1506,7 +1508,7 @@ common_handle_option (struct gcc_options *opts,
switch (code)
{
case OPT__param:
- handle_param (arg);
+ handle_param (opts, opts_set, arg);
break;
case OPT_v:
@@ -1826,8 +1828,10 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_finline_limit_:
- set_param_value ("max-inline-insns-single", value / 2);
- set_param_value ("max-inline-insns-auto", value / 2);
+ set_param_value ("max-inline-insns-single", value / 2,
+ opts->x_param_values, opts_set->x_param_values);
+ set_param_value ("max-inline-insns-auto", value / 2,
+ opts->x_param_values, opts_set->x_param_values);
break;
case OPT_finstrument_functions_exclude_function_list_:
@@ -2122,7 +2126,8 @@ common_handle_option (struct gcc_options *opts,
/* Handle --param NAME=VALUE. */
static void
-handle_param (const char *carg)
+handle_param (struct gcc_options *opts, struct gcc_options *opts_set,
+ const char *carg)
{
char *equal, *arg;
int value;
@@ -2139,7 +2144,8 @@ handle_param (const char *carg)
else
{
*equal = '\0';
- set_param_value (arg, value);
+ set_param_value (arg, value,
+ opts->x_param_values, opts_set->x_param_values);
}
}
diff --git a/gcc/params.c b/gcc/params.c
index 666913a..07950b3 100644
--- a/gcc/params.c
+++ b/gcc/params.c
@@ -35,11 +35,17 @@ param_info *compiler_params;
/* The number of entries in the table. */
static size_t num_compiler_params;
+/* Whether the parameters have all been initialized and had their
+ default values determined. */
+static bool params_finished;
+
/* Add the N PARAMS to the current list of compiler parameters. */
void
add_params (const param_info params[], size_t n)
{
+ gcc_assert (!params_finished);
+
/* Allocate enough space for the new parameters. */
compiler_params = XRESIZEVEC (param_info, compiler_params,
num_compiler_params + n);
@@ -51,25 +57,39 @@ add_params (const param_info params[], size_t n)
num_compiler_params += n;
}
-/* Set the value of the parameter given by NUM to VALUE. If
- EXPLICIT_P, this is being set by the user; otherwise it is being
- set implicitly by the compiler. */
+/* Note that all parameters have been added and all default values
+ set. */
+
+void
+finish_params (void)
+{
+ params_finished = true;
+}
+
+/* Set the value of the parameter given by NUM to VALUE in PARAMS and
+ PARAMS_SET. If EXPLICIT_P, this is being set by the user;
+ otherwise it is being set implicitly by the compiler. */
static void
set_param_value_internal (compiler_param num, int value,
+ int *params, int *params_set,
bool explicit_p)
{
size_t i = (size_t) num;
- compiler_params[i].value = value;
+ gcc_assert (params_finished);
+
+ params[i] = value;
if (explicit_p)
- compiler_params[i].set = true;
+ params_set[i] = true;
}
-/* Set the VALUE associated with the parameter given by NAME. */
+/* Set the VALUE associated with the parameter given by NAME in PARAMS
+ and PARAMS_SET. */
void
-set_param_value (const char *name, int value)
+set_param_value (const char *name, int value,
+ int *params, int *params_set)
{
size_t i;
@@ -90,7 +110,8 @@ set_param_value (const char *name, int value)
compiler_params[i].option,
compiler_params[i].max_value);
else
- set_param_value_internal ((compiler_param) i, value, true);
+ set_param_value_internal ((compiler_param) i, value,
+ params, params_set, true);
return;
}
@@ -98,14 +119,16 @@ set_param_value (const char *name, int value)
error ("invalid parameter %qs", name);
}
-/* Set the value of the parameter given by NUM to VALUE, implicitly,
- if it has not been set explicitly by the user. */
+/* Set the value of the parameter given by NUM to VALUE in PARAMS and
+ PARAMS_SET, implicitly, if it has not been set explicitly by the
+ user. */
void
-maybe_set_param_value (compiler_param num, int value)
+maybe_set_param_value (compiler_param num, int value,
+ int *params, int *params_set)
{
- if (!PARAM_SET_P (num))
- set_param_value_internal (num, value, false);
+ if (!params_set[(int) num])
+ set_param_value_internal (num, value, params, params_set, false);
}
/* Set the default value of a parameter given by NUM to VALUE, before
@@ -114,8 +137,31 @@ maybe_set_param_value (compiler_param num, int value)
void
set_default_param_value (compiler_param num, int value)
{
- gcc_assert (!PARAM_SET_P (num));
- set_param_value_internal (num, value, false);
+ gcc_assert (!params_finished);
+
+ compiler_params[(int) num].default_value = value;
+}
+
+/* Return the default value of parameter NUM. */
+
+int
+default_param_value (compiler_param num)
+{
+ return compiler_params[(int) num].default_value;
+}
+
+/* Initialize an array PARAMS with default values of the
+ parameters. */
+
+void
+init_param_values (int *params)
+{
+ size_t i;
+
+ gcc_assert (params_finished);
+
+ for (i = 0; i < num_compiler_params; i++)
+ params[i] = compiler_params[i].default_value;
}
/* Return the current value of num_compiler_params, for the benefit of
diff --git a/gcc/params.h b/gcc/params.h
index b924e78..5aeb3ef 100644
--- a/gcc/params.h
+++ b/gcc/params.h
@@ -44,11 +44,9 @@ typedef struct param_info
/* The name used with the `--param <name>=<value>' switch to set this
value. */
const char *const option;
- /* The associated value. */
- int value;
- /* True if the parameter was explicitly set. */
- bool set;
+ /* The default value. */
+ int default_value;
/* Minimum acceptable value. */
int min_value;
@@ -72,9 +70,12 @@ extern size_t get_num_compiler_params (void);
extern void add_params (const param_info params[], size_t n);
-/* Set the VALUE associated with the parameter given by NAME. */
+/* Set the VALUE associated with the parameter given by NAME in the
+ table PARAMS using PARAMS_SET to indicate which have been
+ explicitly set. */
-extern void set_param_value (const char *name, int value);
+extern void set_param_value (const char *name, int value,
+ int *params, int *params_set);
/* The parameters in use by language-independent code. */
@@ -90,22 +91,31 @@ typedef enum compiler_param
/* The value of the parameter given by ENUM. Not an lvalue. */
#define PARAM_VALUE(ENUM) \
- ((int) compiler_params[(int) ENUM].value)
+ ((int) global_options.x_param_values[(int) ENUM])
/* Set the value of the parameter given by NUM to VALUE, implicitly,
- if it has not been set explicitly by the user. */
+ if it has not been set explicitly by the user, in the table PARAMS
+ using PARAMS_SET to indicate which have been explicitly set. */
-extern void maybe_set_param_value (compiler_param num, int value);
+extern void maybe_set_param_value (compiler_param num, int value,
+ int *params, int *params_set);
/* Set the default value of a parameter given by NUM to VALUE, before
option processing. */
extern void set_default_param_value (compiler_param num, int value);
-/* True if the value of the parameter was explicitly changed. Not an
- lvalue. */
-#define PARAM_SET_P(ENUM) \
- ((bool) compiler_params[(int) ENUM].set)
+/* Note that all parameters have been added and all default values
+ set. */
+extern void finish_params (void);
+
+/* Return the default value of parameter NUM. */
+
+extern int default_param_value (compiler_param num);
+
+/* Initialize an array PARAMS with default values of the
+ parameters. */
+extern void init_param_values (int *params);
/* Macros for the various parameters. */
#define STRUCT_REORG_COLD_STRUCT_RATIO \
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 21d23fd..808248b 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -286,10 +286,10 @@ const char *user_label_prefix;
static const param_info lang_independent_params[] = {
#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
- { OPTION, DEFAULT, false, MIN, MAX, HELP },
+ { OPTION, DEFAULT, MIN, MAX, HELP },
#include "params.def"
#undef DEFPARAM
- { NULL, 0, false, 0, 0, NULL }
+ { NULL, 0, 0, 0, NULL }
};
/* Output files for assembler code (real compiler output)
@@ -1698,6 +1698,7 @@ general_init (const char *argv0)
init_ggc_heuristics();
init_optimization_passes ();
statistics_early_init ();
+ finish_params ();
}
/* Return true if the current target supports -fsection-anchors. */