From 67e6ba46a4215ab85c2fa8ae0922740f71fa47b5 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 4 Jul 2007 15:05:26 +0000 Subject: [PATCH] target.h (struct gcc_target): Add target_help field. * target.h (struct gcc_target): Add target_help field. * target-def.h (TARGET_HELP): New. (TARGET_INITIALIZER): Use TARGET_HELP. * opts.c (command_handle_option): Invoke target_help function, if defined, when the user has specified --target-help on the command line. * doc/invoke.texi: Mention that --target-help might print additional information. * doc/tm.texi: Document TARGET_HELP hook. * arm.c (TARGET_HELP): Override default definition. (arm_target_help): New - display a wrapped list of cores and architectures supported. From-SVN: r126323 --- gcc/ChangeLog | 16 ++++++++ gcc/config/arm/arm.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ gcc/doc/invoke.texi | 3 +- gcc/doc/tm.texi | 7 ++++ gcc/opts.c | 4 ++ gcc/target-def.h | 2 + gcc/target.h | 4 ++ 7 files changed, 124 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 39da2887dab..cb8bc9519fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2007-07-04 Nick Clifton + + * target.h (struct gcc_target): Add target_help field. + * target-def.h (TARGET_HELP): New. + (TARGET_INITIALIZER): Use TARGET_HELP. + * opts.c (command_handle_option): Invoke target_help function, if + defined, when the user has specified --target-help on the command + line. + * doc/invoke.texi: Mention that --target-help might print + additional information. + * doc/tm.texi: Document TARGET_HELP hook. + + * arm.c (TARGET_HELP): Override default definition. + (arm_target_help): New - display a wrapped list of cores and + architectures supported. + 2007-07-04 Rask Ingemann Lambertsen * config/gcc/v850/v850.c (expand_prologue): Make sure diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 6c9a69594ba..21692568849 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -193,6 +193,7 @@ static bool arm_cxx_class_data_always_comdat (void); static bool arm_cxx_use_aeabi_atexit (void); static void arm_init_libfuncs (void); static bool arm_handle_option (size_t, const char *, int); +static void arm_target_help (void); static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode); static bool arm_cannot_copy_insn_p (rtx); static bool arm_tls_symbol_p (rtx x); @@ -243,6 +244,8 @@ static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; #define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_SCHED_PROLOG) #undef TARGET_HANDLE_OPTION #define TARGET_HANDLE_OPTION arm_handle_option +#undef TARGET_HELP +#define TARGET_HELP arm_target_help #undef TARGET_COMP_TYPE_ATTRIBUTES #define TARGET_COMP_TYPE_ATTRIBUTES arm_comp_type_attributes @@ -930,6 +933,92 @@ arm_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED) } } +static void +arm_target_help (void) +{ + int i; + static int columns = 0; + int remaining; + + /* If we have not done so already, obtain the desired maximum width of + the output. Note - this is a duplication of the code at the start of + gcc/opts.c:print_specific_help() - the two copies should probably be + replaced by a single function. */ + if (columns == 0) + { + const char *p; + + GET_ENVIRONMENT (p, "COLUMNS"); + if (p != NULL) + { + int value = atoi (p); + + if (value > 0) + columns = value; + } + + if (columns == 0) + /* Use a reasonable default. */ + columns = 80; + } + + printf (" Known ARM CPUs (for use with the -mcpu= and -mtune= options):\n"); + + /* The - 2 is because we know that the last entry in the array is NULL. */ + i = ARRAY_SIZE (all_cores) - 2; + gcc_assert (i > 0); + printf (" %s", all_cores[i].name); + remaining = columns - (strlen (all_cores[i].name) + 4); + gcc_assert (remaining >= 0); + + while (i--) + { + int len = strlen (all_cores[i].name); + + if (remaining > len + 2) + { + printf (", %s", all_cores[i].name); + remaining -= len + 2; + } + else + { + if (remaining > 0) + printf (","); + printf ("\n %s", all_cores[i].name); + remaining = columns - (len + 4); + } + } + + printf ("\n\n Known ARM architectures (for use with the -march= option):\n"); + + i = ARRAY_SIZE (all_architectures) - 2; + gcc_assert (i > 0); + + printf (" %s", all_architectures[i].name); + remaining = columns - (strlen (all_architectures[i].name) + 4); + gcc_assert (remaining >= 0); + + while (i--) + { + int len = strlen (all_architectures[i].name); + + if (remaining > len + 2) + { + printf (", %s", all_architectures[i].name); + remaining -= len + 2; + } + else + { + if (remaining > 0) + printf (","); + printf ("\n %s", all_architectures[i].name); + remaining = columns - (len + 4); + } + } + printf ("\n"); + +} + /* Fix up any incompatible options that the user has specified. This has now turned into a maze. */ void diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 57dbb025d08..b1bbcf0bb02 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1106,7 +1106,8 @@ have no documentation associated with them will also be displayed. @item --target-help @opindex target-help Print (on the standard output) a description of target-specific command -line options for each tool. +line options for each tool. For some targets extra target-specific +information may also be printed. @item --help=@var{class}@r{[},@var{qualifier}@r{]} Print (on the standard output) a description of the command line diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 145c81a1fb4..ceeec115008 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -842,6 +842,13 @@ this macro!} The debugging options are not supposed to alter the generated code. @end defmac +@deftypefn {Target Hook} bool TARGET_HELP (void) +This hook is called in response to the user invoking +@option{--target-help} on the command line. It gives the target a +chance to display extra information on the target specific command +line options found in its @file{.opt} file. +@end deftypefn + @defmac CAN_DEBUG_WITHOUT_FP Define this macro if debugging can be performed even without a frame pointer. If this macro is defined, GCC will turn on the diff --git a/gcc/opts.c b/gcc/opts.c index 974c19b3765..97bcb9f998a 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1229,6 +1229,10 @@ common_handle_option (size_t scode, const char *arg, int value, case OPT__target_help: print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0); exit_after_options = true; + + /* Allow the target a chance to give the user some additional information. */ + if (targetm.target_help) + targetm.target_help (); break; case OPT_fhelp_: diff --git a/gcc/target-def.h b/gcc/target-def.h index c106577c7fb..48e1c1ab919 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -369,6 +369,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define TARGET_DEFAULT_TARGET_FLAGS 0 #define TARGET_HANDLE_OPTION hook_bool_size_t_constcharptr_int_true +#define TARGET_HELP NULL /* In except.c */ #define TARGET_EH_RETURN_FILTER_MODE default_eh_return_filter_mode @@ -666,6 +667,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. TARGET_VECTORIZE, \ TARGET_DEFAULT_TARGET_FLAGS, \ TARGET_HANDLE_OPTION, \ + TARGET_HELP, \ TARGET_EH_RETURN_FILTER_MODE, \ TARGET_MERGE_DECL_ATTRIBUTES, \ TARGET_MERGE_TYPE_ATTRIBUTES, \ diff --git a/gcc/target.h b/gcc/target.h index effd93345dd..4e84e5ab229 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -425,6 +425,10 @@ struct gcc_target form was. Return true if the switch was valid. */ bool (* handle_option) (size_t code, const char *arg, int value); + /* Display extra, target specific information in response to a + --target-help switch. */ + void (* target_help) (void); + /* Return machine mode for filter value. */ enum machine_mode (* eh_return_filter_mode) (void);