From 365b4cfd34bc444107b8f90c9c9431c64ee20e44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Sat, 11 Mar 2006 21:41:25 +0000 Subject: [PATCH] insert Keeps to assure should_be_different constraint --- ir/be/bechordal_main.c | 3 ++ ir/be/belower.c | 63 +++++++++++++++++++++++++++++++++++++++++- ir/be/belower.h | 1 + 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/ir/be/bechordal_main.c b/ir/be/bechordal_main.c index b423b2cc3..6767885e7 100644 --- a/ir/be/bechordal_main.c +++ b/ir/be/bechordal_main.c @@ -266,6 +266,9 @@ static void be_ra_chordal_main(const be_irg_t *bi) obstack_init(&chordal_env.obst); + /* add Keeps for should_be_different constrained nodes */ + lower_nodes_before_ra(&chordal_env); + /* Perform the following for each register class. */ for(j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) { chordal_env.cls = arch_isa_get_reg_class(isa, j); diff --git a/ir/be/belower.c b/ir/be/belower.c index 8064401f5..b89c35756 100644 --- a/ir/be/belower.c +++ b/ir/be/belower.c @@ -463,6 +463,50 @@ static void lower_perm_node(ir_node *irn, void *walk_env) { +/** + * Checks if node has a should_be_different constraint in output + * and adds a Keep then to assure the constraint. + */ +static void assure_different_constraint(ir_node *irn, lower_env_t *env) { + const arch_env_t *arch_env = env->chord_env->birg->main_env->arch_env; + const arch_register_req_t *req; + arch_register_req_t req_temp; + ir_node *in[2], *keep; + + req = arch_get_register_req(arch_env, &req_temp, irn, -1); + + if (req && arch_register_req_is(req, should_be_different)) { + /* We found a should_be_different constraint. */ + assert(req->other_different && "missing irn for constraint"); + + in[0] = irn; + in[1] = req->other_different; + + keep = be_new_Keep(req->cls, env->chord_env->birg->irg, get_nodes_block(irn), 2, in); + DBG((env->dbg_module, LEVEL_1, "created %+F for %+F to assure should_be_different\n", keep, irn)); + } +} + + + +/** + * Calls the corresponding lowering function for the node. + * + * @param irn The node to be checked for lowering + * @param walk_env The walker environment + */ +static void lower_nodes_before_ra_walker(ir_node *irn, void *walk_env) { + if (is_Block(irn)) + return; + + if (mode_is_datab(get_irn_mode(irn))) + assure_different_constraint(irn, walk_env); + + return; +} + + + /** * Calls the corresponding lowering function for the node. * @@ -484,9 +528,26 @@ static void lower_nodes_after_ra_walker(ir_node *irn, void *walk_env) { +/** + * Walks over all blocks in an irg and performs action need to be + * done before register allocation (e.g. add Keeps for should be different constraints). + * + * @param chord_env The chordal environment containing the irg + */ +void lower_nodes_before_ra(be_chordal_env_t *chord_env) { + lower_env_t env; + + env.chord_env = chord_env; + env.dbg_module = firm_dbg_register("firm.be.lower"); + + irg_walk_blkwise_graph(chord_env->irg, NULL, lower_nodes_before_ra_walker, &env); +} + + + /** * Walks over all blocks in an irg and performs lowering need to be - * done after register allocation (e.g. perm and spill/reload lowering). + * done after register allocation (e.g. perm lowering). * * @param chord_env The chordal environment containing the irg * @param do_copy 1 == resolve cycles with a free reg if available diff --git a/ir/be/belower.h b/ir/be/belower.h index 06745fdc8..be4302fa7 100644 --- a/ir/be/belower.h +++ b/ir/be/belower.h @@ -10,6 +10,7 @@ #include "bechordal.h" +void lower_nodes_before_ra(be_chordal_env_t *chord_env); void lower_nodes_after_ra(be_chordal_env_t *chord_env, int do_copy); #endif /* _BELOWER_H_ */ -- 2.20.1