Commit 7fa38f2c authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ir: Use get_Proj_for_pn().

parent eb59f4f2
...@@ -162,16 +162,10 @@ static void handle_modeb(ir_node *block, ir_node *selector, pn_Cond pnc, env_t * ...@@ -162,16 +162,10 @@ static void handle_modeb(ir_node *block, ir_node *selector, pn_Cond pnc, env_t *
/* get the other block */ /* get the other block */
if (other_blk == NULL) { if (other_blk == NULL) {
/* we have already tested, that block has only ONE Cond predecessor */ /* we have already tested, that block has only ONE Cond predecessor */
ir_node *cond = get_Proj_pred(get_Block_cfgpred(block, 0)); ir_node *const cond = get_Proj_pred(get_Block_cfgpred(block, 0));
foreach_out_edge(cond, edge) { ir_node *const proj = get_Proj_for_pn(cond, pn_Cond_false + pn_Cond_true - pnc);
ir_node *proj = get_edge_src_irn(edge); assert(proj);
if (get_Proj_num(proj) == pnc) other_blk = get_edge_src_irn(get_irn_out_edge_first(proj));
continue;
edge = get_irn_out_edge_first(proj);
other_blk = get_edge_src_irn(edge);
break;
}
assert(other_blk);
/* /*
* Note the special case here: if block is a then, there might be no else * Note the special case here: if block is a then, there might be no else
......
...@@ -532,15 +532,8 @@ ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg) ...@@ -532,15 +532,8 @@ ir_node *be_get_initial_reg_value(ir_graph *irg, const arch_register_t *reg)
ir_node *start = get_irg_start(irg); ir_node *start = get_irg_start(irg);
ir_mode *mode = arch_register_class_mode(reg->reg_class); ir_mode *mode = arch_register_class_mode(reg->reg_class);
foreach_out_edge(start, edge) { ir_node *const proj = get_Proj_for_pn(start, i);
ir_node *proj = get_edge_src_irn(edge); return proj ? proj : new_r_Proj(start, mode, i);
if (!is_Proj(proj)) // maybe End/Anchor
continue;
if (get_Proj_num(proj) == i) {
return proj;
}
}
return new_r_Proj(start, mode, i);
} }
static ir_entity* dummy_get_frame_entity(const ir_node *node) static ir_entity* dummy_get_frame_entity(const ir_node *node)
......
...@@ -96,21 +96,15 @@ static void ia32_transform_sub_to_neg_add(ir_node *irn) ...@@ -96,21 +96,15 @@ static void ia32_transform_sub_to_neg_add(ir_node *irn)
bool needs_carry = false; bool needs_carry = false;
/** See if someone is interested in a correctly set carry flag */ /** See if someone is interested in a correctly set carry flag */
if (get_irn_mode(irn) == mode_T) { if (get_irn_mode(irn) == mode_T) {
foreach_out_edge(irn, edge) { flags_proj = get_Proj_for_pn(irn, pn_ia32_flags);
ir_node *proj = get_edge_src_irn(edge); if (flags_proj) {
unsigned pn = get_Proj_num(proj); foreach_out_edge(flags_proj, edge) {
if (pn == pn_ia32_flags) { ir_node *user = get_edge_src_irn(edge);
assert(flags_proj == NULL); x86_condition_code_t cc = get_ia32_condcode(user);
flags_proj = proj; if (reads_carry(cc)) {
foreach_out_edge(flags_proj, edge) { needs_carry = true;
ir_node *user = get_edge_src_irn(edge); break;
x86_condition_code_t cc = get_ia32_condcode(user);
if (reads_carry(cc)) {
needs_carry = true;
break;
}
} }
break;
} }
} }
} }
......
...@@ -441,19 +441,10 @@ static void peephole_IncSP_Store_to_push(ir_node *irn) ...@@ -441,19 +441,10 @@ static void peephole_IncSP_Store_to_push(ir_node *irn)
/* create memory Proj */ /* create memory Proj */
ir_node *mem_proj = new_r_Proj(push, mode_M, pn_ia32_Push_M); ir_node *mem_proj = new_r_Proj(push, mode_M, pn_ia32_Push_M);
/* rewire Store Projs */ /* Rewire Store Proj. */
foreach_out_edge_safe(store, edge) { ir_node *const proj = get_Proj_for_pn(store, pn_ia32_Store_M);
ir_node *proj = get_edge_src_irn(edge); if (proj)
if (!is_Proj(proj))
continue;
switch (get_Proj_num(proj)) {
case pn_ia32_Store_M:
exchange(proj, mem_proj); exchange(proj, mem_proj);
break;
default:
panic("unexpected Proj on Store->IncSp");
}
}
/* use the memproj now */ /* use the memproj now */
be_peephole_exchange(store, push); be_peephole_exchange(store, push);
......
...@@ -1207,24 +1207,6 @@ static bool sim_Copy(x87_state *state, ir_node *n) ...@@ -1207,24 +1207,6 @@ static bool sim_Copy(x87_state *state, ir_node *n)
return false; return false;
} }
/**
* Returns the vf0 result Proj of a Call.
*
* @para call the Call node
*/
static ir_node *get_call_result_proj(ir_node *call)
{
/* search the result proj */
foreach_out_edge(call, edge) {
ir_node *proj = get_edge_src_irn(edge);
unsigned pn = get_Proj_num(proj);
if (pn == pn_ia32_Call_first_result)
return proj;
}
panic("result Proj missing");
}
static bool sim_Asm(x87_state *const state, ir_node *const n) static bool sim_Asm(x87_state *const state, ir_node *const n)
{ {
(void)state; (void)state;
...@@ -1261,7 +1243,7 @@ static bool sim_Call(x87_state *state, ir_node *n) ...@@ -1261,7 +1243,7 @@ static bool sim_Call(x87_state *state, ir_node *n)
ir_type *const res_type = get_method_res_type(call_tp, 0); ir_type *const res_type = get_method_res_type(call_tp, 0);
ir_mode *const mode = get_type_mode(res_type); ir_mode *const mode = get_type_mode(res_type);
if (mode && mode_is_float(mode)) { if (mode && mode_is_float(mode)) {
ir_node *const resproj = get_call_result_proj(n); ir_node *const resproj = get_Proj_for_pn(n, pn_ia32_Call_first_result);
arch_register_t const *const reg = arch_get_irn_register(resproj); arch_register_t const *const reg = arch_get_irn_register(resproj);
x87_push(state, reg->index, resproj); x87_push(state, reg->index, resproj);
} }
......
...@@ -636,14 +636,7 @@ static void finish_sparc_Return(ir_node *node) ...@@ -636,14 +636,7 @@ static void finish_sparc_Return(ir_node *node)
*/ */
static bool has_flags_user(ir_node *node) static bool has_flags_user(ir_node *node)
{ {
foreach_out_edge(node, edge) { return get_Proj_for_pn(node, pn_sparc_AddCC_flags) != NULL;
ir_node *src = get_edge_src_irn(edge);
if (is_Proj(src) && get_Proj_num(src) == pn_sparc_AddCC_flags)
return true;
}
return false;
} }
/* /*
......
...@@ -581,20 +581,6 @@ static void get_dest_addrs(const cl_entry *entry, ir_node **ins, ...@@ -581,20 +581,6 @@ static void get_dest_addrs(const cl_entry *entry, ir_node **ins,
} }
} }
static ir_node *find_proj(ir_node *node, long search_pn)
{
assert(get_irn_mode(node) == mode_T);
foreach_out_edge(node, edge) {
ir_node *src = get_edge_src_irn(edge);
if (!is_Proj(src))
continue;
long pn = get_Proj_num(src);
if (pn == search_pn)
return src;
}
return NULL;
}
static void fix_int_return(const cl_entry *entry, ir_node *base_addr, static void fix_int_return(const cl_entry *entry, ir_node *base_addr,
unsigned n_int_rets, long orig_pn, long pn) unsigned n_int_rets, long orig_pn, long pn)
{ {
...@@ -617,7 +603,7 @@ static void fix_int_return(const cl_entry *entry, ir_node *base_addr, ...@@ -617,7 +603,7 @@ static void fix_int_return(const cl_entry *entry, ir_node *base_addr,
if (proj_res == NULL) if (proj_res == NULL)
proj_res = new_r_Proj(call, mode_T, pn_Call_T_result); proj_res = new_r_Proj(call, mode_T, pn_Call_T_result);
/* reroute old users */ /* reroute old users */
ir_node *res_user = find_proj(proj_res, orig_pn); ir_node *const res_user = get_Proj_for_pn(proj_res, orig_pn);
if (res_user != NULL) if (res_user != NULL)
edges_reroute(res_user, base_addr); edges_reroute(res_user, base_addr);
......
...@@ -1822,16 +1822,7 @@ static void lower_Start(ir_node *node, ir_mode *high_mode) ...@@ -1822,16 +1822,7 @@ static void lower_Start(ir_node *node, ir_mode *high_mode)
} }
/* find args Proj */ /* find args Proj */
ir_node *args = NULL; ir_node *const args = get_Proj_for_pn(node, pn_Start_T_args);
foreach_out_edge(node, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj))
continue;
if (get_Proj_num(proj) == pn_Start_T_args) {
args = proj;
break;
}
}
if (args == NULL) if (args == NULL)
return; return;
...@@ -1940,16 +1931,7 @@ static void lower_Call(ir_node *node, ir_mode *mode) ...@@ -1940,16 +1931,7 @@ static void lower_Call(ir_node *node, ir_mode *mode)
set_irn_in(node, j, in); set_irn_in(node, j, in);
/* find results T */ /* find results T */
ir_node *resproj = NULL; ir_node *resproj = get_Proj_for_pn(node, pn_Call_T_result);
foreach_out_edge(node, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj))
continue;
if (get_Proj_num(proj) == pn_Call_T_result) {
resproj = proj;
break;
}
}
if (resproj == NULL) if (resproj == NULL)
return; return;
...@@ -2517,15 +2499,9 @@ static void lower_arithmetic_builtin(ir_node *builtin, ir_mode *mode) ...@@ -2517,15 +2499,9 @@ static void lower_arithmetic_builtin(ir_node *builtin, ir_mode *mode)
} }
/* search result Proj */ /* search result Proj */
foreach_out_edge_safe(builtin, edge) { ir_node *const proj = get_Proj_for_pn(builtin, pn_Builtin_max + 1);
ir_node *proj = get_edge_src_irn(edge); if (proj)
if (!is_Proj(proj)) ir_set_dw_lowered(proj, res_low, res_high);
continue;
if (get_Proj_num(proj) == pn_Builtin_max+1) {
ir_set_dw_lowered(proj, res_low, res_high);
}
}
} }
/** /**
......
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