OSDN Git Service

* gcc.c (modify_target): New variable and struct.
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Sep 2000 20:06:55 +0000 (20:06 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Sep 2000 20:06:55 +0000 (20:06 +0000)
(process_command): Handle MODIFY_TARGET_NAME.
* tm.texi (MODIFY_TARGET_NAME): Add documentation for new macro.
* config/pa/pa.h (MODIFY_TARGET_NAME): New macro.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36555 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/pa/pa.h
gcc/gcc.c
gcc/tm.texi

index 84f7097..2fd3cba 100644 (file)
@@ -1,5 +1,10 @@
 Wed Sep 20 15:39:14 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
+       * gcc.c (modify_target): New variable and struct.
+       (process_command): Handle MODIFY_TARGET_NAME.
+       * tm.texi (MODIFY_TARGET_NAME): Add documentation for new macro.
+       * config/pa/pa.h (MODIFY_TARGET_NAME): New macro.
+
        * c-decl.c (finish_decl): Add else's to avoid referencing
        TYPE_DOMAIN of an ERROR_MARK.
 
index 103ff18..d1ce1d8 100644 (file)
@@ -326,6 +326,15 @@ extern int target_flags;
 #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
 #endif
 
+/* This macro defines command-line switches that modify the default
+   target name.
+
+   The definition is be an initializer for an array of structures.  Each
+   array element has have three elements: the switch name, one of the
+   enumeration codes ADD or DELETE to indicate whether the string should be
+   inserted or deleted, and the string to be inserted or deleted. */
+#define MODIFY_TARGET_NAME {{"-32", DELETE, "64"}, {"-64", ADD, "64"}}
+
 /* Make gcc agree with <machine/ansi.h> */
 
 #define SIZE_TYPE "unsigned int"
index 95cea0b..9884ff7 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -164,6 +164,21 @@ static const char *cross_compile = "1";
 static const char *cross_compile = "0";
 #endif
 
+#ifdef MODIFY_TARGET_NAME
+
+/* Information on how to alter the target name based on a command-line
+   switch.  The only case we support now is simply appending or deleting a
+   string to or from the end of the first part of the configuration name.  */
+
+struct modify_target
+{
+  const char *sw;
+  enum add_del {ADD, DELETE} add_del;
+  const char *str;
+}
+modify_target[] = MODIFY_TARGET_NAME;
+#endif
 /* The number of errors that have occurred; the link phase will not be
    run if this is non-zero.  */
 static int error_count = 0;
@@ -2832,6 +2847,7 @@ process_command (argc, argv)
      const char *const *argv;
 {
   register int i;
+  unsigned int j;
   const char *temp;
   char *temp1;
   const char *spec_lang = 0;
@@ -2839,6 +2855,9 @@ process_command (argc, argv)
   int have_c = 0;
   int have_o = 0;
   int lang_n_infiles = 0;
+#ifdef MODIFY_TARGET_NAME
+  int is_modify_target_name;
+#endif
 
   GET_ENV_PATH_LIST (gcc_exec_prefix, "GCC_EXEC_PREFIX");
 
@@ -3005,6 +3024,7 @@ process_command (argc, argv)
 
   /* Scan argv twice.  Here, the first time, just count how many switches
      there will be in their vector, and how many input files in theirs.
+     Also parse any switches that determine the configuration name, such as -b.
      Here we also parse the switches that cc itself uses (e.g. -v).  */
 
   for (i = 1; i < argc; i++)
@@ -3316,6 +3336,46 @@ process_command (argc, argv)
 
            default:
            normal_switch:
+
+#ifdef MODIFY_TARGET_NAME
+             is_modify_target_name = 0;
+
+             for (j = 0;
+                  j < sizeof modify_target / sizeof modify_target[0]; j++)
+               if (! strcmp (argv[i], modify_target[j].sw))
+                 {
+                   char *new_name
+                     = (char *) xmalloc (strlen (modify_target[j].str)
+                                         + strlen (spec_machine));
+                   const char *p, *r;
+                   char *q;
+                   int made_addition = 0;
+
+                   is_modify_target_name = 1;
+                   for (p = spec_machine, q = new_name; *p != 0; )
+                     {
+                       if (modify_target[j].add_del == DELETE
+                           && (! strncmp (q, modify_target[j].str,
+                                          strlen (modify_target[j].str))))
+                         p += strlen (modify_target[j].str);
+                       else if (modify_target[j].add_del == ADD
+                                && ! made_addition && *p == '-')
+                         {
+                           for (r = modify_target[j].str; *r != 0; )
+                             *q++ = *r++;
+                           made_addition = 1;
+                         }
+
+                       *q++ = *p++;
+                     }
+
+                   spec_machine = new_name;
+                 }
+
+             if (is_modify_target_name)
+               break;
+#endif               
+
              n_switches++;
 
              if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
@@ -3413,6 +3473,17 @@ process_command (argc, argv)
   for (i = 1; i < argc; i++)
     {
       /* Just skip the switches that were handled by the preceding loop.  */
+#ifdef MODIFY_TARGET_NAME
+      is_modify_target_name = 0;
+
+      for (j = 0; j < sizeof modify_target / sizeof modify_target[0]; j++)
+       if (! strcmp (argv[i], modify_target[j].sw))
+         is_modify_target_name = 1;
+
+      if (is_modify_target_name)
+       ;
+      else
+#endif
       if (! strncmp (argv[i], "-Wa,", 4))
        ;
       else if (! strncmp (argv[i], "-Wp,", 4))
index 41ce0ee..ec2da6b 100644 (file)
@@ -387,6 +387,32 @@ comes before @code{SYSTEM_INCLUDE_DIR} in the search order.
 Cross compilers do not use this macro and do not search either
 @file{/usr/local/include} or its replacement.
 
+@findex MODIFY_TARGET_NAME
+@item MODIFY_TARGET_NAME
+Define this macro if you with to define command-line switches that modify the
+default target name
+
+For each switch, you can include a string to be appended to the first
+part of the configuration name or a string to be deleted from the
+configuration name, if present.  The definition should be an initializer
+for an array of structures.  Each array element should have three
+elements: the switch name (a string constant, including the initial
+dash), one of the enumeration codes @code{ADD} or @code{DELETE} to
+indicate whether the string should be inserted or deleted, and the string
+to be inserted or deleted (a string constant).
+
+For example, on a machine where @samp{64} at the end of the
+configuration name denotes a 64-bit target and you want the @samp{-32}
+and @samp{-64} switches to select between 32- and 64-bit targets, you would
+code
+
+@smallexample
+#define MODIFY_TARGET_NAME \
+  @{ @{ "-32", DELETE, "64"@}, \
+     @{"-64", ADD, "64"@}@}
+@end smallexample
+
+
 @findex SYSTEM_INCLUDE_DIR
 @item SYSTEM_INCLUDE_DIR
 Define this macro as a C string constant if you wish to specify a