X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbetranshlp.c;h=ad337cfc6c14524c140bcde8ac8a166388870864;hb=8041ca0d7111bf4ef48fac04849fab339e62f54d;hp=444dc8ceed16ae69708f59cf13215f11195ea8e8;hpb=59f3ed9a540a7368795de28a79b2fc0d7df1d13b;p=libfirm diff --git a/ir/be/betranshlp.c b/ir/be/betranshlp.c index 444dc8cee..ad337cfc6 100644 --- a/ir/be/betranshlp.c +++ b/ir/be/betranshlp.c @@ -24,9 +24,7 @@ * @date 14.06.2007 * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include "pdeq.h" #include "irop_t.h" @@ -41,13 +39,12 @@ #include "cgana.h" #include "debug.h" -#include "beirg_t.h" +#include "beirg.h" #include "betranshlp.h" +#include "belive.h" typedef struct be_transform_env_t { ir_graph *irg; /**< The irg, the node should be created in */ - int visited; /**< visited count that indicates whether a - node is already transformed */ waitq *worklist; /**< worklist of nodes that still need to be transformed */ ir_node *old_anchor; /**< the old anchor node in the old irg */ @@ -66,7 +63,7 @@ int be_is_transformed(const ir_node *node) { return irn_visited(node); } -static INLINE ir_node *be_get_transformed_node(ir_node *old_node) { +static inline ir_node *be_get_transformed_node(ir_node *old_node) { if (irn_visited(old_node)) { ir_node *new_node = get_irn_link(old_node); assert(new_node != NULL); @@ -87,6 +84,14 @@ void be_duplicate_deps(ir_node *old_node, ir_node *new_node) { } } +void be_dep_on_frame(ir_node* node) +{ + ir_graph *const irg = current_ir_graph; + + if (get_irg_start_block(irg) == get_nodes_block(node)) + add_irn_dep(node, get_irg_frame(irg)); +} + ir_node *be_duplicate_node(ir_node *node) { ir_node *block = be_transform_node(get_nodes_block(node)); ir_graph *irg = env.irg; @@ -105,7 +110,7 @@ ir_node *be_duplicate_node(ir_node *node) { add_irn_n(new_node, in); } } else { - ir_node **ins = alloca(arity * sizeof(ins[0])); + ir_node **ins = ALLOCAN(ir_node*, arity); for (i = 0; i < arity; ++i) { ir_node *in = get_irn_n(node, i); ins[i] = be_transform_node(in); @@ -117,10 +122,7 @@ ir_node *be_duplicate_node(ir_node *node) { copy_node_attr(node, new_node); be_duplicate_deps(node, new_node); -#ifdef DEBUG_libfirm new_node->node_nr = node->node_nr; -#endif - return new_node; } @@ -236,11 +238,6 @@ ir_node *be_pre_transform_node(ir_node *place) { return be_transform_node(place); } -ir_node *be_get_old_anchor(int anchor) -{ - return get_irn_n(env.old_anchor, anchor); -} - static void pre_transform_anchor(int anchor) { ir_node *old_anchor_node = get_irn_n(env.old_anchor, anchor); @@ -260,8 +257,7 @@ static void kill_unused_anchor(int anchor) /** * Transforms all nodes. Deletes the old obstack and creates a new one. */ -static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, - void *cg) +static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform) { int i; ir_node *old_end, *new_anchor; @@ -271,7 +267,6 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, inc_irg_visited(irg); env.irg = irg; - env.visited = get_irg_visited(irg); env.worklist = new_waitq(); env.old_anchor = irg->anchor; @@ -299,7 +294,7 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform, kill_unused_anchor(anchor_tls); if (pre_transform) - (*pre_transform)(cg); + pre_transform(); /* process worklist (this should transform all nodes in the graph) */ while (! waitq_empty(env.worklist)) { @@ -349,9 +344,8 @@ static ir_node *gen_Block(ir_node *node) { block = new_ir_node(dbgi, irg, NULL, get_irn_op(node), get_irn_mode(node), get_irn_arity(node), get_irn_in(node) + 1); copy_node_attr(node, block); -#ifdef DEBUG_libfirm block->node_nr = node->node_nr; -#endif + if (node == macroblock) { /* this node is a macroblock header */ set_Block_MacroBlock(block, block); @@ -392,7 +386,7 @@ static ir_node *gen_End(ir_node *node) { return new_end; } -void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func, void *cg) +void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func) { ir_graph *irg = birg->irg; ir_graph *old_current_ir_graph = current_ir_graph; @@ -417,7 +411,7 @@ void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func, void *cg) op_End->ops.generic = (op_func)gen_End; /* do the main transformation */ - transform_nodes(irg, func, cg); + transform_nodes(irg, func); /* free the old obstack */ obstack_free(old_obst, 0); @@ -444,6 +438,6 @@ void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func, void *cg) if (birg->lv) { be_liveness_free(birg->lv); - birg->lv = be_liveness(birg); + birg->lv = be_liveness(irg); } }