This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Remove support for TARGET_SWITCHES and TARGET_OPTIONS


Following on from:

    http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02594.html
    http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02686.html
    http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02687.html

this patch removes support for TARGET_SWITCHES and TARGET_OPTIONS,
and poisons those macros in system.h.

This allows the --target-help routine to be moved from toplev.c
to opts.c, where the other help-printing functions are found.
set_target_switch can be deleted outright.

There were a couple of lingering mentions of TARGET_OPTIONS in comments.
There was also a mention of TARGET_SWITCHES in doc/invoke.texi.  This
seems strange for user-level documentation, and hasn't been strictly
accurate since the invention of TARGET_OPTIONS, so I just removed
that bit.

Tested by bootstrapping and regression testing on i686-pc-linux-gnu
in combination with the patches above.  OK to install?

Richard


	* system.h (TARGET_OPTIONS, TARGET_SWITCHES): Poison.
	* opts.h (print_filtered_help): Delete.
	* opts.c (handle_option, decode_options): Remove calls to
	set_target_switch.
	(print_target_help): New function.
	(common_option, print_help): Call print_target_help instead of
	display_target_options.
	(print_filtered_help): Make static.
	* toplev.h (display_target_options, set_target_switch): Delete.
	* toplev.c (target_switches, target_options, display_target_options)
	(set_target_switch): Delete.
	(print_switch_values): Remove handling of TARGET_SWITCHES and
	TARGET_OPTIONS.
	(default_get_pch_validity): Likewise.  Only treat target_flags
	specially if targetm.check_pch_target_flags is nonnull.
	(pch_option_mismatch): New function.
	(default_pch_valid_p): Use it.  Remove handling of TARGET_SWITCHES
	and TARGET_OPTIONS.  Only treat target_flags specially if
	targetm.check_pch_target_flags is nonnull.
	* config/ia64/ia64.c (ia64_override_options): Don't mention
	TARGET_OPTIONS in comment.
	* config/m68k/m68k-none.h (CC1_SPEC): Likewise.
	* doc/invoke.texi: Remove a reference to TARGET_SWITCHES.
	* doc/tm.texi (TARGET_DEFAULT_TARGET_FLAGS): Don't mention the
	interaction with TARGET_SWITCHES.
	(TARGET_@var{featurename}, TARGET_SWITCHES, TARGET_OPTIONS): Delete.

*** gcc.2/system.h	2005-05-06 08:21:33.000000000 +0100
--- gcc/system.h	2005-05-27 16:22:01.000000000 +0100
*************** extern void fancy_abort (const char *, i
*** 738,744 ****
  	NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE		   \
  	CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0   \
          TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT	   \
!         LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE
  
  /* Hooks that are no longer used.  */
   #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
--- 738,745 ----
  	NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE		   \
  	CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0   \
          TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT	   \
!         LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE		   \
! 	TARGET_OPTIONS TARGET_SWITCHES
  
  /* Hooks that are no longer used.  */
   #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
*** gcc.2/opts.h	2005-05-27 11:28:44.000000000 +0100
--- gcc/opts.h	2005-05-27 16:28:34.000000000 +0100
*************** extern unsigned num_in_fnames;
*** 86,91 ****
  extern void decode_options (unsigned int argc, const char **argv);
  extern int option_enabled (int opt_idx);
  extern bool get_option_state (int, struct cl_option_state *);
- extern void print_filtered_help (unsigned int);
  
  #endif
--- 86,90 ----
*** gcc.2/opts.c	2005-05-27 11:19:24.000000000 +0100
--- gcc/opts.c	2005-05-27 16:50:11.000000000 +0100
*************** static void complain_wrong_lang (const c
*** 110,117 ****
--- 110,119 ----
  				 unsigned int lang_mask);
  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_target_help (void);
  static void print_help (void);
  static void print_param_help (void);
+ static void print_filtered_help (unsigned int);
  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);
*************** handle_option (const char **argv, unsign
*** 294,309 ****
      }
  
    if (opt_index == cl_options_count)
!     {
! #if defined (TARGET_OPTIONS) || defined (TARGET_SWITCHES)
!       if (opt[1] == 'm')
! 	{
! 	  set_target_switch (argv[0] + 2);
! 	  result = 1;
! 	}
! #endif
!       goto done;
!     }
  
    option = &cl_options[opt_index];
  
--- 296,302 ----
      }
  
    if (opt_index == cl_options_count)
!     goto done;
  
    option = &cl_options[opt_index];
  
*************** decode_options (unsigned int argc, const
*** 633,639 ****
    /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
       modify it.  */
    target_flags = targetm.default_target_flags;
-   set_target_switch ("");
  
    /* Unwind tables are always present when a target has ABI-specified unwind
       tables, so the default should be ON.  */
--- 626,631 ----
*************** common_handle_option (size_t scode, cons
*** 726,732 ****
        break;
  
      case OPT__target_help:
!       display_target_options ();
        exit_after_options = true;
        break;
  
--- 718,724 ----
        break;
  
      case OPT__target_help:
!       print_target_help ();
        exit_after_options = true;
        break;
  
*************** set_debug_level (enum debug_info_type ty
*** 1203,1208 ****
--- 1195,1221 ----
      }
  }
  
+ /* Display help for target options.  */
+ static void
+ print_target_help (void)
+ {
+   unsigned int i;
+   static bool displayed = false;
+ 
+   /* Avoid double printing for --help --target-help.  */
+   if (displayed)
+     return;
+ 
+   displayed = true;
+   for (i = 0; i < cl_options_count; i++)
+     if ((cl_options[i].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
+       {
+ 	printf (_("\nTarget specific options:\n"));
+ 	print_filtered_help (CL_TARGET);
+ 	break;
+       }
+ }
+ 
  /* Output --help text.  */
  static void
  print_help (void)
*************** print_help (void)
*** 1229,1236 ****
  	      lang_names[i]);
        print_filtered_help (1U << i);
      }
! 
!   display_target_options ();
  }
  
  /* Print the help for --param.  */
--- 1242,1248 ----
  	      lang_names[i]);
        print_filtered_help (1U << i);
      }
!   print_target_help ();
  }
  
  /* Print the help for --param.  */
*************** print_param_help (void)
*** 1259,1265 ****
  }
  
  /* Print help for a specific front-end, etc.  */
! void
  print_filtered_help (unsigned int flag)
  {
    unsigned int i, len, filter, indent = 0;
--- 1271,1277 ----
  }
  
  /* Print help for a specific front-end, etc.  */
! static void
  print_filtered_help (unsigned int flag)
  {
    unsigned int i, len, filter, indent = 0;
*** gcc.2/toplev.h	2005-05-16 19:07:01.000000000 +0100
--- gcc/toplev.h	2005-05-27 16:26:03.000000000 +0100
*************** extern int time_report;
*** 138,146 ****
  extern int flag_tree_based_profiling;
  
  /* Things to do with target switches.  */
- extern void display_target_options (void);
  extern void print_version (FILE *, const char *);
- extern void set_target_switch (const char *);
  extern void * default_get_pch_validity (size_t *);
  extern const char * default_pch_valid_p (const void *, size_t);
  
--- 138,144 ----
*** gcc.2/toplev.c	2005-05-27 11:21:57.000000000 +0100
--- gcc/toplev.c	2005-05-28 08:47:58.000000000 +0100
*************** static const param_info lang_independent
*** 374,408 ****
    { 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.
-    If VALUE is negative, -VALUE is bits to clear.
-    (The sign bit is not used so there is no confusion.)  */
- 
- static const struct
- {
-   const char *const name;
-   const int value;
-   const char *const description;
- }
- target_switches[] = TARGET_SWITCHES;
- #endif
- 
- /* This table is similar, but allows the switch to have a value.  */
- 
- #ifdef TARGET_OPTIONS
- static const struct
- {
-   const char *const prefix;
-   const char **const variable;
-   const char *const description;
-   const char *const value;
- }
- target_options[] = TARGET_OPTIONS;
- #endif
- 
  /* Output files for assembler code (real compiler output)
     and debugging dumps.  */
  
--- 374,379 ----
*************** compile_file (void)
*** 1057,1148 ****
    targetm.asm_out.file_end ();
  }
  
- /* Display help for target options.  */
- void
- display_target_options (void)
- {
-   int undoc;
- #if defined (TARGET_SWITCHES) || defined (TARGET_OPTIONS)
-   int i;
- #endif
-   unsigned int cli;
-   static bool displayed = false;
- 
-   /* Avoid double printing for --help --target-help.  */
-   if (displayed)
-     return;
- 
-   displayed = true;
- 
-   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 = 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;
- 	  const char *description = target_switches[i].description;
- 
- 	  if (option == NULL || *option == 0)
- 	    continue;
- 	  else if (description == NULL)
- 	    {
- 	      undoc = 1;
- 
- 	      if (extra_warnings)
- 		printf (_("  -m%-23s [undocumented]\n"), option);
- 	    }
- 	  else if (*description != 0)
- 	    doc += printf ("  -m%-23s %s\n", option, _(description));
- 	}
- #endif
- 
- #ifdef TARGET_OPTIONS
-       for (i = ARRAY_SIZE (target_options); i--;)
- 	{
- 	  const char *option      = target_options[i].prefix;
- 	  const char *description = target_options[i].description;
- 
- 	  if (option == NULL || *option == 0)
- 	    continue;
- 	  else if (description == NULL)
- 	    {
- 	      undoc = 1;
- 
- 	      if (extra_warnings)
- 		printf (_("  -m%-23s [undocumented]\n"), option);
- 	    }
- 	  else if (*description != 0)
- 	    doc += printf ("  -m%-23s %s\n", option, _(description));
- 	}
- #endif
-       print_filtered_help (CL_TARGET);
-       if (undoc)
- 	{
- 	  if (doc)
- 	    printf (_("\nThere are undocumented target specific options as well.\n"));
- 	  else
- 	    printf (_("  They exist, but they are not documented.\n"));
- 	}
-     }
- }
- 
  /* Parse a -d... command line switch.  */
  
  void
--- 1028,1033 ----
*************** const char *const debug_type_names[] =
*** 1193,1256 ****
    "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
  };
  
- /* Decode -m switches.  */
- /* Decode the switch -mNAME.  */
- 
- 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))
-       {
- 	if (target_switches[j].value < 0)
- 	  target_flags &= ~-target_switches[j].value;
- 	else
- 	  target_flags |= target_switches[j].value;
- 	if (name[0] != 0)
- 	  {
- 	    if (target_switches[j].value < 0)
- 	      target_flags_explicit |= -target_switches[j].value;
- 	    else
- 	      target_flags_explicit |= target_switches[j].value;
- 	  }
- 	valid_target_option = 1;
-       }
- #endif
- 
- #ifdef TARGET_OPTIONS
-   if (!valid_target_option)
-     for (j = 0; j < ARRAY_SIZE (target_options); j++)
-       {
- 	int len = strlen (target_options[j].prefix);
- 	if (target_options[j].value)
- 	  {
- 	    if (!strcmp (target_options[j].prefix, name))
- 	      {
- 		*target_options[j].variable = target_options[j].value;
- 		valid_target_option = 1;
- 	      }
- 	  }
- 	else
- 	  {
- 	    if (!strncmp (target_options[j].prefix, name, len))
- 	      {
- 		*target_options[j].variable = name + len;
- 		valid_target_option = 1;
- 	      }
- 	  }
-       }
- #endif
- 
-   if (name[0] != 0 && !valid_target_option)
-     error ("invalid option %qs", name);
- }
- 
  /* Print version information to FILE.
     Each line begins with INDENT (for the case where FILE is the
     assembler output file).  */
--- 1078,1083 ----
*************** print_switch_values (FILE *file, int pos
*** 1359,1389 ****
        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
- 	&& ((target_switches[j].value & target_flags)
- 	    == target_switches[j].value))
-       {
- 	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++)
-     if (*target_options[j].variable != NULL)
-       {
- 	char prefix[256];
- 	sprintf (prefix, "-m%s", target_options[j].prefix);
- 	pos = print_single_switch (file, pos, max, indent, sep, term,
- 				   prefix, *target_options[j].variable);
-       }
- #endif
- 
    fprintf (file, "%s", term);
  }
  
--- 1186,1191 ----
*************** default_get_pch_validity (size_t *len)
*** 1460,1474 ****
    size_t i;
    char *result, *r;
  
!   *len = sizeof (target_flags) + 2;
! #ifdef TARGET_OPTIONS
!   for (i = 0; i < ARRAY_SIZE (target_options); i++)
!     {
!       *len += 1;
!       if (*target_options[i].variable)
! 	*len += strlen (*target_options[i].variable);
!     }
! #endif
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        *len += state.size;
--- 1262,1270 ----
    size_t i;
    char *result, *r;
  
!   *len = 2;
!   if (targetm.check_pch_target_flags)
!     *len += sizeof (target_flags);
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        *len += state.size;
*************** default_get_pch_validity (size_t *len)
*** 1477,1497 ****
    r[0] = flag_pic;
    r[1] = flag_pie;
    r += 2;
!   memcpy (r, &target_flags, sizeof (target_flags));
!   r += sizeof (target_flags);
! 
! #ifdef TARGET_OPTIONS
!   for (i = 0; i < ARRAY_SIZE (target_options); i++)
      {
!       const char *str = *target_options[i].variable;
!       size_t l;
!       if (! str)
! 	str = "";
!       l = strlen (str) + 1;
!       memcpy (r, str, l);
!       r += l;
      }
! #endif
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        {
--- 1273,1284 ----
    r[0] = flag_pic;
    r[1] = flag_pie;
    r += 2;
!   if (targetm.check_pch_target_flags)
      {
!       memcpy (r, &target_flags, sizeof (target_flags));
!       r += sizeof (target_flags);
      }
! 
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        {
*************** default_get_pch_validity (size_t *len)
*** 1502,1507 ****
--- 1289,1308 ----
    return result;
  }
  
+ /* Return a message which says that a PCH file was created with a different
+    setting of OPTION.  */
+ 
+ static const char *
+ pch_option_mismatch (const char *option)
+ {
+   char *r;
+ 
+   asprintf (&r, _("created and used with differing settings of '%s'"), option);
+   if (r == NULL)
+     return _("out of memory");
+   return r;
+ }
+ 
  /* Default version of pch_valid_p.  */
  
  const char *
*************** default_pch_valid_p (const void *data_p,
*** 1509,1517 ****
  {
    struct cl_option_state state;
    const char *data = (const char *)data_p;
-   const char *flag_that_differs = NULL;
    size_t i;
-   int tf;
  
    /* -fpic and -fpie also usually make a PCH invalid.  */
    if (data[0] != flag_pic)
--- 1310,1316 ----
*************** default_pch_valid_p (const void *data_p,
*** 1521,1597 ****
    data += 2;
  
    /* Check target_flags.  */
-   memcpy (&tf, data, sizeof (target_flags));
    if (targetm.check_pch_target_flags)
      {
!       const char *r = targetm.check_pch_target_flags (tf);
        if (r != NULL)
  	return r;
      }
- #ifdef TARGET_SWITCHES
-   else if (tf != target_flags)
-     {
-       for (i = 0; i < ARRAY_SIZE (target_switches); i++)
- 	{
- 	  int bits;
- 
- 	  bits = target_switches[i].value;
- 	  if (bits < 0)
- 	    bits = -bits;
- 	  if ((target_flags & bits) != (tf & bits))
- 	    {
- 	      flag_that_differs = target_switches[i].name;
- 	      goto make_message;
- 	    }
- 	}
-       gcc_unreachable ();
-     }
- #endif
-   data += sizeof (target_flags);
-   len -= sizeof (target_flags);
- 
-   /* Check string options.  */
- #ifdef TARGET_OPTIONS
-   for (i = 0; i < ARRAY_SIZE (target_options); i++)
-     {
-       const char *str = *target_options[i].variable;
-       size_t l;
-       if (! str)
- 	str = "";
-       l = strlen (str) + 1;
-       if (len < l || memcmp (data, str, l) != 0)
- 	{
- 	  flag_that_differs = target_options[i].prefix;
- 	  goto make_message;
- 	}
-       data += l;
-       len -= l;
-     }
- #endif
  
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        {
  	if (memcmp (data, state.data, state.size) != 0)
! 	  {
! 	    flag_that_differs = cl_options[i].opt_text + 2;
! 	    goto make_message;
! 	  }
  	data += state.size;
  	len -= state.size;
        }
  
    return NULL;
- 
-  make_message:
-   {
-     char *r;
-     asprintf (&r, _("created and used with differing settings of '-m%s'"),
- 		  flag_that_differs);
-     if (r == NULL)
-       return _("out of memory");
-     return r;
-   }
  }
  
  /* Default tree printer.   Handles declarations only.  */
--- 1320,1348 ----
    data += 2;
  
    /* Check target_flags.  */
    if (targetm.check_pch_target_flags)
      {
!       int tf;
!       const char *r;
! 
!       memcpy (&tf, data, sizeof (target_flags));
!       data += sizeof (target_flags);
!       len -= sizeof (target_flags);
!       r = targetm.check_pch_target_flags (tf);
        if (r != NULL)
  	return r;
      }
  
    for (i = 0; i < cl_options_count; i++)
      if (option_affects_pch_p (i, &state))
        {
  	if (memcmp (data, state.data, state.size) != 0)
! 	  return pch_option_mismatch (cl_options[i].opt_text);
  	data += state.size;
  	len -= state.size;
        }
  
    return NULL;
  }
  
  /* Default tree printer.   Handles declarations only.  */
*** gcc.2/config/ia64/ia64.c	2005-05-26 06:20:43.000000000 +0100
--- gcc/config/ia64/ia64.c	2005-05-27 16:18:56.000000000 +0100
*************** ia64_handle_option (size_t code, const c
*** 4865,4871 ****
      }
  }
  
! /* Handle TARGET_OPTIONS switches.  */
  
  void
  ia64_override_options (void)
--- 4865,4871 ----
      }
  }
  
! /* Implement OVERRIDE_OPTIONS.  */
  
  void
  ia64_override_options (void)
*** gcc.2/config/m68k/m68k-none.h	2005-05-16 19:07:01.000000000 +0100
--- gcc/config/m68k/m68k-none.h	2005-05-27 16:19:51.000000000 +0100
*************** Unrecognized value in TARGET_CPU_DEFAULT
*** 86,93 ****
  "
  
  /* cc1/cc1plus always receives all the -m flags. If the specs strings above 
!    are consistent with the TARGET_OPTIONS flags in m68k.h, there should be no
!    need for any further cc1/cc1plus specs.  */
  
  #undef CC1_SPEC
  #define CC1_SPEC ""
--- 86,93 ----
  "
  
  /* cc1/cc1plus always receives all the -m flags. If the specs strings above 
!    are consistent with the flags in m68k.opt, there should be no need for
!    any further cc1/cc1plus specs.  */
  
  #undef CC1_SPEC
  #define CC1_SPEC ""
*** gcc.2/doc/invoke.texi	2005-05-26 06:30:37.000000000 +0100
--- gcc/doc/invoke.texi	2005-05-27 16:43:12.000000000 +0100
*************** Some configurations of the compiler also
*** 6883,6892 ****
  options, usually for compatibility with other compilers on the same
  platform.
  
- These options are defined by the macro @code{TARGET_SWITCHES} in the
- machine description.  The default for the options is also defined by
- that macro, which enables you to change the defaults.
- 
  @c This list is ordered alphanumerically by subsection name.
  @c It should be the same order and spelling as these options are listed
  @c in Machine Dependent Options
--- 6883,6888 ----
*** gcc.2/doc/tm.texi	2005-05-27 06:54:32.000000000 +0100
--- gcc/doc/tm.texi	2005-05-27 16:22:49.000000000 +0100
*************** any target-specific headers.
*** 728,738 ****
  @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
--- 728,738 ----
  @deftypevar {Target Hook} int TARGET_DEFAULT_TARGET_FLAGS
  This variable specifies the initial value of @code{target_flags}.
  Its default setting is 0.
  @end deftypevar
  
+ @cindex optional hardware or system features
+ @cindex features, optional, in system conventions
+ 
  @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
*************** argument.  Otherwise @var{value} is 1 if
*** 750,902 ****
  option was used and 0 if the ``no-'' form was.
  @end deftypefn
  
- @cindex optional hardware or system features
- @cindex features, optional, in system conventions
- 
- @defmac TARGET_@var{featurename}
- This series of macros is to allow compiler command arguments to
- enable or disable the use of optional features of the target machine.
- For example, one machine description serves both the 68000 and
- the 68020; a command argument tells the compiler whether it should
- use 68020-only instructions or not.  This command argument works
- by means of a macro @code{TARGET_68020} that tests a bit in
- @code{target_flags}.
- 
- Define a macro @code{TARGET_@var{featurename}} for each such option.
- Its definition should test a bit in @code{target_flags}.  It is
- recommended that a helper macro @code{MASK_@var{featurename}}
- is defined for each bit-value to test, and used in
- @code{TARGET_@var{featurename}} and @code{TARGET_SWITCHES}.  For
- example:
- 
- @smallexample
- #define TARGET_MASK_68020 1
- #define TARGET_68020 (target_flags & MASK_68020)
- @end smallexample
- 
- One place where these macros are used is in the condition-expressions
- of instruction patterns.  Note how @code{TARGET_68020} appears
- frequently in the 68000 machine description file, @file{m68k.md}.
- Another place they are used is in the definitions of the other
- macros in the @file{@var{machine}.h} file.
- @end defmac
- 
- @defmac TARGET_SWITCHES
- This macro defines names of command options to set and clear
- bits in @code{target_flags}.  Its definition is an initializer
- with a subgrouping for each command option.
- 
- Each subgrouping contains a string constant, that defines the option
- name, a number, which contains the bits to set in
- @code{target_flags}, and a second string which is the description
- displayed by @option{--help}.  If the number is negative then the bits specified
- by the number are cleared instead of being set.  If the description
- string is present but empty, then no help information will be displayed
- for that option, but it will not count as an undocumented option.  The
- actual option name is made by appending @samp{-m} to the specified name.
- Non-empty description strings should be marked with @code{N_(@dots{})} for
- @command{xgettext}.  Please do not mark empty strings because the empty
- string is reserved by GNU gettext.  @code{gettext("")} returns the header entry
- of the message catalog with meta information, not the empty string.
- 
- In addition to the description for @option{--help},
- more detailed documentation for each option should be added to
- @file{invoke.texi}.
- 
- One of the subgroupings should have a null string.  The number in
- this grouping is the default value for @code{target_flags}.  Any
- target options act starting with that value.
- 
- Here is an example which defines @option{-m68000} and @option{-m68020}
- with opposite meanings, and picks the latter as the default:
- 
- @smallexample
- #define TARGET_SWITCHES \
-   @{ @{ "68020", MASK_68020, "" @},     \
-     @{ "68000", -MASK_68020,          \
-       N_("Compile for the 68000") @}, \
-     @{ "", 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
- This macro is similar to @code{TARGET_SWITCHES} but defines names of command
- options that have values.  Its definition is an initializer with a
- subgrouping for each command option.
- 
- Each subgrouping contains a string constant, that defines the option
- name, the address of a variable, a description string, and a value.
- Non-empty description strings should be marked with @code{N_(@dots{})}
- for @command{xgettext}.  Please do not mark empty strings because the
- empty string is reserved by GNU gettext.  @code{gettext("")} returns the
- header entry of the message catalog with meta information, not the empty
- string.
- 
- If the value listed in the table is @code{NULL}, then the variable, type
- @code{char *}, is set to the variable part of the given option if the
- fixed part matches.  In other words, if the first part of the option
- matches what's in the table, the variable will be set to point to the
- rest of the option.  This allows the user to specify a value for that
- option.  The actual option name is made by appending @samp{-m} to the
- specified name.  Again, each option should also be documented in
- @file{invoke.texi}.
- 
- If the value listed in the table is non-@code{NULL}, then the option
- must match the option in the table exactly (with @samp{-m}), and the
- variable is set to point to the value listed in the table.
- 
- Here is an example which defines @option{-mshort-data-@var{number}}.  If the
- given option is @option{-mshort-data-512}, the variable @code{m88k_short_data}
- will be set to the string @code{"512"}.
- 
- @smallexample
- extern char *m88k_short_data;
- #define TARGET_OPTIONS \
-  @{ @{ "short-data-", &m88k_short_data, \
-      N_("Specify the size of the short data section"), 0 @} @}
- @end smallexample
- 
- Here is a variant of the above that allows the user to also specify
- just @option{-mshort-data} where a default of @code{"64"} is used.
- 
- @smallexample
- extern char *m88k_short_data;
- #define TARGET_OPTIONS \
-  @{ @{ "short-data-", &m88k_short_data, \
-      N_("Specify the size of the short data section"), 0 @} \
-     @{ "short-data", &m88k_short_data, "", "64" @},
-     @}
- @end smallexample
- 
- Here is an example which defines @option{-mno-alu}, @option{-malu1}, and
- @option{-malu2} as a three-state switch, along with suitable macros for
- checking the state of the option (documentation is elided for brevity).
- 
- @smallexample
- [chip.c]
- char *chip_alu = ""; /* @r{Specify default here.}  */
- 
- [chip.h]
- extern char *chip_alu;
- #define TARGET_OPTIONS \
-   @{ @{ "no-alu", &chip_alu, "", "" @}, \
-      @{ "alu1", &chip_alu, "", "1" @}, \
-      @{ "alu2", &chip_alu, "", "2" @}, @}
- #define TARGET_ALU (chip_alu[0] != '\0')
- #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
  This macro is a C statement to print on @code{stderr} a string
  describing the particular machine description choice.  Every machine
--- 750,755 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]