X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Floop.c;h=46665db9293cc11d85533272d132a0a58210a6fe;hb=1c89dc2a2c3cccd6e29fcfbf65248496db66ab92;hp=a5a60505c3587247b02d5137483c6d633b5fac7f;hpb=8a98cf06c4fb193ea8025a6dfcdbe161187d143f;p=libfirm diff --git a/ir/opt/loop.c b/ir/opt/loop.c index a5a60505c..46665db92 100644 --- a/ir/opt/loop.c +++ b/ir/opt/loop.c @@ -49,11 +49,10 @@ #include #include "irbackedge_t.h" -#include "irphase_t.h" +#include "irnodemap.h" #include "irloop_t.h" - -DEBUG_ONLY(static firm_dbg_module_t *dbg); +DEBUG_ONLY(static firm_dbg_module_t *dbg;) /** * Convenience macro for iterating over every phi node of the given block. @@ -212,7 +211,8 @@ static entry_edge *loop_entries; /* Number of unrolls to perform */ static int unroll_nr; /* Phase is used to keep copies of nodes. */ -static ir_phase *phase; +static ir_nodemap map; +static struct obstack obst; /* Loop operations. */ typedef enum loop_op_t { @@ -496,16 +496,14 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp) unrolling_node_info *info; assert(nr != 0 && "0 reserved"); - info = (unrolling_node_info *)phase_get_irn_data(phase, n); + info = (unrolling_node_info*)ir_nodemap_get(&map, n); if (! info) { - ir_node **arr; + ir_node **arr = NEW_ARR_D(ir_node*, &obst, unroll_nr); + memset(arr, 0, unroll_nr * sizeof(ir_node*)); - info = XMALLOCZ(unrolling_node_info); - arr = NEW_ARR_F(ir_node *, unroll_nr); + info = OALLOCZ(&obst, unrolling_node_info); info->copies = arr; - memset(info->copies, 0, (unroll_nr) * sizeof(ir_node *)); - - phase_set_irn_data(phase, n, info); + ir_nodemap_insert(&map, n, info); } /* Original node */ info->copies[0] = n; @@ -517,7 +515,7 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp) static ir_node *get_unroll_copy(ir_node *n, int nr) { ir_node *cp; - unrolling_node_info *info = (unrolling_node_info *)phase_get_irn_data(phase, n); + unrolling_node_info *info = (unrolling_node_info *)ir_nodemap_get(&map, n); if (! info) return NULL; @@ -531,13 +529,13 @@ static ir_node *get_unroll_copy(ir_node *n, int nr) /* Sets copy cp of node n. */ static void set_inversion_copy(ir_node *n, ir_node *cp) { - phase_set_irn_data(phase, n, cp); + ir_nodemap_insert(&map, n, cp); } /* Getter of copy of n for inversion */ static ir_node *get_inversion_copy(ir_node *n) { - ir_node *cp = (ir_node *)phase_get_irn_data(phase, n); + ir_node *cp = (ir_node *)ir_nodemap_get(&map, n); return cp; } @@ -1310,7 +1308,8 @@ static void loop_inversion(ir_graph *irg) inversion_blocks_in_cc = 0; /* Use phase to keep copy of nodes from the condition chain. */ - phase = new_phase(irg, phase_irn_init_default); + ir_nodemap_init(&map, irg); + obstack_init(&obst); /* Search for condition chains and temporarily save the blocks in an array. */ cc_blocks = NEW_ARR_F(ir_node *, 0); @@ -1355,14 +1354,15 @@ static void loop_inversion(ir_graph *irg) DEL_ARR_F(cur_head_outs); /* Duplicated blocks changed doms */ - set_irg_doms_inconsistent(irg); - set_irg_loopinfo_state(irg, loopinfo_cf_inconsistent); + clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE + | IR_GRAPH_STATE_CONSISTENT_LOOPINFO); ++stats.inverted; } /* free */ - phase_free(phase); + obstack_free(&obst, NULL); + ir_nodemap_destroy(&map); DEL_ARR_F(cond_chain_entries); DEL_ARR_F(head_df_loop); @@ -2555,7 +2555,8 @@ static void unroll_loop(void) } /* Use phase to keep copy of nodes from the condition chain. */ - phase = new_phase(current_ir_graph, phase_irn_init_default); + ir_nodemap_init(&map, current_ir_graph); + obstack_init(&obst); /* Copies the loop */ copy_loop(loop_entries, unroll_nr - 1); @@ -2574,9 +2575,11 @@ static void unroll_loop(void) else ++stats.invariant_unroll; - set_irg_doms_inconsistent(current_ir_graph); + clear_irg_state(current_ir_graph, IR_GRAPH_STATE_CONSISTENT_DOMINANCE); DEL_ARR_F(loop_entries); + obstack_free(&obst, NULL); + ir_nodemap_destroy(&map); } } @@ -2738,19 +2741,19 @@ static ir_graph_state_t perform_loop_peeling(ir_graph *irg) return 0; } -optdesc_t opt_unroll_loops = { +static optdesc_t opt_unroll_loops = { "unroll-loops", IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO, perform_loop_unrolling, }; -optdesc_t opt_invert_loops = { +static optdesc_t opt_invert_loops = { "invert-loops", IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO, perform_loop_inversion, }; -optdesc_t opt_peel_loops = { +static optdesc_t opt_peel_loops = { "peel-loops", IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO, perform_loop_peeling,