#include "cgana.h"
#include "irflag_t.h"
-#include "firmstat.h"
+#include "irhooks.h"
/* Defined in iropt.c */
pset *new_identities (void);
*
* @param n The node to be copied
* @param env if non-NULL, the node number attribute will be copied to the new node
+ *
+ * Note: Also used for loop unrolling.
*/
static void
-copy_node (ir_node *n, void *env) {
+firm_copy_node (ir_node *n, void *env) {
ir_node *nn, *block;
int new_arity;
opcode op = get_irn_opcode(n);
* Copies new predecessors of old node to new node remembered in link.
* Spare the Bad predecessors of Phi and Block nodes.
*/
-static void
+void
copy_preds (ir_node *n, void *env) {
ir_node *nn, *block;
int i, j, irn_arity;
set_new_node(om, nm);
/* copy the live nodes */
- irg_walk(get_nodes_block(oe), copy_node, copy_preds, (void *)copy_node_nr);
+ irg_walk(get_nodes_block(oe), firm_copy_node, copy_preds, (void *)copy_node_nr);
/* copy_preds for the end node ... */
set_nodes_block(ne, get_new_node(get_nodes_block(oe)));
(get_irn_visited(ka) < get_irg_visited(current_ir_graph))) {
/* We must keep the block alive and copy everything reachable */
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph)-1);
- irg_walk(ka, copy_node, copy_preds, (void *)copy_node_nr);
+ irg_walk(ka, firm_copy_node, copy_preds, (void *)copy_node_nr);
add_End_keepalive(ne, get_new_node(ka));
}
}
if (get_irn_visited(ka) < get_irg_visited(current_ir_graph)) {
/* We didn't copy the Phi yet. */
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph)-1);
- irg_walk(ka, copy_node, copy_preds, (void *)copy_node_nr);
+ irg_walk(ka, firm_copy_node, copy_preds, (void *)copy_node_nr);
}
add_End_keepalive(ne, get_new_node(ka));
}
free_End(old_end);
set_irg_end_block (current_ir_graph, get_new_node(get_irg_end_block(current_ir_graph)));
if (get_irn_link(get_irg_frame(current_ir_graph)) == NULL) {
- copy_node (get_irg_frame(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node (get_irg_frame(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_frame(current_ir_graph), NULL);
}
if (get_irn_link(get_irg_globals(current_ir_graph)) == NULL) {
- copy_node (get_irg_globals(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node (get_irg_globals(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_globals(current_ir_graph), NULL);
}
if (get_irn_link(get_irg_initial_mem(current_ir_graph)) == NULL) {
- copy_node (get_irg_initial_mem(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node (get_irg_initial_mem(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_initial_mem(current_ir_graph), NULL);
}
if (get_irn_link(get_irg_args(current_ir_graph)) == NULL) {
- copy_node (get_irg_args(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node (get_irg_args(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_args(current_ir_graph), NULL);
}
set_irg_start (current_ir_graph, get_new_node(get_irg_start(current_ir_graph)));
set_irg_args (current_ir_graph, get_new_node(get_irg_args(current_ir_graph)));
if (get_irn_link(get_irg_bad(current_ir_graph)) == NULL) {
- copy_node(get_irg_bad(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node(get_irg_bad(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_bad(current_ir_graph), NULL);
}
set_irg_bad(current_ir_graph, get_new_node(get_irg_bad(current_ir_graph)));
if (get_irn_link(get_irg_no_mem(current_ir_graph)) == NULL) {
- copy_node(get_irg_no_mem(current_ir_graph), (void *)copy_node_nr);
+ firm_copy_node(get_irg_no_mem(current_ir_graph), (void *)copy_node_nr);
copy_preds(get_irg_no_mem(current_ir_graph), NULL);
}
set_irg_no_mem(current_ir_graph, get_new_node(get_irg_no_mem(current_ir_graph)));
struct obstack *graveyard_obst = NULL;
struct obstack *rebirth_obst = NULL;
+ edges_init_graph(irg);
+
/* 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;
graveyard_obst = irg->obst;
/* A new obstack, where the reachable nodes will be copied to. */
- rebirth_obst = (struct obstack *) xmalloc (sizeof (struct obstack));
+ rebirth_obst = xmalloc (sizeof(*rebirth_obst));
current_ir_graph->obst = rebirth_obst;
obstack_init (current_ir_graph->obst);
}
/* 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);
* Copy node for inlineing. Updates attributes that change when
* inlineing but not for dead node elimination.
*
- * Copies the node by calling copy_node and then updates the entity if
+ * Copies the node by calling firm_copy_node and then updates the entity if
* it's a local one. env must be a pointer of the frame type of the
* inlined procedure. The new entities must be in the link field of
* the entities.
ir_node *new;
type *frame_tp = (type *)env;
- copy_node(n, NULL);
+ firm_copy_node(n, NULL);
if (get_irn_op(n) == op_Sel) {
new = get_new_node (n);
assert(get_irn_op(new) == op_Sel);
{
type *call_type = get_Call_type(call);
int params, ress, i, res;
- assert(is_method_type(call_type));
+ assert(is_Method_type(call_type));
params = get_method_n_params(call_type);
ress = get_method_n_ress(call_type);
}
/* 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?
arity = get_irn_arity(end_bl); /* arity = n_exc + n_ret */
n_res = get_method_n_ress(get_Call_type(call));
- res_pred = (ir_node **) xmalloc (n_res * sizeof (ir_node *));
- cf_pred = (ir_node **) xmalloc (arity * sizeof (ir_node *));
+ res_pred = xmalloc (n_res * sizeof(*res_pred));
+ cf_pred = xmalloc (arity * sizeof(*res_pred));
set_irg_current_block(current_ir_graph, post_bl); /* just to make sure */
add_End_keepalive(get_irg_end(current_ir_graph), get_irn_n(end, i));
/* The new end node will die. We need not free as the in array is on the obstack:
- copy_node only generated 'D' arrays. */
+ firm_copy_node only generated 'D' arrays. */
/* -- Replace Return nodes by Jump nodes. -- */
n_ret = 0;
}
main_end_bl = get_irg_end_block(current_ir_graph);
main_end_bl_arity = get_irn_arity(main_end_bl);
- end_preds = (ir_node **) xmalloc ((n_exc + main_end_bl_arity) * sizeof (ir_node *));
+ end_preds = xmalloc ((n_exc + main_end_bl_arity) * sizeof(*end_preds));
for (i = 0; i < main_end_bl_arity; ++i)
end_preds[i] = get_irn_n(main_end_bl, i);
if (i < get_Block_n_cfgpreds(end_bl)) {
bl = get_nodes_block(cf_op);
arity = get_Block_n_cfgpreds(end_bl) + get_Block_n_cfgpreds(bl) - 1;
- cf_pred = (ir_node **) xmalloc (arity * sizeof (ir_node *));
+ cf_pred = xmalloc (arity * sizeof(*cf_pred));
for (j = 0; j < i; j++)
cf_pred[j] = get_Block_cfgpred(end_bl, j);
for (j = j; j < i + get_Block_n_cfgpreds(bl); j++)
} inline_irg_env;
static inline_irg_env *new_inline_irg_env(void) {
- inline_irg_env *env = xmalloc(sizeof(inline_irg_env));
+ inline_irg_env *env = xmalloc(sizeof(*env));
env->n_nodes = -2; /* uncount Start, End */
env->n_nodes_orig = -2; /* uncount Start, End */
env->call_nodes = eset_create();