Commit 79266142 authored by Matthias Braun's avatar Matthias Braun
Browse files

share common phi code, fix missing phi input reqs

parent 5321abc1
...@@ -250,14 +250,8 @@ static inline bool mode_needs_gp_reg(ir_mode *mode) ...@@ -250,14 +250,8 @@ static inline bool mode_needs_gp_reg(ir_mode *mode)
static ir_node *gen_Phi(ir_node *node) static ir_node *gen_Phi(ir_node *node)
{ {
ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *req; const arch_register_req_t *req;
ir_node *block = get_nodes_block(node);
ir_node *new_block = be_transform_node(block);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_mode *mode = get_irn_mode(node);
ir_graph *irg = get_irn_irg(node);
ir_node *phi;
if (mode_needs_gp_reg(mode)) { if (mode_needs_gp_reg(mode)) {
mode = mode_Iu; mode = mode_Iu;
req = TEMPLATE_reg_classes[CLASS_TEMPLATE_gp].class_req; req = TEMPLATE_reg_classes[CLASS_TEMPLATE_gp].class_req;
...@@ -265,14 +259,7 @@ static ir_node *gen_Phi(ir_node *node) ...@@ -265,14 +259,7 @@ static ir_node *gen_Phi(ir_node *node)
req = arch_no_register_req; req = arch_no_register_req;
} }
phi = new_ir_node(dbgi, irg, new_block, op_Phi, mode, get_irn_arity(node), return be_transform_phi(node, req);
get_irn_in(node)+1);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
} }
static ir_node *gen_Proj_Start(ir_node *node) static ir_node *gen_Proj_Start(ir_node *node)
......
...@@ -302,18 +302,10 @@ static bool upper_bits_clean(ir_node *transformed_node, ir_mode *mode) ...@@ -302,18 +302,10 @@ static bool upper_bits_clean(ir_node *transformed_node, ir_mode *mode)
} }
#endif #endif
/**
* Change some phi modes
*/
static ir_node *gen_Phi(ir_node *node) static ir_node *gen_Phi(ir_node *node)
{ {
ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *req; const arch_register_req_t *req;
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_mode *mode = get_irn_mode(node);
ir_node *phi;
if (mode_needs_gp_reg(mode)) { if (mode_needs_gp_reg(mode)) {
/* all integer operations are on 64bit registers now */ /* all integer operations are on 64bit registers now */
mode = mode_Lu; mode = mode_Lu;
...@@ -322,22 +314,9 @@ static ir_node *gen_Phi(ir_node *node) ...@@ -322,22 +314,9 @@ static ir_node *gen_Phi(ir_node *node)
req = arch_no_register_req; req = arch_no_register_req;
} }
/* phi nodes allow loops, so we use the old arguments for now return be_transform_phi(node, req);
* and fix this later */
phi = new_ir_node(dbgi, irg, block, op_Phi, mode, get_irn_arity(node),
get_irn_in(node) + 1);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
} }
/** /**
* Transforms a Conv node. * Transforms a Conv node.
* *
......
...@@ -1991,18 +1991,10 @@ static ir_node *gen_Sel(ir_node *node) ...@@ -1991,18 +1991,10 @@ static ir_node *gen_Sel(ir_node *node)
return new_bd_arm_FrameAddr(dbgi, new_block, new_ptr, entity, 0); return new_bd_arm_FrameAddr(dbgi, new_block, new_ptr, entity, 0);
} }
/**
* Change some phi modes
*/
static ir_node *gen_Phi(ir_node *node) static ir_node *gen_Phi(ir_node *node)
{ {
ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *req; const arch_register_req_t *req;
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_mode *mode = get_irn_mode(node);
ir_node *phi;
if (mode_needs_gp_reg(mode)) { if (mode_needs_gp_reg(mode)) {
/* we shouldn't have any 64bit stuff around anymore */ /* we shouldn't have any 64bit stuff around anymore */
assert(get_mode_size_bits(mode) <= 32); assert(get_mode_size_bits(mode) <= 32);
...@@ -2013,21 +2005,9 @@ static ir_node *gen_Phi(ir_node *node) ...@@ -2013,21 +2005,9 @@ static ir_node *gen_Phi(ir_node *node)
req = arch_no_register_req; req = arch_no_register_req;
} }
/* phi nodes allow loops, so we use the old arguments for now return be_transform_phi(node, req);
* and fix this later */
phi = new_ir_node(dbgi, irg, block, op_Phi, mode, get_irn_arity(node),
get_irn_in(node) + 1);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
} }
/** /**
* Enters all transform functions into the generic pointer * Enters all transform functions into the generic pointer
*/ */
......
...@@ -87,6 +87,34 @@ void be_duplicate_deps(ir_node *old_node, ir_node *new_node) ...@@ -87,6 +87,34 @@ void be_duplicate_deps(ir_node *old_node, ir_node *new_node)
} }
} }
ir_node *be_transform_phi(ir_node *node, const arch_register_req_t *req)
{
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
/* phi nodes allow loops, so we use the old arguments for now
* and fix this later */
ir_node **ins = get_irn_in(node)+1;
int arity = get_irn_arity(node);
ir_mode *mode = req->cls != NULL ? req->cls->mode : get_irn_mode(node);
ir_node *phi = new_ir_node(dbgi, irg, block, op_Phi, mode, arity, ins);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
backend_info_t *info = be_get_info(phi);
struct obstack *obst = be_get_be_obst(irg);
info->in_reqs = OALLOCN(obst, const arch_register_req_t*, arity);
for (int i = 0; i < arity; ++i) {
info->in_reqs[i] = req;
}
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
}
void be_set_transform_function(ir_op *op, be_transform_func func) void be_set_transform_function(ir_op *op, be_transform_func func)
{ {
/* shouldn't be assigned twice (except for exchanging the default /* shouldn't be assigned twice (except for exchanging the default
......
...@@ -47,6 +47,12 @@ ir_node *be_pre_transform_node(ir_node *place); ...@@ -47,6 +47,12 @@ ir_node *be_pre_transform_node(ir_node *place);
*/ */
ir_node *be_transform_node(ir_node *node); ir_node *be_transform_node(ir_node *node);
/**
* Creates a new phi (needs some special handling since we can't transform
* all predecessors yet).
*/
ir_node *be_transform_phi(ir_node *node, const arch_register_req_t *req);
/** /**
* Duplicate all dependency edges of a node. * Duplicate all dependency edges of a node.
*/ */
......
...@@ -4058,18 +4058,10 @@ static ir_node *gen_be_SubSP(ir_node *node) ...@@ -4058,18 +4058,10 @@ static ir_node *gen_be_SubSP(ir_node *node)
return new_node; return new_node;
} }
/**
* Change some phi modes
*/
static ir_node *gen_Phi(ir_node *node) static ir_node *gen_Phi(ir_node *node)
{ {
ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *req; const arch_register_req_t *req;
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_mode *mode = get_irn_mode(node);
ir_node *phi;
if (ia32_mode_needs_gp_reg(mode)) { if (ia32_mode_needs_gp_reg(mode)) {
/* we shouldn't have any 64bit stuff around anymore */ /* we shouldn't have any 64bit stuff around anymore */
assert(get_mode_size_bits(mode) <= 32); assert(get_mode_size_bits(mode) <= 32);
...@@ -4088,18 +4080,7 @@ static ir_node *gen_Phi(ir_node *node) ...@@ -4088,18 +4080,7 @@ static ir_node *gen_Phi(ir_node *node)
req = arch_no_register_req; req = arch_no_register_req;
} }
/* phi nodes allow loops, so we use the old arguments for now return be_transform_phi(node, req);
* and fix this later */
phi = new_ir_node(dbgi, irg, block, op_Phi, mode, get_irn_arity(node),
get_irn_in(node) + 1);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
} }
static ir_node *gen_Jmp(ir_node *node) static ir_node *gen_Jmp(ir_node *node)
......
...@@ -2033,18 +2033,10 @@ static const arch_register_req_t *get_float_req(ir_mode *mode) ...@@ -2033,18 +2033,10 @@ static const arch_register_req_t *get_float_req(ir_mode *mode)
} }
} }
/**
* Transform some Phi nodes
*/
static ir_node *gen_Phi(ir_node *node) static ir_node *gen_Phi(ir_node *node)
{ {
ir_mode *mode = get_irn_mode(node);
const arch_register_req_t *req; const arch_register_req_t *req;
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_mode *mode = get_irn_mode(node);
ir_node *phi;
if (mode_needs_gp_reg(mode)) { if (mode_needs_gp_reg(mode)) {
/* we shouldn't have any 64bit stuff around anymore */ /* we shouldn't have any 64bit stuff around anymore */
assert(get_mode_size_bits(mode) <= 32); assert(get_mode_size_bits(mode) <= 32);
...@@ -2057,14 +2049,7 @@ static ir_node *gen_Phi(ir_node *node) ...@@ -2057,14 +2049,7 @@ static ir_node *gen_Phi(ir_node *node)
req = arch_no_register_req; req = arch_no_register_req;
} }
/* phi nodes allow loops, so we use the old arguments for now return be_transform_phi(node, req);
* and fix this later */
phi = new_ir_node(dbgi, irg, block, op_Phi, mode, get_irn_arity(node), get_irn_in(node) + 1);
copy_node_attr(irg, node, phi);
be_duplicate_deps(node, phi);
arch_set_irn_register_req_out(phi, 0, req);
be_enqueue_preds(node);
return phi;
} }
/** /**
......
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