Commit 4ca20458 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Add and use be_get_or_make_Proj_for_pn().

parent aea257b0
......@@ -416,8 +416,7 @@ ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg)
{
unsigned const i = get_start_reg_index(irg, reg);
ir_node *const start = get_irg_start(irg);
ir_node *const proj = get_Proj_for_pn(start, i);
return proj ? proj : be_new_Proj(start, i);
return be_get_or_make_Proj_for_pn(start, i);
}
ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
......@@ -529,6 +528,12 @@ ir_node *be_new_Proj(ir_node *const pred, unsigned const pos)
return new_r_Proj(pred, req->cls->mode, pos);
}
ir_node *be_get_or_make_Proj_for_pn(ir_node *const irn, unsigned const pn)
{
ir_node *const proj = get_Proj_for_pn(irn, pn);
return proj ? proj : be_new_Proj(irn, pn);
}
/**
* ir_op-Operation: dump a be node to file
*/
......
......@@ -204,6 +204,12 @@ ir_node *be_new_Proj(ir_node *pred, unsigned pos);
*/
ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg);
/**
* Gets the Proj with number pn from irn.
* Creates the Proj, if it does not exist, yet.
*/
ir_node *be_get_or_make_Proj_for_pn(ir_node *irn, unsigned pn);
static inline bool be_is_Asm (const ir_node *irn) { return get_irn_op(irn) == op_be_Asm ; }
static inline bool be_is_Copy (const ir_node *irn) { return get_irn_op(irn) == op_be_Copy ; }
static inline bool be_is_CopyKeep (const ir_node *irn) { return get_irn_op(irn) == op_be_CopyKeep ; }
......
......@@ -161,11 +161,8 @@ static void collect_fpu_mode_nodes_walker(ir_node *node, void *data)
if (reg != &ia32_registers[REG_FPCW])
continue;
ir_node *value = node;
if (get_irn_mode(value) == mode_T) {
value = get_Proj_for_pn(node, o);
if (value == NULL)
value = be_new_Proj(node, o);
}
if (get_irn_mode(value) == mode_T)
value = be_get_or_make_Proj_for_pn(node, o);
ARR_APP1(ir_node*, env->state_nodes, value);
}
}
......
......@@ -496,6 +496,7 @@ ir_node *new_similar_node(ir_node *old, ir_node *block, ir_node **in);
/**
* Gets the Proj with number pn from irn.
* Returns a null pointer, if no such Proj exists.
*/
ir_node *get_Proj_for_pn(ir_node const *irn, unsigned pn);
......
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