From 079f8b9e0a0a949eaa9fa939e693275aad3e4cf9 Mon Sep 17 00:00:00 2001 From: Daniel Grund Date: Fri, 17 Mar 2006 16:06:41 +0000 Subject: [PATCH] Bugfixes --- ir/be/bearch.c | 1 + ir/be/beraextern.c | 25 +++++++++++++++---------- ir/be/besched.c | 16 +++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ir/be/bearch.c b/ir/be/bearch.c index 95a18fde5..8ff66289c 100644 --- a/ir/be/bearch.c +++ b/ir/be/bearch.c @@ -22,6 +22,7 @@ #include "bearch.h" #include "ircons_t.h" +#include "irnode_t.h" #include "bitset.h" #include "pset.h" diff --git a/ir/be/beraextern.c b/ir/be/beraextern.c index c55327a57..cbd55d746 100644 --- a/ir/be/beraextern.c +++ b/ir/be/beraextern.c @@ -86,10 +86,11 @@ alloc ::= node-nr reg-nr . #include "phiclass.h" #include "beraextern.h" +#include "beabi.h" #include "bearch.h" #include "benode_t.h" #include "beirgmod.h" -#include "besched.h" +#include "besched_t.h" #include "beutil.h" #include "belive_t.h" @@ -202,12 +203,10 @@ static void handle_constraints_walker(ir_node *irn, void *env) { arch_get_register_req(raenv->aenv, &req, irn, -1); if (arch_register_req_is(&req, limited)) { ir_node *cpy = be_new_Copy(req.cls, raenv->irg, get_nodes_block(irn), irn); - const ir_edge_t *edge; /* all users of the irn use the copy instead */ sched_add_after(irn, cpy); - foreach_out_edge(irn, edge) - set_irn_n(edge->src, edge->pos, cpy); + edges_reroute(irn, cpy, raenv->irg); } @@ -232,7 +231,7 @@ static void handle_constraints_walker(ir_node *irn, void *env) { } static void handle_constraints(be_raext_env_t *raenv) { - irg_block_walk_graph(raenv->irg, NULL, handle_constraints_walker, raenv); + irg_walk_graph(raenv->irg, NULL, handle_constraints_walker, raenv); } @@ -288,9 +287,10 @@ static ir_node *insert_copies(be_raext_env_t *raenv, ir_node *start_phi, int pos if (has_been_done(start_phi, pos)) return NULL; - /* In case this is a 'normal' phi we insert into - * the schedule before the pred_blk irn */ - last_cpy = pred_blk; + /* In case this is a 'normal' phi we insert at the + * end of the pred block before cf nodes */ + last_cpy = sched_skip(pred_blk, 0, sched_skip_cf_predicator, raenv->aenv); + last_cpy = sched_next(last_cpy); /* If we detect a loop stop recursion. */ if (arg == start_phi) { @@ -303,7 +303,7 @@ static ir_node *insert_copies(be_raext_env_t *raenv, ir_node *start_phi, int pos /* At least 2 phis are involved */ /* Insert a loop breaking copy (an additional variable T) */ loop_breaker = be_new_Copy(raenv->cls, raenv->irg, pred_blk, start_phi); - sched_add_before(pred_blk, loop_breaker); + sched_add_before(last_cpy, loop_breaker); arg = loop_breaker; } @@ -345,6 +345,9 @@ static void ssa_destr_simple_walker(ir_node *blk, void *env) { if (!is_Phi(phi)) break; + if (arch_irn_is_ignore(raenv->aenv, phi)) + continue; + raenv->cls = arch_get_irn_reg_class(raenv->aenv, phi, -1); insert_copies(raenv, phi, pos, phi); } @@ -616,7 +619,7 @@ static void dump_affinities_walker(ir_node *irn, void *env) { int pos, max; var_info_t *vi1, *vi2; - if (arch_get_irn_reg_class(raenv->aenv, irn, -1) == NULL || arch_irn_is_ignore(raenv->aenv, irn)) + if (arch_get_irn_reg_class(raenv->aenv, irn, -1) != raenv->cls || arch_irn_is_ignore(raenv->aenv, irn)) return; vi1 = get_var_info(irn); @@ -929,6 +932,7 @@ static void be_ra_extern_main(const be_irg_t *bi) { var_info_t *vi; compute_doms(irg); + edges_assure(irg); raenv.irg = irg; raenv.aenv = env->arch_env; @@ -969,6 +973,7 @@ static void be_ra_extern_main(const be_irg_t *bi) { dump_to_file(&raenv, out); execute(callee, out, in); done = read_and_apply_results(&raenv, in); + be_abi_fix_stack_nodes(bi->abi); ir_snprintf(in, sizeof(in), "-extern-%s-round-%d", raenv.cls->name, round); be_dump(irg, in, dump_ir_block_graph_sched); diff --git a/ir/be/besched.c b/ir/be/besched.c index add642870..6e71367a3 100644 --- a/ir/be/besched.c +++ b/ir/be/besched.c @@ -184,13 +184,15 @@ int sched_skip_phi_predicator(const ir_node *irn, void *data) { return is_Phi(irn); } -extern ir_node *sched_skip(ir_node *from, int forward, - sched_predicator_t *predicator, void *data) +extern ir_node *sched_skip(ir_node *from, int forward, sched_predicator_t *predicator, void *data) { - const ir_node *bl = get_block(from); - ir_node *curr; + const ir_node *bl = get_block(from); + ir_node *curr; - for(curr = from; curr != bl && predicator(curr, data); - curr = forward ? sched_next(curr) : sched_prev(curr)); - return curr; + if (is_Block(from)) + from = forward ? sched_next(from) : sched_prev(from); + + for(curr = from; curr != bl && predicator(curr, data); curr = forward ? sched_next(curr) : sched_prev(curr)); + + return curr; } -- 2.20.1