* @author Michael Beck
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#ifdef FIRM_STATISTICS
#include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
#include "irouts.h"
#include "irdump.h"
cnt_clr(&elem->cnt_alive);
cnt_clr(&elem->new_node);
cnt_clr(&elem->into_Id);
+ cnt_clr(&elem->normalized);
} /* opcode_clear_entry */
/**
- * Returns the associates node_entry_t for an ir_op
+ * Returns the associates node_entry_t for an ir_op (and allocates
+ * one if not yet available).
*
* @param op the IR operation
* @param hmap a hash map containing ir_op* -> node_entry_t*
/**
* Returns the associated graph_entry_t for an IR graph.
*
- * @param irg the IR graph
+ * @param irg the IR graph, NULL for the global counter
* @param hmap the hash map containing ir_graph* -> graph_entry_t*
*/
static graph_entry_t *graph_get_entry(ir_graph *irg, hmap_graph_entry_t *hmap)
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);
/* 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 */
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);
* Register a dumper.
*/
static void stat_register_dumper(const dumper_t *dumper) {
- dumper_t *p = xmalloc(sizeof(*p));
+ dumper_t *p = XMALLOC(dumper_t);
- if (p) {
- memcpy(p, dumper, sizeof(*p));
+ memcpy(p, dumper, sizeof(*p));
- p->next = status->dumper;
- p->status = status;
- status->dumper = p;
- }
+ p->next = status->dumper;
+ p->status = status;
+ status->dumper = p;
/* FIXME: memory leak */
} /* stat_register_dumper */
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
*
graph->is_leaf_call = 0;
graph->is_recursive = 0;
graph->is_chain_call = 0;
+ graph->is_strict = 1;
graph->is_analyzed = 0;
}
STAT_LEAVE;
stat_finish_pattern_history(fname);
- /* clear the global counter here */
+ /* clear the global counters here */
{
node_entry_t *entry;
opcode_clear_entry(entry);
} /* for */
/* clear all global counter */
- graph_clear_entry(global, 1);
+ graph_clear_entry(global, /*all=*/1);
}
}
STAT_LEAVE;
if (! (enable_options & FIRMSTAT_ENABLED))
return;
- status = xmalloc(sizeof(*status));
- memset(status, 0, sizeof(*status));
+ status = XMALLOCZ(stat_info_t);
/* enable statistics */
status->stat_options = enable_options & FIRMSTAT_ENABLED ? enable_options : 0;
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);