Commit 2c7e6014 authored by Matthias Braun's avatar Matthias Braun
Browse files

make dependency edge handling more robust

parent 60ade3bd
......@@ -431,8 +431,8 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
obstack_init(&birg->obst);
birg->lv = be_liveness_new(irg);
edges_deactivate_kind(irg, EDGE_KIND_DEP);
edges_activate_kind(irg, EDGE_KIND_DEP);
edges_deactivate(irg);
edges_activate(irg);
/* set the current graph (this is important for several firm functions) */
current_ir_graph = irg;
......
......@@ -914,14 +914,12 @@ void edges_activate(ir_graph *irg)
{
edges_activate_kind(irg, EDGE_KIND_NORMAL);
edges_activate_kind(irg, EDGE_KIND_BLOCK);
if (get_irg_phase_state(irg) == phase_backend)
edges_activate_kind(irg, EDGE_KIND_DEP);
edges_activate_kind(irg, EDGE_KIND_DEP);
}
void edges_deactivate(ir_graph *irg)
{
if (get_irg_phase_state(irg) == phase_backend)
edges_deactivate_kind(irg, EDGE_KIND_DEP);
edges_deactivate_kind(irg, EDGE_KIND_DEP);
edges_deactivate_kind(irg, EDGE_KIND_BLOCK);
edges_deactivate_kind(irg, EDGE_KIND_NORMAL);
}
......@@ -930,6 +928,7 @@ void assure_edges(ir_graph *irg)
{
assure_edges_kind(irg, EDGE_KIND_BLOCK);
assure_edges_kind(irg, EDGE_KIND_NORMAL);
assure_edges_kind(irg, EDGE_KIND_DEP);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES);
}
......@@ -943,6 +942,7 @@ void edges_node_deleted(ir_node *irn)
{
edges_node_deleted_kind(irn, EDGE_KIND_NORMAL);
edges_node_deleted_kind(irn, EDGE_KIND_BLOCK);
edges_node_deleted_kind(irn, EDGE_KIND_DEP);
}
void edges_node_revival(ir_node *irn)
......
......@@ -304,19 +304,32 @@ ir_node *(get_irn_dep)(const ir_node *node, int pos)
return get_irn_dep_(node, pos);
}
void (set_irn_dep)(ir_node *node, int pos, ir_node *dep)
void set_irn_dep(ir_node *node, int pos, ir_node *dep)
{
set_irn_dep_(node, pos, dep);
ir_node *old;
ir_graph *irg;
assert(node->deps && "dependency array node yet allocated. use add_irn_dep()");
assert(pos >= 0 && pos < (int)ARR_LEN(node->deps) && "dependency index out of range");
assert(dep != NULL);
old = node->deps[pos];
node->deps[pos] = dep;
irg = get_irn_irg(node);
if (edges_activated_kind(irg, EDGE_KIND_DEP))
edges_notify_edge_kind(node, pos, dep, old, EDGE_KIND_DEP, irg);
}
void add_irn_dep(ir_node *node, ir_node *dep)
{
ir_graph *irg;
assert(dep != NULL);
if (node->deps == NULL) {
node->deps = NEW_ARR_F(ir_node *, 0);
}
ARR_APP1(ir_node*, node->deps, dep);
edges_notify_edge_kind(node, ARR_LEN(node->deps)-1, dep, NULL, EDGE_KIND_DEP, get_irn_irg(node));
irg = get_irn_irg(node);
if (edges_activated_kind(irg, EDGE_KIND_DEP))
edges_notify_edge_kind(node, ARR_LEN(node->deps)-1, dep, NULL, EDGE_KIND_DEP, irg);
}
void delete_irn_dep(ir_node *node, ir_node *dep)
......
......@@ -153,19 +153,6 @@ static inline ir_node *get_irn_dep_(const ir_node *node, int pos)
/* forward declaration outside iredges_t.h to avoid circular include problems */
void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_edge_kind_t kind, ir_graph *irg);
static inline void set_irn_dep_(ir_node *node, int pos, ir_node *dep)
{
ir_node *old;
assert(node->deps && "dependency array node yet allocated. use add_irn_dep()");
assert(pos >= 0 && pos < (int)ARR_LEN(node->deps) && "dependency index out of range");
assert(dep != NULL);
old = node->deps[pos];
node->deps[pos] = dep;
edges_notify_edge_kind(node, pos, dep, old, EDGE_KIND_DEP, get_irn_irg(node));
}
static inline int get_irn_ins_or_deps_(const ir_node *irn)
{
return get_irn_deps_(irn) + get_irn_arity_(irn);
......@@ -635,7 +622,6 @@ void init_irnode(void);
#define get_irn_idx(node) get_irn_idx_(node)
#define get_irn_deps(node) get_irn_deps_(node)
#define set_irn_dep(node, pos, dep) set_irn_dep_(node, pos, dep)
#define get_irn_dep(node, pos) get_irn_dep_(node, pos)
#define get_irn_ins_or_deps(node) get_irn_ins_or_deps_(node)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment