]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* rtl.h (print_insn_with_notes): Remove prototype.
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Dec 2012 18:38:26 +0000 (18:38 +0000)
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Dec 2012 18:38:26 +0000 (18:38 +0000)
(rtl_dump_bb_for_graph): New prototype.
* sched-vis.c (print_insn_with_notes): Make static again.  Fix
printing of notes.
(rtl_dump_bb_for_graph): New function.
* cfghooks.h (struct cfg_hooks) <dump_bb_for_graph>: New hook.
(dump_bb_for_graph): New prototype.
* cfghooks.c (dump_bb_for_graph): New function.
* tree-cfg.c (gimple_cfg_hooks): Register gimple_dump_bb_for_graph
as dump_bb_for_graph hook implementation for GIMPLE.
* cfgrtl.c (rtl_cfg_hooks): Likewise for rtl_dump_bb_for_graph.
(cfg_layout_rtl_cfg_hooks): Likewise.
* graph.c (draw_cfg_node): Don't include sbitmap.h, rtl.h, tree.h,
gimple.h, and gimple-pretty-print.h.
(draw_cfg_node, draw_cfg_node_succ_edges): Use the uniqe function
definition number instead of the function declaration UID.
(print_graph_cfg): Take a struct function instead of a tree.
Use the dump_bb_for_graph hook to dump the basic block content.
* graph.h (print_graph_cfg): Update prototype.
* passes.c (execute_function_dump): Update print_graph_cfg call.
* Makefile.in (graph.o): Fixup dependencies.

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

gcc/ChangeLog
gcc/Makefile.in
gcc/cfghooks.c
gcc/cfghooks.h
gcc/cfgrtl.c
gcc/graph.c
gcc/graph.h
gcc/passes.c
gcc/rtl.h
gcc/sched-vis.c
gcc/tree-cfg.c

index ba9f33ea02fc905a5a0447e866a1fb1c1d096525..32f7a86b453e05fece88c0e36cae69cce1072af0 100644 (file)
@@ -1,3 +1,27 @@
+2012-12-04  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * rtl.h (print_insn_with_notes): Remove prototype.
+       (rtl_dump_bb_for_graph): New prototype.
+       * sched-vis.c (print_insn_with_notes): Make static again.  Fix
+       printing of notes.
+       (rtl_dump_bb_for_graph): New function.
+       * cfghooks.h (struct cfg_hooks) <dump_bb_for_graph>: New hook.
+       (dump_bb_for_graph): New prototype.
+       * cfghooks.c (dump_bb_for_graph): New function.
+       * tree-cfg.c (gimple_cfg_hooks): Register gimple_dump_bb_for_graph
+       as dump_bb_for_graph hook implementation for GIMPLE.
+       * cfgrtl.c (rtl_cfg_hooks): Likewise for rtl_dump_bb_for_graph.
+       (cfg_layout_rtl_cfg_hooks): Likewise.
+       * graph.c (draw_cfg_node): Don't include sbitmap.h, rtl.h, tree.h,
+       gimple.h, and gimple-pretty-print.h.
+       (draw_cfg_node, draw_cfg_node_succ_edges): Use the uniqe function
+       definition number instead of the function declaration UID.
+       (print_graph_cfg): Take a struct function instead of a tree.
+       Use the dump_bb_for_graph hook to dump the basic block content.
+       * graph.h (print_graph_cfg): Update prototype.
+       * passes.c (execute_function_dump): Update print_graph_cfg call.
+       * Makefile.in (graph.o): Fixup dependencies.
+
 2012-12-04  Marcus Shawcroft  <marcus.shawcroft@arm.com>
 
        * config/aarch64/aarch64.c (aarch64_build_builtin_va_list): Set
index 6831244b9f7df95f70cac127df4d3d9bb0599a0c..9efc2d3598fabaf15f86a2be2127e91b527f6e6f 100644 (file)
@@ -1846,7 +1846,7 @@ gcc.srcextra: gengtype-lex.c
        -cp -p $^ $(srcdir)
 
 graph.o: graph.c graph.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-    $(DIAGNOSTIC_CORE_H) $(TM_H) $(RTL_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H)
+    $(DIAGNOSTIC_CORE_H) $(BASIC_BLOCK_H) $(PRETTY_PRINT_H) dumpfile.h
 
 sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h
 sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)
index dfeff08312304cae7fe3d2ecf59976ae474a7a50..f0957316062540306122bc5d0f13c5c30182ea5d 100644 (file)
@@ -280,6 +280,22 @@ dump_bb (FILE *outf, basic_block bb, int indent, int flags)
   fputc ('\n', outf);
 }
 
+/* Dumps basic block BB to pretty-printer PP, for use as a label of
+   a DOT graph record-node.  The implementation of this hook is
+   expected to write the label to the stream that is attached to PP.
+   Field separators between instructions are pipe characters printed
+   verbatim.  Instructions should be written with some characters
+   escaped, using pp_write_text_as_dot_label_to_stream().  */
+
+void
+dump_bb_for_graph (pretty_printer *pp, basic_block bb)
+{
+  if (!cfg_hooks->dump_bb_for_graph)
+    internal_error ("%s does not support dump_bb_for_graph",
+                   cfg_hooks->name);
+  cfg_hooks->dump_bb_for_graph (pp, bb);
+}
+
 /* Dump the complete CFG to FILE.  FLAGS are the TDF_* flags in dumpfile.h.  */
 void
 dump_flow_info (FILE *file, int flags)
index cb81f5a0e2e912fd16176e5294cc81c9e6ca292d..b2cc3449507fecf21b2fe2c059d622559a8e928d 100644 (file)
@@ -29,6 +29,7 @@ struct cfg_hooks
   /* Debugging.  */
   int (*verify_flow_info) (void);
   void (*dump_bb) (FILE *, basic_block, int, int);
+  void (*dump_bb_for_graph) (pretty_printer *, basic_block);
 
   /* Basic CFG manipulation.  */
 
@@ -152,6 +153,8 @@ struct cfg_hooks
 
 extern void verify_flow_info (void);
 extern void dump_bb (FILE *, basic_block, int, int);
+extern void dump_bb_for_graph (pretty_printer *, basic_block);
+
 extern edge redirect_edge_and_branch (edge, basic_block);
 extern basic_block redirect_edge_and_branch_force (edge, basic_block);
 extern bool can_remove_branch_p (const_edge);
index 386dedefd4b192f894f69a057a910258c85bf475..3a18acbbe565dcf0f92c114f01626df2dbc8c459 100644 (file)
@@ -4529,6 +4529,7 @@ struct cfg_hooks rtl_cfg_hooks = {
   "rtl",
   rtl_verify_flow_info,
   rtl_dump_bb,
+  rtl_dump_bb_for_graph,
   rtl_create_basic_block,
   rtl_redirect_edge_and_branch,
   rtl_redirect_edge_and_branch_force,
@@ -4570,6 +4571,7 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = {
   "cfglayout mode",
   rtl_verify_flow_info_1,
   rtl_dump_bb,
+  rtl_dump_bb_for_graph,
   cfg_layout_create_basic_block,
   cfg_layout_redirect_edge_and_branch,
   cfg_layout_redirect_edge_and_branch_force,
index c0a9af824d432ac9cd4d2308758b0ffaa2ad8043..7fdd41ca00c099b11349088a3749336008305efb 100644 (file)
@@ -24,15 +24,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h" /* for fatal_error */
-#include "sbitmap.h"
 #include "basic-block.h"
-#include "rtl.h"
-#include "tree.h"
-#include "gimple.h"
 #include "graph.h"
 #include "dumpfile.h"
 #include "pretty-print.h"
-#include "gimple-pretty-print.h"
 
 /* DOT files with the .dot extension are recognized as document templates
    by a well-known piece of word processing software out of Redmond, WA.
@@ -80,10 +75,10 @@ init_graph_slim_pretty_print (FILE *fp)
   return &graph_slim_pp;
 }
 
-/* Draw a basic block BB belonging to the function with FNDECL_UID
+/* Draw a basic block BB belonging to the function with FUNCDEF_NO
    as its unique number.  */
 static void
-draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
+draw_cfg_node (pretty_printer *pp, int funcdef_no, basic_block bb)
 {
   const char *shape;
   const char *fillcolor;
@@ -105,7 +100,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
   pp_printf (pp,
             "\tfn_%d_basic_block_%d "
             "[shape=%s,style=filled,fillcolor=%s,label=\"",
-            fndecl_uid, bb->index, shape, fillcolor);
+            funcdef_no, bb->index, shape, fillcolor);
 
   if (bb->index == ENTRY_BLOCK)
     pp_string (pp, "ENTRY");
@@ -115,28 +110,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
     {
       pp_character (pp, '{');
       pp_write_text_to_stream (pp);
-
-      /* This would be easier if there'd be an IR independent iterator...  */
-      if (current_ir_type () == IR_GIMPLE)
-       gimple_dump_bb_for_graph (pp, bb);
-      else
-       {
-         rtx insn;
-         bool first = true;
-
-         /* TODO: inter-bb stuff.  */
-         FOR_BB_INSNS (bb, insn)
-           {
-             if (! first)
-               {
-                 pp_character (pp, '|');
-                 pp_write_text_to_stream (pp);
-               }
-             first = false;
-             print_insn_with_notes (pp, insn);
-             pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
-           }
-       }
+      dump_bb_for_graph (pp, bb);
       pp_character (pp, '}');
     }
 
@@ -145,9 +119,9 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb)
 }
 
 /* Draw all successor edges of a basic block BB belonging to the function
-   with FNDECL_UID as its unique number.  */
+   with FUNCDEF_NO as its unique number.  */
 static void
-draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
+draw_cfg_node_succ_edges (pretty_printer *pp, int funcdef_no, basic_block bb)
 {
   edge e;
   edge_iterator ei;
@@ -181,8 +155,8 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
       pp_printf (pp,
                 "\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n "
                 "[style=%s,color=%s,weight=%d,constraint=%s];\n",
-                fndecl_uid, e->src->index,
-                fndecl_uid, e->dest->index,
+                funcdef_no, e->src->index,
+                funcdef_no, e->dest->index,
                 style, color, weight,
                 (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true");
     }
@@ -192,10 +166,10 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb)
 /* Print a graphical representation of the CFG of function FUN.  */
 
 void
-print_graph_cfg (const char *base, tree fndecl)
+print_graph_cfg (const char *base, struct function *fun)
 {
-  const char *funcname = fndecl_name (fndecl);
-  int fndecl_uid = DECL_UID (fndecl);
+  const char *funcname = function_name (fun);
+  int funcdef_no = fun->funcdef_no;
   FILE *fp = open_graph_file (base, "a");
   int *rpo = XNEWVEC (int, n_basic_blocks);
   basic_block bb;
@@ -212,7 +186,7 @@ print_graph_cfg (const char *base, tree fndecl)
      of the nodes.  */
   n = pre_and_rev_post_order_compute (NULL, rpo, true);
   for (i = 0; i < n; i++)
-    draw_cfg_node (pp, fndecl_uid, BASIC_BLOCK (rpo[i]));
+    draw_cfg_node (pp, funcdef_no, BASIC_BLOCK (rpo[i]));
 
   /* Draw all edges at the end to get subgraphs right for GraphViz,
      which requires nodes to be defined before edges to cluster
@@ -224,7 +198,7 @@ print_graph_cfg (const char *base, tree fndecl)
      for ourselves is also not desirable.)  */
   mark_dfs_back_edges ();
   FOR_ALL_BB (bb)
-    draw_cfg_node_succ_edges (pp, fndecl_uid, bb);
+    draw_cfg_node_succ_edges (pp, funcdef_no, bb);
 
   pp_printf (pp, "\t}\n");
   pp_flush (pp);
index d99c70200e2c12030d23a15b39d923aff1f918ab..97bb177dd16c1fa56aaa625e66b5de5ae0b5d9be 100644 (file)
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GRAPH_H
 #define GCC_GRAPH_H
 
-extern void print_graph_cfg (const char *, tree);
+extern void print_graph_cfg (const char *, struct function *);
 extern void clean_graph_dump_file (const char *);
 extern void finish_graph_dump_file (const char *);
 
index ce487fcd0bc2a3b89651e6f7f60152cbe276aca9..b2c4c17b1e25d8927fc5b189f58cf7e05ee22d1d 100644 (file)
@@ -1770,7 +1770,7 @@ execute_function_dump (void *data ATTRIBUTE_UNUSED)
 
       if ((cfun->curr_properties & PROP_cfg)
          && (dump_flags & TDF_GRAPH))
-       print_graph_cfg (dump_file_name, cfun->decl);
+       print_graph_cfg (dump_file_name, cfun);
     }
 }
 
index 2e5ca71a7bf7ef208e708733f1a9c5232c3bc3ee..213e0f55814e01e566bd6041797d671197b0d94f 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2606,7 +2606,7 @@ extern void dump_rtl_slim (FILE *, const_rtx, const_rtx, int, int);
 extern void print_value (pretty_printer *, const_rtx, int);
 extern void print_pattern (pretty_printer *, const_rtx, int);
 extern void print_insn (pretty_printer *, const_rtx, int);
-extern void print_insn_with_notes (pretty_printer *, const_rtx);
+extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block);
 extern const char *str_pattern_slim (const_rtx);
 
 /* In function.c */
index 90b75f18ebfcb25b092b423664356b828e60254d..bdb166e53859696538f7064f60ee62dff38743e9 100644 (file)
@@ -716,10 +716,10 @@ print_insn (pretty_printer *pp, const_rtx x, int verbose)
     }
 }                              /* print_insn */
 
-/* Prerry-print a slim dump of X (an insn) to PP, including any register
+/* Pretty-print a slim dump of X (an insn) to PP, including any register
    note attached to the instruction.  */
 
-void
+static void
 print_insn_with_notes (pretty_printer *pp, const_rtx x)
 {
   pp_string (pp, print_rtx_head);
@@ -728,9 +728,9 @@ print_insn_with_notes (pretty_printer *pp, const_rtx x)
   if (INSN_P (x) && REG_NOTES (x))
     for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1))
       {
-       pp_printf (pp, "%s      %s", print_rtx_head,
+       pp_printf (pp, "%s      %s ", print_rtx_head,
                   GET_REG_NOTE_NAME (REG_NOTE_KIND (note)));
-        print_pattern (pp, XEXP (note, 0), 1);
+       print_pattern (pp, XEXP (note, 0), 1);
        pp_newline (pp);
       }
 }
@@ -800,6 +800,29 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
   pp_flush (pp);
 }
 
+/* Dumps basic block BB to pretty-printer PP in slim form and without and
+   no indentation, for use as a label of a DOT graph record-node.  */
+
+void
+rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
+{
+  rtx insn;
+  bool first = true;
+
+  /* TODO: inter-bb stuff.  */
+  FOR_BB_INSNS (bb, insn)
+    {
+      if (! first)
+       {
+         pp_character (pp, '|');
+         pp_write_text_to_stream (pp);
+       }
+      first = false;
+      print_insn_with_notes (pp, insn);
+      pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
+    }
+}
+
 /* Pretty-print pattern X of some insn in non-verbose mode.
    Return a string pointer to the pretty-printer buffer.
 
index b79c3af3cf3ae07944a3a674730d76d1b7b041ba..be89320559f7ba1a09bda42fbd68f8007c4412d6 100644 (file)
@@ -7620,6 +7620,7 @@ struct cfg_hooks gimple_cfg_hooks = {
   "gimple",
   gimple_verify_flow_info,
   gimple_dump_bb,              /* dump_bb  */
+  gimple_dump_bb_for_graph,    /* dump_bb_for_graph  */
   create_bb,                   /* create_basic_block  */
   gimple_redirect_edge_and_branch, /* redirect_edge_and_branch  */
   gimple_redirect_edge_and_branch_force, /* redirect_edge_and_branch_force  */