Added additional dominator information dumping
[libfirm] / ir / ir / irdump.c
index 424a7b1..79f2977 100644 (file)
 #include "pset.h"
 
 #if DO_HEAPANALYSIS
-void dump_irn_chi_term(FILE *FL, ir_node *n);
-void dump_irn_state(FILE *FL, ir_node *n);
-int  get_opt_dump_abstvals(void);
+extern void dump_irn_chi_term(FILE *FL, ir_node *n);
+extern void dump_irn_state(FILE *FL, ir_node *n);
+extern int  get_opt_dump_abstvals(void);
 typedef unsigned long SeqNo;
-SeqNo get_Block_seqno(ir_node *n);
+extern SeqNo get_Block_seqno(ir_node *n);
 #endif
 
 /* basis for a color range for vcg */
@@ -1725,7 +1725,7 @@ FILE *vcg_open (ir_graph *irg, const char * suffix1, const char *suffix2) {
 
   /* strncpy (fname, nm, len); */     /* copy the filename */
   j = 0;
-  for (i = 0; i < len; ++i) {  /* replase '/' in the name: escape by @. */
+  for (i = 0; i < len; ++i) {  /* replace '/' in the name: escape by @. */
     if (nm[i] == '/') {
       fname[j] = '@'; j++; fname[j] = '1'; j++;
     } else if (nm[i] == '@') {
@@ -1738,7 +1738,11 @@ FILE *vcg_open (ir_graph *irg, const char * suffix1, const char *suffix2) {
   strcat (fname, suffix1);  /* append file suffix */
   strcat (fname, suffix2);  /* append file suffix */
   strcat (fname, ".vcg");   /* append the .vcg suffix */
-  F = fopen (fname, "w");   /* open file for writing */
+
+  /* vcg really expect only a <CR> at end of line, so
+   * the "b"inary mode is what you mean (and even needed for Win32)
+   */
+  F = fopen (fname, "wb");  /* open file for writing */
   if (!F) {
     panic("cannot open %s for writing (%m)", fname);  /* not reached */
   }
@@ -1764,7 +1768,7 @@ FILE *vcg_open_name (const char *name, const char *suffix) {
   fname = malloc (len * 2 + 5 + strlen(suffix));
   /* strcpy (fname, name);*/    /* copy the filename */
   j = 0;
-  for (i = 0; i < len; ++i) {  /* replase '/' in the name: escape by @. */
+  for (i = 0; i < len; ++i) {  /* replace '/' in the name: escape by @. */
     if (name[i] == '/') {
       fname[j] = '@'; j++; fname[j] = '1'; j++;
     } else if (name[i] == '@') {
@@ -1776,7 +1780,11 @@ FILE *vcg_open_name (const char *name, const char *suffix) {
   fname[j] = '\0';
   strcat (fname, suffix);
   strcat (fname, ".vcg");  /* append the .vcg suffix */
-  F = fopen (fname, "w");  /* open file for writing */
+
+  /* vcg really expect only a <CR> at end of line, so
+   * the "b"inary mode is what you mean (and even needed for Win32)
+   */
+  F = fopen (fname, "wb");  /* open file for writing */
   if (!F) {
     panic ("cannot open %s for writing (%m)", fname);  /* not reached */
   }
@@ -1807,7 +1815,7 @@ void vcg_close (FILE *F) {
 /************************************************************************/
 
 /************************************************************************/
-/* Dump ir graphs, differnt formats and additional information.         */
+/* Dump ir graphs, different formats and additional information.        */
 /************************************************************************/
 
 /** Routine to dump a graph, blocks as conventional nodes.  */
@@ -1820,7 +1828,7 @@ dump_ir_graph (ir_graph *irg, const char *suffix )
   rem = current_ir_graph;
 
   if (strncmp(get_entity_name(get_irg_entity(irg)),
-             dump_file_filter, strlen(dump_file_filter)) != 0) return;
+          dump_file_filter, strlen(dump_file_filter)) != 0) return;
 
   current_ir_graph = irg;
   if (get_interprocedural_view()) suffix1 = "-pure-ip";
@@ -1965,8 +1973,11 @@ dump_block_to_cfg(ir_node *block, void *env) {
     PRINT_NODEID(block);
     fprintf (F, "\" ");
     fprintf(F, "info1:\"");
-    if (dump_dominator_information_flag)
+    if (dump_dominator_information_flag) {
       fprintf(F, "dom depth %d\n", get_Block_dom_depth(block));
+      fprintf(F, "tree pre num %d\n", get_Block_dom_tree_pre_num(block));
+      fprintf(F, "max subtree pre num %d\n", get_Block_dom_max_subtree_pre_num(block));
+               }
 
     /* show arity and possible Bad predecessors of the block */
     fprintf(F, "arity: %d\n", get_Block_n_cfgpreds(block));
@@ -2209,7 +2220,7 @@ dump_type_graph (ir_graph *irg, const char *suffix)
   /* walk over the blocks in the graph */
   type_walk_irg(irg, dump_type_info, NULL, f);
   /* The walker for the const code can be called several times for the
-     same (sub) experssion.  So that no nodes are dumped several times
+     same (sub) expression.  So that no nodes are dumped several times
      we decrease the visited flag of the corresponding graph after each
      walk.  So now increase it finally. */
   inc_irg_visited(get_const_code_irg());