- renamed normalize_node() into ir_normalize_node() and make it available outside...
[libfirm] / ir / stat / firmstat.c
index 103e9d6..55f6193 100644 (file)
@@ -23,9 +23,7 @@
  * @author  Michael Beck
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #ifdef FIRM_STATISTICS
 
@@ -212,6 +210,7 @@ static void opcode_clear_entry(node_entry_t *elem) {
        cnt_clr(&elem->cnt_alive);
        cnt_clr(&elem->new_node);
        cnt_clr(&elem->into_Id);
+       cnt_clr(&elem->normalized);
 }  /* opcode_clear_entry */
 
 /**
@@ -970,7 +969,7 @@ static void update_node_stat(ir_node *node, void *env)
        node_entry_t *entry;
 
        ir_op *op = stat_get_irn_op(node);
-       int arity = get_irn_arity(node);
+       int i, arity = get_irn_arity(node);
 
        entry = opcode_get_entry(op, graph->opcode_hash);
 
@@ -1001,6 +1000,16 @@ static void update_node_stat(ir_node *node, void *env)
                /* check address properties */
                stat_update_address(get_Store_ptr(node), graph);
                break;
+       case iro_Phi:
+               /* check for non-strict Phi nodes */
+               for (i = arity - 1; i >= 0; --i) {
+                       ir_node *pred = get_Phi_pred(node, i);
+                       if (is_Unknown(pred)) {
+                               /* found an Unknown predecessor, graph is not strict */
+                               graph->is_strict = 0;
+                               break;
+                       }
+               }
        default:
                ;
        }  /* switch */
@@ -1186,6 +1195,7 @@ static void update_graph_stat(graph_entry_t *global, graph_entry_t *graph)
        graph->is_leaf_call  = LCS_UNKNOWN;
        graph->is_recursive  = 0;
        graph->is_chain_call = 1;
+       graph->is_strict     = 1;
 
        /* create new block counter */
        graph->block_hash = new_pset(block_cmp, 5);
@@ -1527,6 +1537,36 @@ static void stat_turn_into_id(void *ctx, ir_node *node) {
        STAT_LEAVE;
 }  /* stat_turn_into_id */
 
+/**
+ * Hook: A node is normalized
+ *
+ * @param ctx   the hook context
+ * @param node  the IR node that was normalized
+ */
+static void stat_normalize(void *ctx, ir_node *node) {
+       (void) ctx;
+       if (! status->stat_options)
+               return;
+
+       STAT_ENTER;
+       {
+               node_entry_t *entry;
+               graph_entry_t *graph;
+               ir_op *op = stat_get_irn_op(node);
+
+               /* increase global value */
+               graph = graph_get_entry(NULL, status->irg_hash);
+               entry = opcode_get_entry(op, graph->opcode_hash);
+               cnt_inc(&entry->normalized);
+
+               /* increase local value */
+               graph = graph_get_entry(current_ir_graph, status->irg_hash);
+               entry = opcode_get_entry(op, graph->opcode_hash);
+               cnt_inc(&entry->normalized);
+       }
+       STAT_LEAVE;
+}  /* stat_normalize */
+
 /**
  * Hook: A new graph was created
  *
@@ -1550,6 +1590,7 @@ static void stat_new_graph(void *ctx, ir_graph *irg, ir_entity *ent) {
                graph->is_leaf_call  = 0;
                graph->is_recursive  = 0;
                graph->is_chain_call = 0;
+               graph->is_strict     = 1;
                graph->is_analyzed   = 0;
        }
        STAT_LEAVE;
@@ -2194,6 +2235,7 @@ void firm_init_stat(unsigned enable_options)
        HOOK(hook_free_ir_op,                         stat_free_ir_op);
        HOOK(hook_new_node,                           stat_new_node);
        HOOK(hook_turn_into_id,                       stat_turn_into_id);
+       HOOK(hook_normalize,                          stat_normalize);
        HOOK(hook_new_graph,                          stat_new_graph);
        HOOK(hook_free_graph,                         stat_free_graph);
        HOOK(hook_irg_walk,                           stat_irg_walk);