Patchwork Make .opt files define all variables they use

login
register
mail settings
Submitter Joseph S. Myers
Date Sept. 17, 2010, 12:50 p.m.
Message ID <Pine.LNX.4.64.1009171250260.1293@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/65071/
State New
Headers show

Comments

Joseph S. Myers - Sept. 17, 2010, 12:50 p.m.
When variables set by command-line options move to being elements of a
structure, so that the driver can have multiple such structures for
Richard Guenther - Sept. 17, 2010, 2:04 p.m.
On Fri, Sep 17, 2010 at 2:50 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> When variables set by command-line options move to being elements of a
> structure, so that the driver can have multiple such structures for
> different multilibs and compare them for multilib selection, it will
> no longer be possible for Var properties in .opt files to name
> variables whose definitions are not generated by the .opt machinery,
> because the table of options will be storing structure offsets rather
> than pointers to global variables.
>
> This patch fixes all the existing cases where variables defined
> outside the .opt files were used in Var properties.  In general,
> VarExists is removed from some appropriate option definition and Init
> added as needed.  (This involves a dependency on 2 as the value of
> AUTODETECT_VALUE in toplev.c, which is appropriately commented; there
> are already other such Init declarations without a comment.  The
> changes to use structures will also allow all these hardcoded uses of
> 2 or -1 as special values for option variables to go away, as a second
> structure will be automatically used to record which options were
> explicitly set.)  In the case of ix86_isa_flags it seemed
> inappropriate to cause any one of the many options to define that
> variable, so a new form of Variable records was added to the .opt
> machinery to allow .opt files to define variables outside of
> individual option definitions.  I expect this to be useful later for
> defining many other variables derived from option settings (and of
> relevance to multilib selection) but not simply derived through the
> .opt file setting an individual variable from an option.
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
> tested building cc1 for cross to mcore-elf.  OK to commit?

Ok.

Thanks,
Richard.

> 2010-09-17  Joseph Myers  <joseph@codesourcery.com>
>
>        * doc/options.texi (Variable): Document.
>        * optc-gen.awk, opth-gen.awk: Handle Variable records.  Don't
>        generate target_flags declarations explicitly.  Don't define
>        VarExists variables for the driver.
>        * common.opt (target_flags): New Variable record.
>        (flag_dump_unnumbered, flag_dump_unnumbered_links,
>        flag_var_tracking, flag_var_tracking_assignments,
>        flag_var_tracking_assignments_toggle): Don't mark variables with
>        VarExists.
>        * config/i386/i386.c (ix86_isa_flags): Don't define here.
>        * config/i386/i386.opt (ix86_isa_flags): Define here.
>        * config/mcore/mcore.c (mcore_stack_increment): Don't define here.
>        * config/mcore/mcore.opt (mcore_stack_increment): Don't mark with
>        VarExists.
>        * flags.h (flag_dump_unnumbered, flag_var_tracking): Remove.
>        * print-rtl.c (flag_dump_unnumbered, flag_dump_unnumbered_links):
>        Only define for generator programs.
>        * rtlanal.c (target_flags): Remove.
>        * toplev.c (flag_var_tracking, flag_var_tracking_assignments,
>        flag_var_tracking_assignments_toggle): Remove.
>
> Index: gcc/doc/options.texi
> ===================================================================
> --- gcc/doc/options.texi        (revision 164335)
> +++ gcc/doc/options.texi        (working copy)
> @@ -41,6 +41,17 @@ records have two fields: the string @sam
>  declaration type to go in the @code{cl_target_option} structure.
>
>  @item
> +A variable record to define a variable used to store option
> +information.  These records have two fields: the string
> +@samp{Variable}, and a declaration of the type and name of the
> +variable, optionally with an initializer (but without any trailing
> +@samp{;}).  These records may be used for variables used for many
> +options where declaring the variable and its initializer by omitting
> +@code{VarExists} from a single option definition record would be
> +inappropriate, or for variables set in option handlers rather than
> +referenced by @code{Var} properties.
> +
> +@item
>  An option definition record.  These records have the following fields:
>  @enumerate
>  @item
> Index: gcc/flags.h
> ===================================================================
> --- gcc/flags.h (revision 164335)
> +++ gcc/flags.h (working copy)
> @@ -164,11 +164,6 @@ extern int rtl_dump_and_exit;
>
>  extern int flag_gen_aux_info;
>
> -/* Nonzero means suppress output of instruction numbers and line number
> -   notes in debugging dumps.  */
> -
> -extern int flag_dump_unnumbered;
> -
>  /* True if printing into -fdump-final-insns= dump.  */
>
>  extern bool final_insns_dump_p;
> @@ -301,9 +296,6 @@ enum graph_dump_types
>  };
>  extern enum graph_dump_types graph_dump_format;
>
> -/* Nonzero if we should track variables.  */
> -extern int flag_var_tracking;
> -
>  /* True if flag_speculative_prefetching was set by user.  Used to suppress
>    warning message in case flag was set by -fprofile-{generate,use}.  */
>  extern bool flag_speculative_prefetching_set;
> Index: gcc/rtlanal.c
> ===================================================================
> --- gcc/rtlanal.c       (revision 164335)
> +++ gcc/rtlanal.c       (working copy)
> @@ -1,6 +1,6 @@
>  /* Analyze RTL for GNU compiler.
>    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
> -   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
> +   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
>    Free Software Foundation, Inc.
>
>  This file is part of GCC.
> @@ -64,12 +64,6 @@ static unsigned int num_sign_bit_copies1
>    -1 if a code has no such operand.  */
>  static int non_rtx_starting_operands[NUM_RTX_CODE];
>
> -/* Bit flags that specify the machine subtype we are compiling for.
> -   Bits are tested using macros TARGET_... defined in the tm.h file
> -   and set by `-m...' switches.  Must be defined in rtlanal.c.  */
> -
> -int target_flags;
> -
>  /* Truncation narrows the mode from SOURCE mode to DESTINATION mode.
>    If TARGET_MODE_REP_EXTENDED (DESTINATION, DESTINATION_REP) is
>    SIGN_EXTEND then while narrowing we also have to enforce the
> Index: gcc/toplev.c
> ===================================================================
> --- gcc/toplev.c        (revision 164335)
> +++ gcc/toplev.c        (working copy)
> @@ -291,23 +291,6 @@ int flag_dump_rtl_in_asm = 0;
>    the support provided depends on the backend.  */
>  rtx stack_limit_rtx;
>
> -/* Positive if we should track variables, negative if we should run
> -   the var-tracking pass only to discard debug annotations, zero if
> -   we're not to run it.  When flag_var_tracking == AUTODETECT_VALUE it
> -   will be set according to optimize, debug_info_level and debug_hooks
> -   in process_options ().  */
> -int flag_var_tracking = AUTODETECT_VALUE;
> -
> -/* Positive if we should track variables at assignments, negative if
> -   we should run the var-tracking pass only to discard debug
> -   annotations.  When flag_var_tracking_assignments ==
> -   AUTODETECT_VALUE it will be set according to flag_var_tracking.  */
> -int flag_var_tracking_assignments = AUTODETECT_VALUE;
> -
> -/* Nonzero if we should toggle flag_var_tracking_assignments after
> -   processing options and computing its default.  */
> -int flag_var_tracking_assignments_toggle = 0;
> -
>  /* Type of stack check.  */
>  enum stack_check_type flag_stack_check = NO_STACK_CHECK;
>
> Index: gcc/optc-gen.awk
> ===================================================================
> --- gcc/optc-gen.awk    (revision 164335)
> +++ gcc/optc-gen.awk    (working copy)
> @@ -30,6 +30,7 @@ BEGIN {
>        n_opts = 0
>        n_langs = 0
>        n_target_save = 0
> +       n_extra_vars = 0
>         quote = "\042"
>        comma = ","
>        FS=SUBSEP
> @@ -48,6 +49,10 @@ BEGIN {
>                        target_save_decl[n_target_save] = $2
>                        n_target_save++
>                }
> +               else if ($1 == "Variable") {
> +                       extra_vars[n_extra_vars] = $2
> +                       n_extra_vars++
> +               }
>                else {
>                        name = opt_args("Mask", $1)
>                        if (name == "") {
> @@ -72,7 +77,6 @@ print "#include " quote "opts.h" quote
>  print "#include " quote "intl.h" quote
>  print ""
>  print "#ifdef GCC_DRIVER"
> -print "int target_flags;"
>  print "int target_flags_explicit;"
>  print "#else"
>  print "#include " quote "flags.h" quote
> @@ -81,6 +85,9 @@ print "#endif /* GCC_DRIVER */"
>  print ""
>
>  have_save = 0;
> +for (i = 0; i < n_extra_vars; i++) {
> +       print extra_vars[i] ";"
> +}
>  for (i = 0; i < n_opts; i++) {
>        if (flag_set_p("Save", flags[i]))
>                have_save = 1;
> @@ -90,11 +97,7 @@ for (i = 0; i < n_opts; i++) {
>                continue;
>
>        if (flag_set_p("VarExists", flags[i])) {
> -               # Need it for the gcc driver.
> -               if (name in var_seen)
> -                       continue;
> -               init = ""
> -               gcc_driver = 1
> +               continue;
>        }
>        else {
>                init = opt_args("Init", flags[i])
> @@ -102,16 +105,11 @@ for (i = 0; i < n_opts; i++) {
>                        init = " = " init;
>                else if (name in var_seen)
>                        continue;
> -               gcc_driver = 0
>        }
>
> -       if (gcc_driver == 1)
> -               print "#ifdef GCC_DRIVER"
>        print "/* Set by -" opts[i] "."
>        print "   " help[i] "  */"
>        print var_type(flags[i]) name init ";"
> -       if (gcc_driver == 1)
> -               print "#endif /* GCC_DRIVER */"
>        print ""
>
>        var_seen[name] = 1;
> Index: gcc/print-rtl.c
> ===================================================================
> --- gcc/print-rtl.c     (revision 164335)
> +++ gcc/print-rtl.c     (working copy)
> @@ -58,6 +58,10 @@ static void print_rtx (const_rtx);
>    the assembly output file.  */
>  const char *print_rtx_head = "";
>
> +#ifdef GENERATOR_FILE
> +/* These are defined from the .opt file when not used in generator
> +   programs.  */
> +
>  /* Nonzero means suppress output of instruction numbers
>    in debugging dumps.
>    This must be defined here so that programs like gencodes can be linked.  */
> @@ -67,6 +71,7 @@ int flag_dump_unnumbered = 0;
>    and next insns in debugging dumps.
>    This must be defined here so that programs like gencodes can be linked.  */
>  int flag_dump_unnumbered_links = 0;
> +#endif
>
>  /* Nonzero means use simplified format without flags, modes, etc.  */
>  int flag_simple = 0;
> Index: gcc/opth-gen.awk
> ===================================================================
> --- gcc/opth-gen.awk    (revision 164335)
> +++ gcc/opth-gen.awk    (working copy)
> @@ -28,6 +28,7 @@ BEGIN {
>        n_opts = 0
>        n_langs = 0
>        n_target_save = 0
> +       n_extra_vars = 0
>        n_extra_masks = 0
>        FS=SUBSEP
>  }
> @@ -43,6 +44,10 @@ BEGIN {
>                        target_save_decl[n_target_save] = $2
>                        n_target_save++
>                }
> +               else if ($1 == "Variable") {
> +                       extra_vars[n_extra_vars] = $2
> +                       n_extra_vars++
> +               }
>                else {
>                        name = opt_args("Mask", $1)
>                        if (name == "") {
> @@ -65,12 +70,17 @@ print ""
>  print "#ifndef OPTIONS_H"
>  print "#define OPTIONS_H"
>  print ""
> -print "extern int target_flags;"
>  print "extern int target_flags_explicit;"
>  print ""
>
>  have_save = 0;
>
> +for (i = 0; i < n_extra_vars; i++) {
> +       var = extra_vars[i]
> +       sub(" *=.*", "", var)
> +       print "extern " var ";"
> +}
> +
>  for (i = 0; i < n_opts; i++) {
>        if (flag_set_p("Save", flags[i]))
>                have_save = 1;
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt      (revision 164335)
> +++ gcc/common.opt      (working copy)
> @@ -23,6 +23,9 @@
>
>  ; Please try to keep this file in ASCII collating order.
>
> +Variable
> +int target_flags
> +
>  ###
>  Driver
>
> @@ -555,11 +558,11 @@ Common Report Var(flag_dump_noaddr)
>  Suppress output of addresses in debugging dumps
>
>  fdump-unnumbered
> -Common Report Var(flag_dump_unnumbered) VarExists
> +Common Report Var(flag_dump_unnumbered)
>  Suppress output of instruction numbers, line number notes and addresses in debugging dumps
>
>  fdump-unnumbered-links
> -Common Report Var(flag_dump_unnumbered_links) VarExists
> +Common Report Var(flag_dump_unnumbered_links)
>  Suppress output of previous and next insn numbers in debugging dumps
>
>  fdwarf2-cfi-asm
> @@ -1514,16 +1517,27 @@ Just generate unwind tables for exceptio
>  fuse-linker-plugin
>  Common Undocumented
>
> +; Positive if we should track variables, negative if we should run
> +; the var-tracking pass only to discard debug annotations, zero if
> +; we're not to run it.  When flag_var_tracking == 2 (AUTODETECT_VALUE) it
> +; will be set according to optimize, debug_info_level and debug_hooks
> +; in process_options ().
>  fvar-tracking
> -Common Report Var(flag_var_tracking) VarExists Optimization
> +Common Report Var(flag_var_tracking) Init(2) Optimization
>  Perform variable tracking
>
> +; Positive if we should track variables at assignments, negative if
> +; we should run the var-tracking pass only to discard debug
> +; annotations.  When flag_var_tracking_assignments ==
> +; AUTODETECT_VALUE it will be set according to flag_var_tracking.
>  fvar-tracking-assignments
> -Common Report Var(flag_var_tracking_assignments) VarExists Optimization
> +Common Report Var(flag_var_tracking_assignments) Init(2) Optimization
>  Perform variable tracking by annotating assignments
>
> +; Nonzero if we should toggle flag_var_tracking_assignments after
> +; processing options and computing its default.  */
>  fvar-tracking-assignments-toggle
> -Common Report Var(flag_var_tracking_assignments_toggle) VarExists Optimization
> +Common Report Var(flag_var_tracking_assignments_toggle) Optimization
>  Toggle -fvar-tracking-assignments
>
>  fvar-tracking-uninit
> Index: gcc/config/i386/i386.opt
> ===================================================================
> --- gcc/config/i386/i386.opt    (revision 164335)
> +++ gcc/config/i386/i386.opt    (working copy)
> @@ -19,6 +19,10 @@
>  ; along with GCC; see the file COPYING3.  If not see
>  ; <http://www.gnu.org/licenses/>.
>
> +; Bit flags that specify the ISA we are compiling for.
> +Variable
> +int ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT
> +
>  ;; Definitions to add to the cl_target_option structure
>  ;; -march= processor
>  TargetSave
> Index: gcc/config/i386/i386.c
> ===================================================================
> --- gcc/config/i386/i386.c      (revision 164335)
> +++ gcc/config/i386/i386.c      (working copy)
> @@ -2024,9 +2024,6 @@ static enum calling_abi ix86_function_ab
>  static int ix86_tune_defaulted;
>  static int ix86_arch_specified;
>
> -/* Bit flags that specify the ISA we are compiling for.  */
> -int ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT;
> -
>  /* A mask of ix86_isa_flags that includes bit X if X
>    was set or cleared on the command line.  */
>  static int ix86_isa_flags_explicit;
> Index: gcc/config/mcore/mcore.c
> ===================================================================
> --- gcc/config/mcore/mcore.c    (revision 164335)
> +++ gcc/config/mcore/mcore.c    (working copy)
> @@ -46,11 +46,6 @@
>  #include "target-def.h"
>  #include "df.h"
>
> -/* Maximum size we are allowed to grow the stack in a single operation.
> -   If we want more, we must do it in increments of at most this size.
> -   If this value is 0, we don't check at all.  */
> -int mcore_stack_increment = STACK_UNITS_MAXSTEP;
> -
>  /* For dumping information about frame sizes.  */
>  char * mcore_current_function_name = 0;
>  long   mcore_current_compilation_timestamp = 0;
> Index: gcc/config/mcore/mcore.opt
> ===================================================================
> --- gcc/config/mcore/mcore.opt  (revision 164335)
> +++ gcc/config/mcore/mcore.opt  (working copy)
> @@ -63,8 +63,11 @@ mslow-bytes
>  Target Report Mask(SLOW_BYTES)
>  Prefer word accesses over byte accesses
>
> +; Maximum size we are allowed to grow the stack in a single operation.
> +; If we want more, we must do it in increments of at most this size.
> +; If this value is 0, we don't check at all.
>  mstack-increment=
> -Target RejectNegative Joined UInteger Var(mcore_stack_increment) VarExists
> +Target RejectNegative Joined UInteger Var(mcore_stack_increment) Init(STACK_UNITS_MAXSTEP)
>  Set the maximum amount for a single stack increment operation
>
>  mwide-bitfields
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>

Patch

different multilibs and compare them for multilib selection, it will
no longer be possible for Var properties in .opt files to name
variables whose definitions are not generated by the .opt machinery,
because the table of options will be storing structure offsets rather
than pointers to global variables.

This patch fixes all the existing cases where variables defined
outside the .opt files were used in Var properties.  In general,
VarExists is removed from some appropriate option definition and Init
added as needed.  (This involves a dependency on 2 as the value of
AUTODETECT_VALUE in toplev.c, which is appropriately commented; there
are already other such Init declarations without a comment.  The
changes to use structures will also allow all these hardcoded uses of
2 or -1 as special values for option variables to go away, as a second
structure will be automatically used to record which options were
explicitly set.)  In the case of ix86_isa_flags it seemed
inappropriate to cause any one of the many options to define that
variable, so a new form of Variable records was added to the .opt
machinery to allow .opt files to define variables outside of
individual option definitions.  I expect this to be useful later for
defining many other variables derived from option settings (and of
relevance to multilib selection) but not simply derived through the
.opt file setting an individual variable from an option.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
tested building cc1 for cross to mcore-elf.  OK to commit?

2010-09-17  Joseph Myers  <joseph@codesourcery.com>

	* doc/options.texi (Variable): Document.
	* optc-gen.awk, opth-gen.awk: Handle Variable records.  Don't
	generate target_flags declarations explicitly.  Don't define
	VarExists variables for the driver.
	* common.opt (target_flags): New Variable record.
	(flag_dump_unnumbered, flag_dump_unnumbered_links,
	flag_var_tracking, flag_var_tracking_assignments,
	flag_var_tracking_assignments_toggle): Don't mark variables with
	VarExists.
	* config/i386/i386.c (ix86_isa_flags): Don't define here.
	* config/i386/i386.opt (ix86_isa_flags): Define here.
	* config/mcore/mcore.c (mcore_stack_increment): Don't define here.
	* config/mcore/mcore.opt (mcore_stack_increment): Don't mark with
	VarExists.
	* flags.h (flag_dump_unnumbered, flag_var_tracking): Remove.
	* print-rtl.c (flag_dump_unnumbered, flag_dump_unnumbered_links):
	Only define for generator programs.
	* rtlanal.c (target_flags): Remove.
	* toplev.c (flag_var_tracking, flag_var_tracking_assignments,
	flag_var_tracking_assignments_toggle): Remove.

Index: gcc/doc/options.texi
===================================================================
--- gcc/doc/options.texi	(revision 164335)
+++ gcc/doc/options.texi	(working copy)
@@ -41,6 +41,17 @@  records have two fields: the string @sam
 declaration type to go in the @code{cl_target_option} structure.
 
 @item
+A variable record to define a variable used to store option
+information.  These records have two fields: the string
+@samp{Variable}, and a declaration of the type and name of the
+variable, optionally with an initializer (but without any trailing
+@samp{;}).  These records may be used for variables used for many
+options where declaring the variable and its initializer by omitting
+@code{VarExists} from a single option definition record would be
+inappropriate, or for variables set in option handlers rather than
+referenced by @code{Var} properties.
+
+@item
 An option definition record.  These records have the following fields:
 @enumerate
 @item
Index: gcc/flags.h
===================================================================
--- gcc/flags.h	(revision 164335)
+++ gcc/flags.h	(working copy)
@@ -164,11 +164,6 @@  extern int rtl_dump_and_exit;
 
 extern int flag_gen_aux_info;
 
-/* Nonzero means suppress output of instruction numbers and line number
-   notes in debugging dumps.  */
-
-extern int flag_dump_unnumbered;
-
 /* True if printing into -fdump-final-insns= dump.  */
 
 extern bool final_insns_dump_p;
@@ -301,9 +296,6 @@  enum graph_dump_types
 };
 extern enum graph_dump_types graph_dump_format;
 
-/* Nonzero if we should track variables.  */
-extern int flag_var_tracking;
-
 /* True if flag_speculative_prefetching was set by user.  Used to suppress
    warning message in case flag was set by -fprofile-{generate,use}.  */
 extern bool flag_speculative_prefetching_set;
Index: gcc/rtlanal.c
===================================================================
--- gcc/rtlanal.c	(revision 164335)
+++ gcc/rtlanal.c	(working copy)
@@ -1,6 +1,6 @@ 
 /* Analyze RTL for GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -64,12 +64,6 @@  static unsigned int num_sign_bit_copies1
    -1 if a code has no such operand.  */
 static int non_rtx_starting_operands[NUM_RTX_CODE];
 
-/* Bit flags that specify the machine subtype we are compiling for.
-   Bits are tested using macros TARGET_... defined in the tm.h file
-   and set by `-m...' switches.  Must be defined in rtlanal.c.  */
-
-int target_flags;
-
 /* Truncation narrows the mode from SOURCE mode to DESTINATION mode.
    If TARGET_MODE_REP_EXTENDED (DESTINATION, DESTINATION_REP) is
    SIGN_EXTEND then while narrowing we also have to enforce the
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 164335)
+++ gcc/toplev.c	(working copy)
@@ -291,23 +291,6 @@  int flag_dump_rtl_in_asm = 0;
    the support provided depends on the backend.  */
 rtx stack_limit_rtx;
 
-/* Positive if we should track variables, negative if we should run
-   the var-tracking pass only to discard debug annotations, zero if
-   we're not to run it.  When flag_var_tracking == AUTODETECT_VALUE it
-   will be set according to optimize, debug_info_level and debug_hooks
-   in process_options ().  */
-int flag_var_tracking = AUTODETECT_VALUE;
-
-/* Positive if we should track variables at assignments, negative if
-   we should run the var-tracking pass only to discard debug
-   annotations.  When flag_var_tracking_assignments ==
-   AUTODETECT_VALUE it will be set according to flag_var_tracking.  */
-int flag_var_tracking_assignments = AUTODETECT_VALUE;
-
-/* Nonzero if we should toggle flag_var_tracking_assignments after
-   processing options and computing its default.  */
-int flag_var_tracking_assignments_toggle = 0;
-
 /* Type of stack check.  */
 enum stack_check_type flag_stack_check = NO_STACK_CHECK;
 
Index: gcc/optc-gen.awk
===================================================================
--- gcc/optc-gen.awk	(revision 164335)
+++ gcc/optc-gen.awk	(working copy)
@@ -30,6 +30,7 @@  BEGIN {
 	n_opts = 0
 	n_langs = 0
 	n_target_save = 0
+	n_extra_vars = 0
         quote = "\042"
 	comma = ","
 	FS=SUBSEP
@@ -48,6 +49,10 @@  BEGIN {
 			target_save_decl[n_target_save] = $2
 			n_target_save++
 		}
+		else if ($1 == "Variable") {
+			extra_vars[n_extra_vars] = $2
+			n_extra_vars++
+		}
 		else {
 			name = opt_args("Mask", $1)
 			if (name == "") {
@@ -72,7 +77,6 @@  print "#include " quote "opts.h" quote
 print "#include " quote "intl.h" quote
 print ""
 print "#ifdef GCC_DRIVER"
-print "int target_flags;"
 print "int target_flags_explicit;"
 print "#else"
 print "#include " quote "flags.h" quote
@@ -81,6 +85,9 @@  print "#endif /* GCC_DRIVER */"
 print ""
 
 have_save = 0;
+for (i = 0; i < n_extra_vars; i++) {
+	print extra_vars[i] ";"
+}
 for (i = 0; i < n_opts; i++) {
 	if (flag_set_p("Save", flags[i]))
 		have_save = 1;
@@ -90,11 +97,7 @@  for (i = 0; i < n_opts; i++) {
 		continue;
 
 	if (flag_set_p("VarExists", flags[i])) {
-		# Need it for the gcc driver.
-		if (name in var_seen)
-			continue;
-		init = ""
-		gcc_driver = 1
+		continue;
 	}
 	else {
 		init = opt_args("Init", flags[i])
@@ -102,16 +105,11 @@  for (i = 0; i < n_opts; i++) {
 			init = " = " init;
 		else if (name in var_seen)
 			continue;
-		gcc_driver = 0
 	}
 
-	if (gcc_driver == 1)
-		print "#ifdef GCC_DRIVER"
 	print "/* Set by -" opts[i] "."
 	print "   " help[i] "  */"
 	print var_type(flags[i]) name init ";"
-	if (gcc_driver == 1)
-		print "#endif /* GCC_DRIVER */"
 	print ""
 
 	var_seen[name] = 1;
Index: gcc/print-rtl.c
===================================================================
--- gcc/print-rtl.c	(revision 164335)
+++ gcc/print-rtl.c	(working copy)
@@ -58,6 +58,10 @@  static void print_rtx (const_rtx);
    the assembly output file.  */
 const char *print_rtx_head = "";
 
+#ifdef GENERATOR_FILE
+/* These are defined from the .opt file when not used in generator
+   programs.  */
+
 /* Nonzero means suppress output of instruction numbers
    in debugging dumps.
    This must be defined here so that programs like gencodes can be linked.  */
@@ -67,6 +71,7 @@  int flag_dump_unnumbered = 0;
    and next insns in debugging dumps.
    This must be defined here so that programs like gencodes can be linked.  */
 int flag_dump_unnumbered_links = 0;
+#endif
 
 /* Nonzero means use simplified format without flags, modes, etc.  */
 int flag_simple = 0;
Index: gcc/opth-gen.awk
===================================================================
--- gcc/opth-gen.awk	(revision 164335)
+++ gcc/opth-gen.awk	(working copy)
@@ -28,6 +28,7 @@  BEGIN {
 	n_opts = 0
 	n_langs = 0
 	n_target_save = 0
+	n_extra_vars = 0
 	n_extra_masks = 0
 	FS=SUBSEP
 }
@@ -43,6 +44,10 @@  BEGIN {
 			target_save_decl[n_target_save] = $2
 			n_target_save++
 		}
+		else if ($1 == "Variable") {
+			extra_vars[n_extra_vars] = $2
+			n_extra_vars++
+		}
 		else {
 			name = opt_args("Mask", $1)
 			if (name == "") {
@@ -65,12 +70,17 @@  print ""
 print "#ifndef OPTIONS_H"
 print "#define OPTIONS_H"
 print ""
-print "extern int target_flags;"
 print "extern int target_flags_explicit;"
 print ""
 
 have_save = 0;
 
+for (i = 0; i < n_extra_vars; i++) {
+	var = extra_vars[i]
+	sub(" *=.*", "", var)
+	print "extern " var ";"
+}
+
 for (i = 0; i < n_opts; i++) {
 	if (flag_set_p("Save", flags[i]))
 		have_save = 1;
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 164335)
+++ gcc/common.opt	(working copy)
@@ -23,6 +23,9 @@ 
 
 ; Please try to keep this file in ASCII collating order.
 
+Variable
+int target_flags
+
 ###
 Driver
 
@@ -555,11 +558,11 @@  Common Report Var(flag_dump_noaddr)
 Suppress output of addresses in debugging dumps
 
 fdump-unnumbered
-Common Report Var(flag_dump_unnumbered) VarExists
+Common Report Var(flag_dump_unnumbered)
 Suppress output of instruction numbers, line number notes and addresses in debugging dumps
 
 fdump-unnumbered-links
-Common Report Var(flag_dump_unnumbered_links) VarExists
+Common Report Var(flag_dump_unnumbered_links)
 Suppress output of previous and next insn numbers in debugging dumps
 
 fdwarf2-cfi-asm
@@ -1514,16 +1517,27 @@  Just generate unwind tables for exceptio
 fuse-linker-plugin
 Common Undocumented
 
+; Positive if we should track variables, negative if we should run
+; the var-tracking pass only to discard debug annotations, zero if
+; we're not to run it.  When flag_var_tracking == 2 (AUTODETECT_VALUE) it
+; will be set according to optimize, debug_info_level and debug_hooks
+; in process_options ().
 fvar-tracking
-Common Report Var(flag_var_tracking) VarExists Optimization
+Common Report Var(flag_var_tracking) Init(2) Optimization
 Perform variable tracking
 
+; Positive if we should track variables at assignments, negative if
+; we should run the var-tracking pass only to discard debug
+; annotations.  When flag_var_tracking_assignments ==
+; AUTODETECT_VALUE it will be set according to flag_var_tracking.
 fvar-tracking-assignments
-Common Report Var(flag_var_tracking_assignments) VarExists Optimization
+Common Report Var(flag_var_tracking_assignments) Init(2) Optimization
 Perform variable tracking by annotating assignments
 
+; Nonzero if we should toggle flag_var_tracking_assignments after
+; processing options and computing its default.  */
 fvar-tracking-assignments-toggle
-Common Report Var(flag_var_tracking_assignments_toggle) VarExists Optimization
+Common Report Var(flag_var_tracking_assignments_toggle) Optimization
 Toggle -fvar-tracking-assignments
 
 fvar-tracking-uninit
Index: gcc/config/i386/i386.opt
===================================================================
--- gcc/config/i386/i386.opt	(revision 164335)
+++ gcc/config/i386/i386.opt	(working copy)
@@ -19,6 +19,10 @@ 
 ; along with GCC; see the file COPYING3.  If not see
 ; <http://www.gnu.org/licenses/>.
 
+; Bit flags that specify the ISA we are compiling for.
+Variable
+int ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT
+
 ;; Definitions to add to the cl_target_option structure
 ;; -march= processor
 TargetSave
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 164335)
+++ gcc/config/i386/i386.c	(working copy)
@@ -2024,9 +2024,6 @@  static enum calling_abi ix86_function_ab
 static int ix86_tune_defaulted;
 static int ix86_arch_specified;
 
-/* Bit flags that specify the ISA we are compiling for.  */
-int ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT;
-
 /* A mask of ix86_isa_flags that includes bit X if X
    was set or cleared on the command line.  */
 static int ix86_isa_flags_explicit;
Index: gcc/config/mcore/mcore.c
===================================================================
--- gcc/config/mcore/mcore.c	(revision 164335)
+++ gcc/config/mcore/mcore.c	(working copy)
@@ -46,11 +46,6 @@ 
 #include "target-def.h"
 #include "df.h"
 
-/* Maximum size we are allowed to grow the stack in a single operation.
-   If we want more, we must do it in increments of at most this size.
-   If this value is 0, we don't check at all.  */
-int mcore_stack_increment = STACK_UNITS_MAXSTEP;
-
 /* For dumping information about frame sizes.  */
 char * mcore_current_function_name = 0;
 long   mcore_current_compilation_timestamp = 0;
Index: gcc/config/mcore/mcore.opt
===================================================================
--- gcc/config/mcore/mcore.opt	(revision 164335)
+++ gcc/config/mcore/mcore.opt	(working copy)
@@ -63,8 +63,11 @@  mslow-bytes
 Target Report Mask(SLOW_BYTES)
 Prefer word accesses over byte accesses
 
+; Maximum size we are allowed to grow the stack in a single operation.
+; If we want more, we must do it in increments of at most this size.
+; If this value is 0, we don't check at all.
 mstack-increment=
-Target RejectNegative Joined UInteger Var(mcore_stack_increment) VarExists
+Target RejectNegative Joined UInteger Var(mcore_stack_increment) Init(STACK_UNITS_MAXSTEP)
 Set the maximum amount for a single stack increment operation
 
 mwide-bitfields