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]

[PATCH]: Dump rtl in assembly (second version)


Hi!

Geoff Keating <geoffk@cygnus.com>:
> [PATCH]: Dump rtl in assembly
> http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00289.html
>
> This patch needs to be documented.  You need to update
> invoke.texi.

Here is the new patch with documentation.

I also changed the option to use -dP (instead of -dZ in initial patch).
It also turns on -dp. -dP can stand for a full RTL info dump in the assembly
and -dp is the minimal dump that existed before.

For i386, the -dP generates something like:

#(insn 517 564 518 (set (reg:HI 0 ax)
#        (unspec:HI[
#                (compare:CCFPU (reg:DF 8 st(0))
#                    (reg:DF 9 st(1)))
#            ]  9)) 20 {*cmpfp_2u_1} (nil)
#    (expr_list:REG_DEAD (reg:DF 8 st(0))
#        (expr_list:REG_DEAD (reg:DF 9 st(1))
#            (nil))))
        fucompp # 517   *cmpfp_2u_1     [length = 16]
        fnstsw  %ax                                     

Is it Ok to commit this patch?

	Stephane

2000-09-12  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* flags.h (flag_dump_rtl_in_asm): Declare.
	* toplev.c (flag_dump_rtl_in_asm): Define.
	(decode_d_option): Set flag_dump_rtl_in_asm and flag_print_asm_name
	if -dP is specified.
	* rtl.h (print_rtx_head): Declare.
	* print-rtl.c (print_rtx_head): Define.
	(print_rtx): Print the string pointed to by print_rtx_head
	at beginning of each dump line.
	(print_rtl): Likewise.
	(print_rtl_single): Likewise.
	* final.c (final_scan_insn): Dump the insn in the assembly
	file for debugging.
	* gcc.1: Document -dP option.
	* invoke.texi (Debugging Options): Likewise.
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/final.c gcc/gcc/final.c
--- /src/gnu/cygnus/gcc/gcc/final.c	Tue Sep 12 23:04:29 2000
+++ gcc/gcc/final.c	Tue Sep 12 23:49:03 2000
@@ -2922,6 +2922,14 @@ final_scan_insn (insn, file, optimize, p
 	extract_insn (insn);
 	cleanup_subreg_operands (insn);
 
+       /* Dump the insn in the assembly for debugging.  */
+       if (flag_dump_rtl_in_asm)
+         {
+           print_rtx_head = ASM_COMMENT_START;
+           print_rtl_single (asm_out_file, insn);
+           print_rtx_head = "";
+         }
+       
 	if (! constrain_operands (1))
 	  fatal_insn_not_found (insn);
 
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/flags.h gcc/gcc/flags.h
--- /src/gnu/cygnus/gcc/gcc/flags.h	Fri Sep  8 23:46:58 2000
+++ gcc/gcc/flags.h	Tue Sep 12 00:41:12 2000
@@ -474,6 +474,8 @@ extern int flag_verbose_asm;
 
 extern int flag_debug_asm;
 
+extern int flag_dump_rtl_in_asm;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    -fno-gnu-linker says that collect will be used.  */
 extern int flag_gnu_linker;
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/gcc.1 gcc/gcc/gcc.1
--- /src/gnu/cygnus/gcc/gcc/gcc.1	Mon Sep 11 08:10:30 2000
+++ gcc/gcc/gcc.1	Tue Sep 12 00:41:12 2000
@@ -2311,6 +2311,12 @@ standard error.
 Annotate the assembler output with a comment indicating which
 pattern and alternative was used.
 .TP
+.B \-dP
+Dump the RTL in the assembler output as a comment before each instruction.
+Also turns on
+.B \-dp
+annotation.
+.TP
 .B \-fpretend\-float
 When running a cross-compiler, pretend that the target machine uses the
 same floating point format as the host machine.  This causes incorrect
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/invoke.texi gcc/gcc/invoke.texi
--- /src/gnu/cygnus/gcc/gcc/invoke.texi	Fri Sep  8 23:46:59 2000
+++ gcc/gcc/invoke.texi	Tue Sep 12 00:41:12 2000
@@ -2360,6 +2360,9 @@ standard error.
 Annotate the assembler output with a comment indicating which
 pattern and alternative was used.  The length of each instruction is
 also printed.
+@item P
+Dump the RTL in the assembler output as a comment before each instruction.
+Also turns on @samp{-dp} annotation.
 @item v
 For each of the other indicated dump files (except for
 @file{@var{file}.00.rtl}), dump a representation of the control flow graph
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/print-rtl.c gcc/gcc/print-rtl.c
--- /src/gnu/cygnus/gcc/gcc/print-rtl.c	Tue Sep 12 23:04:44 2000
+++ gcc/gcc/print-rtl.c	Tue Sep 12 23:49:17 2000
@@ -55,6 +55,11 @@ static int indent;
 
 static void print_rtx		PARAMS ((rtx));
 
+/* String printed at beginning of each RTL when it is dumped.
+   This string is set to ASM_COMMENT_START when the RTL is dumped in
+   the assembly output file.  */
+char *print_rtx_head = "";
+
 /* Nonzero means suppress output of instruction numbers and line number
    notes in debugging dumps.
    This must be defined here so that programs like gencodes can be linked.  */
@@ -80,8 +85,9 @@ print_rtx (in_rtx)
 
   if (sawclose)
     {
-      fprintf (outfile, "\n%s",
-	       (xspaces + (sizeof xspaces - 1 - indent * 2)));
+      fprintf (outfile, "\n%s%s",
+               print_rtx_head,
+ 	       (xspaces + (sizeof xspaces - 1 - indent * 2)));
       sawclose = 0;
     }
 
@@ -256,7 +262,8 @@ print_rtx (in_rtx)
 	indent += 2;
 	if (sawclose)
 	  {
-	    fprintf (outfile, "\n%s",
+	    fprintf (outfile, "\n%s%s",
+                     print_rtx_head,
 		     (xspaces + (sizeof xspaces - 1 - indent * 2)));
 	    sawclose = 0;
 	  }
@@ -273,7 +280,8 @@ print_rtx (in_rtx)
 	    indent -= 2;
 	  }
 	if (sawclose)
-	  fprintf (outfile, "\n%s",
+	  fprintf (outfile, "\n%s%s",
+                   print_rtx_head,
 		   (xspaces + (sizeof xspaces - 1 - indent * 2)));
 
 	fputs ("] ", outfile);
@@ -600,7 +608,10 @@ print_rtl (outf, rtx_first)
   sawclose = 0;
 
   if (rtx_first == 0)
-    fputs ("(nil)\n", outf);
+    {
+      fputs (print_rtx_head, outf);
+      fputs ("(nil)\n", outf);
+    }
   else
     switch (GET_CODE (rtx_first))
       {
@@ -614,12 +625,14 @@ print_rtl (outf, rtx_first)
 	  if (! flag_dump_unnumbered
 	      || GET_CODE (tmp_rtx) != NOTE || NOTE_LINE_NUMBER (tmp_rtx) < 0)
 	    {
+              fputs (print_rtx_head, outfile);
 	      print_rtx (tmp_rtx);
 	      fprintf (outfile, "\n");
 	    }
 	break;
 
       default:
+        fputs (print_rtx_head, outfile);
 	print_rtx (rtx_first);
       }
 }
@@ -637,6 +650,7 @@ print_rtl_single (outf, x)
   if (! flag_dump_unnumbered
       || GET_CODE (x) != NOTE || NOTE_LINE_NUMBER (x) < 0)
     {
+      fputs (print_rtx_head, outfile);
       print_rtx (x);
       putc ('\n', outf);
       return 1;
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/rtl.h gcc/gcc/rtl.h
--- /src/gnu/cygnus/gcc/gcc/rtl.h	Tue Sep 12 23:04:45 2000
+++ gcc/gcc/rtl.h	Tue Sep 12 23:49:34 2000
@@ -1747,6 +1747,7 @@ extern void schedule_insns		PARAMS ((FIL
 extern void fix_sched_param		PARAMS ((const char *, const char *));
 
 /* In print-rtl.c */
+extern char *print_rtx_head;
 extern void debug_rtx			PARAMS ((rtx));
 extern void debug_rtx_list		PARAMS ((rtx, int));
 extern void debug_rtx_range		PARAMS ((rtx, rtx));
diff -Nrup --exclude-from=gcc-exclude.lst /src/gnu/cygnus/gcc/gcc/toplev.c gcc/gcc/toplev.c
--- /src/gnu/cygnus/gcc/gcc/toplev.c	Tue Sep 12 23:04:45 2000
+++ gcc/gcc/toplev.c	Tue Sep 12 23:50:47 2000
@@ -795,6 +795,10 @@ int flag_verbose_asm = 0;
 
 int flag_debug_asm = 0;
 
+/* -dP causes the rtl to be emitted as a comment in assembly.  */
+
+int flag_dump_rtl_in_asm = 0;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    (Or, more generally, a linker that handles initializations.)
    -fno-gnu-linker says that collect2 will be used.  */
@@ -3970,6 +3974,10 @@ decode_d_option (arg)
       case 'p':
 	flag_print_asm_name = 1;
 	break;
+      case 'P':
+        flag_dump_rtl_in_asm = 1;
+        flag_print_asm_name = 1;
+        break;
       case 'v':
 	graph_dump_format = vcg;
 	break;

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