target.h (struct gcc_target): Add target_help field.
authorNick Clifton <nickc@redhat.com>
Wed, 4 Jul 2007 15:05:26 +0000 (15:05 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Wed, 4 Jul 2007 15:05:26 +0000 (15:05 +0000)
* 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
gcc/config/arm/arm.c
gcc/doc/invoke.texi
gcc/doc/tm.texi
gcc/opts.c
gcc/target-def.h
gcc/target.h

index 39da288..cb8bc95 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-04  Nick Clifton  <nickc@redhat.com>
+
+       * 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  <rask@sygehus.dk>
 
        * config/gcc/v850/v850.c (expand_prologue): Make sure
index 6c9a695..2169256 100644 (file)
@@ -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
index 57dbb02..b1bbcf0 100644 (file)
@@ -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
index 145c81a..ceeec11 100644 (file)
@@ -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
index 974c19b..97bcb9f 100644 (file)
@@ -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_:
index c106577..48e1c1a 100644 (file)
@@ -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,                        \
index effd933..4e84e5a 100644 (file)
@@ -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);