#include "irdump.h"
-#include "firmstat.h"
+#include "irhooks.h"
/* Eindeutige Adresse zur Markierung von besuchten Knoten und zur
* Darstellung der unbekannten Methode. */
#include "dbginfo_t.h"
#include "iropt_dbg.h"
#include "irflag_t.h"
-#include "firmstat.h"
+#include "irhooks.h"
#include "ircons.h"
#include "irarch.h"
-#include "firmstat.h"
#undef DEB
}
if (res != irn)
- stat_arch_dep_replace_mul_with_shifts(irn);
+ hook_arch_dep_replace_mul_with_shifts(irn);
return res;
}
}
if (res != irn)
- stat_arch_dep_replace_div_by_const(irn);
+ hook_arch_dep_replace_div_by_const(irn);
return res;
}
}
if (res != irn)
- stat_arch_dep_replace_mod_by_const(irn);
+ hook_arch_dep_replace_mod_by_const(irn);
return res;
}
}
if (*div)
- stat_arch_dep_replace_DivMod_by_const(irn);
+ hook_arch_dep_replace_DivMod_by_const(irn);
}
# include "irgmod.h"
# include "array.h"
# include "ircons.h"
-# include "firmstat.h"
+# include "irhooks.h"
/* Turns a node into a "useless" Tuple. The Tuple just forms a tuple
from several inputs.
assert (irg);
assert(get_irn_op(old)->opar != oparity_dynamic);
- stat_turn_into_id(old);
+ hook_turn_into_id(old);
block = old->in[0];
if (!block) {
#include "cgana.h"
#include "irflag_t.h"
-#include "firmstat.h"
+#include "irhooks.h"
/* Defined in iropt.c */
pset *new_identities (void);
struct obstack *rebirth_obst = NULL;
/* inform statistics that we started a dead-node elimination run */
- stat_dead_node_elim_start(irg);
+ hook_dead_node_elim_start(irg);
/* Remember external state of current_ir_graph. */
rem = current_ir_graph;
}
/* inform statistics that the run is over */
- stat_dead_node_elim_stop(irg);
+ hook_dead_node_elim_stop(irg);
current_ir_graph = rem;
set_interprocedural_view(rem_ipview);
}
/* here we know we WILL inline, so inform the statistics */
- stat_inline(call, called_graph);
+ hook_inline(call, called_graph);
/* -- Decide how to handle exception control flow: Is there a handler
for the Call node, or do we branch directly to End on an exception?
# include "irgmod.h"
# include "mangle.h"
# include "irouts.h"
-# include "firmstat.h"
+# include "irhooks.h"
# include "irgwalk.h"
/**
res->kind = k_ir_graph;
/* inform statistics here, as blocks will be already build on this graph */
- stat_new_graph(res, ent);
+ hook_new_graph(res, ent);
current_ir_graph = res;
res = alloc_graph();
/* inform statistics here, as blocks will be already build on this graph */
- stat_new_graph(res, NULL);
+ hook_new_graph(res, NULL);
current_ir_graph = res;
res->n_loc = 1; /* Only the memory. */
graph, nor the entity standing for this graph. */
void free_ir_graph (ir_graph *irg) {
- stat_free_graph(irg);
+ hook_free_graph(irg);
if (irg->outs_state != outs_none) free_outs(irg);
if (irg->frame_type) free_type(irg->frame_type);
if (irg->value_table) del_identities(irg->value_table);
#include "irprog.h"
#include "irgwalk.h"
#include "typewalk.h"
-#include "firmstat.h"
+#include "irhooks.h"
#include "ircgcons.h"
#include "eset.h"
void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) {
ir_graph * rem = current_ir_graph;
- stat_irg_walk(irg, (void *)pre, (void *)post);
+ hook_irg_walk(irg, (void *)pre, (void *)post);
current_ir_graph = irg;
irg_walk(get_irg_end(irg), pre, post, env);
current_ir_graph = rem;
ir_node *block, *pred;
int i;
- stat_irg_block_walk(current_ir_graph, node, (void *)pre, (void *)post);
+ hook_irg_block_walk(current_ir_graph, node, (void *)pre, (void *)post);
assert(node);
assert(!get_interprocedural_view()); /* interprocedural_view not implemented, because it
#include "irgwalk.h"
#include "pdeq.h"
#include "pset.h"
-#include "firmstat.h"
+#include "irhooks.h"
/**
* Metadata for block walker
{
ir_graph * rem = current_ir_graph;
- stat_irg_walk_blkwise(irg, (void *)pre, (void *)post);
+ hook_irg_walk_blkwise(irg, (void *)pre, (void *)post);
current_ir_graph = irg;
irg_walk_blkwise(get_irg_end(irg), pre, post, env);
current_ir_graph = rem;
#include "irop_t.h"
#include "irprog_t.h"
-#include "firmstat.h"
+#include "irhooks.h"
/* some constants fixing the positions of nodes predecessors
in the in array */
res->node_nr = get_irp_new_node_nr();
#endif
- stat_new_node(res);
+ hook_new_node(res);
return res;
}
# include "irop_t.h"
# include "irnode_t.h"
-# include "firmstat.h"
+# include "irhooks.h"
# include "iropt_t.h" /* for firm_set_default_operations */
firm_set_default_operations(res);
firm_set_default_copy_attr(res);
- stat_new_ir_op(res);
+ hook_new_ir_op(res);
return res;
}
void free_ir_op(ir_op *code) {
- stat_free_ir_op(code);
+ hook_free_ir_op(code);
free(code);
}
# include "dbginfo_t.h"
# include "iropt_dbg.h"
# include "irflag_t.h"
-# include "firmstat.h"
+# include "irhooks.h"
# include "irarch.h"
# include "hashptr.h"
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = get_Block_cfgpred(oldn, 0); \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_STG); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_dead_code); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = get_Block_cfgpred(oldn, 0); \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_STG); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
} while(0)
ons[1] = a; \
ons[2] = b; \
ons[3] = get_Proj_pred(a); \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_IFSIM); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
} while(0)
*/
#define DBG_OPT_CSTEVAL(oldn, n) \
do { \
- stat_merge_nodes(&n, 1, &oldn, 1, STAT_OPT_CONST_EVAL); \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
__dbg_info_merge_pair(n, oldn, dbg_const_eval); \
} while(0)
ons[0] = oldn; \
ons[1] = a; \
ons[2] = b; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
} while(0)
ons[0] = oldn; \
ons[1] = pred; \
ons[2] = n; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = a; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ALGSIM); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = first_val; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_PHI); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_PHI); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_ssa); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldst; \
ons[1] = st; \
- stat_merge_nodes(&st, 1, ons, SIZ(ons), STAT_OPT_WAW); \
+ hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
__dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
} while(0)
ir_node *ons[2]; \
ons[0] = store; \
ons[1] = load; \
- stat_merge_nodes(&load, 1, ons, SIZ(ons), STAT_OPT_WAR); \
+ hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
__dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
} while(0)
ir_node *ons[2]; \
ons[0] = store; \
ons[1] = load; \
- stat_merge_nodes(&store, 1, ons, SIZ(ons), STAT_OPT_RAW); \
+ hook_merge_nodes(&store, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
__dbg_info_merge_sets(&store, 1, ons, SIZ(ons), dbg_read_after_write); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldld; \
ons[1] = ld; \
- stat_merge_nodes(&ld, 1, ons, SIZ(ons), STAT_OPT_RAR); \
+ hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
__dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
} while(0)
ir_node *ons[2]; \
ons[0] = ld; \
ons[1] = c; \
- stat_merge_nodes(&c, 1, ons, SIZ(ons), STAT_OPT_RC); \
+ hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
__dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
} while(0)
ons[0] = oldn; \
ons[1] = a; \
ons[2] = n; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_TUPLE); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = n; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_ID); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
} while(0)
ir_node *ons[2]; \
ons[0] = oldn; \
ons[1] = n; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_CSE); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
} while(0)
ons[0] = oldn; \
ons[1] = skip_Proj(get_Sel_ptr(oldn)); \
ons[2] = n; \
- stat_merge_nodes(&n, 1, ons, SIZ(ons), STAT_OPT_POLY_CALL); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
__dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_rem_poly_call); \
} while(0)
#define DBG_OPT_POLY(oldn, n) \
do { \
- stat_merge_nodes(&n, 1, &oldn, 1, STAT_OPT_POLY_CALL); \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_POLY_CALL); \
__dbg_info_merge_pair(n, oldn, dbg_rem_poly_call); \
} while(0)
# include "iropt_dbg.h"
# include "irflag_t.h"
# include "array.h"
-# include "firmstat.h"
+# include "irhooks.h"
#undef IMAX
#define IMAX(a,b) ((a) > (b) ? (a) : (b))
# include "irflag_t.h"
# include "irgwalk.h"
# include "reassoc_t.h"
-# include "firmstat.h"
+# include "irhooks.h"
typedef struct _walker_t {
int changes; /* set, if a reassociation take place */
walker_t *wenv = env;
int res;
- stat_reassociate(1);
+ hook_reassociate(1);
/* reassociation must run until fixpoint */
do {
}
} while (res == 1);
- stat_reassociate(0);
+ hook_reassociate(0);
}
/*
#include "dags.h"
#include "stat_dmp.h"
#include "xmalloc.h"
+#include "irhooks.h"
/*
* need this to be static:
return opcode_find_entry(code, status->ir_op_hash);
}
-/* initialize the statistics module. */
-void init_stat(unsigned enable_options)
-{
-#define X(a) a, sizeof(a)-1
-
- /* enable statistics */
- status->stat_options = enable_options & FIRMSTAT_ENABLED ? enable_options : 0;
-
- if (! status->stat_options)
- return;
-
- obstack_init(&status->cnts);
-
- /* create the hash-tables */
- status->irg_hash = new_pset(graph_cmp, 8);
- status->ir_op_hash = new_pset(opcode_cmp_2, 1);
-
- /* create the wait queue */
- status->wait_q = new_pdeq();
-
- if (enable_options & FIRMSTAT_COUNT_STRONG_OP) {
- /* build the pseudo-ops */
- _op_Phi0.code = get_next_ir_opcode();
- _op_Phi0.name = new_id_from_chars(X("Phi0"));
-
- _op_PhiM.code = get_next_ir_opcode();
- _op_PhiM.name = new_id_from_chars(X("PhiM"));
-
- _op_ProjM.code = get_next_ir_opcode();
- _op_ProjM.name = new_id_from_chars(X("ProjM"));
-
- _op_MulC.code = get_next_ir_opcode();
- _op_MulC.name = new_id_from_chars(X("MulC"));
-
- _op_DivC.code = get_next_ir_opcode();
- _op_DivC.name = new_id_from_chars(X("DivC"));
-
- _op_ModC.code = get_next_ir_opcode();
- _op_ModC.name = new_id_from_chars(X("ModC"));
-
- _op_DivModC.code = get_next_ir_opcode();
- _op_DivModC.name = new_id_from_chars(X("DivModC"));
-
- status->op_Phi0 = &_op_Phi0;
- status->op_PhiM = &_op_PhiM;
- status->op_ProjM = &_op_ProjM;
- status->op_MulC = &_op_MulC;
- status->op_DivC = &_op_DivC;
- status->op_ModC = &_op_ModC;
- status->op_DivModC = &_op_DivModC;
- }
- else {
- status->op_Phi0 = NULL;
- status->op_PhiM = NULL;
- status->op_ProjM = NULL;
- status->op_MulC = NULL;
- status->op_DivC = NULL;
- status->op_ModC = NULL;
- status->op_DivModC = NULL;
- }
-
- /* register the dumper */
- stat_register_dumper(&simple_dumper);
-
- if (enable_options & FIRMSTAT_CSV_OUTPUT)
- stat_register_dumper(&csv_dumper);
-
- /* initialize the pattern hash */
- stat_init_pattern_history(enable_options & FIRMSTAT_PATTERN_ENABLED);
-#undef X
-}
-
-/* A new IR op is registered. */
-void stat_new_ir_op(const ir_op *op)
+/** A new IR op is registered. */
+static void stat_new_ir_op(void *ctx, ir_op *op)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/* An IR op is freed. */
-void stat_free_ir_op(const ir_op *op)
+/** An IR op is freed. */
+static void stat_free_ir_op(void *ctx, ir_op *op)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/* A new node is created. */
-void stat_new_node(ir_node *node)
+/** A new node is created. */
+static void stat_new_node(void *ctx, ir_node *node)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/* A node is changed into a Id node */
-void stat_turn_into_id(ir_node *node)
+/** A node is changed into a Id node */
+static void stat_turn_into_id(void *ctx, ir_node *node)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/* A new graph was created */
-void stat_new_graph(ir_graph *irg, entity *ent)
+/** A new graph was created */
+static void stat_new_graph(void *ctx, ir_graph *irg, entity *ent)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* A graph will be deleted
*/
-void stat_free_graph(ir_graph *irg)
+static void stat_free_graph(void *ctx, ir_graph *irg)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* A walk over a graph is initiated. Do not count walks from statistic code.
*/
-void stat_irg_walk(ir_graph *irg, void *pre, void *post)
+static void stat_irg_walk(void *ctx, ir_graph *irg, void *pre, void *post)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* A walk over a graph in block-wise order is initiated. Do not count walks from statistic code.
*/
-void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post)
+static void stat_irg_walk_blkwise(void *ctx, ir_graph *irg, void *pre, void *post)
{
/* for now, do NOT differentiate between blockwise and normal */
- stat_irg_walk(irg, pre, post);
+ stat_irg_walk(ctx, irg, pre, post);
}
-/*
+/**
* A walk over the graph's blocks is initiated. Do not count walks from statistic code.
*/
-void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post)
+static void stat_irg_block_walk(void *ctx, ir_graph *irg, ir_node *node, void *pre, void *post)
{
if (! status->stat_options)
return;
cnt_inc(&entry->count);
}
-/*
+/**
* Some nodes were optimized into some others due to an optimization
*/
-void stat_merge_nodes(
+static void stat_merge_nodes(
+ void *ctx,
ir_node **new_node_array, int new_num_entries,
ir_node **old_node_array, int old_num_entries,
- stat_opt_kind opt)
+ hook_opt_kind opt)
{
if (! status->stat_options)
return;
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
if (status->reassoc_run)
- opt = STAT_OPT_REASSOC;
+ opt = HOOK_OPT_REASSOC;
for (i = 0; i < old_num_entries; ++i) {
for (j = 0; j < new_num_entries; ++j)
STAT_LEAVE;
}
-/*
+/**
* reassociation started/stopped.
*/
-void stat_reassociate(int flag)
+static void stat_reassociate(void *ctx, int flag)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* A node was lowered into other nodes
*/
-void stat_lower(ir_node *node)
+static void stat_lower(void *ctx, ir_node *node)
{
if (! status->stat_options)
return;
{
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
- removed_due_opt(node, graph->opt_hash[STAT_LOWERED]);
+ removed_due_opt(node, graph->opt_hash[HOOK_LOWERED]);
}
STAT_LEAVE;
}
-/*
+/**
* A graph was inlined
*/
-void stat_inline(ir_node *call, ir_graph *called_irg)
+static void stat_inline(void *ctx, ir_node *call, ir_graph *called_irg)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* A graph with tail-recursions was optimized.
*/
-void stat_tail_rec(ir_graph *irg)
+static void stat_tail_rec(void *ctx, ir_graph *irg)
{
if (! status->stat_options)
return;
STAT_LEAVE;
}
-/*
+/**
* Strength reduction was performed on an iteration variable.
*/
-void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp)
+static void stat_strength_red(void *ctx, ir_graph *irg, ir_node *strong, ir_node *cmp)
{
if (! status->stat_options)
return;
graph_entry_t *graph = graph_get_entry(irg, status->irg_hash);
cnt_inc(&graph->cnt_strength_red);
- removed_due_opt(strong, graph->opt_hash[STAT_OPT_STRENGTH_RED]);
+ removed_due_opt(strong, graph->opt_hash[HOOK_OPT_STRENGTH_RED]);
}
STAT_LEAVE;
}
-/*
+/**
* Start the dead node elimination.
*/
-void stat_dead_node_elim_start(ir_graph *irg)
+static void stat_dead_node_elim_start(void *ctx, ir_graph *irg)
{
if (! status->stat_options)
return;
++status->in_dead_node_elim;
}
-/*
+/**
* Stops the dead node elimination.
*/
-void stat_dead_node_elim_stop(ir_graph *irg)
+static void stat_dead_node_elim_stop(void *ctx, ir_graph *irg)
{
if (! status->stat_options)
return;
--status->in_dead_node_elim;
}
-/*
+/**
* A multiply was replaced by a series of Shifts/Adds/Subs
*/
-void stat_arch_dep_replace_mul_with_shifts(ir_node *mul)
+static void stat_arch_dep_replace_mul_with_shifts(void *ctx, ir_node *mul)
{
if (! status->stat_options)
return;
STAT_ENTER;
{
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
- removed_due_opt(mul, graph->opt_hash[STAT_OPT_ARCH_DEP]);
+ removed_due_opt(mul, graph->opt_hash[HOOK_OPT_ARCH_DEP]);
}
STAT_LEAVE;
}
/**
* A division was replaced by a series of Shifts/Muls
*/
-void stat_arch_dep_replace_div_by_const(ir_node *div)
+static void stat_arch_dep_replace_div_by_const(void *ctx, ir_node *div)
{
if (! status->stat_options)
return;
STAT_ENTER;
{
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
- removed_due_opt(div, graph->opt_hash[STAT_OPT_ARCH_DEP]);
+ removed_due_opt(div, graph->opt_hash[HOOK_OPT_ARCH_DEP]);
}
STAT_LEAVE;
}
/**
* A modulo was replaced by a series of Shifts/Muls
*/
-void stat_arch_dep_replace_mod_by_const(ir_node *mod)
+static void stat_arch_dep_replace_mod_by_const(void *ctx, ir_node *mod)
{
if (! status->stat_options)
return;
STAT_ENTER;
{
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
- removed_due_opt(mod, graph->opt_hash[STAT_OPT_ARCH_DEP]);
+ removed_due_opt(mod, graph->opt_hash[HOOK_OPT_ARCH_DEP]);
}
STAT_LEAVE;
}
/**
* A DivMod was replaced by a series of Shifts/Muls
*/
-void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod)
+static void stat_arch_dep_replace_DivMod_by_const(void *ctx, ir_node *divmod)
{
if (! status->stat_options)
return;
STAT_ENTER;
{
graph_entry_t *graph = graph_get_entry(current_ir_graph, status->irg_hash);
- removed_due_opt(divmod, graph->opt_hash[STAT_OPT_ARCH_DEP]);
+ removed_due_opt(divmod, graph->opt_hash[HOOK_OPT_ARCH_DEP]);
}
STAT_LEAVE;
}
STAT_LEAVE;
}
-#else
-
-/* need this for prototypes */
-#define FIRM_STATISTICS
-#include "firmstat.h"
-
-void init_stat(unsigned enable_options) {}
-
-void stat_finish(const char *name) {}
+static hook_entry_t stat_hooks[hook_last];
-void stat_new_ir_op(const ir_op *op) {}
-
-void stat_free_ir_op(const ir_op *op) {}
-
-void stat_new_node(ir_node *node) {}
+/* initialize the statistics module. */
+void init_stat(unsigned enable_options)
+{
+#define X(a) a, sizeof(a)-1
+#define HOOK(h, fkt) \
+ stat_hooks[h].hook._##h = fkt; register_hook(h, &stat_hooks[h])
-void stat_turn_into_id(ir_node *node) {}
+ /* enable statistics */
+ status->stat_options = enable_options & FIRMSTAT_ENABLED ? enable_options : 0;
-void stat_new_graph(ir_graph *irg, entity *ent) {}
+ if (! status->stat_options)
+ return;
-void stat_free_graph(ir_graph *irg) {}
+ /* register all hooks */
+ HOOK(hook_new_ir_op, stat_new_ir_op);
+ 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_new_graph, stat_new_graph);
+ HOOK(hook_free_graph, stat_free_graph);
+ HOOK(hook_irg_walk, stat_irg_walk);
+ HOOK(hook_irg_walk_blkwise, stat_irg_walk_blkwise);
+ HOOK(hook_irg_block_walk, stat_irg_block_walk);
+ HOOK(hook_merge_nodes, stat_merge_nodes);
+ HOOK(hook_reassociate, stat_reassociate);
+ HOOK(hook_lower, stat_lower);
+ HOOK(hook_inline, stat_inline);
+ HOOK(hook_tail_rec, stat_tail_rec);
+ HOOK(hook_strength_red, stat_strength_red);
+ HOOK(hook_dead_node_elim_start, stat_dead_node_elim_start);
+ HOOK(hook_dead_node_elim_stop, stat_dead_node_elim_stop);
+ HOOK(hook_arch_dep_replace_mul_with_shifts, stat_arch_dep_replace_mul_with_shifts);
+ HOOK(hook_arch_dep_replace_div_by_const, stat_arch_dep_replace_div_by_const);
+ HOOK(hook_arch_dep_replace_mod_by_const, stat_arch_dep_replace_mod_by_const);
+ HOOK(hook_arch_dep_replace_DivMod_by_const, stat_arch_dep_replace_DivMod_by_const);
-void stat_irg_walk(ir_graph *irg, void *pre, void *post) {}
+ obstack_init(&status->cnts);
-void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post) {}
+ /* create the hash-tables */
+ status->irg_hash = new_pset(graph_cmp, 8);
+ status->ir_op_hash = new_pset(opcode_cmp_2, 1);
-void stat_merge_nodes(
- ir_node **new_node_array, int new_num_entries,
- ir_node **old_node_array, int old_num_entries,
- stat_opt_kind opt) {}
+ /* create the wait queue */
+ status->wait_q = new_pdeq();
-void stat_reassociate(int start) {}
+ if (enable_options & FIRMSTAT_COUNT_STRONG_OP) {
+ /* build the pseudo-ops */
+ _op_Phi0.code = get_next_ir_opcode();
+ _op_Phi0.name = new_id_from_chars(X("Phi0"));
-void stat_lower(ir_node *node) {}
+ _op_PhiM.code = get_next_ir_opcode();
+ _op_PhiM.name = new_id_from_chars(X("PhiM"));
-void stat_inline(ir_node *call, ir_graph *irg) {}
+ _op_ProjM.code = get_next_ir_opcode();
+ _op_ProjM.name = new_id_from_chars(X("ProjM"));
-void stat_tail_rec(ir_graph *irg) {}
+ _op_MulC.code = get_next_ir_opcode();
+ _op_MulC.name = new_id_from_chars(X("MulC"));
-void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp) {}
+ _op_DivC.code = get_next_ir_opcode();
+ _op_DivC.name = new_id_from_chars(X("DivC"));
-void stat_dead_node_elim_start(ir_graph *irg) {}
+ _op_ModC.code = get_next_ir_opcode();
+ _op_ModC.name = new_id_from_chars(X("ModC"));
-void stat_dead_node_elim_stop(ir_graph *irg) {}
+ _op_DivModC.code = get_next_ir_opcode();
+ _op_DivModC.name = new_id_from_chars(X("DivModC"));
-void stat_arch_dep_replace_mul_with_shifts(ir_node *mul) {}
+ status->op_Phi0 = &_op_Phi0;
+ status->op_PhiM = &_op_PhiM;
+ status->op_ProjM = &_op_ProjM;
+ status->op_MulC = &_op_MulC;
+ status->op_DivC = &_op_DivC;
+ status->op_ModC = &_op_ModC;
+ status->op_DivModC = &_op_DivModC;
+ }
+ else {
+ status->op_Phi0 = NULL;
+ status->op_PhiM = NULL;
+ status->op_ProjM = NULL;
+ status->op_MulC = NULL;
+ status->op_DivC = NULL;
+ status->op_ModC = NULL;
+ status->op_DivModC = NULL;
+ }
-void stat_arch_dep_replace_div_by_const(ir_node *div) {}
+ /* register the dumper */
+ stat_register_dumper(&simple_dumper);
-void stat_arch_dep_replace_mod_by_const(ir_node *mod) {}
+ if (enable_options & FIRMSTAT_CSV_OUTPUT)
+ stat_register_dumper(&csv_dumper);
-void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod) {}
+ /* initialize the pattern hash */
+ stat_init_pattern_history(enable_options & FIRMSTAT_PATTERN_ENABLED);
+#undef HOOK
+#undef X
+}
-#endif
+#endif /* FIRM_STATISTICS */
#ifdef FIRM_STATISTICS
-typedef enum {
- STAT_OPT_STG, /**< straightening optimization */
- STAT_OPT_IFSIM, /**< if simplification */
- STAT_OPT_CONST_EVAL, /**< constant evaluation */
- STAT_OPT_ALGSIM, /**< algebraic simplification */
- STAT_OPT_PHI, /**< Phi optmization */
- STAT_OPT_WAW, /**< Write-After-Write optimization */
- STAT_OPT_WAR, /**< Write-After-Read optimization */
- STAT_OPT_RAW, /**< Read-After-Write optimization */
- STAT_OPT_RAR, /**< Read-After-Read optimization */
- STAT_OPT_RC, /**< Read-a-Const optimization */
- STAT_OPT_TUPLE, /**< Tuple optimization */
- STAT_OPT_ID, /**< ID optimization */
- STAT_OPT_CSE, /**< common subexpression elimination */
- STAT_OPT_STRENGTH_RED,/**< strength reduction */
- STAT_OPT_ARCH_DEP, /**< architecture dependent optimization */
- STAT_OPT_REASSOC, /**< reassociation */
- STAT_OPT_POLY_CALL, /**< polymorphic call optimization */
- STAT_LOWERED, /**< lowered */
-
- STAT_OPT_MAX
-} stat_opt_kind;
-
/**
* initialize the statistics module.
*
*/
void init_stat(unsigned enable_options);
-/**
- * A new IR op is registered.
- */
-void stat_new_ir_op(const ir_op *op);
-
-/**
- * An IR op is freed.
- */
-void stat_free_ir_op(const ir_op *op);
-
-/**
- * A new node is created.
- */
-void stat_new_node(ir_node *node);
-
-/**
- * A node is changed into a Id node
- */
-void stat_turn_into_id(ir_node *node);
-
-/**
- * A new graph was created
- */
-void stat_new_graph(ir_graph *irg, entity *ent);
-
-/**
- * A graph was deleted
- */
-void stat_free_graph(ir_graph *irg);
-
-/**
- * A walk over a graph is initiated
- */
-void stat_irg_walk(ir_graph *irg, void *pre, void *post);
-
-/**
- * A walk over a graph in block-wise order is initiated
- */
-void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post);
-
-/**
- * A walk over the graph's blocks is initiated
- */
-void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post);
-
-/**
- * Some nodes were optimized into some others due to an optimization
- */
-void stat_merge_nodes(
- ir_node **new_node_array, int new_num_entries,
- ir_node **old_node_array, int old_num_entries,
- stat_opt_kind opt);
-
-/**
- * Reassociation of nodes started/stopped.
- */
-void stat_reassociate(int start);
-
-/**
- * A node was lowered into other nodes
- */
-void stat_lower(ir_node *node);
-
-/**
- * A graph was inlined
- */
-void stat_inline(ir_node *call, ir_graph *irg);
-
-/**
- * A graph with tail-recursions was optimized.
- */
-void stat_tail_rec(ir_graph *irg);
-
-/**
- * Strength reduction was performed on an iteration variable.
- */
-void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp);
-
-/**
- * Start the dead node elimination.
- */
-void stat_dead_node_elim_start(ir_graph *irg);
-
-/**
- * Stops the dead node elimination.
- */
-void stat_dead_node_elim_stop(ir_graph *irg);
-
-/**
- * A multiply was replaced by a series of Shifts/Adds/Subs
- */
-void stat_arch_dep_replace_mul_with_shifts(ir_node *mul);
-
-/**
- * A division was replaced by a series of Shifts/Muls
- */
-void stat_arch_dep_replace_div_by_const(ir_node *div);
-
-/**
- * A modulo was replaced by a series of Shifts/Muls
- */
-void stat_arch_dep_replace_mod_by_const(ir_node *mod);
-
-/**
- * A Divod was replaced by a series of Shifts/Muls
- */
-void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod);
-
-/**
- * helper: get an ir_op from an opcode
- *
- * @param code the opcode
- *
- * @return The associated ir_op or NULL if the opcode could not be found.
- */
-ir_op *stat_get_op_from_opcode(opcode code);
-
-#else
-
-#define init_stat(enable_options)
-#define stat_finish(name)
-#define stat_new_ir_op(op)
-#define stat_free_ir_op(op)
-#define stat_new_node(node)
-#define stat_turn_into_id(node)
-#define stat_new_graph(irg, ent)
-#define stat_free_graph(irg)
-#define stat_irg_walk(irg, pre, post)
-#define stat_irg_walk_blkwise(irg, pre, post)
-#define stat_irg_block_walk(irg, node, pre, post)
-#define stat_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt)
-#define stat_reassociate(start)
-#define stat_lower(node)
-#define stat_inline(call, irg)
-#define stat_tail_rec(irg)
-#define stat_strength_red(irg, strong, cmp)
-#define stat_dead_node_elim_start(irg)
-#define stat_dead_node_elim_stop(irg)
-#define stat_arch_dep_replace_mul_with_shifts(irn)
-#define stat_arch_dep_replace_div_by_const(irn)
-#define stat_arch_dep_replace_mod_by_const(irn)
-#define stat_arch_dep_replace_DivMod_by_const(irn)
-
-#endif
+#endif /* FIRM_STATISTICS */
#endif /* _FIRMSTAT_H_ */
#include "irprog.h"
#include "irgwalk.h"
#include "counter.h"
+#include "irhooks.h"
/*
* just be make some things clear :-), the
counter_t cnt_edges; /**< number of DF edges in this graph */
counter_t cnt_all_calls; /**< number of all calls */
counter_t cnt_indirect_calls; /**< number of indirect calls */
- HASH_MAP(opt_entry_t) *opt_hash[STAT_OPT_MAX]; /**< hash maps containing opcode counter for optimizations */
+ HASH_MAP(opt_entry_t) *opt_hash[HOOK_OPT_LAST]; /**< hash maps containing opcode counter for optimizations */
ir_graph *irg; /**< the graph of this object */
entity *ent; /**< the entity of this graph if one exists */
set *address_mark; /**< a set containing the address marks of the nodes */
dumper_t *next; /**< link to the next dumper */
};
+/**
+ * helper: get an ir_op from an opcode
+ */
+ir_op *stat_get_op_from_opcode(opcode code);
/**
* An entry in a distribution table
#include "ident.h"
#include "irop_t.h"
#include "irmode.h"
-#include "firmstat.h"
+#include "firmstat_t.h"
#include "pattern_dmp.h"
/* dumper operations */