Commit d935aa26 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add irn_visited_else_mark(), which combines irn_visited() and mark_irn_visited().

[r22563]
parent 25b98cff
......@@ -211,6 +211,9 @@ void set_irn_visited(ir_node *node, ir_visited_t visited);
void mark_irn_visited(ir_node *node);
/** Returns 1 if visited >= get_irg_visited(current_ir_graph). */
int irn_visited(const ir_node *node);
/** Returns 1 if visited >= get_irg_visited(current_ir_graph). Marks the node
* visited, if it was not. */
int irn_visited_else_mark(ir_node *node);
/**
* Sets the link of a node.
......
......@@ -537,8 +537,7 @@ static void cfscc(ir_node *n) {
assert(is_Block(n));
if (irn_visited(n)) return;
mark_irn_visited(n);
if (irn_visited_else_mark(n)) return;
/* Initialize the node */
set_irn_dfn(n, current_dfn); /* Depth first number for this node */
......
......@@ -111,7 +111,7 @@ static void pre_walk_calc_extbb(ir_node *block, void *ctx) {
*/
ir_node *cf_op = skip_Proj(get_Block_cfgpred(block, 0));
if (!irn_visited(cf_op)) {
if (!irn_visited_else_mark(cf_op)) {
ir_node *pred_bl = get_nodes_block(cf_op);
if (get_block_n_succs(pred_bl) > 2) {
/* More than two successors means we have a jump table.
......@@ -125,7 +125,6 @@ static void pre_walk_calc_extbb(ir_node *block, void *ctx) {
*/
set_Block_extbb(block, NULL);
}
mark_irn_visited(cf_op);
} else {
/* already marked, so begin a new extended block here */
allocate_extblk(block, env);
......
......@@ -109,11 +109,10 @@ static void create_extblk(ir_node *block, env_t *env)
{
ir_extblk *extblk;
if (irn_visited(block))
if (irn_visited_else_mark(block))
return;
extblk = allocate_extblk(block, env);
mark_irn_visited(block);
pick_successor(block, extblk, env);
}
......
......@@ -340,9 +340,7 @@ static int count_outs(ir_graph *irg) {
even if they are not visible. */
for (i = anchor_last - 1; i >= 0; --i) {
n = get_irg_anchor(irg, i);
if (!irn_visited(n)) {
mark_irn_visited(n);
if (!irn_visited_else_mark(n)) {
n->out = INT_TO_PTR(1);
++res;
}
......@@ -414,9 +412,7 @@ static ir_def_use_edge *set_out_edges(ir_graph *irg, ir_def_use_edge *free) {
/* handle anchored nodes */
for (i = anchor_last - 1; i >= 0; --i) {
n = get_irg_anchor(irg, i);
if (!irn_visited(n)) {
mark_irn_visited(n);
if (!irn_visited_else_mark(n)) {
n_outs = PTR_TO_INT(n->out);
n->out = free;
#ifdef DEBUG_libfirm
......
......@@ -715,9 +715,8 @@ static INLINE int is_outermost_loop(ir_loop *l) {
* @param n node to start
*/
static void scc(ir_node *n) {
if (irn_visited(n))
if (irn_visited_else_mark(n))
return;
mark_irn_visited(n);
/* Initialize the node */
set_irn_dfn(n, current_dfn); /* Depth first number for this node */
......@@ -816,9 +815,8 @@ static void scc(ir_node *n) {
#ifdef INTERPROCEDURAL_VIEW
static void my_scc(ir_node *n) {
int i;
if (irn_visited(n))
if (irn_visited_else_mark(n))
return;
mark_irn_visited(n);
/* Initialize the node */
set_irn_dfn(n, current_dfn); /* Depth first number for this node */
......
......@@ -273,11 +273,10 @@ static void pick_block_successor(blocksched_entry_t *entry, blocksched_env_t *en
const ir_edge_t *edge;
double best_succ_execfreq;
if (irn_visited(block))
if (irn_visited_else_mark(block))
return;
env->blockcount++;
mark_irn_visited(block);
DBG((dbg, LEVEL_1, "Pick succ of %+F\n", block));
......
......@@ -161,10 +161,9 @@ static void remove_empty_block(ir_node *block)
ir_node *succ_block;
ir_node *jump = NULL;
if (irn_visited(block))
if (irn_visited_else_mark(block))
return;
mark_irn_visited(block);
if (get_Block_n_cfgpreds(block) != 1)
goto check_preds;
......
......@@ -252,8 +252,8 @@ static ir_node** sched_node(ir_node** sched, ir_node* irn)
int arity = get_irn_arity(irn);
int i;
if (irn_visited(irn)) return sched;
if (is_End(irn)) return sched;
if (irn_visited_else_mark(irn)) return sched;
if (is_End(irn)) return sched;
if (!is_Phi(irn) && !be_is_Keep(irn)) {
for (i = 0; i < arity; ++i) {
......@@ -265,7 +265,6 @@ static ir_node** sched_node(ir_node** sched, ir_node* irn)
}
}
mark_irn_visited(irn);
ARR_APP1(ir_node*, sched, irn);
return sched;
}
......
......@@ -199,7 +199,7 @@ static void fill_and_activate_worklist(worklist_t *new_worklist,
continue;
}
if (irn_visited(value))
if (irn_visited_else_mark(value))
continue;
new_entry = obstack_alloc(&obst, sizeof(new_entry[0]));
......@@ -215,7 +215,6 @@ static void fill_and_activate_worklist(worklist_t *new_worklist,
list_add_tail(&new_entry->head, &new_worklist->live_values);
++n_live_values;
mark_irn_visited(value);
set_irn_link(value, new_entry);
new_worklist->n_live_values++;
}
......
......@@ -222,7 +222,7 @@ ir_node *search_def(be_ssa_construction_env_t *env, ir_node *at)
static
void introduce_def_at_block(ir_node *block, ir_node *def)
{
if(irn_visited(block)) {
if (irn_visited_else_mark(block)) {
ir_node *node = block;
ir_node *current_def;
......@@ -244,7 +244,6 @@ void introduce_def_at_block(ir_node *block, ir_node *def)
} else {
set_irn_link(block, def);
set_irn_link(def, NULL);
mark_irn_visited(block);
}
}
......
......@@ -174,11 +174,9 @@ static void fix_loops(ir_node *node) {
assert(node_is_in_irgs_storage(env.irg, node));
if (irn_visited(node))
if (irn_visited_else_mark(node))
return;
mark_irn_visited(node);
changed = 0;
if (! is_Block(node)) {
ir_node *block = get_nodes_block(node);
......
......@@ -908,9 +908,8 @@ static void check_out_edges(ir_node *node, verify_out_dead_nodes_env *env) {
ir_graph *irg = env->irg;
const ir_edge_t* edge;
if(irn_visited(node))
if (irn_visited_else_mark(node))
return;
mark_irn_visited(node);
/* we find too many (uncritical) dead nodes in block out edges */
if(is_Block(node))
......
......@@ -461,6 +461,10 @@ int (irn_visited)(const ir_node *node) {
return _irn_visited(node);
}
int (irn_visited_else_mark)(ir_node *node) {
return _irn_visited_else_mark(node);
}
void (set_irn_link)(ir_node *node, void *link) {
_set_irn_link(node, link);
}
......
......@@ -342,6 +342,14 @@ _irn_visited(const ir_node *node) {
return (node->visited >= current_ir_graph->visited);
}
static INLINE int
_irn_visited_else_mark(ir_node *node) {
if (_irn_visited(node))
return 1;
_mark_irn_visited(node);
return 0;
}
/**
* Sets the link of a node.
* Intern version of libFirm.
......@@ -1013,6 +1021,7 @@ _is_arg_Proj(const ir_node *node) {
#define set_irn_visited(node, v) _set_irn_visited(node, v)
#define mark_irn_visited(node) _mark_irn_visited(node)
#define irn_visited(node) _irn_visited(node)
#define irn_visited_else_mark(node) _irn_visited_else_mark(node)
#define set_irn_link(node, link) _set_irn_link(node, link)
#define get_irn_link(node) _get_irn_link(node)
#define get_irn_pinned(node) _get_irn_pinned(node)
......
......@@ -413,9 +413,8 @@ static ir_node *find_const_or_confirm(condeval_env_t *env, ir_node *jump, ir_nod
{
ir_node *block = get_nodes_block(jump);
if (irn_visited(value))
if (irn_visited_else_mark(value))
return NULL;
mark_irn_visited(value);
if (is_Const_or_Confirm(value)) {
if (eval_cmp(env, value) <= 0) {
......@@ -478,10 +477,9 @@ static ir_node *find_candidate(condeval_env_t *env, ir_node *jump,
{
ir_node *block = get_nodes_block(jump);
if(irn_visited(value)) {
if (irn_visited_else_mark(value)) {
return NULL;
}
mark_irn_visited(value);
if (is_Const_or_Confirm(value)) {
tarval *tv = get_Const_or_Confirm_tarval(value);
......
......@@ -310,7 +310,7 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel)
* visited more than once causing a ring here, so we use the
* node flag to mark linked nodes
*/
if (irn_visited(sel))
if (irn_visited_else_mark(sel))
return;
/*
......@@ -318,8 +318,6 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel)
*/
set_irn_link(sel, get_entity_link(ent));
set_entity_link(ent, sel);
mark_irn_visited(sel);
}
/* we need a special address that serves as an address taken marker */
......
......@@ -438,11 +438,9 @@ static unsigned _follow_mem(ir_node *node) {
if (mode == mtp_no_property)
return mtp_no_property;
if (irn_visited(node))
if (irn_visited_else_mark(node))
return mode;
mark_irn_visited(node);
switch (get_irn_opcode(node)) {
case iro_Proj:
node = get_Proj_pred(node);
......
......@@ -290,7 +290,7 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel) {
* visited more than once causing a ring here, so we use the
* node flag to mark linked nodes
*/
if (irn_visited(sel))
if (irn_visited_else_mark(sel))
return;
/* we know we are at a leave, because this function is only
......@@ -299,8 +299,6 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel) {
*/
set_irn_link(sel, get_entity_link(ent));
set_entity_link(ent, sel);
mark_irn_visited(sel);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment