aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2005-03-14 20:18:43 +0000
committerRichard Sandiford <rsandifo@redhat.com>2005-03-14 20:18:43 +0000
commitdf1eb048fe2005fac1c3fa67e3393287ac4f00c8 (patch)
tree93e6840750fcec57ca9299b96d2ddd12e82c2805
parenta82f95692108502d6290b78ff41818aa7a9fbf77 (diff)
* config.gcc (extra_options): New variable for listing option files.
Add ${cpu_type}/${cpu_type}.opt to it if that file exists. * configure.ac (extra_opt_files): New AC_SUBST variable. (tm_file_list, tm_include_list): Include options.h first. * configure: Regenerate. * Makefile.in (extra_opt_files, ALL_OPT_FILES): New variables. (s-options): Use $(ALL_OPT_FILES) instead of $(lang_opt_files) (s-options-h): New rule. (options.h): Depend on it. (TEXI_GCCINT_FILES): Add options.texi. * hooks.h (hook_bool_size_t_constcharptr_int_true): Declare. * hooks.c (hook_bool_size_t_constcharptr_int_true): New function. * target.h (gcc_target): Add default_target_flags and handle_option. * target-def.h (TARGET_DEFAULT_TARGET_FLAGS) (TARGET_HANDLE_OPTION): New macros. (TARGET_INITIALIZER): Include them. * opt-functions.awk (opt_args, nth_arg): New functions. (switch_flags): Handle the "Target" flag. (var_args): Delete. (var_name): Use opt_args and nth_arg. (var_set, var_ref): Likewise. Handle "Mask" and "InverseMask". * opth-gen.awk: Declare target_flags. Declare MASK_* and TARGET_* macros for the "Mask" and "InverseMask" options. * opts.h (cl_var_cond): New enum. (cl_option): Replace the "has_set_value" and "set_value" fields with "var_cond" and "var_value". (CL_TARGET): New macro. (option_enabled, print_filtered_help): Declare. (decode_options): Move definition. * opts.c (handle_option): Search for the original option before removing any "no-" prefix. Handle CL_TARGET. Adjust for the new var_cond and var_value fields. Use targetm.handle_option to handle target options. (decode_options): Set target_flags to targetm.default_target_flags. (print_filtered_help): Make global. Handle CL_TARGET. (option_enabled): New function. * toplev.c (target_switches): Guard with #ifdef TARGET_SWITCHES. (display_target_options, set_target_switch, print_switch_values) (default_pch_valid_p): Guard uses of target_switches with #ifdef TARGET_SWITCHES. Also... (display_target_options): Display the CL_TARGET entries in cl_options. (set_target_option): Don't complain about the "" option when TARGET_SWITCHES is undefined. (print_switch_values): Use option_enabled. (default_pch_valid_p): Check cl_options[] when looking for something that has changed the value of target_flags. * c.opt: Remove documentation from top of file. * doc/gccint.texi: Add an "Options" chapter. Include options.texi. * doc/sourecebuild.texi: Refer to the new options documentation instead of c.opt. Document machine-specific .opt files. * doc/tm.texi (target_flags): Say that this variable is declared by options.h. (TARGET_DEFAULT_TARGET_FLAGS, TARGET_HANDLE_OPTION): Document. (TARGET_SWITCHES, TARGET_OPTIONS): Refer to the option files as an alternative. * doc/options.texi: New file. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@96448 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog59
-rw-r--r--gcc/Makefile.in18
-rw-r--r--gcc/c.opt45
-rw-r--r--gcc/config.gcc7
-rwxr-xr-xgcc/configure14
-rw-r--r--gcc/configure.ac11
-rw-r--r--gcc/doc/gccint.texi2
-rw-r--r--gcc/doc/options.texi161
-rw-r--r--gcc/doc/sourcebuild.texi9
-rw-r--r--gcc/doc/tm.texi36
-rw-r--r--gcc/hooks.c8
-rw-r--r--gcc/hooks.h1
-rw-r--r--gcc/opt-functions.awk75
-rw-r--r--gcc/opth-gen.awk26
-rw-r--r--gcc/opts.c74
-rw-r--r--gcc/opts.h24
-rw-r--r--gcc/target-def.h6
-rw-r--r--gcc/target.h10
-rw-r--r--gcc/toplev.c59
19 files changed, 519 insertions, 126 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1e0a0f48f74..fb182eb502a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,62 @@
+2005-03-14 Richard Sandiford <rsandifo@redhat.com>
+
+ * config.gcc (extra_options): New variable for listing option files.
+ Add ${cpu_type}/${cpu_type}.opt to it if that file exists.
+ * configure.ac (extra_opt_files): New AC_SUBST variable.
+ (tm_file_list, tm_include_list): Include options.h first.
+ * configure: Regenerate.
+ * Makefile.in (extra_opt_files, ALL_OPT_FILES): New variables.
+ (s-options): Use $(ALL_OPT_FILES) instead of $(lang_opt_files)
+ (s-options-h): New rule.
+ (options.h): Depend on it.
+ (TEXI_GCCINT_FILES): Add options.texi.
+ * hooks.h (hook_bool_size_t_constcharptr_int_true): Declare.
+ * hooks.c (hook_bool_size_t_constcharptr_int_true): New function.
+ * target.h (gcc_target): Add default_target_flags and handle_option.
+ * target-def.h (TARGET_DEFAULT_TARGET_FLAGS)
+ (TARGET_HANDLE_OPTION): New macros.
+ (TARGET_INITIALIZER): Include them.
+ * opt-functions.awk (opt_args, nth_arg): New functions.
+ (switch_flags): Handle the "Target" flag.
+ (var_args): Delete.
+ (var_name): Use opt_args and nth_arg.
+ (var_set, var_ref): Likewise. Handle "Mask" and "InverseMask".
+ * opth-gen.awk: Declare target_flags. Declare MASK_* and TARGET_*
+ macros for the "Mask" and "InverseMask" options.
+ * opts.h (cl_var_cond): New enum.
+ (cl_option): Replace the "has_set_value" and "set_value" fields with
+ "var_cond" and "var_value".
+ (CL_TARGET): New macro.
+ (option_enabled, print_filtered_help): Declare.
+ (decode_options): Move definition.
+ * opts.c (handle_option): Search for the original option before
+ removing any "no-" prefix. Handle CL_TARGET. Adjust for the new
+ var_cond and var_value fields. Use targetm.handle_option to handle
+ target options.
+ (decode_options): Set target_flags to targetm.default_target_flags.
+ (print_filtered_help): Make global. Handle CL_TARGET.
+ (option_enabled): New function.
+ * toplev.c (target_switches): Guard with #ifdef TARGET_SWITCHES.
+ (display_target_options, set_target_switch, print_switch_values)
+ (default_pch_valid_p): Guard uses of target_switches with
+ #ifdef TARGET_SWITCHES. Also...
+ (display_target_options): Display the CL_TARGET entries in cl_options.
+ (set_target_option): Don't complain about the "" option when
+ TARGET_SWITCHES is undefined.
+ (print_switch_values): Use option_enabled.
+ (default_pch_valid_p): Check cl_options[] when looking for something
+ that has changed the value of target_flags.
+ * c.opt: Remove documentation from top of file.
+ * doc/gccint.texi: Add an "Options" chapter. Include options.texi.
+ * doc/sourecebuild.texi: Refer to the new options documentation
+ instead of c.opt. Document machine-specific .opt files.
+ * doc/tm.texi (target_flags): Say that this variable is declared
+ by options.h.
+ (TARGET_DEFAULT_TARGET_FLAGS, TARGET_HANDLE_OPTION): Document.
+ (TARGET_SWITCHES, TARGET_OPTIONS): Refer to the option files as
+ an alternative.
+ * doc/options.texi: New file.
+
2005-03-14 Alexandre Oliva <aoliva@redhat.com>
PR middle-end/18628
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 1b72ac8132e..fbdc9e11ac9 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -425,6 +425,7 @@ GCC_THREAD_FILE=@thread_file@
OBJC_BOEHM_GC=@objc_boehm_gc@
GTHREAD_FLAGS=@gthread_flags@
extra_modes_file=@extra_modes_file@
+extra_opt_files=@extra_opt_files@
host_hook_obj=@out_host_hook_obj@
# Be prepared for gcc2 merges.
gcc_version=@gcc_version@
@@ -880,6 +881,9 @@ SUBDIR_FLAGS_TO_PASS = $(ORDINARY_FLAGS_TO_PASS) \
#
# Lists of files for various purposes.
+# All option source files
+ALL_OPT_FILES=$(lang_opt_files) $(extra_opt_files)
+
# Target specific, C specific object file
C_TARGET_OBJS=@c_target_objs@
@@ -1529,19 +1533,21 @@ s-specs : Makefile
$(STAMP) s-specs
optionlist: s-options ; @true
-s-options: $(lang_opt_files) Makefile $(srcdir)/opt-gather.awk
- $(AWK) -f $(srcdir)/opt-gather.awk $(lang_opt_files) > tmp-optionlist
+s-options: $(ALL_OPT_FILES) Makefile $(srcdir)/opt-gather.awk
+ $(AWK) -f $(srcdir)/opt-gather.awk $(ALL_OPT_FILES) > tmp-optionlist
$(SHELL) $(srcdir)/../move-if-change tmp-optionlist optionlist
$(STAMP) s-options
-
options.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/optc-gen.awk
$(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/optc-gen.awk \
-v header_name="options.h" < $< > $@
-options.h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opth-gen.awk
+options.h: s-options-h ; @true
+s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opth-gen.awk
$(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opth-gen.awk \
- < $< > $@
+ < $< > tmp-options.h
+ $(SHELL) $(srcdir)/../move-if-change tmp-options.h options.h
+ $(STAMP) $@
options.o: options.c options.h opts.h intl.h
@@ -2977,7 +2983,7 @@ TEXI_GCCINT_FILES = gccint.texi gcc-common.texi contribute.texi makefile.texi \
c-tree.texi rtl.texi md.texi tm.texi hostconfig.texi fragments.texi \
configfiles.texi collect2.texi headerdirs.texi funding.texi gnu.texi \
gpl.texi fdl.texi contrib.texi languages.texi sourcebuild.texi \
- gty.texi libgcc.texi cfg.texi tree-ssa.texi
+ gty.texi libgcc.texi cfg.texi tree-ssa.texi options.texi
TEXI_GCCINSTALL_FILES = install.texi install-old.texi fdl.texi
diff --git a/gcc/c.opt b/gcc/c.opt
index 8267e0ee497..25826611292 100644
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -19,51 +19,6 @@
; 02111-1307, USA.
-; This file is processed by the script opts.sh. It is a database of
-; command line options, with each record separated by a blank line,
-; and each field appearing on its own line. The first field is the
-; command-line switch with the leading "-" removed. All options
-; beginning with "f" or "W" are implicitly assumed to take a "no-"
-; form; this form should not be listed. If you do not want this
-; negative form and you want it to be automatically rejected, add
-; RejectNegative to the second field.
-
-; The second field is a space-separated list of which parts of the
-; compiler recognize the switch, as declared by "Language" entries.
-; If the switch takes an argument, then you should also specify
-; "Joined" and/or "Separate" to indicate where the argument can
-; appear. If a Joined argument can legitimately be omitted, specify
-; "JoinedOrMissing" instead of "Joined". If the argument to a switch
-; is a non-negative integer, you can specify "UInteger" and the switch
-; decoder will convert the argument for you, or complain to the user
-; if the argument is invalid. "Var(name,set)" creates an integer
-; variable "name". The variable is declared and initialized to value
-; given by "Init(value)" (or zero if this property is not defined).
-; When the option is passed to compiler, this variable is set to "set"
-; if value passed through the flag is nonzero, !"set" if value is zero,
-; or to value if "set" is omitted. If "VarExists" is specified, the
-; declaration for the variable is not created. If "Report" is specified,
-; the flag is output with -fverbose-asm.
-
-; The third field is the help text to output with --help. This is
-; automatically line-wrapped on output. Normally the switch is output
-; automatically, with the help text on the right hand side of the
-; output. However, if the help text contains a tab character, the
-; text to the left of the tab is output instead of the switch, and the
-; text to its right forms the help. This is useful for elaborating on
-; what type of argument a switch takes, for example. If the second
-; field contains "Undocumented" then nothing is output with --help.
-; Only do this with good reason like the switch being internal between
-; the driver and the front end - it is not an excuse to leave a switch
-; undocumented.
-
-; Comments can appear on their own line anwhere in the file, preceded
-; by a semicolon. Whitespace is permitted before the semicolon.
-
-; For each switch XXX below, an enumeration constant is created by the
-; script opts.sh spelt OPT_XXX, but with all non-alphanumeric
-; characters replaced with an underscore.
-
; Please try to keep this file in ASCII collating order.
Language
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9de2bb57c70..bd542c4df6d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -98,6 +98,8 @@
#
# extra_programs Like extra_passes, but these are used when linking.
#
+# extra_options List of target-dependent .opt files.
+#
# c_target_objs List of extra target-dependent objects that be
# linked into the C compiler only.
#
@@ -151,6 +153,7 @@ extra_parts=
extra_programs=
extra_objs=
extra_gcc_objs=
+extra_options=
c_target_objs=
cxx_target_objs=
tm_defines=
@@ -318,6 +321,10 @@ if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-modes.def
then
extra_modes=${cpu_type}/${cpu_type}-modes.def
fi
+if test -f ${srcdir}/config/${cpu_type}/${cpu_type}.opt
+then
+ extra_options="${extra_options} ${cpu_type}/${cpu_type}.opt"
+fi
case ${target} in
x86_64-*-*)
diff --git a/gcc/configure b/gcc/configure
index 0283bb9c490..02fdf0bb596 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir gcc_version_trigger gcc_version_full gcc_version GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file PACKAGE VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS host_cc_for_libada CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default set_gcc_lib_path GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir gcc_version_trigger gcc_version_full gcc_version GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files PACKAGE VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS host_cc_for_libada CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default set_gcc_lib_path GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
ac_subst_files='language_hooks'
# Initialize some variables set by options.
@@ -12061,6 +12061,13 @@ _ACEOF
fi
+# Convert extra_options into a form suitable for Makefile use.
+extra_opt_files=
+for f in $extra_options; do
+ extra_opt_files="$extra_opt_files \$(srcdir)/config/$f"
+done
+
+
# auto-host.h is the file containing items generated by autoconf and is
# the first file included by config.h.
# If host=build, it is correct to have bconfig include auto-host.h
@@ -12445,8 +12452,8 @@ host_cc_for_libada=${CC}
out_object_file=`basename $out_file .c`.o
-tm_file_list=
-tm_include_list=
+tm_file_list="options.h"
+tm_include_list="options.h"
for f in $tm_file; do
case $f in
defaults.h )
@@ -16029,6 +16036,7 @@ s,@manext@,$manext,;t t
s,@objext@,$objext,;t t
s,@gthread_flags@,$gthread_flags,;t t
s,@extra_modes_file@,$extra_modes_file,;t t
+s,@extra_opt_files@,$extra_opt_files,;t t
s,@PACKAGE@,$PACKAGE,;t t
s,@VERSION@,$VERSION,;t t
s,@USE_NLS@,$USE_NLS,;t t
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 3cad882f947..dedb8002970 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1332,6 +1332,13 @@ if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
for this architecture.])
fi
+# Convert extra_options into a form suitable for Makefile use.
+extra_opt_files=
+for f in $extra_options; do
+ extra_opt_files="$extra_opt_files \$(srcdir)/config/$f"
+done
+AC_SUBST(extra_opt_files)
+
# auto-host.h is the file containing items generated by autoconf and is
# the first file included by config.h.
# If host=build, it is correct to have bconfig include auto-host.h
@@ -1525,8 +1532,8 @@ AC_SUBST(host_cc_for_libada)
out_object_file=`basename $out_file .c`.o
-tm_file_list=
-tm_include_list=
+tm_file_list="options.h"
+tm_include_list="options.h"
for f in $tm_file; do
case $f in
defaults.h )
diff --git a/gcc/doc/gccint.texi b/gcc/doc/gccint.texi
index 031c707a2ad..d66a4a4a210 100644
--- a/gcc/doc/gccint.texi
+++ b/gcc/doc/gccint.texi
@@ -105,6 +105,7 @@ Additional tutorial information is linked to from
* Libgcc:: Low-level runtime library used by GCC.
* Languages:: Languages for which GCC front ends are written.
* Source Tree:: GCC source tree structure and build system.
+* Options:: Option specification files.
* Passes:: Order of passes, what they do, and what each file is for.
* Trees:: The source representation used by the C and C++ front ends.
* RTL:: The intermediate representation that most passes work on.
@@ -136,6 +137,7 @@ Additional tutorial information is linked to from
@include libgcc.texi
@include languages.texi
@include sourcebuild.texi
+@include options.texi
@include passes.texi
@include c-tree.texi
@include tree-ssa.texi
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
new file mode 100644
index 00000000000..138ebdb838d
--- /dev/null
+++ b/gcc/doc/options.texi
@@ -0,0 +1,161 @@
+@c Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+@c This is part of the GCC manual.
+@c For copying conditions, see the file gcc.texi.
+
+@node Options
+@chapter Option specification files
+@cindex option specification files
+@cindex @samp{opts.sh}
+
+Most GCC command-line options are described by special option
+definition files, the names of which conventionally end in
+@code{.opt}. This chapter describes the format of these files.
+
+@menu
+* Option file format:: The general layout of the files
+* Option properties:: Supported option properties
+@end menu
+
+@node Option file format
+@section Option file format
+
+Option files are a simple list of records in which each field occupies
+its own line and in which the records themselves are separated by
+blank lines. Comments may appear on their own line anywhere within
+the file and are preceded by semicolons. Whitespace is allowed before
+the semicolon.
+
+The files can contain two types of record: language definitions and
+option definitions.
+
+A language definition record has two fields: the string
+@samp{Language} and the name of the language. Once a language has
+been declared in this way, it can be used as an option property.
+@xref{Option properties}.
+
+An option definition record has the following fields:
+
+@enumerate
+@item
+the name of the option, with the leading ``-'' removed
+@item
+a space-separated list of option properties (@pxref{Option properties})
+@item
+the help text to use for @option{--help} (omitted if the second field
+contains the @code{Undocumented} property).
+@end enumerate
+
+By default, all options beginning with ``f'', ``W'' or ``m'' are
+implicitly assumed to take a ``no-'' form. This form should not be
+listed separately. If an option beginning with one of these letters
+does not have a ``no-'' form, you can use the @code{RejectNegative}
+property to reject it.
+
+The help text is automatically line-wrapped before being displayed.
+Normally the name of the option is printed on the left-hand side of
+the output and the help text is printed on the right. However, if the
+help text contains a tab character, the text to the left of the tab is
+used instead of the option's name and the text to the right of the
+tab forms the help text. This allows you to elaborate on what type
+of argument the option takes.
+
+@node Option properties
+@section Option properties
+
+The second field of an option record can specify the following properties:
+
+@table @code
+@item Common
+The option is available for all languages and targets.
+
+@item Target
+The option is available for all languages but is target-specific.
+
+@item @var{language}
+The option is available when compiling for the given language.
+
+It is possible to specify several different languages for the same
+option. Each @var{language} must have been declared by an earlier
+@code{Language} record. @xref{Option file format}.
+
+@item RejectNegative
+The option does not have a ``no-'' form. All options beginning with
+``f'', ``W'' or ``m'' are assumed to have a ``no-'' form unless this
+property is used.
+
+@item Joined
+@itemx Separate
+The option takes a mandatory argument. @code{Joined} indicates
+that the option and argument can be included in the same @code{argv}
+entry (as with @code{-mflush-func=@var{name}}, for example).
+@code{Separate} indicates that the option and argument can be
+separate @code{argv} entries (as with @code{-o}). An option is
+allowed to have both of these properties.
+
+@item JoinedOrMissing
+The option takes an optional argument. If the argument is given,
+it will be part of the same @code{argv} entry as the option itself.
+
+This property cannot be used alongside @code{Joined} or @code{Separate}.
+
+@item UInteger
+The option's argument is a non-negative integer. The option parser
+will check and convert the argument before passing it to the relevant
+option handler.
+
+@item Var(@var{var})
+The option controls an integer variable @var{var}. If the option has
+the @code{UInteger} property, the option parser will set @var{var} to
+the value of the user-specified argument. Otherwise the option is
+assumed to be an on/off switch that is active when @var{var} is nonzero.
+In this case, the option parser will set @var{var} to 1 when the positive
+form of the option is used and 0 when the ``no-'' form is used.
+
+The option-processing script will usually declare @var{var} in
+@file{options.c} and leave it to be zero-initialized at start-up time.
+You can modify this behavior using @code{VarExists} and @code{Init}.
+
+@item Var(@var{var}, @var{set})
+The option controls an integer variable @var{var} and is active when
+@var{var} equals @var{set}. The option parser will set @var{var} to
+@var{set} when the positive form of the option is used and @code{!@var{set}}
+when the ``no-'' form is used.
+
+@var{var} is declared in the same way as for the single-argument form
+described above.
+
+@item VarExists
+The variable specified by the @code{Var} property already exists.
+No definition should be added to @file{options.c} in response to
+this option record.
+
+You should use this property if an earlier option has already declared
+the variable or if the variable is declared outside @file{options.c}.
+
+@item Init(@var{value})
+The variable specified by the @code{Var} property should be statically
+initialized to @var{value}.
+
+@item Mask(@var{name})
+The option is associated with a bit in the @code{target_flags} variable
+(@pxref{Run-time Target}) and is active when that bit is set.
+
+The options-processing script will automatically allocate a unique
+bit for the option and set the macro @code{MASK_@var{name}} to the
+appropriate bitmask. It will also declare a @code{TARGET_@var{name}}
+macro that has the value 1 when the option is active and 0 otherwise.
+
+@item InverseMask(@var{othername})
+@itemx InverseMask(@var{othername}, @var{thisname})
+The option is the inverse of another option that has the
+@code{Mask(@var{othername})} property. If @var{thisname} is given,
+the options-processing script will declare a @code{TARGET_@var{thisname}}
+macro that is 1 when the option is active and 0 otherwise.
+
+@item Report
+The state of the option should be printed by @option{-fverbose-asm}.
+
+@item Undocumented
+The option is deliberately missing documentation and should not
+be included in the @option{--help} output.
+@end table
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index edb61b13f26..128322d7768 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -652,9 +652,7 @@ Move to the stage directory files not included in @code{stagestuff} in
@item lang.opt
This file registers the set of switches that the front end accepts on
-the command line, and their @option{--help} text. The file format is
-documented in the file @file{c.opt}. These files are processed by the
-script @file{opts.sh}.
+the command line, and their @option{--help} text. @xref{Options}.
@item lang-specs.h
This file provides entries for @code{default_compilers} in
@file{gcc.c} which override the default of giving an error that a
@@ -746,6 +744,11 @@ If necessary, a file @file{@var{machine}-modes.def} in the
@file{@var{machine}} directory, containing additional machine modes to
represent condition codes. @xref{Condition Code}, for further details.
@item
+An optional @file{@var{machine}.opt} file in the @file{@var{machine}}
+directory, containing a list of target-specific options. You can also
+add other option files using the @code{extra_options} variable in
+@file{config.gcc}. @xref{Options}.
+@item
Entries in @file{config.gcc} (@pxref{System Config, , The
@file{config.gcc} File}) for the systems with this target
architecture.
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 0a6735387ad..aa5c929f048 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -721,9 +721,35 @@ it yourself.
@end defmac
@deftypevar {extern int} target_flags
-This declaration should be present.
+This variable is declared in @file{options.h}, which is included before
+any target-specific headers.
@end deftypevar
+@deftypevar {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS
+This variable specifies the initial value of @code{target_flags}.
+Its default setting is 0.
+
+If the target defines @code{TARGET_SWITCHES}, the null
+@code{TARGET_SWITCHES} entry will override this value.
+@end deftypevar
+
+@deftypefn {Target Hook} bool TARGET_HANDLE_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
+This hook is called whenever the user specifies one of the
+target-specific options described by the @file{.opt} definition files
+(@pxref{Options}). It has the opportunity to do some option-specific
+processing and should return true if the option is valid. The default
+definition does nothing but return true.
+
+@var{code} specifies the @code{OPT_@var{name}} enumeration value
+associated with the selected option; @var{name} is just a rendering of
+the option name in which non-alphanumeric characters are replaced by
+underscores. @var{arg} specifies the string argument and is null if
+no argument was given. If the option is flagged as a @code{UInteger}
+(@pxref{Option properties}), @var{value} is the numeric value of the
+argument. Otherwise @var{value} is 1 if the positive form of the
+option was used and 0 if the ``no-'' form was.
+@end deftypefn
+
@cindex optional hardware or system features
@cindex features, optional, in system conventions
@@ -792,6 +818,10 @@ with opposite meanings, and picks the latter as the default:
@{ "", MASK_68020, "" @}, \
@}
@end smallexample
+
+This macro is being kept for compatibility with older backends.
+New targets should use option definition files instead.
+@xref{Back End}.
@end defmac
@defmac TARGET_OPTIONS
@@ -861,6 +891,10 @@ extern char *chip_alu;
#define TARGET_ALU1 (chip_alu[0] == '1')
#define TARGET_ALU2 (chip_alu[0] == '2')
@end smallexample
+
+This macro is being kept for compatibility with older backends.
+New targets should use option definition files instead.
+@xref{Back End}.
@end defmac
@defmac TARGET_VERSION
diff --git a/gcc/hooks.c b/gcc/hooks.c
index d091583a2d3..fc59b97bd6c 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -102,6 +102,14 @@ hook_bool_constcharptr_size_t_false (const char *a ATTRIBUTE_UNUSED,
}
bool
+hook_bool_size_t_constcharptr_int_true (size_t a ATTRIBUTE_UNUSED,
+ const char *b ATTRIBUTE_UNUSED,
+ int c ATTRIBUTE_UNUSED)
+{
+ return true;
+}
+
+bool
default_can_output_mi_thunk_no_vcall (tree a ATTRIBUTE_UNUSED,
HOST_WIDE_INT b ATTRIBUTE_UNUSED,
HOST_WIDE_INT c,
diff --git a/gcc/hooks.h b/gcc/hooks.h
index b0f47b7913f..a4a38041f25 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -38,6 +38,7 @@ extern bool hook_bool_rtx_false (rtx);
extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *);
extern bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
extern bool hook_bool_constcharptr_size_t_false (const char *, size_t);
+extern bool hook_bool_size_t_constcharptr_int_true (size_t, const char *, int);
extern void hook_void_void (void);
extern void hook_void_constcharptr (const char *);
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index a21f29d4b12..35ab4453f31 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -18,6 +18,33 @@
# Some common subroutines for use by opt[ch]-gen.awk.
+# If FLAGS contains a "NAME(...argument...)" flag, return the value
+# of the argument. Return the empty string otherwise.
+function opt_args(name, flags)
+{
+ flags = " " flags
+ if (flags !~ " " name "\\(")
+ return ""
+ sub(".* " name "\\(", "", flags)
+ sub("\\).*", "", flags)
+
+ return flags
+}
+
+# Return the Nth comma-separated element of S. Return the empty string
+# if S does not contain N elements.
+function nth_arg(n, s)
+{
+ while (n-- > 0) {
+ if (s !~ ",")
+ return ""
+ sub("[^,]*, *", "", s)
+ }
+ sub(",.*", "", s)
+ return s
+}
+
+# Return a bitmask of CL_* values for option flags FLAGS.
function switch_flags (flags)
{
flags = " " flags " "
@@ -29,6 +56,7 @@ function switch_flags (flags)
result = result " | " macros[j]
}
if (flags ~ " Common ") result = result " | CL_COMMON"
+ if (flags ~ " Target ") result = result " | CL_TARGET"
if (flags ~ " Joined ") result = result " | CL_JOINED"
if (flags ~ " JoinedOrMissing ") \
result = result " | CL_JOINED | CL_MISSING_OK"
@@ -41,36 +69,39 @@ function switch_flags (flags)
return result
}
-function var_args(flags)
-{
- if (flags !~ "Var\\(")
- return ""
- sub(".*Var\\(", "", flags)
- sub("\\).*", "", flags)
-
- return flags
-}
+# If FLAGS includes a Var flag, return the name of the variable it specifies.
+# Return the empty string otherwise.
function var_name(flags)
{
- s = var_args(flags)
- if (s == "")
- return "";
- sub( ",.*", "", s)
- return s
+ return nth_arg(0, opt_args("Var", flags))
}
+
+# Given that an option has flags FLAGS, return an initializer for the
+# "var_cond" and "var_value" fields of its cl_options[] entry.
function var_set(flags)
{
- s = var_args(flags)
- if (s !~ ",")
- return "0, 0"
- sub( "[^,]*,", "", s)
- return "1, " s
+ s = nth_arg(1, opt_args("Var", flags))
+ if (s != "")
+ return "CLVC_EQUAL, " s
+ s = opt_args("Mask", flags);
+ if (s != "")
+ return "CLVC_BIT_SET, MASK_" s
+ s = nth_arg(0, opt_args("InverseMask", flags));
+ if (s != "")
+ return "CLVC_BIT_CLEAR, MASK_" s
+ return "CLVC_BOOLEAN, 0"
}
+
+# Given that an option has flags FLAGS, return an initializer for the
+# "flag_var" field of its cl_options[] entry.
function var_ref(flags)
{
name = var_name(flags)
- if (name == "")
- return "0"
- else
+ if (name != "")
return "&" name
+ if (opt_args("Mask", flags) != "")
+ return "&target_flags"
+ if (opt_args("InverseMask", flags) != "")
+ return "&target_flags"
+ return "0"
}
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 6cea944bc49..83d19343e87 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -53,6 +53,7 @@ print ""
print "#ifndef OPTIONS_H"
print "#define OPTIONS_H"
print ""
+print "extern int target_flags;"
for (i = 0; i < n_opts; i++) {
name = var_name(flags[i]);
@@ -66,6 +67,31 @@ for (i = 0; i < n_opts; i++) {
}
+masknum = 0
+for (i = 0; i < n_opts; i++) {
+ name = opt_args("Mask", flags[i])
+ if (name != "")
+ print "#define MASK_" name " (1 << " masknum++ ")"
+}
+if (masknum > 31)
+ print "#error too many target masks"
+print ""
+
+for (i = 0; i < n_opts; i++) {
+ name = opt_args("Mask", flags[i])
+ if (name != "")
+ print "#define TARGET_" name \
+ " ((target_flags & MASK_" name ") != 0)"
+}
+print ""
+
+for (i = 0; i < n_opts; i++) {
+ opt = opt_args("InverseMask", flags[i])
+ if (opt ~ ",")
+ print "#define TARGET_" nth_arg(1, opt) \
+ " ((target_flags & MASK_" nth_arg(0, opt) ") == 0)"
+}
+print ""
for (i = 0; i < n_langs; i++) {
macros[i] = "CL_" langs[i]
diff --git a/gcc/opts.c b/gcc/opts.c
index c6940013a50..3361c9fe724 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -112,7 +112,6 @@ static void handle_options (unsigned int, const char **, unsigned int);
static void wrap_help (const char *help, const char *item, unsigned int);
static void print_help (void);
static void print_param_help (void);
-static void print_filtered_help (unsigned int flag);
static unsigned int print_switch (const char *text, unsigned int indent);
static void set_debug_level (enum debug_info_type type, int extended,
const char *arg);
@@ -277,10 +276,12 @@ handle_option (const char **argv, unsigned int lang_mask)
opt = argv[0];
- /* Drop the "no-" from negative switches. */
- if ((opt[1] == 'W' || opt[1] == 'f')
+ opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
+ if (opt_index == cl_options_count
+ && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm')
&& opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
{
+ /* Drop the "no-" from negative switches. */
size_t len = strlen (opt) - 3;
dup = xmalloc (len + 1);
@@ -289,9 +290,9 @@ handle_option (const char **argv, unsigned int lang_mask)
memcpy (dup + 2, opt + 5, len - 2 + 1);
opt = dup;
value = 0;
+ opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
}
- opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
if (opt_index == cl_options_count)
goto done;
@@ -335,7 +336,7 @@ handle_option (const char **argv, unsigned int lang_mask)
/* Now we've swallowed any potential argument, complain if this
is a switch for a different front end. */
- if (!(option->flags & (lang_mask | CL_COMMON)))
+ if (!(option->flags & (lang_mask | CL_COMMON | CL_TARGET)))
{
complain_wrong_lang (argv[0], option, lang_mask);
goto done;
@@ -361,17 +362,26 @@ handle_option (const char **argv, unsigned int lang_mask)
}
if (option->flag_var)
- {
- if (option->has_set_value)
- {
- if (value)
- *option->flag_var = option->set_value;
- else
- *option->flag_var = !option->set_value;
- }
- else
+ switch (option->var_cond)
+ {
+ case CLVC_BOOLEAN:
*option->flag_var = value;
- }
+ break;
+
+ case CLVC_EQUAL:
+ *option->flag_var = value ? option->var_value : !option->var_value;
+ break;
+
+ case CLVC_BIT_CLEAR:
+ case CLVC_BIT_SET:
+ if ((value != 0) == (option->var_cond == CLVC_BIT_SET))
+ *option->flag_var |= option->var_value;
+ else
+ *option->flag_var &= ~option->var_value;
+ if (option->flag_var == &target_flags)
+ target_flags_explicit |= option->var_value;
+ break;
+ }
if (option->flags & lang_mask)
if (lang_hooks.handle_option (opt_index, arg, value) == 0)
@@ -381,6 +391,10 @@ handle_option (const char **argv, unsigned int lang_mask)
if (common_handle_option (opt_index, arg, value) == 0)
result = 0;
+ if (result && (option->flags & CL_TARGET))
+ if (!targetm.handle_option (opt_index, arg, value))
+ result = 0;
+
done:
if (dup)
free (dup);
@@ -591,7 +605,7 @@ decode_options (unsigned int argc, const char **argv)
/* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
modify it. */
- target_flags = 0;
+ target_flags = targetm.default_target_flags;
set_target_switch ("");
/* Unwind tables are always present when a target has ABI-specified unwind
@@ -1223,7 +1237,7 @@ print_param_help (void)
}
/* Print help for a specific front-end, etc. */
-static void
+void
print_filtered_help (unsigned int flag)
{
unsigned int i, len, filter, indent = 0;
@@ -1231,7 +1245,7 @@ print_filtered_help (unsigned int flag)
const char *help, *opt, *tab;
static char *printed;
- if (flag == CL_COMMON)
+ if (flag == CL_COMMON || flag == CL_TARGET)
{
filter = flag;
if (!printed)
@@ -1378,3 +1392,27 @@ wrap_help (const char *help, const char *item, unsigned int item_width)
}
while (remaining);
}
+
+/* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't
+ a simple on-off switch. */
+
+int
+option_enabled (const struct cl_option *option)
+{
+ if (option->flag_var)
+ switch (option->var_cond)
+ {
+ case CLVC_BOOLEAN:
+ return *option->flag_var != 0;
+
+ case CLVC_EQUAL:
+ return *option->flag_var == option->var_value;
+
+ case CLVC_BIT_CLEAR:
+ return (*option->flag_var & option->var_value) == 0;
+
+ case CLVC_BIT_SET:
+ return (*option->flag_var & option->var_value) != 0;
+ }
+ return -1;
+}
diff --git a/gcc/opts.h b/gcc/opts.h
index e1e921babe0..de1fe31e90a 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -21,7 +21,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_OPTS_H
#define GCC_OPTS_H
-extern void decode_options (unsigned int argc, const char **argv);
+/* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */
+enum cl_var_cond {
+ /* The switch is enabled when FLAG_VAR is nonzero. */
+ CLVC_BOOLEAN,
+
+ /* The switch is enabled when FLAG_VAR == VAR_VALUE. */
+ CLVC_EQUAL,
+
+ /* The switch is enabled when VAR_VALUE is not set in FLAG_VAR. */
+ CLVC_BIT_CLEAR,
+
+ /* The switch is enabled when VAR_VALUE is set in FLAG_VAR. */
+ CLVC_BIT_SET
+};
struct cl_option
{
@@ -31,14 +44,15 @@ struct cl_option
unsigned char opt_len;
unsigned int flags;
int *flag_var;
- int has_set_value;
- int set_value;
+ enum cl_var_cond var_cond;
+ int var_value;
};
extern const struct cl_option cl_options[];
extern const unsigned int cl_options_count;
extern const char *const lang_names[];
+#define CL_TARGET (1 << 22) /* Target-specific option. */
#define CL_REPORT (1 << 23) /* Report argument with -fverbose-asm */
#define CL_JOINED (1 << 24) /* If takes joined argument. */
#define CL_SEPARATE (1 << 25) /* If takes a separate argument. */
@@ -56,4 +70,8 @@ extern const char **in_fnames;
extern unsigned num_in_fnames;
+extern void decode_options (unsigned int argc, const char **argv);
+extern int option_enabled (const struct cl_option *);
+extern void print_filtered_help (unsigned int);
+
#endif
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 0a072a59e96..e4e2b36a3d0 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -278,6 +278,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_VECTORIZE \
{TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD}
+#define TARGET_DEFAULT_TARGET_FLAGS 0
+
+#define TARGET_HANDLE_OPTION hook_bool_size_t_constcharptr_int_true
+
/* In except.c */
#define TARGET_EH_RETURN_FILTER_MODE default_eh_return_filter_mode
@@ -485,6 +489,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_ASM_OUT, \
TARGET_SCHED, \
TARGET_VECTORIZE, \
+ TARGET_DEFAULT_TARGET_FLAGS, \
+ TARGET_HANDLE_OPTION, \
TARGET_EH_RETURN_FILTER_MODE, \
TARGET_MERGE_DECL_ATTRIBUTES, \
TARGET_MERGE_TYPE_ATTRIBUTES, \
diff --git a/gcc/target.h b/gcc/target.h
index b43517baa3c..35135501b16 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -291,6 +291,16 @@ struct gcc_target
tree (* builtin_mask_for_load) (void);
} vectorize;
+ /* The initial value of target_flags. */
+ int default_target_flags;
+
+ /* Handle target switch CODE (an OPT_* value). ARG is the argument
+ passed to the switch; it is NULL if no argument was. VALUE is the
+ value of ARG if CODE specifies a UInteger option, otherwise it is
+ 1 if the positive form of the switch was used and 0 if the negative
+ form was. Return true if the switch was valid. */
+ bool (* handle_option) (size_t code, const char *arg, int value);
+
/* Return machine mode for filter value. */
enum machine_mode (* eh_return_filter_mode) (void);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e7947eba2eb..04b02bc6ecf 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -374,6 +374,7 @@ static const param_info lang_independent_params[] = {
{ NULL, 0, 0, 0, NULL }
};
+#ifdef TARGET_SWITCHES
/* Here is a table, controlled by the tm.h file, listing each -m switch
and which bits in `target_switches' it should set or clear.
If VALUE is positive, it is bits to set.
@@ -387,6 +388,7 @@ static const struct
const char *const description;
}
target_switches[] = TARGET_SWITCHES;
+#endif
/* This table is similar, but allows the switch to have a value. */
@@ -1066,6 +1068,7 @@ void
display_target_options (void)
{
int undoc, i;
+ unsigned int cli;
static bool displayed = false;
/* Avoid double printing for --help --target-help. */
@@ -1074,18 +1077,26 @@ display_target_options (void)
displayed = true;
- if (ARRAY_SIZE (target_switches) > 1
+ for (cli = 0; cli < cl_options_count; cli++)
+ if ((cl_options[cli].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
+ break;
+
+ if (cli < cl_options_count
+#ifdef TARGET_SWITCHES
+ || ARRAY_SIZE (target_switches) > 1
+#endif
#ifdef TARGET_OPTIONS
|| ARRAY_SIZE (target_options) > 1
#endif
)
{
- int doc = 0;
+ int doc = cli < cl_options_count;
undoc = 0;
printf (_("\nTarget specific options:\n"));
+#ifdef TARGET_SWITCHES
for (i = ARRAY_SIZE (target_switches); i--;)
{
const char *option = target_switches[i].name;
@@ -1103,6 +1114,7 @@ display_target_options (void)
else if (*description != 0)
doc += printf (" -m%-23s %s\n", option, _(description));
}
+#endif
#ifdef TARGET_OPTIONS
for (i = ARRAY_SIZE (target_options); i--;)
@@ -1123,6 +1135,7 @@ display_target_options (void)
doc += printf (" -m%-23s %s\n", option, _(description));
}
#endif
+ print_filtered_help (CL_TARGET);
if (undoc)
{
if (doc)
@@ -1189,9 +1202,12 @@ const char *const debug_type_names[] =
void
set_target_switch (const char *name)
{
+#if defined (TARGET_SWITCHES) || defined (TARGET_OPTIONS)
size_t j;
+#endif
int valid_target_option = 0;
+#ifdef TARGET_SWITCHES
for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (!strcmp (target_switches[j].name, name))
{
@@ -1208,6 +1224,7 @@ set_target_switch (const char *name)
}
valid_target_option = 1;
}
+#endif
#ifdef TARGET_OPTIONS
if (!valid_target_option)
@@ -1233,7 +1250,7 @@ set_target_switch (const char *name)
}
#endif
- if (!valid_target_option)
+ if (name[0] != 0 && !valid_target_option)
error ("invalid option %qs", name);
}
@@ -1340,28 +1357,14 @@ print_switch_values (FILE *file, int pos, int max,
_("options enabled: "), "");
for (j = 0; j < cl_options_count; j++)
- {
- if (!cl_options[j].flag_var
- || !(cl_options[j].flags & CL_REPORT))
- continue;
-
- if (cl_options[j].has_set_value)
- {
- if (*cl_options[j].flag_var != cl_options[j].set_value)
- continue;
- }
- else
- {
- if (!*cl_options[j].flag_var)
- continue;
- }
-
+ if ((cl_options[j].flags & CL_REPORT)
+ && option_enabled (&cl_options[j]) > 0)
pos = print_single_switch (file, pos, max, indent, sep, term,
"", cl_options[j].opt_text);
- }
/* Print target specific options. */
+#ifdef TARGET_SWITCHES
for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (target_switches[j].name[0] != '\0'
&& target_switches[j].value > 0
@@ -1371,6 +1374,7 @@ print_switch_values (FILE *file, int pos, int max,
pos = print_single_switch (file, pos, max, indent, sep, term,
"-m", target_switches[j].name);
}
+#endif
#ifdef TARGET_OPTIONS
for (j = 0; j < ARRAY_SIZE (target_options); j++)
@@ -1497,12 +1501,13 @@ default_pch_valid_p (const void *data_p, size_t len)
/* Check target_flags. */
if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
{
+ int tf;
+
+ memcpy (&tf, data, sizeof (target_flags));
+#ifdef TARGET_SWITCHES
for (i = 0; i < ARRAY_SIZE (target_switches); i++)
{
int bits;
- int tf;
-
- memcpy (&tf, data, sizeof (target_flags));
bits = target_switches[i].value;
if (bits < 0)
@@ -1513,6 +1518,14 @@ default_pch_valid_p (const void *data_p, size_t len)
goto make_message;
}
}
+#endif
+ for (i = 0; i < cl_options_count; i++)
+ if (cl_options[i].flag_var == &target_flags
+ && (cl_options[i].var_value & (target_flags ^ tf)) != 0)
+ {
+ flag_that_differs = cl_options[i].opt_text + 2;
+ goto make_message;
+ }
gcc_unreachable ();
}
data += sizeof (target_flags);