summaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-09-03 10:16:27 +0200
committerMartin Liska <marxin@gcc.gnu.org>2018-09-03 08:16:27 +0000
commitc98c243078c380ad4c9a1ef08869d3b64abb128f (patch)
treef170c789ad3b3928dd6a9c1052207da98693895c /gcc/opts.c
parentd1dfeff07917739fd5ae157be0825a757c576bef (diff)
downloadgcc-c98c243078c380ad4c9a1ef08869d3b64abb128f.tar.gz
Come up with TARGET_GET_VALID_OPTION_VALUES option hook (PR driver/83193).
2018-09-03 Martin Liska <mliska@suse.cz> PR driver/83193 * common/common-target.def: Add TARGET_GET_VALID_OPTION_VALUES. * common/common-targhooks.c (default_get_valid_option_values): New function. * common/common-targhooks.h (default_get_valid_option_values): Likewise. * common/config/i386/i386-common.c: Move processor_target_table from i386.c. (ix86_get_valid_option_values): New function. (TARGET_GET_VALID_OPTION_VALUES): New macro. * config/i386/i386.c (struct ptt): Move to i386-common.c. (PTA_*): Move all defined masks into i386-common.c. (ix86_function_specific_restore): Use new processor_cost_table. * config/i386/i386.h (struct ptt): Moved from i386.c. (struct pta): Likewise. * doc/tm.texi: Document new TARGET_GET_VALID_OPTION_VALUES. * doc/tm.texi.in: Likewise. * opt-suggestions.c (option_proposer::suggest_option): Pass prefix to build_option_suggestions. (option_proposer::get_completions): Likewise. (option_proposer::build_option_suggestions): Use the new target hook. * opts.c (struct option_help_tuple): New struct. (print_filtered_help): Use the new target hook. 2018-09-03 Martin Liska <mliska@suse.cz> PR driver/83193 * gcc.dg/completion-4.c: New test. From-SVN: r264052
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index a5c9ed9d09d..dc12c2ecefd 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1090,6 +1090,21 @@ wrap_help (const char *help,
while (remaining);
}
+/* Data structure used to print list of valid option values. */
+
+struct option_help_tuple
+{
+ option_help_tuple (int code, vec<const char *> values):
+ m_code (code), m_values (values)
+ {}
+
+ /* Code of an option. */
+ int m_code;
+
+ /* List of possible values. */
+ vec<const char *> m_values;
+};
+
/* Print help for a specific front-end, etc. */
static void
print_filtered_help (unsigned int include_flags,
@@ -1143,6 +1158,8 @@ print_filtered_help (unsigned int include_flags,
if (!opts->x_help_enum_printed)
opts->x_help_enum_printed = XCNEWVAR (char, cl_enums_count);
+ auto_vec<option_help_tuple> help_tuples;
+
for (i = 0; i < cl_options_count; i++)
{
const struct cl_option *option = cl_options + i;
@@ -1303,6 +1320,13 @@ print_filtered_help (unsigned int include_flags,
if (option->var_type == CLVC_ENUM
&& opts->x_help_enum_printed[option->var_enum] != 2)
opts->x_help_enum_printed[option->var_enum] = 1;
+ else
+ {
+ vec<const char *> option_values
+ = targetm_common.get_valid_option_values (i, NULL);
+ if (!option_values.is_empty ())
+ help_tuples.safe_push (option_help_tuple (i, option_values));
+ }
}
if (! found)
@@ -1366,6 +1390,15 @@ print_filtered_help (unsigned int include_flags,
printf ("\n\n");
opts->x_help_enum_printed[i] = 2;
}
+
+ for (unsigned i = 0; i < help_tuples.length (); i++)
+ {
+ const struct cl_option *option = cl_options + help_tuples[i].m_code;
+ printf (" Known valid arguments for %s option:\n ", option->opt_text);
+ for (unsigned j = 0; j < help_tuples[i].m_values.length (); j++)
+ printf (" %s", help_tuples[i].m_values[j]);
+ printf ("\n\n");
+ }
}
/* Display help for a specified type of option.