#include "besched.h"
#include "irgmod.h"
-#include "iredges.h"
+#include "iredges_t.h"
#include "irgwalk.h"
#undef is_Perm
PERM_COPY
} perm_type_t;
+/* structure to represent cycles or chains in a perm */
typedef struct _perm_cycle_t {
const arch_register_t **elems; /**< the registers in the cycle */
int n_elems; /**< number of elements in the cycle */
return -1;
}
+/* returns the number register pairs marked as checked */
static int get_n_checked_pairs(reg_pair_t *pairs, int n) {
int i, n_checked = 0;
* @param walk_env The environment
*/
static void lower_perm_node(ir_node *irn, void *walk_env) {
- const be_node_factory_t *fact;
const arch_register_class_t *reg_class;
const arch_env_t *arch_env;
firm_dbg_module_t *mod;
if (is_Block(irn))
return;
- fact = env->chord_env->main_env->node_factory;
arch_env = env->chord_env->main_env->arch_env;
do_copy = env->do_copy;
mod = env->dbg_module;
set_Proj_proj(pairs[i].out_node, get_Proj_proj(pairs[i].in_node));
}
-
/* remove the proj from the schedule */
sched_remove(pairs[i].out_node);
- /* exchange the proj with the argument */
+ /* reroute the edges from the proj to the argument */
edges_reroute(pairs[i].out_node, pairs[i].in_node, env->chord_env->irg);
pairs[i].checked = 1;
continue;
}
-//todo: - iff PERM_CYCLE && do_copy -> determine free temp reg and insert copy to/from it before/after
+//TODO: - iff PERM_CYCLE && do_copy -> determine free temp reg and insert copy to/from it before/after
// the copy cascade (this reduces the cycle into a chain)
/* build copy/swap nodes from back to front */
DBG((mod, LEVEL_1, "%+F (%+F, %s) and (%+F, %s)\n",
irn, res1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
- cpyxchg = new_Perm(fact, reg_class, env->chord_env->irg, block, 2, in);
+ cpyxchg = be_new_Perm(reg_class, env->chord_env->irg, block, 2, in);
sched_remove(res1);
sched_remove(res2);
DBG((mod, LEVEL_1, "%+F creating copy node (%+F, %s) -> (%+F, %s)\n",
irn, arg1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
- cpyxchg = new_Copy(fact, reg_class, env->chord_env->irg, block, arg1);
+ cpyxchg = be_new_Copy(reg_class, env->chord_env->irg, block, arg1);
arch_set_irn_register(arch_env, cpyxchg, cycle->elems[i + 1]);
/* remove the proj from the schedule */