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

ir: Move be_get_Proj_for_pn() from the backend to the middleend as get_Proj_for_pn().

parent 3c4ca849
......@@ -21,7 +21,6 @@
#include "benode.h"
#include "betranshlp.h"
#include "beutil.h"
#include "bearch_amd64_t.h"
#include "beirg.h"
#include "besched.h"
......@@ -720,7 +719,7 @@ static void match_binop(amd64_args_t *args, ir_node *block,
args->in[mem_input] = new_mem;
addr->mem_input = mem_input;
args->mem_proj = be_get_Proj_for_pn(load, pn_Load_M);
args->mem_proj = get_Proj_for_pn(load, pn_Load_M);
args->attr.base.base.op_mode = AMD64_OP_ADDR_REG;
} else {
/* simply transform the arguments */
......@@ -812,7 +811,7 @@ static ir_node *gen_binop_rax(ir_node *node, ir_node *op1, ir_node *op2,
in[mem_input] = new_mem;
addr.mem_input = mem_input;
mem_proj = be_get_Proj_for_pn(load, pn_Load_M);
mem_proj = get_Proj_for_pn(load, pn_Load_M);
op_mode = AMD64_OP_RAX_ADDR;
} else {
/* simply transform the arguments */
......@@ -1303,7 +1302,7 @@ static ir_node *gen_IJmp(ir_node *node)
ir_node *load = source_am_possible(block, op);
if (load != NULL) {
ir_node *load_ptr = get_Load_ptr(load);
mem_proj = be_get_Proj_for_pn(load, pn_Load_M);
mem_proj = get_Proj_for_pn(load, pn_Load_M);
perform_address_matching(load_ptr, &arity, in, &addr);
assert((size_t)arity < ARRAY_SIZE(in));
......@@ -1597,7 +1596,7 @@ static ir_node *gen_Call(ir_node *node)
}
if (am_okay) {
ir_node *load_ptr = get_Load_ptr(load);
mem_proj = be_get_Proj_for_pn(load, pn_Load_M);
mem_proj = get_Proj_for_pn(load, pn_Load_M);
perform_address_matching(load_ptr, &in_arity, in, &addr);
......
......@@ -1154,7 +1154,7 @@ static ir_node *gen_Load(ir_node *node)
set_irn_pinned(new_load, get_irn_pinned(node));
/* check for special case: the loaded value might not be used */
if (be_get_Proj_for_pn(node, pn_Load_res) == NULL) {
if (!get_Proj_for_pn(node, pn_Load_res)) {
/* add a result proj and a Keep to produce a pseudo use */
ir_node *proj = new_r_Proj(new_load, arm_mode_gp, pn_arm_Ldr_res);
be_new_Keep(block, 1, &proj);
......
......@@ -28,22 +28,6 @@
#include "irtools.h"
#include "util.h"
/**
* Gets the Proj with number pn from irn.
*/
ir_node *be_get_Proj_for_pn(const ir_node *irn, unsigned pn)
{
assert(get_irn_mode(irn) == mode_T && "need mode_T");
foreach_out_edge(irn, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (is_Proj(proj) && get_Proj_num(proj) == pn)
return proj;
}
return NULL;
}
/**
* Block-walker: adds the visited block to a flexible array.
*/
......
......@@ -34,11 +34,6 @@ static inline const ir_node *get_block_const(const ir_node *irn)
return is_Block(irn) ? irn : get_nodes_block(irn);
}
/**
* Gets the Proj with number pn from irn.
*/
ir_node *be_get_Proj_for_pn(const ir_node *irn, unsigned pn);
/**
* Returns an array (an ARR_F) of the programs blocks in reverse postorder
* (note: caller has to free the memory with DEL_ARR_F after use;
......
......@@ -52,7 +52,6 @@
#include "bedwarf.h"
#include "beemitter.h"
#include "begnuas.h"
#include "beutil.h"
#include "ia32_emitter.h"
#include "ia32_common_transform.h"
......@@ -793,9 +792,9 @@ static void emit_ia32_Jcc(const ir_node *node)
cc = determine_final_cc(node, 0, cc);
/* get both Projs */
ir_node const *proj_true = be_get_Proj_for_pn(node, pn_ia32_Jcc_true);
ir_node const *proj_true = get_Proj_for_pn(node, pn_ia32_Jcc_true);
ir_node const *target_true = get_cfop_target_block(proj_true);
ir_node const *proj_false = be_get_Proj_for_pn(node, pn_ia32_Jcc_false);
ir_node const *proj_false = get_Proj_for_pn(node, pn_ia32_Jcc_false);
ir_node const *block = get_nodes_block(node);
if (fallthrough_possible(block, target_true)) {
/* exchange both proj's so the second one can be omitted */
......@@ -2836,8 +2835,8 @@ static void bemit_ia32_jcc(const ir_node *node)
cc = determine_final_cc(node, 0, cc);
/* get both Projs */
ir_node const *proj_true = be_get_Proj_for_pn(node, pn_ia32_Jcc_true);
ir_node const *proj_false = be_get_Proj_for_pn(node, pn_ia32_Jcc_false);
ir_node const *proj_true = get_Proj_for_pn(node, pn_ia32_Jcc_true);
ir_node const *proj_false = get_Proj_for_pn(node, pn_ia32_Jcc_false);
ir_node const *block = get_nodes_block(node);
ir_node const *target_true = get_cfop_target_block(proj_true);
if (fallthrough_possible(block, target_true)) {
......
......@@ -28,7 +28,6 @@
#include "besched.h"
#include "benode.h"
#include "bestate.h"
#include "beutil.h"
#include "bessaconstr.h"
static ir_entity *fpcw_round = NULL;
......@@ -219,7 +218,7 @@ static void collect_fpu_mode_nodes_walker(ir_node *node, void *data)
continue;
ir_node *value = node;
if (get_irn_mode(value) == mode_T) {
value = be_get_Proj_for_pn(node, o);
value = get_Proj_for_pn(node, o);
if (value == NULL)
value = new_r_Proj(node, ia32_mode_fpcw, o);
}
......
......@@ -34,7 +34,6 @@
#include "benode.h"
#include "besched.h"
#include "beutil.h"
#include "betranshlp.h"
#include "be_t.h"
......@@ -647,7 +646,7 @@ static void build_address(ia32_address_mode_t *am, ir_node *node,
ir_node *new_mem = be_transform_node(mem);
am->pinned = get_irn_pinned(load);
am->ls_mode = get_Load_mode(load);
am->mem_proj = be_get_Proj_for_pn(load, pn_Load_M);
am->mem_proj = get_Proj_for_pn(load, pn_Load_M);
am->am_node = node;
/* construct load address */
......@@ -5834,7 +5833,7 @@ static void add_parameter_loads(ir_graph *irg, const x86_cconv_t *cconv)
ir_node *start_block = get_irg_start_block(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *frame = get_irg_frame(irg);
ir_node *proj_args = be_get_Proj_for_pn(start, pn_Start_T_args);
ir_node *proj_args = get_Proj_for_pn(start, pn_Start_T_args);
foreach_out_edge_safe(proj_args, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!is_Proj(proj))
......
......@@ -1076,3 +1076,14 @@ ir_switch_table *ir_switch_table_duplicate(ir_graph *irg,
}
return res;
}
ir_node *get_Proj_for_pn(ir_node const *const irn, unsigned const pn)
{
assert(get_irn_mode(irn) == mode_T && "need mode_T");
foreach_out_edge(irn, edge) {
ir_node *const proj = get_edge_src_irn(edge);
if (is_Proj(proj) && get_Proj_num(proj) == pn)
return proj;
}
return NULL;
}
......@@ -523,6 +523,11 @@ void remove_keep_alive(const ir_node *kept_node);
*/
ir_node *new_similar_node(ir_node *old, ir_node *block, ir_node **in);
/**
* Gets the Proj with number pn from irn.
*/
ir_node *get_Proj_for_pn(ir_node const *irn, unsigned pn);
#define foreach_irn_in(irn, idx, pred) \
for (bool pred##__b = true; pred##__b;) \
for (ir_node const *const pred##__irn = (irn); pred##__b; pred##__b = false) \
......
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