+ir_op *stat_get_op_from_opcode(ir_opcode code) {
+ return opcode_find_entry(code, status->ir_op_hash);
+} /* stat_get_op_from_opcode */
+
+/**
+ * Hook: A new IR op is registered.
+ *
+ * @param ctx the hook context
+ * @param op the new IR opcode that was created.
+ */
+static void stat_new_ir_op(void *ctx, ir_op *op) {
+ if (! status->stat_options)
+ return;
+
+ STAT_ENTER;
+ {
+ graph_entry_t *graph = graph_get_entry(NULL, status->irg_hash);
+
+ /* execute for side effect :-) */
+ (void)opcode_get_entry(op, graph->opcode_hash);
+
+ pset_insert(status->ir_op_hash, op, op->code);
+ }
+ STAT_LEAVE;
+} /* stat_new_ir_op */
+
+/**
+ * Hook: An IR op is freed.
+ *
+ * @param ctx the hook context
+ * @param op the IR opcode that is freed
+ */
+static void stat_free_ir_op(void *ctx, ir_op *op) {
+ if (! status->stat_options)
+ return;
+
+ STAT_ENTER;
+ {
+ }
+ STAT_LEAVE;
+} /* stat_free_ir_op */
+
+/**
+ * Hook: A new node is created.
+ *
+ * @param ctx the hook context
+ * @param irg the IR graph on which the node is created
+ * @param node the new IR node that was created
+ */
+static void stat_new_node(void *ctx, ir_graph *irg, ir_node *node) {
+ if (! status->stat_options)
+ return;
+
+ /* do NOT count during dead node elimination */
+ if (status->in_dead_node_elim)
+ 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->new_node);
+
+ /* increase local value */
+ graph = graph_get_entry(current_ir_graph, status->irg_hash);
+ entry = opcode_get_entry(op, graph->opcode_hash);
+ cnt_inc(&entry->new_node);
+ }
+ STAT_LEAVE;
+} /* stat_new_node */
+
+/**
+ * Hook: A node is changed into a Id node
+ *
+ * @param ctx the hook context
+ * @param node the IR node that will be turned into an ID
+ */
+static void stat_turn_into_id(void *ctx, ir_node *node) {
+ 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->into_Id);
+
+ /* increase local value */
+ graph = graph_get_entry(current_ir_graph, status->irg_hash);
+ entry = opcode_get_entry(op, graph->opcode_hash);
+ cnt_inc(&entry->into_Id);
+ }
+ STAT_LEAVE;
+} /* stat_turn_into_id */
+
+/**
+ * Hook: A new graph was created
+ *
+ * @param ctx the hook context
+ * @param irg the new IR graph that was created
+ * @param ent the entity of this graph
+ */
+static void stat_new_graph(void *ctx, ir_graph *irg, ir_entity *ent) {
+ if (! status->stat_options)
+ return;
+
+ STAT_ENTER;
+ {
+ /* execute for side effect :-) */
+ graph_entry_t * graph = graph_get_entry(irg, status->irg_hash);
+
+ graph->ent = ent;
+ graph->is_deleted = 0;
+ graph->is_leaf = 0;
+ graph->is_leaf_call = 0;
+ graph->is_recursive = 0;
+ graph->is_chain_call = 0;
+ graph->is_analyzed = 0;
+ }
+ STAT_LEAVE;
+} /* stat_new_graph */
+
+/**
+ * Hook: A graph will be deleted
+ *
+ * @param ctx the hook context
+ * @param irg the IR graph that will be deleted
+ *
+ * Note that we still hold the information for this graph
+ * in our hash maps, only a flag is set which prevents this
+ * information from being changed, it's "frozen" from now.
+ */
+static void stat_free_graph(void *ctx, ir_graph *irg) {
+ if (! status->stat_options)
+ return;
+
+ STAT_ENTER;
+ {
+ graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
+ graph_entry_t *global = graph_get_entry(NULL, status->irg_hash);
+
+ graph->is_deleted = 1;
+
+ if (status->stat_options & FIRMSTAT_COUNT_DELETED) {
+ /* count the nodes of the graph yet, it will be destroyed later */
+ update_graph_stat(global, graph);
+ } /* if */
+ }
+ STAT_LEAVE;
+} /* stat_free_graph */
+
+/**
+ * Hook: A walk over a graph is initiated. Do not count walks from statistic code.
+ *
+ * @param ctx the hook context
+ * @param irg the IR graph that will be walked
+ * @param pre the pre walker
+ * @param post the post walker
+ */
+static void stat_irg_walk(void *ctx, ir_graph *irg, generic_func *pre, generic_func *post)