Commit b6e7e9af by Kazu Hirata Committed by Kazu Hirata

sbitmap.h (sbitmap_iterator, [...]): New.

	* sbitmap.h (sbitmap_iterator, sbitmap_iter_init,
	sbitmap_iter_cond, sbitmap_iter_next): New.
	* bt-load.c, cfganal.c, combine.c, ddg.c, flow.c,
	modulo-sched.c, sbitmap.c, sched-rgn.c, tree-into-ssa.c,
	tree-outof-ssa.c, tree-ssa-alias.c, tree-ssa-live.c: Update
	uses of EXECUTE_IF_SET_IN_SBITMAP to the new style.

From-SVN: r100709
parent ac182688
2005-06-07 Kazu Hirata <kazu@codesourcery.com>
* sbitmap.h (sbitmap_iterator, sbitmap_iter_init,
sbitmap_iter_cond, sbitmap_iter_next): New.
* bt-load.c, cfganal.c, combine.c, ddg.c, flow.c,
modulo-sched.c, sbitmap.c, sched-rgn.c, tree-into-ssa.c,
tree-outof-ssa.c, tree-ssa-alias.c, tree-ssa-live.c: Update
uses of EXECUTE_IF_SET_IN_SBITMAP to the new style.
2005-06-07 Zdenek Dvorak <dvorakz@suse.cz> 2005-06-07 Zdenek Dvorak <dvorakz@suse.cz>
* tree-ssa-address.c: New file. * tree-ssa-address.c: New file.
......
...@@ -699,7 +699,8 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out, ...@@ -699,7 +699,8 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
{ {
/* Find all the reaching defs for this use. */ /* Find all the reaching defs for this use. */
sbitmap reaching_defs_of_reg = sbitmap_alloc(max_uid); sbitmap reaching_defs_of_reg = sbitmap_alloc(max_uid);
int uid; unsigned int uid;
sbitmap_iterator sbi;
if (user->use) if (user->use)
sbitmap_a_and_b ( sbitmap_a_and_b (
...@@ -720,7 +721,7 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out, ...@@ -720,7 +721,7 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
reaching_defs, reaching_defs,
btr_defset[reg - first_btr]); btr_defset[reg - first_btr]);
} }
EXECUTE_IF_SET_IN_SBITMAP (reaching_defs_of_reg, 0, uid, EXECUTE_IF_SET_IN_SBITMAP (reaching_defs_of_reg, 0, uid, sbi)
{ {
btr_def def = def_array[uid]; btr_def def = def_array[uid];
...@@ -752,7 +753,7 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out, ...@@ -752,7 +753,7 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
def->other_btr_uses_after_use = 1; def->other_btr_uses_after_use = 1;
user->next = def->uses; user->next = def->uses;
def->uses = user; def->uses = user;
}); }
sbitmap_free (reaching_defs_of_reg); sbitmap_free (reaching_defs_of_reg);
} }
......
...@@ -521,13 +521,15 @@ find_edge_index (struct edge_list *edge_list, basic_block pred, basic_block succ ...@@ -521,13 +521,15 @@ find_edge_index (struct edge_list *edge_list, basic_block pred, basic_block succ
void void
flow_nodes_print (const char *str, const sbitmap nodes, FILE *file) flow_nodes_print (const char *str, const sbitmap nodes, FILE *file)
{ {
int node; unsigned int node;
sbitmap_iterator sbi;
if (! nodes) if (! nodes)
return; return;
fprintf (file, "%s { ", str); fprintf (file, "%s { ", str);
EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, node, {fprintf (file, "%d ", node);}); EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, node, sbi)
fprintf (file, "%d ", node);
fputs ("}\n", file); fputs ("}\n", file);
} }
......
...@@ -639,7 +639,9 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -639,7 +639,9 @@ combine_instructions (rtx f, unsigned int nregs)
rtx prev; rtx prev;
#endif #endif
int i; int i;
unsigned int j;
rtx links, nextlinks; rtx links, nextlinks;
sbitmap_iterator sbi;
int new_direct_jump_p = 0; int new_direct_jump_p = 0;
...@@ -884,8 +886,8 @@ combine_instructions (rtx f, unsigned int nregs) ...@@ -884,8 +886,8 @@ combine_instructions (rtx f, unsigned int nregs)
} }
clear_bb_flags (); clear_bb_flags ();
EXECUTE_IF_SET_IN_SBITMAP (refresh_blocks, 0, i, EXECUTE_IF_SET_IN_SBITMAP (refresh_blocks, 0, j, sbi)
BASIC_BLOCK (i)->flags |= BB_DIRTY); BASIC_BLOCK (j)->flags |= BB_DIRTY;
new_direct_jump_p |= purge_all_dead_edges (); new_direct_jump_p |= purge_all_dead_edges ();
delete_noop_moves (); delete_noop_moves ();
......
...@@ -692,7 +692,8 @@ static ddg_scc_ptr ...@@ -692,7 +692,8 @@ static ddg_scc_ptr
create_scc (ddg_ptr g, sbitmap nodes) create_scc (ddg_ptr g, sbitmap nodes)
{ {
ddg_scc_ptr scc; ddg_scc_ptr scc;
int u; unsigned int u;
sbitmap_iterator sbi;
scc = (ddg_scc_ptr) xmalloc (sizeof (struct ddg_scc)); scc = (ddg_scc_ptr) xmalloc (sizeof (struct ddg_scc));
scc->backarcs = NULL; scc->backarcs = NULL;
...@@ -701,7 +702,7 @@ create_scc (ddg_ptr g, sbitmap nodes) ...@@ -701,7 +702,7 @@ create_scc (ddg_ptr g, sbitmap nodes)
sbitmap_copy (scc->nodes, nodes); sbitmap_copy (scc->nodes, nodes);
/* Mark the backarcs that belong to this SCC. */ /* Mark the backarcs that belong to this SCC. */
EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, sbi)
{ {
ddg_edge_ptr e; ddg_edge_ptr e;
ddg_node_ptr n = &g->nodes[u]; ddg_node_ptr n = &g->nodes[u];
...@@ -713,7 +714,7 @@ create_scc (ddg_ptr g, sbitmap nodes) ...@@ -713,7 +714,7 @@ create_scc (ddg_ptr g, sbitmap nodes)
if (e->distance > 0) if (e->distance > 0)
add_backarc_to_scc (scc, e); add_backarc_to_scc (scc, e);
} }
}); }
set_recurrence_length (scc, g); set_recurrence_length (scc, g);
return scc; return scc;
...@@ -782,13 +783,14 @@ get_node_of_insn (ddg_ptr g, rtx insn) ...@@ -782,13 +783,14 @@ get_node_of_insn (ddg_ptr g, rtx insn)
void void
find_successors (sbitmap succ, ddg_ptr g, sbitmap ops) find_successors (sbitmap succ, ddg_ptr g, sbitmap ops)
{ {
int i; unsigned int i;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (ops, 0, i, EXECUTE_IF_SET_IN_SBITMAP (ops, 0, i, sbi)
{ {
const sbitmap node_succ = NODE_SUCCESSORS (&g->nodes[i]); const sbitmap node_succ = NODE_SUCCESSORS (&g->nodes[i]);
sbitmap_a_or_b (succ, succ, node_succ); sbitmap_a_or_b (succ, succ, node_succ);
}); };
/* We want those that are not in ops. */ /* We want those that are not in ops. */
sbitmap_difference (succ, succ, ops); sbitmap_difference (succ, succ, ops);
...@@ -800,13 +802,14 @@ find_successors (sbitmap succ, ddg_ptr g, sbitmap ops) ...@@ -800,13 +802,14 @@ find_successors (sbitmap succ, ddg_ptr g, sbitmap ops)
void void
find_predecessors (sbitmap preds, ddg_ptr g, sbitmap ops) find_predecessors (sbitmap preds, ddg_ptr g, sbitmap ops)
{ {
int i; unsigned int i;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (ops, 0, i, EXECUTE_IF_SET_IN_SBITMAP (ops, 0, i, sbi)
{ {
const sbitmap node_preds = NODE_PREDECESSORS (&g->nodes[i]); const sbitmap node_preds = NODE_PREDECESSORS (&g->nodes[i]);
sbitmap_a_or_b (preds, preds, node_preds); sbitmap_a_or_b (preds, preds, node_preds);
}); };
/* We want those that are not in ops. */ /* We want those that are not in ops. */
sbitmap_difference (preds, preds, ops); sbitmap_difference (preds, preds, ops);
...@@ -901,8 +904,11 @@ int ...@@ -901,8 +904,11 @@ int
find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to) find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
{ {
int answer; int answer;
int change, u; int change;
unsigned int u;
int num_nodes = g->num_nodes; int num_nodes = g->num_nodes;
sbitmap_iterator sbi;
sbitmap workset = sbitmap_alloc (num_nodes); sbitmap workset = sbitmap_alloc (num_nodes);
sbitmap reachable_from = sbitmap_alloc (num_nodes); sbitmap reachable_from = sbitmap_alloc (num_nodes);
sbitmap reach_to = sbitmap_alloc (num_nodes); sbitmap reach_to = sbitmap_alloc (num_nodes);
...@@ -917,7 +923,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to) ...@@ -917,7 +923,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
change = 0; change = 0;
sbitmap_copy (workset, tmp); sbitmap_copy (workset, tmp);
sbitmap_zero (tmp); sbitmap_zero (tmp);
EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, sbi)
{ {
ddg_edge_ptr e; ddg_edge_ptr e;
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
...@@ -934,7 +940,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to) ...@@ -934,7 +940,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
change = 1; change = 1;
} }
} }
}); }
} }
sbitmap_copy (reach_to, to); sbitmap_copy (reach_to, to);
...@@ -946,7 +952,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to) ...@@ -946,7 +952,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
change = 0; change = 0;
sbitmap_copy (workset, tmp); sbitmap_copy (workset, tmp);
sbitmap_zero (tmp); sbitmap_zero (tmp);
EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, sbi)
{ {
ddg_edge_ptr e; ddg_edge_ptr e;
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
...@@ -963,7 +969,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to) ...@@ -963,7 +969,7 @@ find_nodes_on_paths (sbitmap result, ddg_ptr g, sbitmap from, sbitmap to)
change = 1; change = 1;
} }
} }
}); }
} }
answer = sbitmap_a_and_b_cg (result, reachable_from, reach_to); answer = sbitmap_a_and_b_cg (result, reachable_from, reach_to);
...@@ -1008,7 +1014,8 @@ update_dist_to_successors (ddg_node_ptr u_node, sbitmap nodes, sbitmap tmp) ...@@ -1008,7 +1014,8 @@ update_dist_to_successors (ddg_node_ptr u_node, sbitmap nodes, sbitmap tmp)
int int
longest_simple_path (struct ddg * g, int src, int dest, sbitmap nodes) longest_simple_path (struct ddg * g, int src, int dest, sbitmap nodes)
{ {
int i, u; int i;
unsigned int u;
int change = 1; int change = 1;
int result; int result;
int num_nodes = g->num_nodes; int num_nodes = g->num_nodes;
...@@ -1027,15 +1034,17 @@ longest_simple_path (struct ddg * g, int src, int dest, sbitmap nodes) ...@@ -1027,15 +1034,17 @@ longest_simple_path (struct ddg * g, int src, int dest, sbitmap nodes)
while (change) while (change)
{ {
sbitmap_iterator sbi;
change = 0; change = 0;
sbitmap_copy (workset, tmp); sbitmap_copy (workset, tmp);
sbitmap_zero (tmp); sbitmap_zero (tmp);
EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, EXECUTE_IF_SET_IN_SBITMAP (workset, 0, u, sbi)
{ {
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
change |= update_dist_to_successors (u_node, nodes, tmp); change |= update_dist_to_successors (u_node, nodes, tmp);
}); }
} }
result = g->nodes[dest].aux.count; result = g->nodes[dest].aux.count;
sbitmap_free (workset); sbitmap_free (workset);
......
...@@ -653,7 +653,9 @@ update_life_info (sbitmap blocks, enum update_life_extent extent, ...@@ -653,7 +653,9 @@ update_life_info (sbitmap blocks, enum update_life_extent extent,
if (blocks) if (blocks)
{ {
EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, sbi)
{ {
bb = BASIC_BLOCK (i); bb = BASIC_BLOCK (i);
...@@ -662,7 +664,7 @@ update_life_info (sbitmap blocks, enum update_life_extent extent, ...@@ -662,7 +664,7 @@ update_life_info (sbitmap blocks, enum update_life_extent extent,
if (extent == UPDATE_LIFE_LOCAL) if (extent == UPDATE_LIFE_LOCAL)
verify_local_live_at_start (tmp, bb); verify_local_live_at_start (tmp, bb);
}); };
} }
else else
{ {
...@@ -1032,7 +1034,7 @@ calculate_global_regs_live (sbitmap blocks_in, sbitmap blocks_out, int flags) ...@@ -1032,7 +1034,7 @@ calculate_global_regs_live (sbitmap blocks_in, sbitmap blocks_out, int flags)
In other words, regs that are set only as part of a COND_EXEC. */ In other words, regs that are set only as part of a COND_EXEC. */
regset *cond_local_sets; regset *cond_local_sets;
int i; unsigned int i;
/* Some passes used to forget clear aux field of basic block causing /* Some passes used to forget clear aux field of basic block causing
sick behavior here. */ sick behavior here. */
...@@ -1406,12 +1408,14 @@ calculate_global_regs_live (sbitmap blocks_in, sbitmap blocks_out, int flags) ...@@ -1406,12 +1408,14 @@ calculate_global_regs_live (sbitmap blocks_in, sbitmap blocks_out, int flags)
if (blocks_out) if (blocks_out)
{ {
EXECUTE_IF_SET_IN_SBITMAP (blocks_out, 0, i, sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (blocks_out, 0, i, sbi)
{ {
basic_block bb = BASIC_BLOCK (i); basic_block bb = BASIC_BLOCK (i);
FREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]); FREE_REG_SET (local_sets[bb->index - (INVALID_BLOCK + 1)]);
FREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]); FREE_REG_SET (cond_local_sets[bb->index - (INVALID_BLOCK + 1)]);
}); };
} }
else else
{ {
...@@ -4355,7 +4359,7 @@ int ...@@ -4355,7 +4359,7 @@ int
count_or_remove_death_notes (sbitmap blocks, int kill) count_or_remove_death_notes (sbitmap blocks, int kill)
{ {
int count = 0; int count = 0;
int i; unsigned int i;
basic_block bb; basic_block bb;
/* This used to be a loop over all the blocks with a membership test /* This used to be a loop over all the blocks with a membership test
...@@ -4367,10 +4371,12 @@ count_or_remove_death_notes (sbitmap blocks, int kill) ...@@ -4367,10 +4371,12 @@ count_or_remove_death_notes (sbitmap blocks, int kill)
than an sbitmap. */ than an sbitmap. */
if (blocks) if (blocks)
{ {
EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, sbi)
{ {
count += count_or_remove_death_notes_bb (BASIC_BLOCK (i), kill); count += count_or_remove_death_notes_bb (BASIC_BLOCK (i), kill);
}); };
} }
else else
{ {
...@@ -4450,7 +4456,6 @@ static void ...@@ -4450,7 +4456,6 @@ static void
clear_log_links (sbitmap blocks) clear_log_links (sbitmap blocks)
{ {
rtx insn; rtx insn;
int i;
if (!blocks) if (!blocks)
{ {
...@@ -4459,15 +4464,20 @@ clear_log_links (sbitmap blocks) ...@@ -4459,15 +4464,20 @@ clear_log_links (sbitmap blocks)
free_INSN_LIST_list (&LOG_LINKS (insn)); free_INSN_LIST_list (&LOG_LINKS (insn));
} }
else else
EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, {
{ unsigned int i;
basic_block bb = BASIC_BLOCK (i); sbitmap_iterator sbi;
for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, sbi)
insn = NEXT_INSN (insn)) {
if (INSN_P (insn)) basic_block bb = BASIC_BLOCK (i);
free_INSN_LIST_list (&LOG_LINKS (insn));
}); for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb));
insn = NEXT_INSN (insn))
if (INSN_P (insn))
free_INSN_LIST_list (&LOG_LINKS (insn));
}
}
} }
/* Given a register bitmap, turn on the bits in a HARD_REG_SET that /* Given a register bitmap, turn on the bits in a HARD_REG_SET that
......
...@@ -499,9 +499,10 @@ generate_reg_moves (partial_schedule_ptr ps) ...@@ -499,9 +499,10 @@ generate_reg_moves (partial_schedule_ptr ps)
for (i_reg_move = 0; i_reg_move < nreg_moves; i_reg_move++) for (i_reg_move = 0; i_reg_move < nreg_moves; i_reg_move++)
{ {
int i_use; unsigned int i_use;
rtx new_reg = gen_reg_rtx (GET_MODE (prev_reg)); rtx new_reg = gen_reg_rtx (GET_MODE (prev_reg));
rtx reg_move = gen_move_insn (new_reg, prev_reg); rtx reg_move = gen_move_insn (new_reg, prev_reg);
sbitmap_iterator sbi;
add_insn_before (reg_move, last_reg_move); add_insn_before (reg_move, last_reg_move);
last_reg_move = reg_move; last_reg_move = reg_move;
...@@ -509,7 +510,7 @@ generate_reg_moves (partial_schedule_ptr ps) ...@@ -509,7 +510,7 @@ generate_reg_moves (partial_schedule_ptr ps)
if (!SCHED_FIRST_REG_MOVE (u)) if (!SCHED_FIRST_REG_MOVE (u))
SCHED_FIRST_REG_MOVE (u) = reg_move; SCHED_FIRST_REG_MOVE (u) = reg_move;
EXECUTE_IF_SET_IN_SBITMAP (uses_of_defs[i_reg_move], 0, i_use, EXECUTE_IF_SET_IN_SBITMAP (uses_of_defs[i_reg_move], 0, i_use, sbi)
{ {
struct undo_replace_buff_elem *rep; struct undo_replace_buff_elem *rep;
...@@ -528,7 +529,7 @@ generate_reg_moves (partial_schedule_ptr ps) ...@@ -528,7 +529,7 @@ generate_reg_moves (partial_schedule_ptr ps)
} }
replace_rtx (g->nodes[i_use].insn, old_reg, new_reg); replace_rtx (g->nodes[i_use].insn, old_reg, new_reg);
}); }
prev_reg = new_reg; prev_reg = new_reg;
} }
...@@ -1842,11 +1843,12 @@ calculate_order_params (ddg_ptr g, int mii ATTRIBUTE_UNUSED) ...@@ -1842,11 +1843,12 @@ calculate_order_params (ddg_ptr g, int mii ATTRIBUTE_UNUSED)
static int static int
find_max_asap (ddg_ptr g, sbitmap nodes) find_max_asap (ddg_ptr g, sbitmap nodes)
{ {
int u; unsigned int u;
int max_asap = -1; int max_asap = -1;
int result = -1; int result = -1;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, sbi)
{ {
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
...@@ -1855,19 +1857,20 @@ find_max_asap (ddg_ptr g, sbitmap nodes) ...@@ -1855,19 +1857,20 @@ find_max_asap (ddg_ptr g, sbitmap nodes)
max_asap = ASAP (u_node); max_asap = ASAP (u_node);
result = u; result = u;
} }
}); }
return result; return result;
} }
static int static int
find_max_hv_min_mob (ddg_ptr g, sbitmap nodes) find_max_hv_min_mob (ddg_ptr g, sbitmap nodes)
{ {
int u; unsigned int u;
int max_hv = -1; int max_hv = -1;
int min_mob = INT_MAX; int min_mob = INT_MAX;
int result = -1; int result = -1;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, sbi)
{ {
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
...@@ -1883,19 +1886,20 @@ find_max_hv_min_mob (ddg_ptr g, sbitmap nodes) ...@@ -1883,19 +1886,20 @@ find_max_hv_min_mob (ddg_ptr g, sbitmap nodes)
min_mob = MOB (u_node); min_mob = MOB (u_node);
result = u; result = u;
} }
}); }
return result; return result;
} }
static int static int
find_max_dv_min_mob (ddg_ptr g, sbitmap nodes) find_max_dv_min_mob (ddg_ptr g, sbitmap nodes)
{ {
int u; unsigned int u;
int max_dv = -1; int max_dv = -1;
int min_mob = INT_MAX; int min_mob = INT_MAX;
int result = -1; int result = -1;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, EXECUTE_IF_SET_IN_SBITMAP (nodes, 0, u, sbi)
{ {
ddg_node_ptr u_node = &g->nodes[u]; ddg_node_ptr u_node = &g->nodes[u];
...@@ -1911,7 +1915,7 @@ find_max_dv_min_mob (ddg_ptr g, sbitmap nodes) ...@@ -1911,7 +1915,7 @@ find_max_dv_min_mob (ddg_ptr g, sbitmap nodes)
min_mob = MOB (u_node); min_mob = MOB (u_node);
result = u; result = u;
} }
}); }
return result; return result;
} }
......
...@@ -691,8 +691,10 @@ int ...@@ -691,8 +691,10 @@ int
sbitmap_first_set_bit (sbitmap bmap) sbitmap_first_set_bit (sbitmap bmap)
{ {
unsigned int n; unsigned int n;
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (bmap, 0, n, { return n; }); EXECUTE_IF_SET_IN_SBITMAP (bmap, 0, n, sbi)
return n;
return -1; return -1;
} }
......
...@@ -55,36 +55,86 @@ typedef SBITMAP_ELT_TYPE *sbitmap_ptr; ...@@ -55,36 +55,86 @@ typedef SBITMAP_ELT_TYPE *sbitmap_ptr;
((BITMAP)->elms [(BITNO) / SBITMAP_ELT_BITS] \ ((BITMAP)->elms [(BITNO) / SBITMAP_ELT_BITS] \
&= ~((SBITMAP_ELT_TYPE) 1 << (BITNO) % SBITMAP_ELT_BITS)) &= ~((SBITMAP_ELT_TYPE) 1 << (BITNO) % SBITMAP_ELT_BITS))
/* Loop over all elements of SBITSET, starting with MIN. */ /* The iterator for sbitmap. */
#define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, CODE) \ typedef struct {
do { \ /* The pointer to the first word of the bitmap. */
unsigned int word_num_ = (MIN) / (unsigned int) SBITMAP_ELT_BITS; \ SBITMAP_ELT_TYPE *ptr;
unsigned int bit_num_ = (MIN) % (unsigned int) SBITMAP_ELT_BITS; \
unsigned int size_ = (SBITMAP)->size; \ /* The size of the bitmap. */
SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms; \ unsigned int size;
SBITMAP_ELT_TYPE word_; \
\ /* The current word index. */
if (word_num_ < size_) \ unsigned int word_num;
{ \
word_ = ptr_[word_num_] >> bit_num_; \ /* The current bit index. */
\ unsigned int bit_num;
while (1) \
{ \ /* The words currently visited. */
for (; word_ != 0; word_ >>= 1, bit_num_++) \ SBITMAP_ELT_TYPE word;
{ \ } sbitmap_iterator;
if ((word_ & 1) != 0) \
{ \ /* Initialize the iterator I with sbitmap BMP and the initial index
(N) = word_num_ * SBITMAP_ELT_BITS + bit_num_; \ MIN. */
CODE; \
} \ static inline void
} \ sbitmap_iter_init (sbitmap_iterator *i, sbitmap bmp, unsigned int min)
word_num_++; \ {
if (word_num_ >= size_) \ i->word_num = min / (unsigned int) SBITMAP_ELT_BITS;
break; \ i->bit_num = min % (unsigned int) SBITMAP_ELT_BITS;
bit_num_ = 0, word_ = ptr_[word_num_]; \ i->size = bmp->size;
} \ i->ptr = bmp->elms;
} \
} while (0) if (i->word_num >= i->size)
i->word = 0;
else
i->word = i->ptr[i->word_num] >> i->bit_num;
}
/* Return true if we have more bits to visit, in which case *N is set
to the index of the bit to be visited. Otherwise, return
false. */
static inline bool
sbitmap_iter_cond (sbitmap_iterator *i, unsigned int *n)
{
/* Skip words that are zeros. */
for (; i->word == 0; i->word = i->ptr[i->word_num])
{
i->word_num++;
/* If we have reached the end, break. */
if (i->word_num >= i->size)
return false;
i->bit_num = i->word_num * SBITMAP_ELT_BITS;
}
/* Skip bits that are zero. */
for (; (i->word & 1) == 0; i->word >>= 1)
i->bit_num++;
*n = i->bit_num;
return true;
}
/* Advance to the next bit. */
static inline void
sbitmap_iter_next (sbitmap_iterator *i)
{
i->word >>= 1;
i->bit_num++;
}
/* Loop over all elements of SBITMAP, starting with MIN. In each
iteration, N is set to the index of the bit being visited. ITER is
an instance of sbitmap_iterator used to iterate the bitmap. */
#define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, ITER) \
for (sbitmap_iter_init (&(ITER), (SBITMAP), (MIN)); \
sbitmap_iter_cond (&(ITER), &(N)); \
sbitmap_iter_next (&(ITER)))
#define EXECUTE_IF_SET_IN_SBITMAP_REV(SBITMAP, N, CODE) \ #define EXECUTE_IF_SET_IN_SBITMAP_REV(SBITMAP, N, CODE) \
do { \ do { \
......
...@@ -351,7 +351,8 @@ is_cfg_nonregular (void) ...@@ -351,7 +351,8 @@ is_cfg_nonregular (void)
static void static void
extract_edgelst (sbitmap set, edgelst *el) extract_edgelst (sbitmap set, edgelst *el)
{ {
int i; unsigned int i;
sbitmap_iterator sbi;
/* edgelst table space is reused in each call to extract_edgelst. */ /* edgelst table space is reused in each call to extract_edgelst. */
edgelst_last = 0; edgelst_last = 0;
...@@ -360,11 +361,11 @@ extract_edgelst (sbitmap set, edgelst *el) ...@@ -360,11 +361,11 @@ extract_edgelst (sbitmap set, edgelst *el)
el->nr_members = 0; el->nr_members = 0;
/* Iterate over each word in the bitset. */ /* Iterate over each word in the bitset. */
EXECUTE_IF_SET_IN_SBITMAP (set, 0, i, EXECUTE_IF_SET_IN_SBITMAP (set, 0, i, sbi)
{ {
edgelst_table[edgelst_last++] = rgn_edges[i]; edgelst_table[edgelst_last++] = rgn_edges[i];
el->nr_members++; el->nr_members++;
}); }
} }
/* Functions for the construction of regions. */ /* Functions for the construction of regions. */
......
...@@ -2033,6 +2033,7 @@ prepare_names_to_update (bitmap blocks, bool insert_phi_p) ...@@ -2033,6 +2033,7 @@ prepare_names_to_update (bitmap blocks, bool insert_phi_p)
{ {
unsigned i; unsigned i;
bitmap_iterator bi; bitmap_iterator bi;
sbitmap_iterator sbi;
/* If a name N from NEW_SSA_NAMES is also marked to be released, /* If a name N from NEW_SSA_NAMES is also marked to be released,
remove it from NEW_SSA_NAMES so that we don't try to visit its remove it from NEW_SSA_NAMES so that we don't try to visit its
...@@ -2046,17 +2047,17 @@ prepare_names_to_update (bitmap blocks, bool insert_phi_p) ...@@ -2046,17 +2047,17 @@ prepare_names_to_update (bitmap blocks, bool insert_phi_p)
/* First process names in NEW_SSA_NAMES. Otherwise, uses of old /* First process names in NEW_SSA_NAMES. Otherwise, uses of old
names may be considered to be live-in on blocks that contain names may be considered to be live-in on blocks that contain
definitions for their replacements. */ definitions for their replacements. */
EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
prepare_def_site_for (ssa_name (i), blocks, insert_phi_p)); prepare_def_site_for (ssa_name (i), blocks, insert_phi_p);
/* If an old name is in NAMES_TO_RELEASE, we cannot remove it from /* If an old name is in NAMES_TO_RELEASE, we cannot remove it from
OLD_SSA_NAMES, but we have to ignore its definition site. */ OLD_SSA_NAMES, but we have to ignore its definition site. */
EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
{ {
if (names_to_release == NULL || !bitmap_bit_p (names_to_release, i)) if (names_to_release == NULL || !bitmap_bit_p (names_to_release, i))
prepare_def_site_for (ssa_name (i), blocks, insert_phi_p); prepare_def_site_for (ssa_name (i), blocks, insert_phi_p);
prepare_use_sites_for (ssa_name (i), blocks, insert_phi_p); prepare_use_sites_for (ssa_name (i), blocks, insert_phi_p);
}); }
} }
...@@ -2105,12 +2106,14 @@ dump_update_ssa (FILE *file) ...@@ -2105,12 +2106,14 @@ dump_update_ssa (FILE *file)
if (new_ssa_names && sbitmap_first_set_bit (new_ssa_names) >= 0) if (new_ssa_names && sbitmap_first_set_bit (new_ssa_names) >= 0)
{ {
sbitmap_iterator sbi;
fprintf (file, "\nSSA replacement table\n"); fprintf (file, "\nSSA replacement table\n");
fprintf (file, "N_i -> { O_1 ... O_j } means that N_i replaces " fprintf (file, "N_i -> { O_1 ... O_j } means that N_i replaces "
"O_1, ..., O_j\n\n"); "O_1, ..., O_j\n\n");
EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
dump_names_replaced_by (file, ssa_name (i))); dump_names_replaced_by (file, ssa_name (i));
fprintf (file, "\n"); fprintf (file, "\n");
fprintf (file, "Number of virtual NEW -> OLD mappings: %7u\n", fprintf (file, "Number of virtual NEW -> OLD mappings: %7u\n",
...@@ -2346,10 +2349,11 @@ ssa_names_to_replace (void) ...@@ -2346,10 +2349,11 @@ ssa_names_to_replace (void)
{ {
unsigned i; unsigned i;
bitmap ret; bitmap ret;
sbitmap_iterator sbi;
ret = BITMAP_ALLOC (NULL); ret = BITMAP_ALLOC (NULL);
EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
bitmap_set_bit (ret, i)); bitmap_set_bit (ret, i);
return ret; return ret;
} }
...@@ -2516,6 +2520,7 @@ static void ...@@ -2516,6 +2520,7 @@ static void
switch_virtuals_to_full_rewrite (void) switch_virtuals_to_full_rewrite (void)
{ {
unsigned i; unsigned i;
sbitmap_iterator sbi;
if (dump_file) if (dump_file)
{ {
...@@ -2531,13 +2536,13 @@ switch_virtuals_to_full_rewrite (void) ...@@ -2531,13 +2536,13 @@ switch_virtuals_to_full_rewrite (void)
/* Remove all virtual names from NEW_SSA_NAMES and OLD_SSA_NAMES. /* Remove all virtual names from NEW_SSA_NAMES and OLD_SSA_NAMES.
Note that it is not really necessary to remove the mappings from Note that it is not really necessary to remove the mappings from
REPL_TBL, that would only waste time. */ REPL_TBL, that would only waste time. */
EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
if (!is_gimple_reg (ssa_name (i))) if (!is_gimple_reg (ssa_name (i)))
RESET_BIT (new_ssa_names, i)); RESET_BIT (new_ssa_names, i);
EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
if (!is_gimple_reg (ssa_name (i))) if (!is_gimple_reg (ssa_name (i)))
RESET_BIT (old_ssa_names, i)); RESET_BIT (old_ssa_names, i);
bitmap_ior_into (syms_to_rename, update_ssa_stats.virtual_symbols); bitmap_ior_into (syms_to_rename, update_ssa_stats.virtual_symbols);
} }
...@@ -2616,6 +2621,7 @@ update_ssa (unsigned update_flags) ...@@ -2616,6 +2621,7 @@ update_ssa (unsigned update_flags)
unsigned i; unsigned i;
sbitmap tmp; sbitmap tmp;
bool insert_phi_p; bool insert_phi_p;
sbitmap_iterator sbi;
if (!need_ssa_update_p ()) if (!need_ssa_update_p ())
return; return;
...@@ -2746,6 +2752,8 @@ update_ssa (unsigned update_flags) ...@@ -2746,6 +2752,8 @@ update_ssa (unsigned update_flags)
if (sbitmap_first_set_bit (old_ssa_names) >= 0) if (sbitmap_first_set_bit (old_ssa_names) >= 0)
{ {
sbitmap_iterator sbi;
/* insert_update_phi_nodes_for will call add_new_name_mapping /* insert_update_phi_nodes_for will call add_new_name_mapping
when inserting new PHI nodes, so the set OLD_SSA_NAMES when inserting new PHI nodes, so the set OLD_SSA_NAMES
will grow while we are traversing it (but it will not will grow while we are traversing it (but it will not
...@@ -2753,9 +2761,9 @@ update_ssa (unsigned update_flags) ...@@ -2753,9 +2761,9 @@ update_ssa (unsigned update_flags)
for traversal. */ for traversal. */
sbitmap tmp = sbitmap_alloc (old_ssa_names->n_bits); sbitmap tmp = sbitmap_alloc (old_ssa_names->n_bits);
sbitmap_copy (tmp, old_ssa_names); sbitmap_copy (tmp, old_ssa_names);
EXECUTE_IF_SET_IN_SBITMAP (tmp, 0, i, EXECUTE_IF_SET_IN_SBITMAP (tmp, 0, i, sbi)
insert_updated_phi_nodes_for (ssa_name (i), dfs, blocks, insert_updated_phi_nodes_for (ssa_name (i), dfs, blocks,
update_flags)); update_flags);
sbitmap_free (tmp); sbitmap_free (tmp);
} }
...@@ -2776,8 +2784,8 @@ update_ssa (unsigned update_flags) ...@@ -2776,8 +2784,8 @@ update_ssa (unsigned update_flags)
/* Reset the current definition for name and symbol before renaming /* Reset the current definition for name and symbol before renaming
the sub-graph. */ the sub-graph. */
EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
set_current_def (ssa_name (i), NULL_TREE)); set_current_def (ssa_name (i), NULL_TREE);
EXECUTE_IF_SET_IN_BITMAP (syms_to_rename, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (syms_to_rename, 0, i, bi)
set_current_def (referenced_var (i), NULL_TREE); set_current_def (referenced_var (i), NULL_TREE);
......
...@@ -695,6 +695,7 @@ coalesce_ssa_name (var_map map, int flags) ...@@ -695,6 +695,7 @@ coalesce_ssa_name (var_map map, int flags)
conflict_graph graph; conflict_graph graph;
basic_block bb; basic_block bb;
coalesce_list_p cl = NULL; coalesce_list_p cl = NULL;
sbitmap_iterator sbi;
if (num_var_partitions (map) <= 1) if (num_var_partitions (map) <= 1)
return NULL; return NULL;
...@@ -797,7 +798,7 @@ coalesce_ssa_name (var_map map, int flags) ...@@ -797,7 +798,7 @@ coalesce_ssa_name (var_map map, int flags)
/* Assign root variable as partition representative for each live on entry /* Assign root variable as partition representative for each live on entry
partition. */ partition. */
EXECUTE_IF_SET_IN_SBITMAP (live, 0, x, EXECUTE_IF_SET_IN_SBITMAP (live, 0, x, sbi)
{ {
var = root_var (rv, root_var_find (rv, x)); var = root_var (rv, root_var_find (rv, x));
ann = var_ann (var); ann = var_ann (var);
...@@ -817,7 +818,7 @@ coalesce_ssa_name (var_map map, int flags) ...@@ -817,7 +818,7 @@ coalesce_ssa_name (var_map map, int flags)
change_partition_var (map, var, x); change_partition_var (map, var, x);
} }
}); }
sbitmap_free (live); sbitmap_free (live);
......
...@@ -1073,12 +1073,13 @@ compute_flow_insensitive_aliasing (struct alias_info *ai) ...@@ -1073,12 +1073,13 @@ compute_flow_insensitive_aliasing (struct alias_info *ai)
if (sbitmap_first_set_bit (may_aliases2) >= 0) if (sbitmap_first_set_bit (may_aliases2) >= 0)
{ {
size_t k; unsigned int k;
sbitmap_iterator sbi;
/* Add all the aliases for TAG2 into TAG1's alias set. /* Add all the aliases for TAG2 into TAG1's alias set.
FIXME, update grouping heuristic counters. */ FIXME, update grouping heuristic counters. */
EXECUTE_IF_SET_IN_SBITMAP (may_aliases2, 0, k, EXECUTE_IF_SET_IN_SBITMAP (may_aliases2, 0, k, sbi)
add_may_alias (tag1, referenced_var (k))); add_may_alias (tag1, referenced_var (k));
sbitmap_a_or_b (may_aliases1, may_aliases1, may_aliases2); sbitmap_a_or_b (may_aliases1, may_aliases1, may_aliases2);
} }
else else
...@@ -1133,11 +1134,12 @@ total_alias_vops_cmp (const void *p, const void *q) ...@@ -1133,11 +1134,12 @@ total_alias_vops_cmp (const void *p, const void *q)
static void static void
group_aliases_into (tree tag, sbitmap tag_aliases, struct alias_info *ai) group_aliases_into (tree tag, sbitmap tag_aliases, struct alias_info *ai)
{ {
size_t i; unsigned int i;
var_ann_t tag_ann = var_ann (tag); var_ann_t tag_ann = var_ann (tag);
size_t num_tag_refs = VARRAY_UINT (ai->num_references, tag_ann->uid); size_t num_tag_refs = VARRAY_UINT (ai->num_references, tag_ann->uid);
sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (tag_aliases, 0, i, EXECUTE_IF_SET_IN_SBITMAP (tag_aliases, 0, i, sbi)
{ {
tree var = referenced_var (i); tree var = referenced_var (i);
var_ann_t ann = var_ann (var); var_ann_t ann = var_ann (var);
...@@ -1157,7 +1159,7 @@ group_aliases_into (tree tag, sbitmap tag_aliases, struct alias_info *ai) ...@@ -1157,7 +1159,7 @@ group_aliases_into (tree tag, sbitmap tag_aliases, struct alias_info *ai)
itself won't be removed. We will merely replace them with itself won't be removed. We will merely replace them with
references to TAG. */ references to TAG. */
ai->total_alias_vops -= num_tag_refs; ai->total_alias_vops -= num_tag_refs;
}); }
/* We have reduced the number of virtual operands that TAG makes on /* We have reduced the number of virtual operands that TAG makes on
behalf of all the variables formerly aliased with it. However, behalf of all the variables formerly aliased with it. However,
......
...@@ -185,7 +185,8 @@ void ...@@ -185,7 +185,8 @@ void
compact_var_map (var_map map, int flags) compact_var_map (var_map map, int flags)
{ {
sbitmap used; sbitmap used;
int x, limit, count, tmp, root, root_i; int tmp, root, root_i;
unsigned int x, limit, count;
tree var; tree var;
root_var_p rv = NULL; root_var_p rv = NULL;
...@@ -238,10 +239,12 @@ compact_var_map (var_map map, int flags) ...@@ -238,10 +239,12 @@ compact_var_map (var_map map, int flags)
/* Build a compacted partitioning. */ /* Build a compacted partitioning. */
if (count != limit) if (count != limit)
{ {
sbitmap_iterator sbi;
map->compact_to_partition = (int *)xmalloc (count * sizeof (int)); map->compact_to_partition = (int *)xmalloc (count * sizeof (int));
count = 0; count = 0;
/* SSA renaming begins at 1, so skip 0 when compacting. */ /* SSA renaming begins at 1, so skip 0 when compacting. */
EXECUTE_IF_SET_IN_SBITMAP (used, 1, x, EXECUTE_IF_SET_IN_SBITMAP (used, 1, x, sbi)
{ {
map->partition_to_compact[x] = count; map->partition_to_compact[x] = count;
map->compact_to_partition[count] = x; map->compact_to_partition[count] = x;
...@@ -249,7 +252,7 @@ compact_var_map (var_map map, int flags) ...@@ -249,7 +252,7 @@ compact_var_map (var_map map, int flags)
if (TREE_CODE (var) != SSA_NAME) if (TREE_CODE (var) != SSA_NAME)
change_partition_var (map, var, count); change_partition_var (map, var, count);
count++; count++;
}); }
} }
else else
{ {
...@@ -408,9 +411,11 @@ create_ssa_var_map (int flags) ...@@ -408,9 +411,11 @@ create_ssa_var_map (int flags)
sbitmap_a_and_b (both, used_in_real_ops, used_in_virtual_ops); sbitmap_a_and_b (both, used_in_real_ops, used_in_virtual_ops);
if (sbitmap_first_set_bit (both) >= 0) if (sbitmap_first_set_bit (both) >= 0)
{ {
EXECUTE_IF_SET_IN_SBITMAP (both, 0, i, sbitmap_iterator sbi;
EXECUTE_IF_SET_IN_SBITMAP (both, 0, i, sbi)
fprintf (stderr, "Variable %s used in real and virtual operands\n", fprintf (stderr, "Variable %s used in real and virtual operands\n",
get_name (referenced_var (i)))); get_name (referenced_var (i)));
internal_error ("SSA corruption"); internal_error ("SSA corruption");
} }
......
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