Commit e285173d authored by Christoph Mallon's avatar Christoph Mallon
Browse files

belower: Remove be_Perm_reduce() and rewrite it at its only user.

Now the number of outputs is adjusted, too.
This did not cause any problems, because the Perm is lowered right afterwards.
parent a4699884
...@@ -417,20 +417,26 @@ done: ...@@ -417,20 +417,26 @@ done:
kill_node(perm); kill_node(perm);
return false; return false;
} else if (new_size != arity) { } else if (new_size != arity) {
/* Some, but not all, values were pushed through; adjust the Perm. */ /* Some, but not all, values were pushed through.
int *const map = ALLOCAN(int, new_size); * Rewrite Perm to skip all moved slots. */
unsigned n = 0; unsigned n = 0;
backend_info_t *const info = be_get_info(perm);
arch_register_req_t const **const in_reqs = info->in_reqs;
reg_out_info_t *const out_infos = info->out_infos;
for (unsigned pn = 0; pn != arity; ++pn) { for (unsigned pn = 0; pn != arity; ++pn) {
ir_node *const proj = projs[pn]; ir_node *const proj = projs[pn];
if (!proj) if (!proj)
continue; continue;
set_Proj_num(proj, n); set_Proj_num(proj, n);
map[n] = pn; in_reqs[n] = in_reqs[pn];
n++; out_infos[n] = out_infos[pn];
/* Reuse projs for reduced Perm inputs. */
projs[n] = get_irn_n(perm, pn);
++n;
} }
assert(n == new_size); assert(n == new_size);
ARR_SHRINKLEN(out_infos, new_size);
be_Perm_reduce(perm, new_size, map); set_irn_in(perm, n, projs);
} }
return true; return true;
} }
......
...@@ -150,31 +150,6 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls, ...@@ -150,31 +150,6 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls,
return irn; return irn;
} }
void be_Perm_reduce(ir_node *perm, int new_size, int *map)
{
assert(be_is_Perm(perm));
int arity = get_irn_arity(perm);
assert(new_size <= arity);
const arch_register_req_t **old_in_reqs
= ALLOCAN(const arch_register_req_t*, arity);
reg_out_info_t *old_infos = ALLOCAN(reg_out_info_t, arity);
backend_info_t *info = be_get_info(perm);
ir_node **new_in = ALLOCAN(ir_node*, new_size);
/* save the old register data */
MEMCPY(old_in_reqs, info->in_reqs, arity);
MEMCPY(old_infos, info->out_infos, arity);
/* compose the new in array and set the new register data directly */
for (int i = 0; i < new_size; ++i) {
int idx = map[i];
new_in[i] = get_irn_n(perm, idx);
info->in_reqs[i] = old_in_reqs[idx];
info->out_infos[i] = old_infos[idx];
}
set_irn_in(perm, new_size, new_in);
}
ir_node *be_new_MemPerm(ir_node *const block, int n, ir_node *const *const in) ir_node *be_new_MemPerm(ir_node *const block, int n, ir_node *const *const in)
{ {
ir_graph *const irg = get_irn_irg(block); ir_graph *const irg = get_irn_irg(block);
......
...@@ -73,22 +73,6 @@ ir_node *be_get_Copy_op(const ir_node *cpy); ...@@ -73,22 +73,6 @@ ir_node *be_get_Copy_op(const ir_node *cpy);
ir_node *be_new_Perm(arch_register_class_t const *cls, ir_node *block, int n, ir_node *be_new_Perm(arch_register_class_t const *cls, ir_node *block, int n,
ir_node *const *in); ir_node *const *in);
/**
* Reduce a Perm.
* Basically, we provide a map to remap the Perm's arguments. If an entry in the
* map is -1, the argument gets deleted.
* This function takes care, that the register data and the input array reflects
* the changes described by the map.
* This is needed by the Perm optimization/movement in belower.c, see
* push_through_perm().
* @param perm The perm node.
* @param new_size The new number of arguments (must be smaller or equal to the
* current one).
* @param map A map assigning each operand a new index (or -1 to indicate
* deletion).
*/
void be_Perm_reduce(ir_node *perm, int new_size, int *map);
/** /**
* Create a new MemPerm node. * Create a new MemPerm node.
* A MemPerm node exchanges the values of memory locations. (Typically entities * A MemPerm node exchanges the values of memory locations. (Typically entities
......
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