X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firgmod.c;h=46b299dea6f3027f58a90dc09a66d4fafa7d1e56;hb=95ea45b6d9050f3638c68dda8c4fcc92a79c81ed;hp=de99bf8323fc17cad05e093b10febe9fc8fece89;hpb=5f663c52fa1bed75bad98fc0d68d7e0da995c3eb;p=libfirm diff --git a/ir/ir/irgmod.c b/ir/ir/irgmod.c index de99bf832..46b299dea 100644 --- a/ir/ir/irgmod.c +++ b/ir/ir/irgmod.c @@ -1,6 +1,6 @@ /* * Project: libFIRM - * File name: ir/ir/irgmod.h + * File name: ir/ir/irgmod.c * Purpose: Support for ir graph modification. * Author: Martin Trapp, Christian Schaefer * Modified by: Goetz Lindenmaier @@ -14,16 +14,17 @@ # include "config.h" #endif -# include "irvrfy.h" -# include "irflag_t.h" -# include "irgwalk.h" -# include "irnode_t.h" -# include "irgraph_t.h" -# include "irgmod.h" -# include "array.h" -# include "ircons.h" -# include "irhooks.h" -# include "iredges_t.h" +#include "irvrfy.h" +#include "irflag_t.h" +#include "irgwalk.h" +#include "irnode_t.h" +#include "irgraph_t.h" +#include "irgmod.h" +#include "array.h" +#include "ircons.h" +#include "irhooks.h" +#include "iredges_t.h" +#include "irtools.h" /* Turns a node into a "useless" Tuple. The Tuple just forms a tuple from several inputs. @@ -51,52 +52,49 @@ turn_into_tuple (ir_node *node, int arity) void exchange (ir_node *old, ir_node *nw) { - /* - * If new outs are on, we can skip the id node creation and reroute - * the edges from the old node to the new directly. - */ - if (edges_activated(current_ir_graph)) { - edges_reroute(old, nw, current_ir_graph); - } + hook_replace(old, nw); + + /* + * If new outs are on, we can skip the id node creation and reroute + * the edges from the old node to the new directly. + */ + if (edges_activated(current_ir_graph)) { + edges_reroute(old, nw, current_ir_graph); + } else { /* Else, do it the old-fashioned way. */ - ir_graph *irg = get_irn_irg (old); - ir_node *block; + ir_graph *irg = get_irn_irg (old); + ir_node *block; - assert(old != nw); - assert (irg); - assert(get_irn_op(old)->opar != oparity_dynamic); + assert(old != nw); + assert (irg); + assert(get_irn_op(old)->opar != oparity_dynamic); - hook_turn_into_id(old); + hook_turn_into_id(old); - block = old->in[0]; - if (!block) { - block = is_Block(nw) ? nw : get_nodes_block(nw); + block = old->in[0]; + if (!block) { + block = is_Block(nw) ? nw : get_nodes_block(nw); - if (!block) { - DDMN(old); - DDMN(nw); - assert(0 && "cannot find legal block for id"); - } - } + if (!block) { + DDMN(old); + DDMN(nw); + assert(0 && "cannot find legal block for id"); + } + } - old->op = op_Id; - old->in = NEW_ARR_D (ir_node *, irg->obst, 2); - old->in[0] = block; - old->in[1] = nw; - } + old->op = op_Id; + old->in = NEW_ARR_D (ir_node *, irg->obst, 2); + old->in[0] = block; + old->in[1] = nw; + } } /*--------------------------------------------------------------------*/ /* Functionality for collect_phis */ /*--------------------------------------------------------------------*/ -static void -clear_link (ir_node *n, void *env) { - set_irn_link(n, NULL); -} - static void collect (ir_node *n, void *env) { ir_node *pred; @@ -120,7 +118,7 @@ void collect_phiprojs(ir_graph *irg) { rem = current_ir_graph; current_ir_graph = irg; - irg_walk(get_irg_end(current_ir_graph), clear_link, collect, NULL); + irg_walk(get_irg_end(current_ir_graph), firm_clear_link, collect, NULL); current_ir_graph = rem; } @@ -177,9 +175,8 @@ void part_block(ir_node *node) { get_Block_cfgpred_arr(old_block)); set_irg_current_block(current_ir_graph, new_block); { - ir_node *in[1]; - in[0] = new_Jmp(); - set_irn_in(old_block, 1, in); + ir_node *jmp = new_Jmp(); + set_irn_in(old_block, 1, &jmp); irn_vrfy_irg(old_block, current_ir_graph); }