- add support for statistics and merge debug info
[libfirm] / ir / ana / interval_analysis.c
index 5070200..5dedb02 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
  * @brief   Implementation of interval analysis
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
-#ifdef HAVE_STRING_H
 #include <string.h>
-#endif
 
+#include "debug.h"
 #include "interval_analysis.h"
 #include "execution_frequency.h"
 #include "firm_common_t.h"
@@ -44,6 +41,8 @@
 #include "irprintf.h"
 #include "hashptr.h"
 
+DEBUG_ONLY(static firm_dbg_module_t *dbg);
+
 /*------------------------------------------------------------------*/
 /* A new in array via a hashmap. */
 /* The in array refers to the loop the block is contained in if the */
@@ -67,11 +66,11 @@ int region_attr_cmp(const void *e1, const void *e2, size_t size) {
   return (ra1->reg != ra2->reg);
 }
 
-static INLINE int attr_set_hash(region_attr *a) {
+static inline int attr_set_hash(region_attr *a) {
   return HASH_PTR(a->reg);
 }
 
-static INLINE region_attr *get_region_attr(void *region) {
+static inline region_attr *get_region_attr(void *region) {
   region_attr r_attr, *res;
   r_attr.reg = region;
 
@@ -127,7 +126,7 @@ void add_loop_cfop (void *region, void *cfop) {
   ARR_APP1(void *, get_region_attr(region)->op_array, cfop);
 }
 
-static INLINE void exc_outs(void *reg, ir_node *cfop) {
+static inline void exc_outs(void *reg, ir_node *cfop) {
   if (is_fragile_op(cfop) || (is_fragile_Proj(cfop)))
     inc_region_n_exc_outs(reg);
 }
@@ -249,9 +248,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) {
 
     if (is_backedge(b, i)) {
       if (b != get_loop_element(l, 0).node) {
-        if (get_firm_verbosity()) {
-               ir_printf("Loophead not at loop position 0. %+F\n", b);
-        }
+       DB((dbg, LEVEL_1, "Loophead not at loop position 0. %+F\n", b));
       }
       /* There are no backedges in the interval decomposition. */
       add_region_in(b, NULL);
@@ -260,7 +257,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) {
 
     cfop = get_Block_cfgpred(b, i);
     if (is_Proj(cfop)) {
-      if (get_irn_op(get_Proj_pred(cfop)) != op_Cond) {
+      if (!is_Cond(get_Proj_pred(cfop))) {
         cfop = skip_Proj(cfop);
       } else {
         assert(get_nodes_block(cfop) == get_nodes_block(skip_Proj(cfop)));
@@ -269,8 +266,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) {
 
     pred = skip_Proj(get_nodes_block(cfop));
     /* We want nice blocks. */
-    assert(   get_irn_op(pred) != op_Bad
-           && get_irn_op(skip_Proj(get_Block_cfgpred(b, i))) != op_Bad);
+    assert(!is_Bad(pred) && !is_Bad(skip_Proj(get_Block_cfgpred(b, i))));
     pred_l = get_irn_loop(pred);
     if (pred_l == l) {
       add_region_in(b, pred);
@@ -280,9 +276,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) {
       int found = find_inner_loop(b, l, pred, cfop);
       if (!found) {
            if (b != get_loop_element(l, 0).node) {
-             if (get_firm_verbosity()) {
-               ir_printf("Loop entry not at loop position 0. %+F\n", b);
-             }
+             DB((dbg, LEVEL_1, "Loop entry not at loop position 0. %+F\n", b));
            }
            found = find_outer_loop(l, pred_l, pred, cfop);
            if (found) add_region_in(b, NULL);  /* placeholder */
@@ -326,6 +320,8 @@ void construct_intervals(ir_graph *irg) {
   ir_graph *rem = current_ir_graph;
   current_ir_graph = irg;
 
+  FIRM_DBG_REGISTER(dbg, "firm.ana.interval");
+
   if (!region_attr_set)
     region_attr_set = new_set(region_attr_cmp, 256);
 
@@ -498,11 +494,12 @@ void dump_interval_graph(ir_graph *irg, const char *suffix) {
     return;
 
   f = vcg_open(irg, suffix, "-intervals");
-  dump_vcg_header(f, get_irg_dump_name(irg), NULL);
+  dump_vcg_header(f, get_irg_dump_name(irg), NULL, NULL);
 
   current_ir_graph = irg;
 
   dump_interval_loop(f, get_irg_loop(current_ir_graph));
 
-  vcg_close(f);
+  dump_vcg_footer(f);
+  fclose(f);
 }