Commit 40db13da authored by Christoph Mallon's avatar Christoph Mallon
Browse files

bearch: Add and use be_foreach_value().

This also handles the latent problem, that nobody checks, whether the user of a tuple is actually a Proj and not the End node.
parent 21859ae9
......@@ -568,6 +568,21 @@ static inline bool arch_irn_consider_in_reg_alloc(
return req->cls == cls && !arch_register_req_is(req, ignore);
}
#define be_foreach_value(node, value, code) \
do { \
if (get_irn_mode(node) == mode_T) { \
foreach_out_edge(node, node##__edge) { \
ir_node *const value = get_edge_src_irn(node##__edge); \
if (!is_Proj(value)) \
continue; \
code \
} \
} else { \
ir_node *const value = node; \
code \
} \
} while (0)
/**
* Iterate over all values defined by an instruction.
* Only looks at values in a certain register class where the requirements
......@@ -575,26 +590,12 @@ static inline bool arch_irn_consider_in_reg_alloc(
* Executes @p code for each definition.
*/
#define be_foreach_definition_(node, ccls, value, req, code) \
do { \
if (get_irn_mode(node) == mode_T) { \
foreach_out_edge(node, edge_) { \
ir_node *const value = get_edge_src_irn(edge_); \
if (!is_Proj(value)) \
continue; \
long pn = get_Proj_proj(value); \
arch_register_req_t const *const req = arch_get_irn_register_req_out(node, pn); \
if (req->cls != ccls) \
continue; \
code \
} \
} else { \
ir_node *const value = node; \
arch_register_req_t const *const req = arch_get_irn_register_req(node); \
if (req->cls == ccls) { \
code \
} \
} \
} while (0)
be_foreach_value(node, value, \
arch_register_req_t const *const req = arch_get_irn_register_req(value); \
if (req->cls != ccls) \
continue; \
code \
)
#define be_foreach_definition(node, ccls, value, req, code) \
be_foreach_definition_(node, ccls, value, req, \
......
......@@ -614,19 +614,10 @@ static void assure_constraints_walker(ir_node *block, void *walk_env)
constraint_env_t *env = (constraint_env_t*)walk_env;
sched_foreach_reverse(block, irn) {
ir_mode *mode = get_irn_mode(irn);
if (mode == mode_T) {
foreach_out_edge(irn, edge) {
ir_node *proj = get_edge_src_irn(edge);
mode = get_irn_mode(proj);
if (mode_is_datab(mode))
assure_different_constraints(proj, irn, env);
}
} else if (mode_is_datab(mode)) {
assure_different_constraints(irn, irn, env);
}
be_foreach_value(irn, value,
if (mode_is_datab(get_irn_mode(value)))
assure_different_constraints(value, irn, env);
);
}
}
......
......@@ -332,57 +332,27 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
/* create pbqp nodes, interference edges and reverse perfect elimination order */
sched_foreach_reverse(block, irn) {
if (get_irn_mode(irn) == mode_T) {
foreach_out_edge(irn, edge) {
ir_node *proj = get_edge_src_irn(edge);
if (!arch_irn_consider_in_reg_alloc(cls, proj))
continue;
/* create pbqp source node if it dosn't exist */
if (get_node(pbqp_inst, get_irn_idx(proj)) == NULL) {
create_pbqp_node(pbqp_alloc_env, proj);
}
/* create nodes and interference edges */
foreach_ir_nodeset(&live_nodes, live, iter) {
/* create pbqp source node if it dosn't exist */
if (get_node(pbqp_inst, get_irn_idx(live)) == NULL) {
create_pbqp_node(pbqp_alloc_env, live);
}
be_foreach_value(irn, value,
if (!arch_irn_consider_in_reg_alloc(cls, value))
continue;
/* no edges to itself */
if (proj == live) {
continue;
}
/* create pbqp source node if it dosn't exist */
if (!get_node(pbqp_inst, get_irn_idx(value)))
create_pbqp_node(pbqp_alloc_env, value);
insert_ife_edge(pbqp_alloc_env, proj, live);
}
}
}
else {
if (arch_irn_consider_in_reg_alloc(cls, irn)) {
/* create nodes and interference edges */
foreach_ir_nodeset(&live_nodes, live, iter) {
/* create pbqp source node if it dosn't exist */
if (get_node(pbqp_inst, get_irn_idx(irn)) == NULL) {
create_pbqp_node(pbqp_alloc_env, irn);
}
/* create nodes and interference edges */
foreach_ir_nodeset(&live_nodes, live, iter) {
/* create pbqp source node if it dosn't exist */
if (get_node(pbqp_inst, get_irn_idx(live)) == NULL) {
create_pbqp_node(pbqp_alloc_env, live);
}
if (!get_node(pbqp_inst, get_irn_idx(live)))
create_pbqp_node(pbqp_alloc_env, live);
/* no edges to itself */
if (irn == live) {
continue;
}
/* no edges to itself */
if (value == live)
continue;
/* insert interference edge */
insert_ife_edge(pbqp_alloc_env, irn, live);
}
insert_ife_edge(pbqp_alloc_env, value, live);
}
}
);
/* get living nodes for next step */
if (!is_Phi(irn)) {
......
......@@ -93,14 +93,9 @@ static void set_reg_value(ir_node *node)
static void clear_defs(ir_node *node)
{
/* clear values defined */
if (get_irn_mode(node) == mode_T) {
foreach_out_edge(node, edge) {
ir_node *proj = get_edge_src_irn(edge);
clear_reg_value(proj);
}
} else {
clear_reg_value(node);
}
be_foreach_value(node, value,
clear_reg_value(value);
);
}
static void set_uses(ir_node *node)
......
......@@ -408,29 +408,15 @@ static void belady(minibelady_env_t *env, ir_node *block)
DBG((dbg, LEVEL_3, " ...%+F\n", node));
/* record state changes by the node */
if (get_irn_mode(node) == mode_T) {
foreach_out_edge(node, edge) {
const arch_register_t *reg;
ir_node *proj = get_edge_src_irn(edge);
if (!mode_is_data(get_irn_mode(proj)))
continue;
reg = arch_get_irn_register(proj);
if (reg == env->reg) {
current_state = proj;
DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
}
}
} else {
if (mode_is_data(get_irn_mode(node))) {
const arch_register_t *reg = arch_get_irn_register(node);
if (reg == env->reg) {
current_state = node;
DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
}
}
}
be_foreach_value(node, value,
if (!mode_is_data(get_irn_mode(value)))
continue;
arch_register_t const *const reg = arch_get_irn_register(value);
if (reg != env->reg)
continue;
current_state = value;
DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
);
}
/* Remember end-workset for this block */
......
......@@ -760,17 +760,10 @@ static void verify_block_register_allocation(ir_node *block, void *data)
}
sched_foreach_reverse(block, node) {
if (get_irn_mode(node) == mode_T) {
foreach_out_edge(node, edge) {
ir_node *def = get_edge_src_irn(edge);
value_def(def);
check_output_constraints(def);
}
} else {
value_def(node);
check_output_constraints(node);
}
be_foreach_value(node, value,
value_def(value);
check_output_constraints(value);
);
check_input_constraints(node);
......
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