HOOK_OPT_CONFIRM_C, /**< a value was substituted by a const due to a Confirm */
HOOK_OPT_CONFIRM_E, /**< a value was evaluated due to a Confirm */
HOOK_OPT_EXC_REM, /**< a exception edge was removed due to a Confirmation prove */
+ HOOK_OPT_NORMALIZE, /**< a commutative node was normalized */
HOOK_LOWERED, /**< lowered */
HOOK_BACKEND, /**< a backend transformation */
HOOK_OPT_LAST
/** This hook is called, before a node is changed into an Id node. */
void (*_hook_turn_into_id)(void *context, ir_node *node);
+ /** This hook is called, after a commutative node was normalized. */
+ void (*_hook_normalize)(void *context, ir_node *node);
+
/** This hook is called, after a new graph was created and before the first block
* on this graph is build. */
void (*_hook_new_graph)(void *context, ir_graph *irg, ir_entity *ent);
hook_set_irn_n,
hook_replace,
hook_turn_into_id,
+ hook_normalize,
hook_new_graph,
hook_free_graph,
hook_irg_walk,
hook_exec(hook_set_irn_n, (ctx, src, pos, tgt, old_tgt))
#define hook_replace(old, nw) hook_exec(hook_replace, (ctx, old, nw))
#define hook_turn_into_id(node) hook_exec(hook_turn_into_id, (ctx, node))
+#define hook_normalize(node) hook_exec(hook_normalize, (ctx, node))
#define hook_new_graph(irg, ent) hook_exec(hook_new_graph, (ctx, irg, ent))
#define hook_free_graph(irg) hook_exec(hook_free_graph, (ctx, irg))
#define hook_irg_walk(irg, pre, post) hook_exec(hook_irg_walk, (ctx, irg, pre, post))
#include "opt_confirms.h"
#include "opt_polymorphy.h"
#include "irtools.h"
+#include "irhooks.h"
#include "array_t.h"
/* Make types visible to allow most efficient access */
if (!operands_are_normalized(l, r)) {
set_binop_left(n, r);
set_binop_right(n, l);
+ hook_normalize(n);
}
}
} /* normalize_node */
cnt_clr(&elem->cnt_alive);
cnt_clr(&elem->new_node);
cnt_clr(&elem->into_Id);
+ cnt_clr(&elem->normalized);
} /* opcode_clear_entry */
/**
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
*
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);
counter_t cnt_alive; /**< amount of nodes in this entry */
counter_t new_node; /**< amount of new nodes for this entry */
counter_t into_Id; /**< amount of nodes that turned into Id's for this entry */
+ counter_t normalized; /**< amount of nodes that normalized for this entry */
const ir_op *op; /**< the op for this entry */
} node_entry_t;
{ HOOK_OPT_CONFIRM_C, "Confirm-based optimization: replaced by const" },
{ HOOK_OPT_CONFIRM_E, "Confirm-based optimization: evaluated" },
{ HOOK_OPT_EXC_REM, "a exception edge was removed due to a Confirmation prove" },
+ { HOOK_OPT_NORMALIZE, "a commutative node was normalized" },
{ HOOK_LOWERED, "Lowered" },
{ HOOK_BACKEND, "Backend transformation" },
{ FS_OPT_NEUTRAL_0, "algebraic simplification: a op 0 = 0 op a = a" },
counter_t f_alive;
counter_t f_new_node;
counter_t f_Id;
+ counter_t f_normlized;
cnt_clr(&f_alive);
cnt_clr(&f_new_node);
cnt_clr(&f_Id);
+ cnt_clr(&f_normlized);
- fprintf(dmp->f, "%-16s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id");
+ fprintf(dmp->f, "%-16s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id", "normalized");
foreach_pset(set, entry) {
fprintf(dmp->f, "%-16s %8u %8u %8u\n",
get_id_str(entry->op->name),
cnt_to_uint(&entry->cnt_alive),
cnt_to_uint(&entry->new_node),
- cnt_to_uint(&entry->into_Id)
+ cnt_to_uint(&entry->into_Id),
+ cnt_to_uint(&entry->normalized)
);
- cnt_add(&f_alive, &entry->cnt_alive);
- cnt_add(&f_new_node, &entry->new_node);
- cnt_add(&f_Id, &entry->into_Id);
+ cnt_add(&f_alive, &entry->cnt_alive);
+ cnt_add(&f_new_node, &entry->new_node);
+ cnt_add(&f_Id, &entry->into_Id);
+ cnt_add(&f_normlized, &entry->normalized);
} /* foreach_pset */
fprintf(dmp->f, "-------------------------------------------\n");
- fprintf(dmp->f, "%-16s %8u %8u %8u\n", "Sum",
+ fprintf(dmp->f, "%-16s %8u %8u %8u %8u\n", "Sum",
cnt_to_uint(&f_alive),
cnt_to_uint(&f_new_node),
- cnt_to_uint(&f_Id)
+ cnt_to_uint(&f_Id),
+ cnt_to_uint(&f_normlized)
);
} /* simple_dump_opcode_hash */