used new xcalloc
[libfirm] / ir / ir / irdump.c
index 2805c00..3f2c874 100644 (file)
@@ -432,8 +432,8 @@ void dump_consts_local(bool b) {
   dump_const_local = b;
 }
 
-void turn_off_constant_entity_values(void) {
-  const_entities = 0;
+void dump_constant_entity_values(bool b) {
+  const_entities = b;
 }
 
 void dump_keepalive_edges(bool b) {
@@ -444,20 +444,16 @@ bool get_opt_dump_keepalive_edges(void) {
   return dump_keepalive;
 }
 
-void dump_out_edges(void) {
-  dump_out_edge_flag = 1;
+void dump_out_edges(bool b) {
+  dump_out_edge_flag = b;
 }
 
-void dump_dominator_information(void) {
-  dump_dominator_information_flag = 1;
+void dump_dominator_information(bool b) {
+  dump_dominator_information_flag = b;
 }
 
-void dump_loop_information(void) {
-  dump_loop_information_flag = 1;
-}
-
-void dont_dump_loop_information(void) {
-  dump_loop_information_flag = 0;
+void dump_loop_information(bool b) {
+  dump_loop_information_flag = b;
 }
 
 void dump_backedge_information(bool b) {
@@ -668,17 +664,21 @@ dump_node_nodeattr(FILE *F, ir_node *n)
  * dumps the attributes of a node n into the file F.
  * Currently this is only the color of a node.
  */
-static void dump_node_vcgattr(FILE *F, ir_node *n, int bad)
+static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad)
 {
+  ir_node *n;
+
   if (bad) {
     fprintf(F, "color: red");
     return;
   }
 
   if (dump_node_vcgattr_hook)
-    if (dump_node_vcgattr_hook(F, n))
+    if (dump_node_vcgattr_hook(F, node, local))
       return;
 
+  n = local ? local : node;
+
   switch (get_irn_opcode(n)) {
   case iro_Start:
   case iro_EndReg:
@@ -765,7 +765,7 @@ static void dump_const_node_local(FILE *F, ir_node *n) {
       fprintf(F, " %ld", get_irn_node_nr(con));
       fprintf(F, "\" ");
       bad |= dump_node_info(F, con);
-      dump_node_vcgattr(F, con, bad);
+      dump_node_vcgattr(F, n, con, bad);
       fprintf(F, "}\n");
     }
   }
@@ -773,9 +773,11 @@ static void dump_const_node_local(FILE *F, ir_node *n) {
 
 /** If the block of an edge is a const_like node, dump it local with an edge */
 static void dump_const_block_local(FILE *F, ir_node *n) {
+  ir_node *blk;
+
   if (!get_opt_dump_const_local()) return;
 
-  ir_node *blk = get_nodes_block(n);
+  blk = get_nodes_block(n);
   if (is_constlike_node(blk)) {
     int bad = 0;
 
@@ -791,7 +793,7 @@ static void dump_const_block_local(FILE *F, ir_node *n) {
     fprintf(F, " %ld", get_irn_node_nr(blk));
     fprintf(F, "\" ");
     bad |= dump_node_info(F, blk);
-    dump_node_vcgattr(F, blk, bad);
+    dump_node_vcgattr(F, n, blk, bad);
     fprintf(F, "}\n");
 
     fprintf (F, "edge: { sourcename: \"");
@@ -836,7 +838,7 @@ static void dump_node(FILE *F, ir_node *n)
   fprintf(F, "\" ");
   bad |= dump_node_info(F, n);
   print_node_error(F, p);
-  dump_node_vcgattr(F, n, bad);
+  dump_node_vcgattr(F, n, NULL, bad);
   fprintf(F, "}\n");
   dump_const_node_local(F, n);
 #if DO_HEAPANALYSIS
@@ -1009,7 +1011,8 @@ print_edge_vcgattr(FILE *F, ir_node *from, int to) {
 /* dump edges to our inputs */
 static void
 dump_ir_data_edges(FILE *F, ir_node *n)  {
-  int i, visited = get_irn_visited(n);
+  int i;
+  unsigned long visited = get_irn_visited(n);
 
   if ((get_irn_op(n) == op_End) && (!dump_keepalive))
     return;
@@ -2052,11 +2055,13 @@ static int compute_color (int my, int max) {
   if (!max) {
     color = 0;
   } else {
+    int step;
+
     /* if small, scale to the full color range. */
     if (max < n_colors)
       my = my * (n_colors/max);
 
-    int step = 1 + (max / n_colors);
+    step = 1 + (max / n_colors);
 
     color = my/step;
   }
@@ -2064,22 +2069,24 @@ static int compute_color (int my, int max) {
 }
 
 static int get_entity_color(entity *ent) {
-  assert(get_entity_irg(ent));
   ir_graph *irg = get_entity_irg(ent);
+  assert(irg);
 
-  int rec_depth     = get_irg_recursion_depth(irg);
-  int loop_depth    = get_irg_loop_depth(irg);
-  int overall_depth = weight_overall(rec_depth, loop_depth);
+  {
+    int rec_depth     = get_irg_recursion_depth(irg);
+    int loop_depth    = get_irg_loop_depth(irg);
+    int overall_depth = weight_overall(rec_depth, loop_depth);
 
-  int max_rec_depth     = irp->max_callgraph_recursion_depth;
-  int max_loop_depth    = irp->max_callgraph_loop_depth;
-  int max_overall_depth = weight_overall(max_rec_depth, max_loop_depth);
+    int max_rec_depth     = irp->max_callgraph_recursion_depth;
+    int max_loop_depth    = irp->max_callgraph_loop_depth;
+    int max_overall_depth = weight_overall(max_rec_depth, max_loop_depth);
 
-  /* int my_rec_color     = compute_color(rec_depth, max_rec_depth); */
-  /* int my_loop_color    = compute_color(loop_depth, max_loop_depth); */
-  int my_overall_color = compute_color(overall_depth, max_overall_depth);;
+    /* int my_rec_color     = compute_color(rec_depth, max_rec_depth); */
+    /* int my_loop_color    = compute_color(loop_depth, max_loop_depth); */
+    int my_overall_color = compute_color(overall_depth, max_overall_depth);;
 
-  return my_overall_color;
+    return my_overall_color;
+  }
 }
 
 void dump_callgraph(const char *suffix) {
@@ -2278,9 +2285,11 @@ void dump_loops_standalone(FILE *F, ir_loop *loop) {
       /* Causes indeterministic output: if (is_Block(n)) fprintf (F, "\t ->%d", (int)get_irn_link(n)); */
       if (has_backedges(n)) fprintf(F, "\t loop head!");
     } else { /* for callgraph loop tree */
+      ir_graph *n;
       assert(get_kind(son) == k_ir_graph);
+
       /* We are a loop node -> Collect firm graphs */
-      ir_graph *n = (ir_graph *)le.node;
+      n = (ir_graph *)le.node;
       if (!loop_node_started) {
         /* Start a new node which contains all firm nodes of the current loop */
         fprintf (F, "node: { title: \"");
@@ -2290,7 +2299,7 @@ void dump_loops_standalone(FILE *F, ir_loop *loop) {
         first = i;
       }
       else
-    fprintf(F, "\n");
+        fprintf(F, "\n");
       fprintf (F, " %s", get_irg_dump_name(n));
       /* fprintf (F, " %s (depth %d)", get_irg_dump_name(n), n->callgraph_weighted_loop_depth); */
     }