aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-03-24 21:15:37 +0000
committerTom Tromey <tromey@redhat.com>2008-03-24 21:15:37 +0000
commit8d8f3ee8d87488e6931cd7ce113842279bbe69f6 (patch)
tree1dde9e2859ffb4cd3ea3061aba19b96113ba8696
parentdd2a849318adea7d6cdcd94bac85f1eaffb78875 (diff)
* toplev.c (lang_independent_params): Update for params.h change.
(DEFPARAM): Likewise. * opts.c (option_value): New typedef. (default_values, defaults_saved): New globals. (verbose): Move out of function scope. (type_explicit): Likewise. (clean_up): Call restore_default_option_values, reset_params. (decode_options): Call save_default_option_values. (common_handle_option): Move 'verbose' to file scope. (set_debug_level): Move 'type_explicit' to file scope. (save_default_option_values): New function. (restore_default_option_values): Likewise. * params.c (reset_params): New function. * params.h (param_info) <default_value>: New field. (reset_params): Declare. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/incremental-compiler@133491 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog18
-rw-r--r--gcc/opts.c120
-rw-r--r--gcc/params.c15
-rw-r--r--gcc/params.h9
-rw-r--r--gcc/toplev.c4
5 files changed, 156 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8c4c0790ed7..ddee749aa82 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2008-03-24 Tom Tromey <tromey@redhat.com>
+
+ * toplev.c (lang_independent_params): Update for params.h change.
+ (DEFPARAM): Likewise.
+ * opts.c (option_value): New typedef.
+ (default_values, defaults_saved): New globals.
+ (verbose): Move out of function scope.
+ (type_explicit): Likewise.
+ (clean_up): Call restore_default_option_values, reset_params.
+ (decode_options): Call save_default_option_values.
+ (common_handle_option): Move 'verbose' to file scope.
+ (set_debug_level): Move 'type_explicit' to file scope.
+ (save_default_option_values): New function.
+ (restore_default_option_values): Likewise.
+ * params.c (reset_params): New function.
+ * params.h (param_info) <default_value>: New field.
+ (reset_params): Declare.
+
2008-03-19 Tom Tromey <tromey@redhat.com>
* toplev.c (do_compile): Set ggc_protect_identifiers here...
diff --git a/gcc/opts.c b/gcc/opts.c
index 260a4fc0835..937bf493e9d 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1,5 +1,5 @@
/* Command line option handling.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Neil Booth.
@@ -42,6 +42,19 @@ along with GCC; see the file COPYING3. If not see
#include "dbgcnt.h"
#include "debug.h"
+/* We save the default values of options using this type. */
+typedef union
+{
+ const char *strvalue;
+ int intvalue;
+} option_value;
+
+static option_value default_values[N_OPTS];
+
+static bool defaults_saved;
+
+static bool verbose = false;
+
/* Value of the -G xx switch, and whether it was passed or not. */
unsigned HOST_WIDE_INT g_switch_value;
bool g_switch_set;
@@ -386,6 +399,8 @@ static void complain_wrong_lang (const char *, const struct cl_option *,
static void handle_options (unsigned int, const char **, unsigned int);
static void set_debug_level (enum debug_info_type type, int extended,
const char *arg);
+static void save_default_option_values (void);
+static void restore_default_option_values (void);
/* If ARG is a non-negative integer made up solely of digits, return its
value, otherwise return -1. */
@@ -782,6 +797,9 @@ clean_up (void)
in_fnames = NULL;
num_in_fnames = 0;
}
+
+ restore_default_option_values ();
+ reset_params ();
}
/* Parse command line options and set default flag values. Do minimal
@@ -791,8 +809,16 @@ decode_options (unsigned int argc, const char **argv)
{
unsigned int i, lang_mask;
- /* Clean up from previous run. */
- clean_up ();
+ if (! defaults_saved)
+ {
+ save_default_option_values ();
+ defaults_saved = true;
+ }
+ else
+ {
+ /* Clean up from previous run. */
+ clean_up ();
+ }
/* Perform language-specific options initialization. */
lang_mask = lang_hooks.init_options (argc, argv);
@@ -1368,7 +1394,6 @@ static int
common_handle_option (size_t scode, const char *arg, int value,
unsigned int lang_mask)
{
- static bool verbose = false;
enum opt_code code = (enum opt_code) scode;
switch (code)
@@ -2020,13 +2045,13 @@ fast_math_flags_set_p (void)
&& !flag_errno_math);
}
+static bool type_explicit;
+
/* Handle a debug output -g switch. EXTENDED is true or false to support
extended output (2 is special and means "-ggdb" was given). */
static void
set_debug_level (enum debug_info_type type, int extended, const char *arg)
{
- static bool type_explicit;
-
use_gnu_debug_info_extensions = extended;
if (type == NO_DEBUG)
@@ -2167,3 +2192,86 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask)
}
free (new_option);
}
+
+/* Save the default values of all options. */
+static void
+save_default_option_values (void)
+{
+ int i;
+ for (i = 0; i < N_OPTS; ++i)
+ {
+ if (! cl_options[i].flag_var)
+ continue;
+ if (cl_options[i].var_type == CLVC_STRING)
+ default_values[i].strvalue = *(const char **) cl_options[i].flag_var;
+ else
+ {
+ /* All others have type int. */
+ default_values[i].intvalue = *(int *) cl_options[i].flag_var;
+ }
+ }
+}
+
+/* Restore the default values of all options. */
+static void
+restore_default_option_values (void)
+{
+ int i;
+ gcc_assert (defaults_saved);
+ for (i = 0; i < N_OPTS; ++i)
+ {
+ if (! cl_options[i].flag_var)
+ continue;
+ if (cl_options[i].var_type == CLVC_STRING)
+ *(const char **) cl_options[i].flag_var = default_values[i].strvalue;
+ else
+ {
+ /* All others have type int. */
+ *(int *) cl_options[i].flag_var = default_values[i].intvalue;
+ }
+ }
+
+ /* Reset option variables which are not described in cl_options. */
+ verbose = false;
+ g_switch_value = 0;
+ g_switch_set = false;
+ extra_warnings = false;
+ warn_larger_than = 0;
+ larger_than_size = 0;
+ warn_frame_larger_than = false;
+ frame_larger_than_size = 0;
+ maybe_warn_unused_parameter = false;
+ write_symbols = NO_DEBUG;
+ debug_info_level = DINFO_LEVEL_NONE;
+
+ debug_struct_ordinary[0] = DINFO_STRUCT_FILE_ANY;
+ debug_struct_ordinary[1] = DINFO_STRUCT_FILE_ANY;
+ debug_struct_ordinary[2] = DINFO_STRUCT_FILE_ANY;
+ debug_struct_generic[0] = DINFO_STRUCT_FILE_ANY;
+ debug_struct_generic[1] = DINFO_STRUCT_FILE_ANY;
+ debug_struct_generic[2] = DINFO_STRUCT_FILE_ANY;
+
+ use_gnu_debug_info_extensions = false;
+ default_visibility = VISIBILITY_DEFAULT;
+
+ no_unit_at_a_time_default = false;
+
+ memset (&visibility_options, 0, sizeof (struct visibility_flags));
+
+ profile_arc_flag_set = flag_profile_values_set = false;
+ flag_unroll_loops_set = flag_tracer_set = false;
+ flag_value_profile_transformations_set = false;
+ flag_peel_loops_set = flag_branch_probabilities_set = false;
+ flag_inline_functions_set = false;
+
+ VEC_free (char_p, heap, flag_instrument_functions_exclude_functions);
+ VEC_free (char_p, heap, flag_instrument_functions_exclude_files);
+ VEC_free (const_char_p, heap, ignored_options);
+
+ type_explicit = false;
+
+ optimize = 0;
+ optimize_size = 0;
+
+ stack_limit_rtx = NULL_RTX;
+}
diff --git a/gcc/params.c b/gcc/params.c
index 569ae47f040..fd3e4c28500 100644
--- a/gcc/params.c
+++ b/gcc/params.c
@@ -1,5 +1,5 @@
/* params.c - Run-time parameters.
- Copyright (C) 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
@@ -84,3 +84,16 @@ set_param_value (const char *name, int value)
/* If we didn't find this parameter, issue an error message. */
error ("invalid parameter %qs", name);
}
+
+/* Reset each parameter to the default setting. */
+
+void
+reset_params (void)
+{
+ size_t i;
+ for (i = 0; i < num_compiler_params; ++i)
+ {
+ compiler_params[i].value = compiler_params[i].default_value;
+ compiler_params[i].set = false;
+ }
+}
diff --git a/gcc/params.h b/gcc/params.h
index 7c54b5da292..3fc7cbed31a 100644
--- a/gcc/params.h
+++ b/gcc/params.h
@@ -1,5 +1,5 @@
/* params.h - Run-time parameters.
- Copyright (C) 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
@@ -43,6 +43,7 @@ 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;
@@ -55,6 +56,9 @@ typedef struct param_info
/* Maximum acceptable value, if greater than minimum */
int max_value;
+ /* The default value. */
+ int default_value;
+
/* A short description of the option. */
const char *const help;
} param_info;
@@ -72,6 +76,9 @@ extern void add_params (const param_info params[], size_t n);
extern void set_param_value (const char *name, int value);
+/* Reset the all params to their default values. */
+extern void reset_params (void);
+
/* The parameters in use by language-independent code. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 48458e6c9d5..61acca83a4f 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -373,10 +373,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, false, MIN, MAX, DEFAULT, HELP },
#include "params.def"
#undef DEFPARAM
- { NULL, 0, false, 0, 0, NULL }
+ { NULL, 0, false, 0, 0, 0, NULL }
};
/* Output files for assembler code (real compiler output)