return info != NULL && info->is_definition;
}
-/**
- * @return Whether the node is a use.
- */
-static bool is_use(const be_ssa_construction_env_t *env, ir_node *node)
-{
- constr_info *info = get_info(env, node);
- return info != NULL && info->is_use;
-}
-
/**
* Introduces a definition at the corresponding block.
*/
* If an operand of the use is a (original) definition,
* it will be replaced by the given definition.
*/
-static void set_operands(be_ssa_construction_env_t *env, ir_node *use, ir_node *def)
+static void set_operands(be_ssa_construction_env_t *env, ir_node *use, ir_node *def, constr_info *const use_info)
{
- constr_info *info = get_info(env, use);
- int arity = get_irn_arity(use);
- int i;
-
- for (i = 0; i < arity; ++i) {
+ int arity = get_irn_arity(use);
+ for (int i = 0; i < arity; ++i) {
ir_node *op = get_irn_n(use, i);
if (is_definition(env, op)) {
}
}
- info->already_processed = true;
+ use_info->already_processed = true;
}
/**
DBG((dbg, LEVEL_3, "\tprocessing block %+F\n", block));
sched_foreach(block, node) {
- if (is_use(env, node) && !is_Phi(node)) {
+ constr_info *const info = get_info(env, node);
+ if (!info)
+ continue;
+
+ if (info->is_use && !is_Phi(node)) {
DBG((dbg, LEVEL_3, "\t...found use %+F\n", node));
if (def == NULL) {
}
}
- set_operands(env, node, def);
+ set_operands(env, node, def, info);
}
- if (is_definition(env, node)) {
- constr_info *info = get_info(env, node);
+ if (info->is_definition) {
def = info->u.definition;
DBG((dbg, LEVEL_3, "\t...found definition %+F\n", def));
}
else {
/* Search the last definition of the block. */
sched_foreach_reverse(block, def) {
- if (is_definition(env, def)) {
- constr_info *info = get_info(env, def);
+ constr_info const *const info = get_info(env, def);
+ if (info && info->is_definition) {
DBG((dbg, LEVEL_3, "\t...found definition %+F\n", info->u.definition));
block_info->u.last_definition = info->u.definition;
break;
/**
* Fixes all operands of the given use.
*/
-static void search_def_at_block(be_ssa_construction_env_t *env, ir_node *use)
+static void search_def_at_block(be_ssa_construction_env_t *const env, ir_node *const use, constr_info *const info)
{
ir_node *block = get_nodes_block(use);
constr_info *block_info = get_or_set_info(env, block);
} else if (Block_block_visited(block)) {
ir_node *phi = insert_dummy_phi(env, block);
- set_operands(env, use, phi);
+ set_operands(env, use, phi, info);
} else {
ir_node *def = get_def_at_idom(env, block);
- set_operands(env, use, def);
+ set_operands(env, use, def, info);
}
}
*
* @see insert_dummy_phi
*/
-static void fix_phi_arguments(be_ssa_construction_env_t *env, ir_node *phi)
+static void fix_phi_arguments(be_ssa_construction_env_t *const env, ir_node *const phi, constr_info *const info)
{
- constr_info *info = get_info(env, phi);
- ir_node *block = get_nodes_block(phi);
- int i;
- int n_preds = get_Block_n_cfgpreds(block);
+ ir_node *block = get_nodes_block(phi);
+ int n_preds = get_Block_n_cfgpreds(block);
DBG((dbg, LEVEL_3, "\tfixing phi arguments %+F\n", phi));
- for (i = 0; i < n_preds; ++i) {
+ for (int i = 0; i < n_preds; ++i) {
ir_node *op = get_irn_n(phi, i);
if (is_definition(env, op) || is_Dummy(op)) {
continue;
if (is_Phi(use)) {
- fix_phi_arguments(env, use);
+ fix_phi_arguments(env, use, info);
}
else {
DBG((dbg, LEVEL_3, "\tsearching def for %+F at %+F\n", use, get_nodes_block(use)));
- search_def_at_block(env, use);
+ search_def_at_block(env, use, info);
}
stat_ev_cnt_inc(uses);