Commit 59d977a8 authored by Matthias Braun's avatar Matthias Braun
Browse files

add remove_End_n, rename del_Sync_n to remove_Sync_n

parent b49d4ae9
...@@ -302,6 +302,9 @@ FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]); ...@@ -302,6 +302,9 @@ FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
/** Removes irn from the keep-alive set. */ /** Removes irn from the keep-alive set. */
FIRM_API void remove_End_keepalive(ir_node *end, ir_node *irn); FIRM_API void remove_End_keepalive(ir_node *end, ir_node *irn);
/** Removes predecessor (a keepalive) at index @p idx from End node @p end. */
FIRM_API void remove_End_n(ir_node *end, int idx);
/** Removes Bads, NoMem and doublets from the keep-alive set. */ /** Removes Bads, NoMem and doublets from the keep-alive set. */
FIRM_API void remove_End_Bads_and_doublets(ir_node *end); FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
...@@ -497,8 +500,8 @@ FIRM_API void set_memop_mem(ir_node *node, ir_node *mem); ...@@ -497,8 +500,8 @@ FIRM_API void set_memop_mem(ir_node *node, ir_node *mem);
/** Adds @p pred to predecessor list of Sync node @p node. */ /** Adds @p pred to predecessor list of Sync node @p node. */
FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred); FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
/** Removes predecessor i from Sync n */ /** Removes predecessor @p i from Sync @p n */
FIRM_API void del_Sync_n(ir_node *n, int i); FIRM_API void remove_Sync_n(ir_node *n, int i);
/** @} */ /** @} */
......
...@@ -227,7 +227,7 @@ int add_irn_n(ir_node *node, ir_node *in) ...@@ -227,7 +227,7 @@ int add_irn_n(ir_node *node, ir_node *in)
return pos; return pos;
} }
static void del_irn_n(ir_node *node, int n) static void remove_irn_n(ir_node *node, int n)
{ {
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
...@@ -249,9 +249,9 @@ static void del_irn_n(ir_node *node, int n) ...@@ -249,9 +249,9 @@ static void del_irn_n(ir_node *node, int n)
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS); clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
} }
void del_Sync_n(ir_node *n, int i) void remove_Sync_n(ir_node *n, int i)
{ {
del_irn_n(n, i); remove_irn_n(n, i);
} }
int (get_irn_deps)(const ir_node *node) int (get_irn_deps)(const ir_node *node)
...@@ -576,6 +576,11 @@ void set_End_keepalives(ir_node *end, int n, ir_node *in[]) ...@@ -576,6 +576,11 @@ void set_End_keepalives(ir_node *end, int n, ir_node *in[])
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS); clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
} }
void remove_End_n(ir_node *n, int idx)
{
remove_irn_n(n, idx);
}
void remove_End_keepalive(ir_node *end, ir_node *irn) void remove_End_keepalive(ir_node *end, ir_node *irn)
{ {
int n = get_End_n_keepalives(end); int n = get_End_n_keepalives(end);
...@@ -593,7 +598,7 @@ void remove_End_keepalive(ir_node *end, ir_node *irn) ...@@ -593,7 +598,7 @@ void remove_End_keepalive(ir_node *end, ir_node *irn)
} }
} }
assert(idx != -1); assert(idx != -1);
del_irn_n(end, idx); remove_irn_n(end, idx);
} }
void remove_End_Bads_and_doublets(ir_node *end) void remove_End_Bads_and_doublets(ir_node *end)
...@@ -614,7 +619,7 @@ void remove_End_Bads_and_doublets(ir_node *end) ...@@ -614,7 +619,7 @@ void remove_End_Bads_and_doublets(ir_node *end)
if (is_Bad(ka) || is_NoMem(ka) || pset_new_contains(&keeps, ka)) { if (is_Bad(ka) || is_NoMem(ka) || pset_new_contains(&keeps, ka)) {
changed = true; changed = true;
del_irn_n(end, idx - END_KEEPALIVE_OFFSET); remove_irn_n(end, idx - END_KEEPALIVE_OFFSET);
--n; --n;
} else { } else {
pset_new_insert(&keeps, ka); pset_new_insert(&keeps, ka);
......
...@@ -5759,7 +5759,7 @@ static ir_node *transform_node_Sync(ir_node *n) ...@@ -5759,7 +5759,7 @@ static ir_node *transform_node_Sync(ir_node *n)
/* Remove Bad predecessors */ /* Remove Bad predecessors */
if (is_Bad(pred)) { if (is_Bad(pred)) {
del_Sync_n(n, i); remove_Sync_n(n, i);
--arity; --arity;
continue; continue;
} }
...@@ -5767,7 +5767,7 @@ static ir_node *transform_node_Sync(ir_node *n) ...@@ -5767,7 +5767,7 @@ static ir_node *transform_node_Sync(ir_node *n)
/* Remove duplicate predecessors */ /* Remove duplicate predecessors */
for (j = 0; j < i; ++j) { for (j = 0; j < i; ++j) {
if (get_Sync_pred(n, j) == pred) { if (get_Sync_pred(n, j) == pred) {
del_Sync_n(n, i); remove_Sync_n(n, i);
--arity; --arity;
break; break;
} }
...@@ -5780,7 +5780,7 @@ static ir_node *transform_node_Sync(ir_node *n) ...@@ -5780,7 +5780,7 @@ static ir_node *transform_node_Sync(ir_node *n)
continue; continue;
} }
del_Sync_n(n, i); remove_Sync_n(n, i);
--arity; --arity;
pred_arity = get_Sync_n_preds(pred); pred_arity = get_Sync_n_preds(pred);
......
...@@ -22,35 +22,29 @@ ...@@ -22,35 +22,29 @@
*/ */
static void exchange_tuple_projs(ir_node *node, void *env) static void exchange_tuple_projs(ir_node *node, void *env)
{ {
ir_node *pred;
int proj;
(void)env; (void)env;
if (!is_Proj(node))
return;
if (!is_Proj(node)) return; ir_node *pred = get_Proj_pred(node);
if (!is_Tuple(pred))
return;
pred = get_Proj_pred(node); int pn = get_Proj_proj(node);
proj = get_Proj_proj(node); ir_node *tuple_pred = get_Tuple_pred(pred, pn);
exchange(node, tuple_pred);
if (!is_Tuple(pred)) return;
pred = get_Tuple_pred(pred, proj);
exchange(node, pred);
} }
void remove_tuples(ir_graph *irg) void remove_tuples(ir_graph *irg)
{ {
irg_walk_graph(irg, exchange_tuple_projs, NULL, NULL); irg_walk_graph(irg, exchange_tuple_projs, NULL, NULL);
ir_node *end = get_irg_end(irg); /* remove Tuples only held by keep-alive edges */
int n_keepalives = get_End_n_keepalives(end); ir_node *end = get_irg_end(irg);
int i; for (int i = get_End_n_keepalives(end); i-- > 0; ) {
for (i = n_keepalives - 1; i >= 0; --i) {
ir_node *irn = get_End_keepalive(end, i); ir_node *irn = get_End_keepalive(end, i);
if (is_Tuple(irn))
if (is_Tuple(irn)) { remove_End_n(end, i);
remove_End_keepalive(end, irn);
}
} }
add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_TUPLES); add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_TUPLES);
......
Supports Markdown
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