public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] RFA: slim RTL printing cleanups
@ 2012-11-26 23:21 Steven Bosscher
  2012-11-27 13:07 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Bosscher @ 2012-11-26 23:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: rdsandiford

[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]

Hello,

This patch performs some necessary TLC on slim RTL printing in sched-vis.c:

* Make it independent of the scheduler. Actually it already was,
mostly. This patch completes the job.

* Harmonize dumping templates for INSN_UID.

* Always print the pattern of a CALL_INSN.

* Don't print "jump" for sched dumps only.

* Harmonize function names:
  - print_* print to a "char *" buffer
  - dump_* print to a given "FILE *"
  - debug_* print to stderr.

Some of the ideas come from Richard S.'s
http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00284.html.

The next patch addresses a bigger problem: The print_* variants should
use something better than a fixed-size buffer. I plan to use
pretty-print. An obstack would also work; but I'd like to keep one
layer of abstraction between the file output and the printers, so that
users can post-process the string if necessary (the case I'm thinking
of, is the graph dumpers, which need to escape some characters before
writing to a file). Any thoughts on this from anyone?

Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
(Yes, I know it's stage3, but look at it this way: the patch does no
harm, and good dumps help for debugging real bugs ;-)

Ciao!
Steven

[-- Attachment #2: print-rtl-slim_1.diff --]
[-- Type: application/octet-stream, Size: 21452 bytes --]

	* rtl.h (debug_bb_n_slim, debug_bb_slim, debug_insn_slim): Remove
	prototypes.
	(debug_rtl_slim): Rename to dump_rtl_slim.
	(print_value_slim): Rename to dump_value_slim.
	* ira.c (ira_update_equiv_info_by_shuffle_insn): Update
	print_value_slim user.
	* lra.c (lra_process_new_insns): Use dump_insn_slim to dump single
	insns.  Use dump_rtl_slim for insn chains.
	* lra-constraints.c (get_reload_reg): Update print_value_slim user.
	(process_addr_reg): Likewise.
	(equiv_address_substitution): Likewise.
	(inherit_reload_reg): Likewise.  Use dump_insn_slim to dump single
	insns.
	(check_and_process_move): Likewise.
	(lra_constraints): Likewise.
	(split_reg): Likewise.
	(update_ebb_live_info): Likewise.
	(remove_inheritance_pseudos): Likewise.
	* sched-vis.c: Don't include sched-int.h.
	Remove #ifdef INSN_SCHEDULING tests.
	(print_value_slim): Rename to dump_value_slim.  Simplify a few
	cases using GET_RTX_NAME.
	(print_pattern): Do not handle UNSPEC and UNSPECV here, explain why.
	(print_insn): Reorganize code to be independent of INSN_SCHEDULING.
	Always print CALL_INSN patterns.  Harmonize INSN_UID dumping template.
	Handle NOTE_INSN_CALL_ARG_LOCATION.
	(dump_rtl_slim): Copied from debug_rtl_slim.
	(debug_rtl_slim): Wrapper around dump_rtl_slim to stderr.
	* haifa-sched.c (schedule_insn): Update print_insn user.

Index: rtl.h
===================================================================
--- rtl.h	(revision 193821)
+++ rtl.h	(working copy)
@@ -2575,14 +2575,6 @@ extern rtx make_compound_operation (rtx, enum rtx_
 /* In cfgcleanup.c  */
 extern void delete_dead_jumptables (void);
 
-/* In sched-vis.c.  */
-extern void debug_bb_n_slim (int);
-extern void debug_bb_slim (struct basic_block_def *);
-extern void print_value_slim (FILE *, const_rtx, int);
-extern void debug_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
-extern void dump_insn_slim (FILE *f, const_rtx x);
-extern void debug_insn_slim (const_rtx x);
-
 /* In sched-rgn.c.  */
 extern void schedule_insns (void);
 
@@ -2609,9 +2601,12 @@ extern void print_inline_rtx (FILE *, const_rtx, i
    sched-vis.c is compiled always.  FIXME: Ideally these functions would
    not be in sched-vis.c but in rtl.c, because they are not only used
    by the scheduler anymore but for all "slim" RTL dumping.  */
-extern void print_insn (char *, const_rtx, int);
-extern void print_pattern (char *, const_rtx, int);
+extern void dump_value_slim (FILE *, const_rtx, int);
+extern void dump_insn_slim (FILE *, const_rtx);
+extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
 extern void print_value (char *, const_rtx, int);
+extern void print_pattern (char *, const_rtx, int);
+extern void print_insn (char *, const_rtx, int);
 
 /* In function.c */
 extern void reposition_prologue_and_epilogue_notes (void);
Index: ira.c
===================================================================
--- ira.c	(revision 193820)
+++ ira.c	(working copy)
@@ -2246,7 +2246,7 @@ ira_update_equiv_info_by_shuffle_insn (int to_regn
 	      fprintf (ira_dump_file,
 		       "      Adding equiv note to insn %u for reg %d ",
 		       INSN_UID (insn), to_regno);
-	      print_value_slim (ira_dump_file, x, 1);
+	      dump_value_slim (ira_dump_file, x, 1);
 	      fprintf (ira_dump_file, "\n");
 	    }
 	}
Index: lra.c
===================================================================
--- lra.c	(revision 193820)
+++ lra.c	(working copy)
@@ -1817,16 +1817,16 @@ lra_process_new_insns (rtx insn, rtx before, rtx a
 
   if (lra_dump_file != NULL && (before != NULL_RTX || after != NULL_RTX))
     {
-      debug_rtl_slim (lra_dump_file, insn, insn, -1, 0);
+      dump_insn_slim (lra_dump_file, insn);
       if (before != NULL_RTX)
 	{
 	  fprintf (lra_dump_file,"    %s before:\n", title);
-	  debug_rtl_slim (lra_dump_file, before, NULL_RTX, -1, 0);
+	  dump_rtl_slim (lra_dump_file, before, NULL_RTX, -1, 0);
 	}
       if (after != NULL_RTX)
 	{
 	  fprintf (lra_dump_file, "    %s after:\n", title);
-	  debug_rtl_slim (lra_dump_file, after, NULL_RTX, -1, 0);
+	  dump_rtl_slim (lra_dump_file, after, NULL_RTX, -1, 0);
 	}
       fprintf (lra_dump_file, "\n");
     }
Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 193820)
+++ lra-constraints.c	(working copy)
@@ -423,7 +423,7 @@ get_reload_reg (enum op_type type, enum machine_mo
 	if (lra_dump_file != NULL)
 	  {
 	    fprintf (lra_dump_file, "	 Reuse r%d for reload ", regno);
-	    print_value_slim (lra_dump_file, original, 1);
+	    dump_value_slim (lra_dump_file, original, 1);
 	  }
 	if (new_class != lra_get_allocno_class (regno))
 	  change_class (regno, new_class, ", change", false);
@@ -992,7 +992,7 @@ check_and_process_move (bool *change_p, bool *sec_
       if (lra_dump_file != NULL)
 	{
 	  fprintf (lra_dump_file, "Deleting move %u\n", INSN_UID (curr_insn));
-	  debug_rtl_slim (lra_dump_file, curr_insn, curr_insn, -1, 0);
+	  dump_insn_slim (lra_dump_file, curr_insn);
 	}
       lra_set_insn_deleted (curr_insn);
       return true;
@@ -1086,7 +1086,7 @@ process_addr_reg (rtx *loc, rtx *before, rtx *afte
 	      fprintf (lra_dump_file,
 		       "Changing pseudo %d in address of insn %u on equiv ",
 		       REGNO (reg), INSN_UID (curr_insn));
-	      print_value_slim (lra_dump_file, *loc, 1);
+	      dump_value_slim (lra_dump_file, *loc, 1);
 	      fprintf (lra_dump_file, "\n");
 	    }
 	  *loc = copy_rtx (*loc);
@@ -2213,7 +2213,7 @@ equiv_address_substitution (struct address_info *a
     {
       fprintf (lra_dump_file, "Changing address in insn %d ",
 	       INSN_UID (curr_insn));
-      print_value_slim (lra_dump_file, *ad->outer, 1);
+      dump_value_slim (lra_dump_file, *ad->outer, 1);
     }
   if (base_reg != new_base_reg)
     {
@@ -2270,7 +2270,7 @@ equiv_address_substitution (struct address_info *a
       else
 	{
 	  fprintf (lra_dump_file, " on equiv ");
-	  print_value_slim (lra_dump_file, *ad->outer, 1);
+	  dump_value_slim (lra_dump_file, *ad->outer, 1);
 	  fprintf (lra_dump_file, "\n");
 	}
     }
@@ -2674,7 +2674,7 @@ curr_insn_transform (void)
 	      fprintf (lra_dump_file,
 		       "Changing pseudo %d in operand %i of insn %u on equiv ",
 		       REGNO (old), i, INSN_UID (curr_insn));
-	      print_value_slim (lra_dump_file, subst, 1);
+	      dump_value_slim (lra_dump_file, subst, 1);
 	      fprintf (lra_dump_file, "\n");
 	    }
 	  op_change_p = change_p = true;
@@ -3465,8 +3465,7 @@ lra_constraints (bool first_p)
 			       "      Removing equiv init insn %i (freq=%d)\n",
 			       INSN_UID (curr_insn),
 			       BLOCK_FOR_INSN (curr_insn)->frequency);
-		      debug_rtl_slim (lra_dump_file,
-				      curr_insn, curr_insn, -1, 0);
+		      dump_insn_slim (lra_dump_file, curr_insn);
 		    }
 		  if (contains_reg_p (x, true, false))
 		    lra_risky_transformations_p = true;
@@ -3805,7 +3804,7 @@ inherit_reload_reg (bool def_p, int original_regno
 		   "    Rejecting inheritance %d->%d "
 		   "as it results in 2 or more insns:\n",
 		   original_regno, REGNO (new_reg));
-	  debug_rtl_slim (lra_dump_file, new_insns, NULL_RTX, -1, 0);
+	  dump_rtl_slim (lra_dump_file, new_insns, NULL_RTX, -1, 0);
 	  fprintf (lra_dump_file,
 		   "	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
 	}
@@ -3851,8 +3850,7 @@ inherit_reload_reg (bool def_p, int original_regno
 		   "    Inheritance reuse change %d->%d (bb%d):\n",
 		   original_regno, REGNO (new_reg),
 		   BLOCK_FOR_INSN (usage_insn)->index);
-	  debug_rtl_slim (lra_dump_file, usage_insn, usage_insn,
-			  -1, 0);
+	  dump_insn_slim (lra_dump_file, usage_insn);
 	}
     }
   if (lra_dump_file != NULL)
@@ -4056,7 +4054,7 @@ split_reg (bool before_p, int original_regno, rtx
 	    (lra_dump_file,
 	     "	  Rejecting split %d->%d resulting in > 2 %s save insns:\n",
 	     original_regno, REGNO (new_reg), call_save_p ? "call" : "");
-	  debug_rtl_slim (lra_dump_file, save, NULL_RTX, -1, 0);
+	  dump_rtl_slim (lra_dump_file, save, NULL_RTX, -1, 0);
 	  fprintf (lra_dump_file,
 		   "	))))))))))))))))))))))))))))))))))))))))))))))))\n");
 	}
@@ -4072,7 +4070,7 @@ split_reg (bool before_p, int original_regno, rtx
 		   "	Rejecting split %d->%d "
 		   "resulting in > 2 %s restore insns:\n",
 		   original_regno, REGNO (new_reg), call_save_p ? "call" : "");
-	  debug_rtl_slim (lra_dump_file, restore, NULL_RTX, -1, 0);
+	  dump_rtl_slim (lra_dump_file, restore, NULL_RTX, -1, 0);
 	  fprintf (lra_dump_file,
 		   "	))))))))))))))))))))))))))))))))))))))))))))))))\n");
 	}
@@ -4099,8 +4097,7 @@ split_reg (bool before_p, int original_regno, rtx
 	{
 	  fprintf (lra_dump_file, "    Split reuse change %d->%d:\n",
 		   original_regno, REGNO (new_reg));
-	  debug_rtl_slim (lra_dump_file, usage_insn, usage_insn,
-			  -1, 0);
+	  dump_insn_slim (lra_dump_file, usage_insn);
 	}
     }
   lra_assert (NOTE_P (usage_insn) || NONDEBUG_INSN_P (usage_insn));
@@ -4243,7 +4240,7 @@ update_ebb_live_info (rtx head, rtx tail)
 	  if (lra_dump_file != NULL)
 	    {
 	      fprintf (lra_dump_file, "	    Removing dead insn:\n ");
-	      debug_rtl_slim (lra_dump_file, curr_insn, curr_insn, -1, 0);
+	      dump_insn_slim (lra_dump_file, curr_insn);
 	    }
 	  lra_set_insn_deleted (curr_insn);
 	}
@@ -4859,8 +4856,7 @@ remove_inheritance_pseudos (bitmap remove_pseudos)
 			       bitmap_bit_p (&lra_split_regs, sregno)
 			       || bitmap_bit_p (&lra_split_regs, dregno)
 			       ? "split" : "inheritance");
-		      debug_rtl_slim (lra_dump_file,
-				      curr_insn, curr_insn, -1, 0);
+		      dump_insn_slim (lra_dump_file, curr_insn);
 		    }
 		  lra_set_insn_deleted (curr_insn);
 		  done_p = true;
@@ -4912,8 +4908,7 @@ remove_inheritance_pseudos (bitmap remove_pseudos)
 		      if (lra_dump_file != NULL)
 			{
 			  fprintf (lra_dump_file, "    Change reload insn:\n");
-			  debug_rtl_slim (lra_dump_file,
-					  curr_insn, curr_insn, -1, 0);
+			  dump_insn_slim (lra_dump_file, curr_insn);
 			}
 		    }
 		}
@@ -4956,7 +4951,7 @@ remove_inheritance_pseudos (bitmap remove_pseudos)
 	      if (restored_regs_p && lra_dump_file != NULL)
 		{
 		  fprintf (lra_dump_file, "   Insn after restoring regs:\n");
-		  debug_rtl_slim (lra_dump_file, curr_insn, curr_insn, -1, 0);
+		  dump_insn_slim (lra_dump_file, curr_insn);
 		}
 	    }
 	}
Index: sched-vis.c
===================================================================
--- sched-vis.c	(revision 193821)
+++ sched-vis.c	(working copy)
@@ -1,6 +1,5 @@
-/* Instruction scheduling pass.
-   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
+/* Printing of RTL in "slim", mnemonic like form.
+   Copyright (C) 1992-2012
    Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
    and currently maintained by, Jim Wilson (wilson@cygnus.com)
@@ -20,6 +19,10 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
+/* Historically this form of RTL dumping was introduced along with
+   the Haifa instruction scheduling pass, hence the name of this file.
+   But there is nothing in this file left that is scheduler-specific.  */
 \f
 #include "config.h"
 #include "system.h"
@@ -31,7 +34,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "hard-reg-set.h"
 #include "basic-block.h"
 #include "insn-attr.h"
-#include "sched-int.h"
 #include "dumpfile.h"	/* for the TDF_* flags */
 
 static char *safe_concat (char *, char *, const char *);
@@ -498,11 +500,7 @@ print_value (char *buf, const_rtx x, int verbose)
 	  sprintf (t, "r%d", REGNO (x));
 	  cur = safe_concat (buf, cur, t);
 	}
-      if (verbose
-#ifdef INSN_SCHEDULING
-	  && !current_sched_info
-#endif
-	 )
+      if (verbose)
 	{
 	  sprintf (t, ":%s", GET_MODE_NAME (GET_MODE (x)));
 	  cur = safe_concat (buf, cur, t);
@@ -553,7 +551,7 @@ print_value (char *buf, const_rtx x, int verbose)
    memory.  */
 
 void
-print_value_slim (FILE *f, const_rtx x, int verbose)
+dump_value_slim (FILE *f, const_rtx x, int verbose)
 {
   char buf[BUF_LEN];
 
@@ -590,12 +588,9 @@ print_pattern (char *buf, const_rtx x, int verbose
       print_exp (buf, x, verbose);
       break;
     case CLOBBER:
-      print_value (t1, XEXP (x, 0), verbose);
-      sprintf (buf, "clobber %s", t1);
-      break;
     case USE:
       print_value (t1, XEXP (x, 0), verbose);
-      sprintf (buf, "use %s", t1);
+      sprintf (buf, "%s %s", GET_RTX_NAME (GET_CODE (x)), t1);
       break;
     case VAR_LOCATION:
       print_value (t1, PAT_VAR_LOCATION_LOC (x), verbose);
@@ -657,151 +652,102 @@ print_pattern (char *buf, const_rtx x, int verbose
       sprintf (buf, "trap_if %s", t1);
       break;
     case UNSPEC:
-      {
-	int i;
-
-	sprintf (t1, "unspec{");
-	for (i = 0; i < XVECLEN (x, 0); i++)
-	  {
-	    print_pattern (t2, XVECEXP (x, 0, i), verbose);
-	    sprintf (t3, "%s%s;", t1, t2);
-	    strcpy (t1, t3);
-	  }
-	sprintf (buf, "%s}", t1);
-      }
-      break;
     case UNSPEC_VOLATILE:
-      {
-	int i;
-
-	sprintf (t1, "unspec/v{");
-	for (i = 0; i < XVECLEN (x, 0); i++)
-	  {
-	    print_pattern (t2, XVECEXP (x, 0, i), verbose);
-	    sprintf (t3, "%s%s;", t1, t2);
-	    strcpy (t1, t3);
-	  }
-	sprintf (buf, "%s}", t1);
-      }
-      break;
+      /* Fallthru -- leave UNSPECs to print_exp.  */
     default:
       print_value (buf, x, verbose);
     }
 }				/* print_pattern */
 
-/* This is the main function in rtl visualization mechanism. It
-   accepts an rtx and tries to recognize it as an insn, then prints it
-   properly in human readable form, resembling assembler mnemonics.
-   For every insn it prints its UID and BB the insn belongs too.
-   (Probably the last "option" should be extended somehow, since it
-   depends now on sched.c inner variables ...)  */
+/* This is the main function in slim rtl visualization mechanism.
 
+   X is an insn, to be printed into BUF.
+
+   This function tries to print it properly in human-readable form,
+   resembling assembler mnemonics (instead of the older Lisp-style
+   form).
+
+   If VERBOSE is TRUE, insns are printed with more complete (but
+   longer) pattern names and with extra information, and prefixed
+   with their INSN_UIDs.  */
+
 void
 print_insn (char *buf, const_rtx x, int verbose)
 {
-  char t[BUF_LEN];
-  const_rtx insn = x;
+  /* Collect the string to output for X in t1.  t2 is a scratch area.  */
+  char t1[BUF_LEN], t2[BUF_LEN];
 
   switch (GET_CODE (x))
     {
     case INSN:
-      print_pattern (t, PATTERN (x), verbose);
-#ifdef INSN_SCHEDULING
-      if (verbose && current_sched_info)
-	sprintf (buf, "%s: %s", (*current_sched_info->print_insn) (x, 1),
-		 t);
-      else
-#endif
-	sprintf (buf, " %4d %s", INSN_UID (x), t);
+      print_pattern (t1, PATTERN (x), verbose);
       break;
 
     case DEBUG_INSN:
       {
 	const char *name = "?";
 
-	if (DECL_P (INSN_VAR_LOCATION_DECL (insn)))
+	if (DECL_P (INSN_VAR_LOCATION_DECL (x)))
 	  {
-	    tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (insn));
+	    tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x));
 	    char idbuf[32];
 	    if (id)
 	      name = IDENTIFIER_POINTER (id);
-	    else if (TREE_CODE (INSN_VAR_LOCATION_DECL (insn))
+	    else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x))
 		     == DEBUG_EXPR_DECL)
 	      {
 		sprintf (idbuf, "D#%i",
-			 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (insn)));
+			 DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x)));
 		name = idbuf;
 	      }
 	    else
 	      {
 		sprintf (idbuf, "D.%i",
-			 DECL_UID (INSN_VAR_LOCATION_DECL (insn)));
+			 DECL_UID (INSN_VAR_LOCATION_DECL (x)));
 		name = idbuf;
 	      }
 	  }
-	if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn)))
-	  sprintf (buf, " %4d: debug %s optimized away", INSN_UID (insn), name);
+	if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x)))
+	  sprintf (t1, "debug %s optimized away", name);
 	else
 	  {
-	    print_pattern (t, INSN_VAR_LOCATION_LOC (insn), verbose);
-	    sprintf (buf, " %4d: debug %s => %s", INSN_UID (insn), name, t);
+	    print_pattern (t2, INSN_VAR_LOCATION_LOC (x), verbose);
+	    sprintf (t1, "debug %s => %s", name, t2);
 	  }
       }
       break;
 
     case JUMP_INSN:
-      print_pattern (t, PATTERN (x), verbose);
-#ifdef INSN_SCHEDULING
-      if (verbose && current_sched_info)
-	sprintf (buf, "%s: jump %s", (*current_sched_info->print_insn) (x, 1),
-		 t);
-      else
-#endif
-	sprintf (buf, " %4d %s", INSN_UID (x), t);
+      print_pattern (t1, PATTERN (x), verbose);
       break;
     case CALL_INSN:
-      x = PATTERN (insn);
-      if (GET_CODE (x) == PARALLEL)
-	{
-	  x = XVECEXP (x, 0, 0);
-	  print_pattern (t, x, verbose);
-	}
+      if (GET_CODE (PATTERN (x)) == PARALLEL)
+        print_pattern (t1, XVECEXP (PATTERN (x), 0, 0), verbose);
       else
-	strcpy (t, "call <...>");
-#ifdef INSN_SCHEDULING
-      if (verbose && current_sched_info)
-	sprintf (buf, "%s: %s", (*current_sched_info->print_insn) (insn, 1), t);
-      else
-#endif
-	sprintf (buf, " %4d %s", INSN_UID (insn), t);
+	print_pattern (t1, PATTERN (x), verbose);
       break;
     case CODE_LABEL:
-      sprintf (buf, "L%d:", INSN_UID (x));
+      sprintf (t1, "L%d:", INSN_UID (x));
       break;
     case BARRIER:
-      sprintf (buf, "i%4d: barrier", INSN_UID (x));
+      sprintf (t1, "barrier");
       break;
     case NOTE:
       {
-        int uid = INSN_UID (x);
-        const char *note_name = GET_NOTE_INSN_NAME (NOTE_KIND (x));
 	switch (NOTE_KIND (x))
 	  {
 	  case NOTE_INSN_EH_REGION_BEG:
 	  case NOTE_INSN_EH_REGION_END:
-	    sprintf (buf, " %4d %s %d", uid, note_name,
-		     NOTE_EH_HANDLER (x));
+	    sprintf (t2, "%d", NOTE_EH_HANDLER (x));
 	    break;
 
 	  case NOTE_INSN_BLOCK_BEG:
 	  case NOTE_INSN_BLOCK_END:
-	    sprintf (buf, " %4d %s %d", uid, note_name,
-		     BLOCK_NUMBER (NOTE_BLOCK (x)));
+	    sprintf (t2, "%d", BLOCK_NUMBER (NOTE_BLOCK (x)));
 	    break;
 
 	  case NOTE_INSN_BASIC_BLOCK:
-	    sprintf (buf, " %4d %s %d", uid, note_name,
-		     NOTE_BASIC_BLOCK (x)->index);
+	    sprintf (t2, "%d", NOTE_BASIC_BLOCK (x)->index);
 	    break;
 
 	  case NOTE_INSN_DELETED_LABEL:
@@ -810,26 +756,35 @@ print_insn (char *buf, const_rtx x, int verbose)
 	      const char *label = NOTE_DELETED_LABEL_NAME (x);
 	      if (label == NULL)
 		label = "";
-	      sprintf (buf, " %4d %s (\"%s\")", uid, note_name, label);
+	      sprintf (t2, "(\"%s\")", label);
 	    }
 	    break;
 
 	  case NOTE_INSN_VAR_LOCATION:
-	    print_pattern (t, NOTE_VAR_LOCATION (x), verbose);
-	    sprintf (buf, " %4d %s {%s}", uid, note_name, t);
+	  case NOTE_INSN_CALL_ARG_LOCATION:
+	    /* It's safe here to use t1 for scratch because the output
+	       is printed in t2 and put back in t1 at the bottom of
+	       the inner switch statement.  */
+	    print_pattern (t1, NOTE_VAR_LOCATION (x), verbose);
+	    sprintf (t2, "{%s}", t1);
 	    break;
 
 	  default:
-	    sprintf (buf, " %4d %s", uid, note_name);
+	    t2[0] = '\0';
 	    break;
 	  }
+	sprintf (t1, "%s %s", GET_NOTE_INSN_NAME (NOTE_KIND (x)), t2);
 	break;
       }
     default:
-      sprintf (buf, "i%4d  <What %s?>", INSN_UID (x),
-	       GET_RTX_NAME (GET_CODE (x)));
+      sprintf (t1, "<What %s?>", GET_RTX_NAME (GET_CODE (x)));
       break;
     }
+
+  if (verbose)
+    sprintf (buf, " %4d: %s", INSN_UID (x), t1);
+  else
+    sprintf (buf, "%s", t1);
 }				/* print_insn */
 
 /* Emit a slim dump of X (an insn) to the file F, including any register
@@ -854,20 +809,12 @@
       }
 }
 
-/* Emit a slim dump of X (an insn) to stderr.  */
-extern void debug_insn_slim (const_rtx);
-DEBUG_FUNCTION void
-debug_insn_slim (const_rtx x)
-{
-  dump_insn_slim (stderr, x);
-}
-
 /* Same as above, but stop at LAST or when COUNT == 0.
    If COUNT < 0 it will stop only at LAST or NULL rtx.  */
-extern void debug_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
-DEBUG_FUNCTION void
-debug_rtl_slim (FILE *f, const_rtx first, const_rtx last,
-		int count, int flags ATTRIBUTE_UNUSED)
+
+void
+dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
+	       int count, int flags ATTRIBUTE_UNUSED)
 {
   const_rtx insn, tail;
 
@@ -882,6 +829,22 @@ dump_insn_slim (FILE *f, const_rtx x)
     }
 }
 
+/* Emit a slim dump of X (an insn) to stderr.  */
+extern void debug_insn_slim (const_rtx);
+DEBUG_FUNCTION void
+debug_insn_slim (const_rtx x)
+{
+  dump_insn_slim (stderr, x);
+}
+
+/* Same as above, but using dump_rtl_slim.  */
+extern void debug_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
+DEBUG_FUNCTION void
+debug_rtl_slim (const_rtx first, const_rtx last, int count, int flags)
+{
+  dump_rtl_slim (stderr, first, last, count, flags);
+}
+
 extern void debug_bb_slim (basic_block);
 DEBUG_FUNCTION void
 debug_bb_slim (basic_block bb)
Index: haifa-sched.c
===================================================================
--- haifa-sched.c	(revision 193820)
+++ haifa-sched.c	(working copy)
@@ -3719,7 +3719,8 @@ schedule_insn (rtx insn)
 
       print_insn (buf, insn, 0);
       buf[40] = 0;
-      fprintf (sched_dump, ";;\t%3i--> %-40s:", clock_var, buf);
+      fprintf (sched_dump, ";;\t%3i--> %s%-40s:",
+	       clock_var, (*current_sched_info->print_insn) (insn, 1), buf);
 
       if (recog_memoized (insn) < 0)
 	fprintf (sched_dump, "nothing");

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] RFA: slim RTL printing cleanups
  2012-11-26 23:21 [patch] RFA: slim RTL printing cleanups Steven Bosscher
@ 2012-11-27 13:07 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2012-11-27 13:07 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc-patches, rdsandiford

On Tue, Nov 27, 2012 at 12:20 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> This patch performs some necessary TLC on slim RTL printing in sched-vis.c:
>
> * Make it independent of the scheduler. Actually it already was,
> mostly. This patch completes the job.
>
> * Harmonize dumping templates for INSN_UID.
>
> * Always print the pattern of a CALL_INSN.
>
> * Don't print "jump" for sched dumps only.
>
> * Harmonize function names:
>   - print_* print to a "char *" buffer
>   - dump_* print to a given "FILE *"
>   - debug_* print to stderr.
>
> Some of the ideas come from Richard S.'s
> http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00284.html.
>
> The next patch addresses a bigger problem: The print_* variants should
> use something better than a fixed-size buffer. I plan to use
> pretty-print. An obstack would also work; but I'd like to keep one
> layer of abstraction between the file output and the printers, so that
> users can post-process the string if necessary (the case I'm thinking
> of, is the graph dumpers, which need to escape some characters before
> writing to a file). Any thoughts on this from anyone?
>
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
> (Yes, I know it's stage3, but look at it this way: the patch does no
> harm, and good dumps help for debugging real bugs ;-)

Ok!

Thanks,
Richard.

> Ciao!
> Steven

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-27 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 23:21 [patch] RFA: slim RTL printing cleanups Steven Bosscher
2012-11-27 13:07 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).