Rename set_iter_t's member to value.

Makes more sense now that the membership of the value depends on the
inversion of the set.
This commit is contained in:
Bill Currie 2012-12-06 21:11:38 +09:00
parent eb8fd55677
commit e0c92b6089
6 changed files with 30 additions and 30 deletions

View file

@ -60,18 +60,18 @@ typedef struct set_s {
create_and_populate (set);
for (iter = set_first (set); iter; iter = set_next (iter))
do_something (iter->member);
do_something (iter->value);
\endcode
*/
typedef struct set_iter_s {
struct set_iter_s *next; ///< private. for ALLOC
const set_t *set; ///< the set to which this iterator belongs
/** The result of set_first() or set_next(). set_next() will start at the
following member.
following value.
\note For inverted sets, indicates a non-member.
*/
unsigned member;
unsigned value;
} set_iter_t;
/** Delete a set iterator that is no longer needed.

View file

@ -530,7 +530,7 @@ set_first (const set_t *set)
if (_set_is_member (set, x)) {
set_iter = new_setiter ();
set_iter->set = set;
set_iter->member = x;
set_iter->value = x;
return set_iter;
}
}
@ -542,9 +542,9 @@ set_next (set_iter_t *set_iter)
{
unsigned x;
for (x = set_iter->member + 1; x < set_iter->set->size; x++) {
for (x = set_iter->value + 1; x < set_iter->set->size; x++) {
if (_set_is_member (set_iter->set, x)) {
set_iter->member = x;
set_iter->value = x;
return set_iter;
}
}

View file

@ -393,7 +393,7 @@ dag_sort_visit (dag_t *dag, set_t *visited, int node_index, int *topo)
node = dag->nodes[node_index];
for (node_iter = set_first (node->edges); node_iter;
node_iter = set_next (node_iter))
dag_sort_visit (dag, visited, node_iter->member, topo);
dag_sort_visit (dag, visited, node_iter->value, topo);
node->topo = *topo;
dag->topo[(*topo)++] = node_index;
}
@ -408,7 +408,7 @@ dag_sort_nodes (dag_t *dag)
dag->topo = malloc (dag->num_nodes * sizeof (int));
for (root_iter = set_first (dag->roots); root_iter;
root_iter = set_next (root_iter))
dag_sort_visit (dag, visited, root_iter->member, &topo);
dag_sort_visit (dag, visited, root_iter->value, &topo);
set_delete (visited);
}
@ -614,7 +614,7 @@ generate_assignments (dag_t *dag, sblock_t *block, operand_t *src,
operands[0] = src;
for ( ; var_iter; var_iter = set_next (var_iter)) {
var = dag->labels[var_iter->member];
var = dag->labels[var_iter->value];
operands[1] = var->op;
if (!dst)
dst = operands[1];
@ -665,7 +665,7 @@ dag_gencode (dag_t *dag, sblock_t *block, dagnode_t *dagnode)
if (!(var_iter = set_first (dagnode->identifiers))) {
operands[2] = temp_operand (get_type (dagnode->label->expr));
} else {
daglabel_t *var = dag->labels[var_iter->member];
daglabel_t *var = dag->labels[var_iter->value];
operands[2] = var->op;
var_iter = set_next (var_iter);

View file

@ -66,7 +66,7 @@ print_root_nodes (dstring_t *dstr, dag_t *dag)
dasprintf (dstr, " rank=same;");
for (node_iter = set_first (dag->roots); node_iter;
node_iter = set_next (node_iter)) {
dagnode_t *node = dag->nodes[node_iter->member];
dagnode_t *node = dag->nodes[node_iter->value];
print_node_def (dstr, node);
dasprintf (dstr, " dag_enter_%p ->dagnode_%p [style=invis];\n",
dag, node);
@ -107,7 +107,7 @@ print_node (dstring_t *dstr, dag_t *dag, dagnode_t *node)
edge_iter = set_next (edge_iter)) {
dasprintf (dstr,
" \"dagnode_%p\" -> \"dagnode_%p\" [style=dashed];\n",
node, dag->nodes[edge_iter->member]);
node, dag->nodes[edge_iter->value]);
}
set_delete (edges);
if (!set_is_empty (node->identifiers)) {
@ -123,7 +123,7 @@ print_node (dstring_t *dstr, dag_t *dag, dagnode_t *node)
dasprintf (dstr, " <td>");
for (id_iter = set_first (node->identifiers); id_iter;
id_iter = set_next (id_iter)) {
id = dag->labels[id_iter->member];
id = dag->labels[id_iter->value];
dasprintf (dstr, " %s", html_string (daglabel_string(id)));
}
dasprintf (dstr, " </td>");

View file

@ -190,7 +190,7 @@ print_flow_node_live (dstring_t *dstr, flowgraph_t *graph, flownode_t *node,
node->id, node->dfn);
for (var_iter = set_first (node->live_vars.out); var_iter;
var_iter = set_next (var_iter)) {
var = graph->func->vars[var_iter->member];
var = graph->func->vars[var_iter->value];
dasprintf (dstr, "%*s<tr><td>(%d) %s</td></tr>\n", indent + 4, "",
var->number, html_string(operand_string (var->op)));
}

View file

@ -407,7 +407,7 @@ flow_live_vars (flowgraph_t *graph)
set_empty (tmp);
for (succ = set_first (node->successors); succ;
succ = set_next (succ))
set_union (tmp, graph->nodes[succ->member]->live_vars.in);
set_union (tmp, graph->nodes[succ->value]->live_vars.in);
if (!set_is_equivalent (node->live_vars.out, tmp)) {
changed = 1;
set_assign (node->live_vars.out, tmp);
@ -486,19 +486,19 @@ flow_uninitialized (flowgraph_t *graph)
// not interested in back edges
for (pred_iter = set_first (predecessors); pred_iter;
pred_iter = set_next (pred_iter)) {
pred = graph->nodes[pred_iter->member];
pred = graph->nodes[pred_iter->value];
if (pred->dfn >= node->dfn)
set_remove (predecessors, pred->id);
}
set_empty (tmp);
pred_iter = set_first (predecessors);
if (pred_iter) {
pred = graph->nodes[pred_iter->member];
pred = graph->nodes[pred_iter->value];
set_assign (tmp, pred->init_vars.out);
pred_iter = set_next (pred_iter);
}
for ( ; pred_iter; pred_iter = set_next (pred_iter)) {
pred = graph->nodes[pred_iter->member];
pred = graph->nodes[pred_iter->value];
set_intersection (tmp, pred->init_vars.out);
}
set_assign (node->init_vars.in, tmp);
@ -511,7 +511,7 @@ flow_uninitialized (flowgraph_t *graph)
for (var_iter = set_first (uninit); var_iter;
var_iter = set_next (var_iter)) {
expr_t dummy;
flowvar_t *var = func->vars[var_iter->member];
flowvar_t *var = func->vars[var_iter->value];
def_t *def;
if (var->op->op_type == op_temp) {
@ -564,11 +564,11 @@ flow_data_flow (flowgraph_t *graph)
for (st = node->sblock->statements; st; st = st->next) {
flow_analyze_statement (st, stuse, stdef, 0, 0);
for (var_i = set_first (stdef); var_i; var_i = set_next (var_i)) {
var = graph->func->vars[var_i->member];
var = graph->func->vars[var_i->value];
set_add (var->define, st->number);
}
for (var_i = set_first (stuse); var_i; var_i = set_next (var_i)) {
var = graph->func->vars[var_i->member];
var = graph->func->vars[var_i->value];
set_add (var->use, st->number);
}
}
@ -750,7 +750,7 @@ flow_find_predecessors (flowgraph_t *graph)
node = graph->nodes[i];
for (succ = set_first (node->successors); succ;
succ = set_next (succ)) {
set_add (graph->nodes[succ->member]->predecessors, i);
set_add (graph->nodes[succ->value]->predecessors, i);
}
}
for (i = 1; i < graph->num_nodes; i++) {
@ -792,7 +792,7 @@ flow_find_dominators (flowgraph_t *graph)
set_empty (work);
for (pred = set_first (node->predecessors); pred;
pred = set_next (pred))
set_intersection (work, graph->nodes[pred->member]->dom);
set_intersection (work, graph->nodes[pred->value]->dom);
set_add (work, i);
if (!set_is_equivalent (work, node->dom))
changed = 1;
@ -824,13 +824,13 @@ make_loop (flowgraph_t *graph, unsigned n, unsigned d)
insert_loop_node (loop, n, stack);
while (!set_is_empty (stack)) {
set_iter_t *ss = set_first (stack);
unsigned m = ss->member;
unsigned m = ss->value;
set_del_iter (ss);
set_remove (stack, m);
node = graph->nodes[m];
for (pred = set_first (node->predecessors); pred;
pred = set_next (pred))
insert_loop_node (loop, pred->member, stack);
insert_loop_node (loop, pred->value, stack);
}
set_delete (stack);
return loop;
@ -849,8 +849,8 @@ flow_find_loops (flowgraph_t *graph)
node = graph->nodes[i];
for (succ = set_first (node->successors); succ;
succ = set_next (succ)) {
if (set_is_member (node->dom, succ->member)) {
loop = make_loop (graph, node->id, succ->member);
if (set_is_member (node->dom, succ->value)) {
loop = make_loop (graph, node->id, succ->value);
for (l = loop_list; l; l = l->next) {
if (l->head == loop->head
&& !set_is_subset (l->nodes, loop->nodes)
@ -881,9 +881,9 @@ df_search (flowgraph_t *graph, set_t *visited, int *i, int n)
set_add (visited, n);
node = graph->nodes[n];
for (edge = set_first (node->edges); edge; edge = set_next (edge)) {
succ = graph->edges[edge->member].head;
succ = graph->edges[edge->value].head;
if (!set_is_member (visited, succ)) {
set_add (graph->dfst, edge->member);
set_add (graph->dfst, edge->value);
df_search (graph, visited, i, succ);
}
}
@ -970,7 +970,7 @@ flow_build_graph (sblock_t *sblock, function_t *func)
succ = set_next (succ), j++) {
set_add (node->edges, j);
graph->edges[j].tail = i;
graph->edges[j].head = succ->member;
graph->edges[j].head = succ->value;
}
}
flow_build_dfst (graph);