From 9b23a130beb15ad7eac348a9e98108892a11f0a5 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 8 May 2006 15:28:50 +0000 Subject: [PATCH] removed the INPLACE_EDGES option. They are now always available [r7702] --- ir/ana/irextbb.c | 12 ++---- ir/common/firm_common_t.h | 7 --- ir/ir/iredges.c | 91 +++++++++++++++++++++++---------------- ir/ir/iredges_t.h | 23 +--------- ir/ir/irgraph_t.h | 9 ++-- ir/ir/irnode.c | 27 +++++------- ir/ir/irnode_t.h | 2 - ir/opt/opt_frame.c | 5 +-- 8 files changed, 73 insertions(+), 103 deletions(-) diff --git a/ir/ana/irextbb.c b/ir/ana/irextbb.c index 789cb2567..5d9591261 100644 --- a/ir/ana/irextbb.c +++ b/ir/ana/irextbb.c @@ -71,7 +71,6 @@ static void addto_extblk(ir_extblk *extblk, ir_node *block) * we are interested only in 1, 2 and >2. */ static int get_block_n_succs(ir_node *block) { -#ifdef FIRM_EDGES_INPLACE if (edges_activated(current_ir_graph)) { const ir_edge_t *edge; @@ -84,7 +83,6 @@ static int get_block_n_succs(ir_node *block) { edge = get_block_succ_next(block, edge); return edge ? 3 : 2; } -#endif return get_Block_n_cfg_outs(block); } @@ -274,14 +272,10 @@ void compute_extbb(ir_graph *irg) { env.obst = irg->extbb_obst; env.head = NULL; -#ifdef FIRM_EDGES_INPLACE - if (edges_activated(irg)) { - /* we have edges */ + if (! edges_activated(irg)) { + /* we don't have edges */ + assure_irg_outs(irg); } - else -#endif - if (get_irg_outs_state(irg) != outs_consistent) - compute_irg_outs(irg); /* we must mark nodes, so increase the visited flag */ inc_irg_visited(irg); diff --git a/ir/common/firm_common_t.h b/ir/common/firm_common_t.h index 480e2e978..c06b84dd7 100644 --- a/ir/common/firm_common_t.h +++ b/ir/common/firm_common_t.h @@ -48,11 +48,4 @@ * Sometimes it's useful to see the pointer values, though. */ #define NODEID_AS_LABEL 1 -/** - * Enable the possibility for automatic out edges. - * Note, that you have to enable them manually to use them by - * calling edges_activate(). - */ -#define FIRM_EDGES_INPLACE 1 - # endif /*_COMMON_T_H_ */ diff --git a/ir/ir/iredges.c b/ir/ir/iredges.c index 0702244ea..12eff93d2 100644 --- a/ir/ir/iredges.c +++ b/ir/ir/iredges.c @@ -26,8 +26,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg;) -#if FIRM_EDGES_INPLACE - /** * This flag is set to 1, if the edges get initialized for an irg. * Then register additional data is forbidden. @@ -121,6 +119,7 @@ static INLINE void edge_change_cnt(ir_node *tgt, int ofs) { void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg) { const char *msg = ""; + int is_tgt_bad = tgt && is_Bad(tgt); if(!edges_activated(irg)) return; @@ -218,39 +217,60 @@ void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir "target list head must have been initialized"); /* - * insert the edge, if it is not yet in the set or return - * the instance in the set. + * Do NOT add edges that point to Bad nodes. */ - edge = set_insert(edges, templ, size, edge_hash(templ)); - block_edge = (ir_block_edge_t *) edge; +#if 0 + if (is_tgt_bad) { + if(old_tgt) { + edge = set_find(edges, templ, size, edge_hash(templ)); + block_edge = (ir_block_edge_t *) edge; + + assert(edge); + list_del(&edge->list); + if(is_block_edge) { + list_del(&block_edge->succ_list); + } + } + } + else +#endif + { + /* + * insert the edge, if it is not yet in the set or return + * the instance in the set. + */ + edge = set_insert(edges, templ, size, edge_hash(templ)); + block_edge = (ir_block_edge_t *) edge; #ifdef DEBUG_libfirm - assert(!edge->invalid && "Invalid edge encountered"); + assert(!edge->invalid && "Invalid edge encountered"); #endif - /* If the old target is not null, the edge is moved. */ - if(old_tgt) { - msg = "redirecting"; - list_move(&edge->list, head); + /* If the old target is not null, the edge is moved. */ + if(old_tgt) { + msg = "redirecting"; - /* If the edge is a cf edge, move it from the successor list. */ - if(is_block_edge) - list_move(&block_edge->succ_list, succ_head); + list_move(&edge->list, head); - edge_change_cnt(old_tgt, -1); - } + /* If the edge is a cf edge, move it from the successor list. */ + if(is_block_edge) + list_move(&block_edge->succ_list, succ_head); - /* The old target was null, thus, the edge is newly created. */ - else { - msg = "adding"; - list_add(&edge->list, head); + edge_change_cnt(old_tgt, -1); + } - /* - * If the edge is cf edge, enter it into the successor list - * of the target node's block. - */ - if(is_block_edge) - list_add(&block_edge->succ_list, succ_head); + /* The old target was null, thus, the edge is newly created. */ + else { + msg = "adding"; + list_add(&edge->list, head); + + /* + * If the edge is cf edge, enter it into the successor list + * of the target node's block. + */ + if(is_block_edge) + list_add(&block_edge->succ_list, succ_head); + } } edge_change_cnt(tgt, +1); @@ -258,8 +278,8 @@ void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir } /* If the target and the old target are equal, nothing is done. */ - DBG((dbg, LEVEL_5, "announce out edge: %n[%p] %d-> %n[%p](%n[%p]): %s\n", - src, src, pos, tgt, tgt, old_tgt, old_tgt, msg)); + DBG((dbg, LEVEL_5, "announce out edge: %+F %d-> %+F(%+F): %s\n", + src, pos, tgt, old_tgt, msg)); } void edges_node_deleted(ir_node *old, ir_graph *irg) @@ -268,12 +288,12 @@ void edges_node_deleted(ir_node *old, ir_graph *irg) int not_a_block = !is_Block(old); int i, n; - DBG((dbg, LEVEL_5, "node deleted: %n\n", old)); + DBG((dbg, LEVEL_5, "node deleted: %+F\n", old)); /* Change to get_irn_n */ for(i = -not_a_block, n = get_irn_arity(old); i < n; ++i) { ir_node *old_tgt = get_irn_n(old, i); - DBG((dbg, LEVEL_5, "\tdelete to old target %n\n", old_tgt)); + DBG((dbg, LEVEL_5, "\tdelete to old target %+F\n", old_tgt)); edges_notify_edge(old, i, NULL, old_tgt, irg); } @@ -348,7 +368,7 @@ void edges_reroute(ir_node *from, ir_node *to, ir_graph *irg) struct list_head *head = _get_irn_outs_head(from); DBG((dbg, LEVEL_5, - "reroute from %n to %n\n", from, to)); + "reroute from %+F to %+F\n", from, to)); while(head != head->next) { ir_edge_t *edge = list_entry(head->next, ir_edge_t, list); @@ -379,7 +399,7 @@ static void verify_set_presence(ir_node *irn, void *data) if(e != NULL) e->present = 1; else - DBG((dbg, LEVEL_DEFAULT, "edge %n,%d is missing\n", irn, templ->pos)); + DBG((dbg, LEVEL_DEFAULT, "edge %+F,%d is missing\n", irn, templ->pos)); } } @@ -390,7 +410,7 @@ static void verify_list_presence(ir_node *irn, void *data) foreach_out_edge(irn, e) { ir_node *tgt = get_irn_n(e->src, e->pos); if(irn != tgt) - DBG((dbg, LEVEL_DEFAULT, "edge %n,%d is no out edge of %n but of %n\n", + DBG((dbg, LEVEL_DEFAULT, "edge %+F,%d is no out edge of %+F but of %+F\n", e->src, e->pos, irn, tgt)); } @@ -414,7 +434,7 @@ void edges_verify(ir_graph *irg) */ for(e = set_first(edges); e; e = set_next(edges)) { if(!e->invalid && !e->present) - DBG((dbg, LEVEL_DEFAULT, "edge %n,%d is superfluous\n", e->src, e->pos)); + DBG((dbg, LEVEL_DEFAULT, "edge %+F,%d is superfluous\n", e->src, e->pos)); } } @@ -449,6 +469,3 @@ int (get_irn_n_edges)(const ir_node *irn) { return _get_irn_n_edges(irn); } - - -#endif /* FIRM_EDGES_INPLACE */ diff --git a/ir/ir/iredges_t.h b/ir/ir/iredges_t.h index 18b224df1..f29dfba95 100644 --- a/ir/ir/iredges_t.h +++ b/ir/ir/iredges_t.h @@ -29,9 +29,7 @@ #include "iredges.h" -#if FIRM_EDGES_INPLACE - -#define DBG_EDGES "edges" +#define DBG_EDGES "firm.ir.edges" /** * An edge. @@ -252,23 +250,4 @@ extern void init_edges(void); #define edges_activated(irg) _edges_activated(irg) #define edges_assure(irg) _edges_assure(irg) -#else -/* new edges are disabled */ - -#define init_edges() -#define edges_reroute(old, nw, irg) -#define edges_init_graph(irg); -#define edges_notify_edge(src, pos, tgt, old_tgt, irg) -#define edges_node_deleted(old, irg) -#define edges_invalidate(irn, irg) -#define get_irn_out_edge_first(irn) NULL -#define get_irn_out_edge_next(irn,last) NULL -#define get_edge_src_irn(edge) NULL -#define get_edge_src_pos(edge) -1 -#define get_edge_private_data(edge,ofs) NULL -#define edges_activated(irg) 0 -#define edges_assure(irg) - -#endif /* FIRM_EDGES_INPLACE */ - #endif /* _FIRM_EDGES_T_H */ diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index 8c57cea4d..19aaef3c5 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -112,16 +112,13 @@ struct ir_graph { #endif int n_loc; /**< number of local variable in this procedure including procedure parameters. */ - void **loc_descriptions; /**< storage for local variable desriptions */ + void **loc_descriptions; /**< storage for local variable descriptions */ /* -- Fields for optimizations / analysis information -- */ pset *value_table; /**< hash table for global value numbering (cse) for optimizing use in iropt.c */ ir_node **outs; /**< Space for the out arrays. */ -#ifdef DEBUG_libfirm - int n_outs; /**< Size wasted for outs */ -#endif /* defined DEBUG_libfirm */ ir_loop *loop; /**< The outermost loop */ void *link; /**< A void* field to link any information to the node. */ @@ -144,10 +141,10 @@ struct ir_graph { unsigned long block_visited; /**< same as visited, for a complete block */ unsigned estimated_node_count; /**< estimated number of nodes in this graph, updated after every walk */ -#if FIRM_EDGES_INPLACE irg_edge_info_t edge_info; /**< edge info for automatic outs */ -#endif + #ifdef DEBUG_libfirm + int n_outs; /**< Size wasted for outs */ long graph_nr; /**< a unique graph number for each graph to make output readable. */ #endif diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index e43349cba..dafd5b4f9 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -130,12 +130,13 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo { ir_node *res; size_t node_size = offsetof(ir_node, attr) + op->attr_size + firm_add_node_size; - char *p; + char *p; + int i, is_bl; assert(irg && op && mode); p = obstack_alloc (irg->obst, node_size); memset(p, 0, node_size); - res = (ir_node *) (p + firm_add_node_size); + res = (ir_node *) (p + firm_add_node_size); res->kind = k_ir_node; res->op = op; @@ -158,20 +159,14 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo res->node_nr = get_irp_new_node_nr(); #endif -#if FIRM_EDGES_INPLACE - { - int i; - int is_bl = is_Block(res); + INIT_LIST_HEAD(&res->edge_info.outs_head); + is_bl = is_Block(res); + if (is_bl) + INIT_LIST_HEAD(&res->attr.block.succ_head); - INIT_LIST_HEAD(&res->edge_info.outs_head); - if(is_bl) - INIT_LIST_HEAD(&res->attr.block.succ_head); - - for (i = is_bl; i <= arity; ++i) - edges_notify_edge(res, i - 1, res->in[i], NULL, irg); - } -#endif + for (i = is_bl; i <= arity; ++i) + edges_notify_edge(res, i - 1, res->in[i], NULL, irg); hook_new_node(irg, res); @@ -795,8 +790,8 @@ void set_End_keepalives(ir_node *end, int n, ir_node *in[]) { ir_graph *irg = get_irn_irg(end); /* notify that edges are deleted */ - for (i = END_KEEPALIVE_OFFSET; i < ARR_LEN(end->in); ++i) { - edges_notify_edge(end, i, in[i], NULL, irg); + for (i = 1 + END_KEEPALIVE_OFFSET; i < ARR_LEN(end->in); ++i) { + edges_notify_edge(end, i, end->in[i], NULL, irg); } ARR_RESIZE(ir_node *, end->in, n + 1 + END_KEEPALIVE_OFFSET); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index 1ec1f1652..f7b80ba5d 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -260,9 +260,7 @@ struct ir_node { struct abstval *av; /**< the abstract value of this node */ struct section *sec; #endif -#if FIRM_EDGES_INPLACE irn_edge_info_t edge_info; /**< everlasting out edges */ -#endif /* ------- Opcode depending fields -------- */ attr attr; /**< attribute of this node. Depends on opcode. Must be last field of struct ir_node. */ diff --git a/ir/opt/opt_frame.c b/ir/opt/opt_frame.c index b9a0ac280..9304c282c 100644 --- a/ir/opt/opt_frame.c +++ b/ir/opt/opt_frame.c @@ -48,7 +48,6 @@ void opt_frame_irg(ir_graph *irg) { /* look for uses */ frame = get_irg_frame(irg); -#ifdef FIRM_EDGES_INPLACE if (edges_activated(irg)) { /* use inplace edges */ const ir_edge_t *edge; @@ -59,9 +58,7 @@ void opt_frame_irg(ir_graph *irg) { set_entity_link(ent, ent); } } - else -#endif /* FIRM_EDGES_INPLACE */ - { + else { /* use traditionally out edges */ if (get_irg_outs_state(irg) != outs_consistent) compute_irg_outs(irg); -- 2.20.1