graph_clear_entry(elem, 1);
/* new hash table for opcodes here */
- elem->opcode_hash = new_pset(opcode_cmp, 5);
- elem->address_mark = new_set(address_mark_cmp, 5);
- elem->irg = irg;
+ elem->opcode_hash = new_pset(opcode_cmp, 5);
+ elem->address_mark = new_set(address_mark_cmp, 5);
+ elem->irg = irg;
/* these hash tables are created on demand */
elem->block_hash = NULL;
/* count extended block edges */
if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
- undate_extbb_info(node, graph);
+ if (graph->irg != get_const_code_irg())
+ undate_extbb_info(node, graph);
}
/* handle statistics for special node types */
graph->block_hash = new_pset(block_cmp, 5);
/* we need dominator info */
- if (graph->irg != get_const_code_irg())
- if (get_irg_dom_state(graph->irg) != dom_consistent)
- compute_doms(graph->irg);
+ if (graph->irg != get_const_code_irg()) {
+ assure_doms(graph->irg);
- if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
- /* we need extended basic blocks */
- compute_extbb(graph->irg);
+ if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
+ /* we need extended basic blocks */
+ compute_extbb(graph->irg);
- /* create new extbb counter */
- graph->extbb_hash = new_pset(block_cmp, 5);
+ /* create new extbb counter */
+ graph->extbb_hash = new_pset(block_cmp, 5);
+ }
}
/* count the nodes in the graph */
dumper_t *p = xmalloc(sizeof(*p));
if (p) {
- *p = *dumper;
+ memcpy(p, dumper, sizeof(*p));
p->next = status->dumper;
p->status = status;
}
}
+/**
+ * calls all registered functions.
+ */
+static void stat_dump_registered(graph_entry_t *entry)
+{
+ dumper_t *dumper;
+
+ for (dumper = status->dumper; dumper; dumper = dumper->next) {
+ if (dumper->func_map) {
+ dump_graph_FUNC func;
+
+ foreach_pset(dumper->func_map, func)
+ func(dumper, entry);
+ }
+ }
+}
+
/**
* dumps a constant table
*/
}
}
+/**
+ * register an additional function for all dumper
+ */
+void stat_register_dumper_func(dump_graph_FUNC func) {
+ dumper_t *dumper;
+
+ for (dumper = status->dumper; dumper; dumper = dumper->next) {
+ if (! dumper->func_map)
+ dumper->func_map = pset_new_ptr(3);
+ pset_insert_ptr(dumper->func_map, func);
+ }
+}
+
/* ---------------------------------------------------------------------- */
/*
*
* @param ctx the hook context
*/
-static void stat_strength_red(void *ctx, ir_graph *irg, ir_node *strong, ir_node *cmp)
+static void stat_strength_red(void *ctx, ir_graph *irg, ir_node *strong)
{
if (! status->stat_options)
return;
if (! entry->is_deleted || status->stat_options & FIRMSTAT_COUNT_DELETED) {
stat_dump_graph(entry);
+ stat_dump_registered(entry);
}
if (! entry->is_deleted) {
#undef X
}
+/**
+ * Frees all dumper structures;
+ */
+static void stat_term_dumper() {
+ dumper_t *dumper, *next_dumper;
+
+ for (dumper = status->dumper; dumper; /* iteration done in loop body */ ) {
+ if (dumper->func_map)
+ del_pset(dumper->func_map);
+
+ next_dumper = dumper->next;
+ free(dumper);
+ dumper = next_dumper;
+ }
+}
+
+
/* terminates the statistics module, frees all memory */
void stat_term(void) {
if (status != (stat_info_t *)&status_disable) {
obstack_free(&status->be_data, NULL);
obstack_free(&status->cnts, NULL);
+
+ stat_term_dumper();
+
xfree(status);
status = (stat_info_t *)&status_disable;
}