added two more hooks to the ir graph dumper
authorGernot Veit Batz <batz@ipd.info.uni-karlsruhe.de>
Mon, 10 Oct 2005 13:42:30 +0000 (13:42 +0000)
committerGernot Veit Batz <batz@ipd.info.uni-karlsruhe.de>
Mon, 10 Oct 2005 13:42:30 +0000 (13:42 +0000)
[r6668]

ir/ir/irdump.c
ir/ir/irdump.h

index d53a9c7..722b91c 100644 (file)
@@ -105,13 +105,25 @@ DUMP_NODE_EDGE_FUNC get_dump_node_edge_hook(void)
 }
 
 
-/** The vcg attribute hook. */
+/** The vcg node attribute hook. */
+static DUMP_IR_GRAPH_FUNC dump_ir_graph_hook = NULL;
+/** The vcg node attribute hook. */
 static DUMP_NODE_VCGATTR_FUNC dump_node_vcgattr_hook = NULL;
+/** The vcg edge attribute hook. */
+static DUMP_EDGE_VCGATTR_FUNC dump_edge_vcgattr_hook = NULL;
 
-/* set the hook */
+/* set the ir graph hook */
+void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook) {
+  dump_ir_graph_hook = hook;
+}
+/* set the node attribute hook */
 void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook) {
   dump_node_vcgattr_hook = hook;
 }
+/* set the edge attribute hook */
+void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook) {
+  dump_edge_vcgattr_hook = hook;
+}
 
 INLINE bool get_opt_dump_const_local(void) {
   if (!dump_out_edge_flag && !dump_loop_information_flag)
@@ -1073,6 +1085,19 @@ static void dump_const_block_local(FILE *F, ir_node *n) {
     fprintf (F, "edge: { sourcename: \"");
     PRINT_NODEID(n);
     fprintf (F, "\" targetname: \""); PRINT_CONSTBLKID(n,blk);
+
+       if (dump_edge_vcgattr_hook) {
+         fprintf (F, "\" ");
+      if (dump_edge_vcgattr_hook(F, n, -1)) {
+        fprintf (F, "}\n");
+        return;
+      }
+         else {
+        fprintf (F, " " BLOCK_EDGE_ATTR "}\n");
+               return;
+         }
+    }
+
     fprintf (F, "\" "   BLOCK_EDGE_ATTR "}\n");
   }
 }
@@ -1151,6 +1176,19 @@ dump_ir_block_edge(FILE *F, ir_node *n)  {
       PRINT_NODEID(n);
       fprintf (F, "\" targetname: ");
       fprintf(F, "\""); PRINT_NODEID(block); fprintf(F, "\"");
+
+         if (dump_edge_vcgattr_hook) {
+           fprintf (F, " ");
+        if (dump_edge_vcgattr_hook(F, n, -1)) {
+          fprintf (F, "}\n");
+          return;
+        }
+           else {
+          fprintf (F, " "  BLOCK_EDGE_ATTR "}\n");
+                 return;
+           }
+      }
+
       fprintf (F, " "   BLOCK_EDGE_ATTR "}\n");
     }
   }
@@ -1184,6 +1222,10 @@ static void
 print_edge_vcgattr(FILE *F, ir_node *from, int to) {
   assert(from);
 
+  if (dump_edge_vcgattr_hook)
+       if (dump_edge_vcgattr_hook(F, from, to))
+               return;
+
   if (dump_backedge_information_flag && is_backedge(from, to))
     fprintf (F, BACK_EDGE_ATTR);
 
@@ -2197,6 +2239,11 @@ dump_ir_graph (ir_graph *irg, const char *suffix )
   f = vcg_open(irg, suffix, suffix1);
   dump_vcg_header(f, get_irg_dump_name(irg), NULL);
 
+  /* call the dump graph hook */
+  if (dump_ir_graph_hook)
+    if (dump_ir_graph_hook(f, irg))
+      return;
+
   /* walk over the graph */
   /* dump_whole_node must be called in post visiting predecessors */
   irg_walk(get_irg_end(irg), NULL, dump_whole_node, f);
index be72fbd..2e03d27 100644 (file)
 /*                                 GRAPH DUMPERS                                */
 /* **************************************************************************** */
 
+/**
+ * This hook is called to insert some special nodes into dumped graph
+ */
+typedef int (*DUMP_IR_GRAPH_FUNC)(FILE *F, ir_graph *irg);
 /**
  * This hook is called to dump the vcg attributes of a node to a file.
  * If this function returns zero, the default attributes are added, else
  * removed.
  */
 typedef int (*DUMP_NODE_VCGATTR_FUNC)(FILE *F, ir_node *node, ir_node *local);
+/**
+ * This hook is called to dump the vcg attributes of an edge to a file.
+ * If this function returns zero, the default attributes are added, else
+ * removed.
+ */
+typedef int (*DUMP_EDGE_VCGATTR_FUNC)(FILE *F, ir_node *node, int to);
 
+/** Set the ir graph dump hook. */
+void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook);
 /** Set the node_vcgattr hook. */
 void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook);
+/** Set the edge_vcgattr hook. */
+void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook);
 
 typedef int (*DUMP_NODE_EDGE_FUNC)(FILE *f, ir_node *node);