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]

MODIFY_TARGET_NAME: new macro


This patch adds support for a MODIFY_TARGET_NAME configuration macro
that allows a port to support command-line switches that modify the
configuration name to a variant name, for example to switch between
32- and 64-bit modes.  It also adds a definition of that macro to
pa.h (at the request of HP).

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.

*** gcc.c	2000/09/18 16:24:25	1.167
--- gcc.c	2000/09/20 14:51:40
*************** static const char *cross_compile = "0";
*** 165,168 ****
--- 165,183 ----
  #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.  */
*************** process_command (argc, argv)
*** 2833,2836 ****
--- 2848,2852 ----
  {
    register int i;
+   unsigned int j;
    const char *temp;
    char *temp1;
*************** process_command (argc, argv)
*** 2840,2843 ****
--- 2856,2862 ----
    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");
*************** process_command (argc, argv)
*** 3006,3009 ****
--- 3025,3029 ----
    /* 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).  */
  
*************** process_command (argc, argv)
*** 3317,3320 ****
--- 3337,3380 ----
  	    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++;
  
*************** process_command (argc, argv)
*** 3414,3417 ****
--- 3474,3488 ----
      {
        /* 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))
  	;
*** tm.texi	2000/09/07 22:24:32	1.144
--- tm.texi	2000/09/20 14:52:04
*************** Cross compilers do not use this macro an
*** 388,391 ****
--- 388,417 ----
  @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
*** config/pa/pa.h	2000/06/21 16:11:39	1.91
--- config/pa/pa.h	2000/09/20 14:52:17
*************** extern int target_flags;
*** 327,330 ****
--- 327,339 ----
  #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> */
  

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