Commit 8750ea7c authored by Michael Beck's avatar Michael Beck
Browse files

used new hooks instead of firmstat

[r4846]
parent 491030fc
......@@ -46,7 +46,7 @@
#include "irdump.h"
#include "firmstat.h"
#include "irhooks.h"
/* Eindeutige Adresse zur Markierung von besuchten Knoten und zur
* Darstellung der unbekannten Methode. */
......
......@@ -20,10 +20,9 @@
#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
......@@ -338,7 +337,7 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn)
}
if (res != irn)
stat_arch_dep_replace_mul_with_shifts(irn);
hook_arch_dep_replace_mul_with_shifts(irn);
return res;
}
......@@ -706,7 +705,7 @@ ir_node *arch_dep_replace_div_by_const(ir_node *irn)
}
if (res != irn)
stat_arch_dep_replace_div_by_const(irn);
hook_arch_dep_replace_div_by_const(irn);
return res;
}
......@@ -797,7 +796,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn)
}
if (res != irn)
stat_arch_dep_replace_mod_by_const(irn);
hook_arch_dep_replace_mod_by_const(irn);
return res;
}
......@@ -904,7 +903,7 @@ void arch_dep_replace_divmod_by_const(ir_node **div, ir_node **mod, ir_node *irn
}
if (*div)
stat_arch_dep_replace_DivMod_by_const(irn);
hook_arch_dep_replace_DivMod_by_const(irn);
}
......
......@@ -22,7 +22,7 @@
# 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.
......@@ -56,7 +56,7 @@ exchange (ir_node *old, ir_node *nw)
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) {
......
......@@ -39,7 +39,7 @@
#include "cgana.h"
#include "irflag_t.h"
#include "firmstat.h"
#include "irhooks.h"
/* Defined in iropt.c */
pset *new_identities (void);
......@@ -508,7 +508,7 @@ dead_node_elimination(ir_graph *irg) {
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;
......@@ -546,7 +546,7 @@ dead_node_elimination(ir_graph *irg) {
}
/* 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);
......@@ -796,7 +796,7 @@ int inline_method(ir_node *call, ir_graph *called_graph) {
}
/* 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?
......
......@@ -31,7 +31,7 @@
# include "irgmod.h"
# include "mangle.h"
# include "irouts.h"
# include "firmstat.h"
# include "irhooks.h"
# include "irgwalk.h"
/**
......@@ -124,7 +124,7 @@ new_r_ir_graph (entity *ent, int n_loc)
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;
......@@ -232,7 +232,7 @@ ir_graph *new_const_code_irg(void) {
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. */
......@@ -297,7 +297,7 @@ void del_identities (pset *value_table);
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);
......
......@@ -32,7 +32,7 @@
#include "irprog.h"
#include "irgwalk.h"
#include "typewalk.h"
#include "firmstat.h"
#include "irhooks.h"
#include "ircgcons.h"
#include "eset.h"
......@@ -246,7 +246,7 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
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;
......@@ -430,7 +430,7 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void
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
......
......@@ -18,7 +18,7 @@
#include "irgwalk.h"
#include "pdeq.h"
#include "pset.h"
#include "firmstat.h"
#include "irhooks.h"
/**
* Metadata for block walker
......@@ -217,7 +217,7 @@ void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *po
{
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;
......
......@@ -28,7 +28,7 @@
#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 */
......@@ -155,7 +155,7 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo
res->node_nr = get_irp_new_node_nr();
#endif
stat_new_node(res);
hook_new_node(res);
return res;
}
......
......@@ -20,7 +20,7 @@
# include "irop_t.h"
# include "irnode_t.h"
# include "firmstat.h"
# include "irhooks.h"
# include "iropt_t.h" /* for firm_set_default_operations */
......@@ -149,12 +149,12 @@ new_ir_op(opcode code, const char *name, op_pin_state p, unsigned flags, op_arit
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);
}
......
......@@ -35,7 +35,7 @@
# include "dbginfo_t.h"
# include "iropt_dbg.h"
# include "irflag_t.h"
# include "firmstat.h"
# include "irhooks.h"
# include "irarch.h"
# include "hashptr.h"
......
......@@ -25,7 +25,7 @@
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)
......@@ -38,7 +38,7 @@
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)
......@@ -52,7 +52,7 @@
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)
......@@ -61,7 +61,7 @@
*/
#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)
......@@ -71,7 +71,7 @@
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)
......@@ -81,7 +81,7 @@
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)
......@@ -90,7 +90,7 @@
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)
......@@ -99,7 +99,7 @@
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)
......@@ -113,7 +113,7 @@
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)
......@@ -126,7 +126,7 @@
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)
......@@ -139,7 +139,7 @@
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)
......@@ -152,7 +152,7 @@
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)
......@@ -165,7 +165,7 @@
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)
......@@ -175,7 +175,7 @@
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)
......@@ -184,7 +184,7 @@
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)
......@@ -196,7 +196,7 @@
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)
......@@ -206,12 +206,12 @@
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)
......@@ -35,7 +35,7 @@
# 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))
......
......@@ -24,7 +24,7 @@
# 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 */
......@@ -313,7 +313,7 @@ static void do_reassociation(ir_node *n, void *env)
walker_t *wenv = env;
int res;
stat_reassociate(1);
hook_reassociate(1);
/* reassociation must run until fixpoint */
do {
......@@ -334,7 +334,7 @@ static void do_reassociation(ir_node *n, void *env)
}
} while (res == 1);
stat_reassociate(0);
hook_reassociate(0);
}
/*
......
......@@ -32,6 +32,7 @@
#include "dags.h"
#include "stat_dmp.h"
#include "xmalloc.h"
#include "irhooks.h"
/*
* need this to be static:
......@@ -817,80 +818,8 @@ ir_op *stat_get_op_from_opcode(opcode code)
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;
......@@ -907,8 +836,8 @@ void stat_new_ir_op(const ir_op *op)
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;
......@@ -919,8 +848,8 @@ void stat_free_ir_op(const ir_op *op)
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;
......@@ -948,8 +877,8 @@ void stat_new_node(ir_node *node)
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;
......@@ -973,8 +902,8 @@ void stat_turn_into_id(ir_node *node)
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;
......@@ -995,10 +924,10 @@ void stat_new_graph(ir_graph *irg, entity *ent)
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;
......@@ -1018,10 +947,10 @@ void stat_free_graph(ir_graph *irg)
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;
......@@ -1035,19 +964,19 @@ void stat_irg_walk(ir_graph *irg, void *pre, void *post)
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;
......@@ -1073,13 +1002,14 @@ static void removed_due_opt(ir_node *n, pset *set)
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;
......@@ -1090,7 +1020,7 @@ void stat_merge_nodes(
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)
......@@ -1106,10 +1036,10 @@ void stat_merge_nodes(
STAT_LEAVE;
}
/*
/**
* reassociation started/stopped.