Commit 2da93aea authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Factorise code to create a register requirement.

parent 35093541
...@@ -158,6 +158,15 @@ int be_default_is_valid_clobber(char const *const clobber) ...@@ -158,6 +158,15 @@ int be_default_is_valid_clobber(char const *const clobber)
return false; return false;
} }
arch_register_req_t *be_create_cls_req(ir_graph *const irg, arch_register_class_t const *const cls, unsigned char const width)
{
struct obstack *const obst = be_get_be_obst(irg);
arch_register_req_t *const req = OALLOCZ(obst, arch_register_req_t);
req->cls = cls;
req->width = width;
return req;
}
arch_register_req_t const *be_create_reg_req(ir_graph *const irg, arch_register_t const *const reg, bool const ignore) arch_register_req_t const *be_create_reg_req(ir_graph *const irg, arch_register_t const *const reg, bool const ignore)
{ {
if (!ignore) if (!ignore)
......
...@@ -388,6 +388,8 @@ void arch_copy_irn_out_info(ir_node *dst, unsigned dst_pos, ir_node const *src); ...@@ -388,6 +388,8 @@ void arch_copy_irn_out_info(ir_node *dst, unsigned dst_pos, ir_node const *src);
int be_default_is_valid_clobber(char const *clobber); int be_default_is_valid_clobber(char const *clobber);
arch_register_req_t *be_create_cls_req(ir_graph *irg, arch_register_class_t const *cls, unsigned char width);
arch_register_req_t const *be_create_reg_req(ir_graph *irg, arch_register_t const *reg, bool ignore); arch_register_req_t const *be_create_reg_req(ir_graph *irg, arch_register_t const *reg, bool ignore);
#endif #endif
...@@ -105,13 +105,6 @@ arch_register_req_t const **be_allocate_in_reqs(ir_graph *const irg, unsigned co ...@@ -105,13 +105,6 @@ arch_register_req_t const **be_allocate_in_reqs(ir_graph *const irg, unsigned co
return OALLOCN(obst, arch_register_req_t const*, n); return OALLOCN(obst, arch_register_req_t const*, n);
} }
static arch_register_req_t *allocate_reg_req(ir_graph *const irg)
{
struct obstack *obst = be_get_be_obst(irg);
arch_register_req_t *req = OALLOCZ(obst, arch_register_req_t);
return req;
}
static void be_node_set_register_req_in(ir_node *const node, int const pos, static void be_node_set_register_req_in(ir_node *const node, int const pos,
arch_register_req_t const *const req) arch_register_req_t const *const req)
{ {
...@@ -162,9 +155,7 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls, ...@@ -162,9 +155,7 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls,
be_node_set_register_req_in(irn, i, cls->class_req); be_node_set_register_req_in(irn, i, cls->class_req);
arch_set_irn_register_req_out(irn, i, cls->class_req); arch_set_irn_register_req_out(irn, i, cls->class_req);
} else { } else {
arch_register_req_t *const new_req = allocate_reg_req(irg); arch_register_req_t *const new_req = be_create_cls_req(irg, cls, req->width);
new_req->cls = cls;
new_req->width = req->width;
be_node_set_register_req_in(irn, i, new_req); be_node_set_register_req_in(irn, i, new_req);
arch_set_irn_register_req_out(irn, i, new_req); arch_set_irn_register_req_out(irn, i, new_req);
} }
...@@ -202,10 +193,8 @@ static void set_copy_info(ir_node *const irn, ir_graph *const irg, ir_node *cons ...@@ -202,10 +193,8 @@ static void set_copy_info(ir_node *const irn, ir_graph *const irg, ir_node *cons
be_node_set_register_req_in(irn, 0, cls->class_req); be_node_set_register_req_in(irn, 0, cls->class_req);
arch_register_req_t *const out_req = allocate_reg_req(irg); arch_register_req_t *const out_req = be_create_cls_req(irg, cls, op_req->width);
out_req->cls = cls;
out_req->should_be_same = 1U << 0; out_req->should_be_same = 1U << 0;
out_req->width = op_req->width;
arch_set_irn_register_req_out(irn, 0, out_req); arch_set_irn_register_req_out(irn, 0, out_req);
} }
......
...@@ -1437,13 +1437,6 @@ static void assign_phi_registers(ir_node *block) ...@@ -1437,13 +1437,6 @@ static void assign_phi_registers(ir_node *block)
} }
} }
static arch_register_req_t *allocate_reg_req(ir_graph *irg)
{
struct obstack *obst = be_get_be_obst(irg);
arch_register_req_t *req = OALLOCZ(obst, arch_register_req_t);
return req;
}
/** /**
* Walker: assign registers to all nodes of a block that * Walker: assign registers to all nodes of a block that
* need registers from the currently considered register class. * need registers from the currently considered register class.
...@@ -1514,12 +1507,8 @@ static void allocate_coalesce_block(ir_node *block, void *data) ...@@ -1514,12 +1507,8 @@ static void allocate_coalesce_block(ir_node *block, void *data)
if (need_phi) { if (need_phi) {
ir_mode *mode = get_irn_mode(node); ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *phi_req = cls->class_req; const arch_register_req_t *phi_req = cls->class_req;
if (req->width > 1) { if (req->width > 1)
arch_register_req_t *new_req = allocate_reg_req(irg); phi_req = be_create_cls_req(irg, cls, req->width);
new_req->cls = cls;
new_req->width = req->width;
phi_req = new_req;
}
ir_node *phi = be_new_Phi(block, n_preds, phi_ins, mode, ir_node *phi = be_new_Phi(block, n_preds, phi_ins, mode,
phi_req); phi_req);
......
...@@ -400,12 +400,8 @@ static void determine_phi_req(be_ssa_construction_env_t *env, ir_node *value) ...@@ -400,12 +400,8 @@ static void determine_phi_req(be_ssa_construction_env_t *env, ir_node *value)
env->phi_req = req->cls->class_req; env->phi_req = req->cls->class_req;
} else { } else {
/* construct a new register req... */ /* construct a new register req... */
ir_graph *irg = get_irn_irg(value); ir_graph *const irg = get_irn_irg(value);
struct obstack *obst = be_get_be_obst(irg); env->phi_req = be_create_cls_req(irg, req->cls, req->width);
arch_register_req_t *new_req = OALLOCZ(obst, arch_register_req_t);
new_req->cls = req->cls;
new_req->width = req->width;
env->phi_req = new_req;
} }
} }
......
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