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]

Re: g++.dg/other/static11.C regression


Krister Walfridsson <cato@df.lth.se> writes:

> On Sun, 19 Oct 2003, Zack Weinberg wrote:
>
>>         * config/i386/i386.c (print_reg): Abort if REGNO (x) is a
>>         virtual register, but only if file == asm_out_file.
>>         * config/i386/i386.h (HI_REGISTER_NAMES): Use "argp", not "",
>>         for ARG_POINTER_REGNUM.
>
> This change causes gcc to abort for gcc.dg/old-style-asm-1.c on
> i386-unknown-netbsdelf1.6.

This demonstrates that checking file == asm_out_file is no good,
because of -dP (which causes RTL to be dumped into the .s file).

There aren't very many places that call PRINT_REG.  And the i386 is
the only target with a custom implementation.  Thus, it seems feasible
to define a special value for the "code" argument that means "don't
abort on virtual registers."

Please try the appended patch.  It makes the abort go away in an
i386-linux -> i386-unknown-netbsdelf1.6 cross compile configuration.
(Deleting DEBUG_PRINT_REG is not related to the bug fix; but I thought
I'd done it before, with the patch that caused this problem in the
first place, and it's dead code.)

zw

        * print-rtl.c (print_rtx): Call PRINT_REG with second argument -1.
        * config/i386/i386.c (print_reg): Abort on a virtual register
        if code != -1; not if file == asm_out_file.
        * config/i386/i386.h (PRINT_REG): Document meaning of CODE == -1.
        (DEBUG_PRINT_REG): Delete, unused.

===================================================================
Index: print-rtl.c
--- print-rtl.c	13 Oct 2003 21:16:18 -0000	1.102
+++ print-rtl.c	1 Nov 2003 22:42:30 -0000
@@ -386,7 +386,7 @@ print_rtx (rtx in_rtx)
 	    if (GET_CODE (in_rtx) == REG && value < FIRST_PSEUDO_REGISTER)
 	      {
 		fputc (' ', outfile);
-		PRINT_REG (in_rtx, 0, outfile);
+		PRINT_REG (in_rtx, -1, outfile);
 	      }
 	    else if (GET_CODE (in_rtx) == REG
 		     && value <= LAST_VIRTUAL_REGISTER)
===================================================================
Index: config/i386/i386.c
--- config/i386/i386.c	30 Oct 2003 21:01:15 -0000	1.615
+++ config/i386/i386.c	1 Nov 2003 22:42:32 -0000
@@ -6993,11 +6993,14 @@ put_condition_code (enum rtx_code code, 
 void
 print_reg (rtx x, int code, FILE *file)
 {
-  if ((REGNO (x) == ARG_POINTER_REGNUM
-       || REGNO (x) == FRAME_POINTER_REGNUM
-       || REGNO (x) == FLAGS_REG
-       || REGNO (x) == FPSR_REG)
-      && file == asm_out_file)
+  /* Code -1 indicates we are called from print_rtx, and it is not
+     an error for a virtual register to appear here.  */
+  if (code == -1)
+    code = 0;
+  else if (REGNO (x) == ARG_POINTER_REGNUM
+	   || REGNO (x) == FRAME_POINTER_REGNUM
+	   || REGNO (x) == FLAGS_REG
+	   || REGNO (x) == FPSR_REG)
     abort ();
 
   if (ASSEMBLER_DIALECT == ASM_ATT || USER_LABEL_PREFIX[0] == 0)
===================================================================
Index: config/i386/i386.h
--- config/i386/i386.h	30 Oct 2003 21:01:16 -0000	1.357
+++ config/i386/i386.h	1 Nov 2003 22:42:32 -0000
@@ -2882,7 +2882,8 @@ do {									\
    If CODE is 'k', pretend the mode is SImode.
    If CODE is 'q', pretend the mode is DImode.
    If CODE is 'h', pretend the reg is the `high' byte register.
-   If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.  */
+   If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.
+   If CODE is -1, it is not an error for X to be a virtual register.  */
 
 #define PRINT_REG(X, CODE, FILE)  \
   print_reg ((X), (CODE), (FILE))
@@ -2898,70 +2899,6 @@ do {						\
   if (! output_addr_const_extra (FILE, (X)))	\
     goto FAIL;					\
 } while (0);
-
-/* Print the name of a register for based on its machine mode and number.
-   This macro is used to print debugging output.
-   This macro is different from PRINT_REG in that it may be used in
-   programs that are not linked with aux-output.o.  */
-
-#define DEBUG_PRINT_REG(X, CODE, FILE)			\
-  do { static const char * const hi_name[] = HI_REGISTER_NAMES;	\
-       static const char * const qi_name[] = QI_REGISTER_NAMES;	\
-       fprintf ((FILE), "%d ", REGNO (X));		\
-       if (REGNO (X) == FLAGS_REG)			\
-	 { fputs ("flags", (FILE)); break; }		\
-       if (REGNO (X) == DIRFLAG_REG)			\
-	 { fputs ("dirflag", (FILE)); break; }		\
-       if (REGNO (X) == FPSR_REG)			\
-	 { fputs ("fpsr", (FILE)); break; }		\
-       if (REGNO (X) == ARG_POINTER_REGNUM)		\
-	 { fputs ("argp", (FILE)); break; }		\
-       if (REGNO (X) == FRAME_POINTER_REGNUM)		\
-	 { fputs ("frame", (FILE)); break; }		\
-       if (STACK_TOP_P (X))				\
-	 { fputs ("st(0)", (FILE)); break; }		\
-       if (FP_REG_P (X))				\
-	 { fputs (hi_name[REGNO(X)], (FILE)); break; }	\
-       if (REX_INT_REG_P (X))				\
-	 {						\
-	   switch (GET_MODE_SIZE (GET_MODE (X)))	\
-	     {						\
-	     default:					\
-	     case 8:					\
-	       fprintf ((FILE), "r%i", REGNO (X)	\
-			- FIRST_REX_INT_REG + 8);	\
-	       break;					\
-	     case 4:					\
-	       fprintf ((FILE), "r%id", REGNO (X)	\
-			- FIRST_REX_INT_REG + 8);	\
-	       break;					\
-	     case 2:					\
-	       fprintf ((FILE), "r%iw", REGNO (X)	\
-			- FIRST_REX_INT_REG + 8);	\
-	       break;					\
-	     case 1:					\
-	       fprintf ((FILE), "r%ib", REGNO (X)	\
-			- FIRST_REX_INT_REG + 8);	\
-	       break;					\
-	     }						\
-	   break;					\
-	 }						\
-       switch (GET_MODE_SIZE (GET_MODE (X)))		\
-	 {						\
-	 case 8:					\
-	   fputs ("r", (FILE));				\
-	   fputs (hi_name[REGNO (X)], (FILE));		\
-	   break;					\
-	 default:					\
-	   fputs ("e", (FILE));				\
-	 case 2:					\
-	   fputs (hi_name[REGNO (X)], (FILE));		\
-	   break;					\
-	 case 1:					\
-	   fputs (qi_name[REGNO (X)], (FILE));		\
-	   break;					\
-	 }						\
-     } while (0)
 
 /* a letter which is not needed by the normal asm syntax, which
    we can use for operand syntax in the extended asm */


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