* ... -> Proj -> NULL. */
static void collect_phicallproj(void) {
int i;
+
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
ir_node * start = get_irg_start(irg);
ir_node * end = get_irg_end(irg);
current_ir_graph = irg;
assert(irg && start);
+
+ set_using_irn_link(irg);
+
/* Die speziellen Parameter der Start-Operation extra verlinken,
* auch wenn sie nicht im intraprozeduralen Graphen erreichbar
* sind. */
link(start, get_irg_globals(irg));
/* walk */
irg_walk_graph(irg, firm_clear_link, (irg_walk_func *) collect_phicallproj_walker, &end);
+
+ clear_using_irn_link(irg);
}
}
static ir_node **construct_block_lists(ir_graph *irg) {
int i;
int rem_view = get_interprocedural_view();
- int walk_flag = inside_irg_walk(irg);
+ int walk_flag = using_visited(irg);
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
- clear_inside_irg_walk(current_ir_graph);
+ if(walk_flag)
+ clear_using_visited(current_ir_graph);
for (i = get_irp_n_irgs() - 1; i >= 0; --i)
ird_set_irg_link(get_irp_irg(i), NULL);
set_interprocedural_view(rem_view);
- if (walk_flag)
- set_inside_irg_walk(current_ir_graph);
+ if(walk_flag)
+ set_using_visited(current_ir_graph);
current_ir_graph = rem;
return ird_get_irg_link(irg);
set_irg_doms_inconsistent(irg);
set_irg_loopinfo_inconsistent(irg);
+ set_using_irn_link(irg);
+
/* walk over the graph */
irg_walk_graph(irg, NULL, opt_walker, waitq);
del_pdeq(waitq);
+ clear_using_irn_link(irg);
+
if (! state)
edges_deactivate(irg);
return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL;
}
-/* Sets the inside block walk flag */
-void (set_inside_block_walk)(ir_graph *irg) {
- _set_inside_block_walk(irg);
+#ifndef NDEBUG
+void set_using_block_visited(ir_graph *irg) {
+ assert(irg->using_block_visited == 0);
+ irg->using_block_visited = 1;
}
-/* Clears the inside block walk flag */
-void (clear_inside_block_walk)(ir_graph *irg) {
- _clear_inside_block_walk(irg);
+void clear_using_block_visited(ir_graph *irg) {
+ assert(irg->using_block_visited == 1);
+ irg->using_block_visited = 0;
}
-/* Returns the inside block walk flag */
-unsigned (inside_block_walk)(const ir_graph *irg) {
- return _inside_block_walk(irg);
+int using_block_visited(const ir_graph *irg) {
+ return irg->using_block_visited;
}
-/* Sets the inside irg walk flag */
-void (set_inside_irg_walk)(ir_graph *irg) {
- _clear_inside_irg_walk(irg);
+
+void set_using_visited(ir_graph *irg) {
+ assert(irg->using_visited == 0);
+ irg->using_visited = 1;
}
-/* Clears the inside irg walk flag */
-void (clear_inside_irg_walk)(ir_graph *irg) {
- _clear_inside_irg_walk(irg);
+void clear_using_visited(ir_graph *irg) {
+ assert(irg->using_visited == 1);
+ irg->using_visited = 0;
}
-/* Returns the inside irg walk flag */
-unsigned (inside_irg_walk)(const ir_graph *irg) {
- return _inside_irg_walk(irg);
+int using_visited(const ir_graph *irg) {
+ return irg->using_visited;
}
+
+void set_using_irn_link(ir_graph *irg) {
+ assert(irg->using_irn_link == 0);
+ irg->using_irn_link = 1;
+}
+
+void clear_using_irn_link(ir_graph *irg) {
+ assert(irg->using_irn_link == 1);
+ irg->using_irn_link = 0;
+}
+
+int using_irn_link(const ir_graph *irg) {
+ return irg->using_irn_link;
+}
+#endif
+
/* Returns a estimated node count of the irg. */
unsigned (get_irg_estimated_node_cnt)(const ir_graph *irg) {
return _get_irg_estimated_node_cnt(irg);
unsigned long get_irg_block_visited (const ir_graph *irg);
void set_irg_block_visited (ir_graph *irg, unsigned long i);
-/** Flags indicating whether or not we are inside an irg/block walk. */
-void set_inside_block_walk(ir_graph *irg);
-void clear_inside_block_walk(ir_graph *irg);
-unsigned inside_block_walk(const ir_graph *irg);
-void set_inside_irg_walk(ir_graph *irg);
-void clear_inside_irg_walk(ir_graph *irg);
-unsigned inside_irg_walk(const ir_graph *irg);
+/**
+ * Debug helpers: You can indicate wether you are currently using visited or
+ * block_visited flags. If NDEBUG is not defined, then the compiler will abort
+ * if 2 parties try to use the flags.
+ */
+#ifndef NDEBUG
+void set_using_block_visited(ir_graph *irg);
+void clear_using_block_visited(ir_graph *irg);
+int using_block_visited(const ir_graph *irg);
+void set_using_visited(ir_graph *irg);
+void clear_using_visited(ir_graph *irg);
+int using_visited(const ir_graph *irg);
+void set_using_irn_link(ir_graph *irg);
+void clear_using_irn_link(ir_graph *irg);
+int using_irn_link(const ir_graph *irg);
+#else
+static INLINE void set_using_block_visited(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_block_visited(ir_graph *irg) { (void) irg; }
+static int using_block_visited(const ir_graph *irg) { (void) irg; return 0; }
+static INLINE void set_using_visited(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_visited(ir_graph *irg) { (void) irg; }
+static int using_visited(const ir_graph *irg) { (void) irg; return 0; }
+static INLINE void set_using_irn_link(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_irn_link(ir_graph *irg) { (void) irg; }
+static int using_irn_link(const ir_graph *irg) { (void) irg; return 0; }
+#endif
/** move Proj nodes into the same block as its predecessors */
void normalize_proj_nodes(ir_graph *irg);
every time someone walks through
the graph */
unsigned long block_visited; /**< same as visited, for a complete block */
- unsigned inside_irg_walk : 1; /**< set to 1 if we are currently in an irg walk */
- unsigned inside_block_walk : 1; /**< set to 1 if we are currently in a block walk */
+
+#ifndef NDEBUG
+ unsigned using_visited : 1; /**< set to 1 if we are currently using the visited flag */
+ unsigned using_block_visited : 1; /**< set to 1 if we are currently using the block_visited flag */
+ unsigned using_irn_link : 1; /**< set to 1 if we are currently using the irn_link fields */
+#endif
+
unsigned estimated_node_count; /**< estimated number of nodes in this graph,
updated after every walk */
irg_edges_info_t edge_info; /**< edge info for automatic outs */
--irg->block_visited;
}
-static INLINE void
-_set_inside_block_walk(ir_graph *irg) {
- irg->inside_block_walk = 1;
-}
-
-static INLINE void
-_clear_inside_block_walk(ir_graph *irg) {
- irg->inside_block_walk = 0;
-}
-
-static INLINE unsigned
-_inside_block_walk(const ir_graph *irg) {
- return irg->inside_block_walk;
-}
-
-static INLINE void
-_set_inside_irg_walk(ir_graph *irg) {
- irg->inside_irg_walk = 1;
-}
-
-static INLINE void
-_clear_inside_irg_walk(ir_graph *irg) {
- irg->inside_irg_walk = 0;
-}
-
-static INLINE unsigned
-_inside_irg_walk(const ir_graph *irg) {
- return irg->inside_irg_walk;
-}
-
static INLINE unsigned
_get_irg_estimated_node_cnt(const ir_graph *irg) {
return irg->estimated_node_count;
#define set_irg_block_visited(irg, v) _set_irg_block_visited(irg, v)
#define inc_irg_block_visited(irg) _inc_irg_block_visited(irg)
#define dec_irg_block_visited(irg) _dec_irg_block_visited(irg)
-#define set_inside_block_walk(irg) _set_inside_block_walk(irg)
-#define clear_inside_block_walk(irg) _clear_inside_block_walk(irg)
-#define inside_block_walk(irg) _inside_block_walk(irg)
-#define set_inside_irg_walk(irg) _set_inside_irg_walk(irg)
-#define clear_inside_irg_walk(irg) _clear_inside_irg_walk(irg)
-#define inside_irg_walk(irg) _inside_irg_walk(irg)
#define get_irg_estimated_node_cnt(irg) _get_irg_estimated_node_cnt(irg)
#define get_irg_fp_model(irg) _get_irg_fp_model(irg)
irg_walk_cg(node, visited, irg_set, pre, post, env);
eset_destroy(irg_set);
} else {
- assert(! inside_irg_walk(current_ir_graph)); /* we must not already be inside an irg walk */
- set_inside_irg_walk(current_ir_graph);
+ set_using_visited(current_ir_graph);
inc_irg_visited(current_ir_graph);
nodes_touched = irg_walk_2(node, pre, post, env);
- clear_inside_irg_walk(current_ir_graph);
+ clear_using_visited(current_ir_graph);
}
return;
}
if (get_interprocedural_view()) {
assert(0 && "This is not yet implemented.");
} else {
- assert(! inside_irg_walk(current_ir_graph)); /* we must not already be inside an irg walk */
- set_inside_irg_walk(current_ir_graph);
+ set_using_visited(current_ir_graph);
inc_irg_visited(current_ir_graph);
nodes_touched = irg_walk_in_or_dep_2(node, pre, post, env);
- clear_inside_irg_walk(current_ir_graph);
+ clear_using_visited(current_ir_graph);
}
return;
}
assert(node);
assert(!get_interprocedural_view()); /* interprocedural_view not implemented, because it
* interleaves with irg_walk */
- assert(! inside_irg_walk(current_ir_graph)); /* we must not already be in a block walk */
+ set_using_block_visited(current_ir_graph);
inc_irg_block_visited(current_ir_graph);
- set_inside_block_walk(current_ir_graph);
block = is_Block(node) ? node : get_nodes_block(node);
assert(get_irn_op(block) == op_Block);
irg_block_walk_2(block, pre, post, env);
}
}
- clear_inside_block_walk(current_ir_graph);
- return;
+ clear_using_block_visited(current_ir_graph);
}
/*
int old_view = get_interprocedural_view();
block_entry_t *entry;
- assert(! inside_irg_walk(irg)); /* we must not already be inside an irg walk */
- set_inside_irg_walk(irg);
-
/* switch off interprocedural view */
set_interprocedural_view(0);
blks.follow_deps = follow_deps != 0;
/* first step: traverse the graph and fill the lists */
+ set_using_visited(irg);
inc_irg_visited(irg);
collect_walk(end_node, &blks);
obstack_free(&blks.obst, NULL);
set_interprocedural_view(old_view);
- clear_inside_irg_walk(irg);
+ clear_using_visited(irg);
}
void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
#include "iredges.h"
#include "iredges_t.h"
#include "irtools.h"
+#include "irgraph.h"
#include "tv.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);
int changed;
FIRM_DBG_REGISTER(dbg, "firm.opt.condeval");
- //firm_dbg_set_mask(dbg, SET_LEVEL_5);
DB((dbg, LEVEL_1, "===> Performing condition evaluation on %+F\n", irg));
normalize_proj_nodes(irg);
+ set_using_irn_link(irg);
+ set_using_visited(irg);
+
do {
changed = 0;
irg_block_walk_graph(irg, cond_eval, NULL, &changed);
} while(changed);
+
+ clear_using_visited(irg);
+ clear_using_irn_link(irg);
}