Commit 26b90086 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Use foreach_pset().

parent a6e4400b
...@@ -438,7 +438,7 @@ void *(pset_insert) (SET *se, const void *key, unsigned hash) ...@@ -438,7 +438,7 @@ void *(pset_insert) (SET *se, const void *key, unsigned hash)
void pset_insert_pset_ptr(pset *target, pset *src) void pset_insert_pset_ptr(pset *target, pset *src)
{ {
void *elt; void *elt;
for (elt = pset_first(src); elt; elt = pset_next(src)) { foreach_pset(src, void*, elt) {
pset_insert_ptr(target, elt); pset_insert_ptr(target, elt);
} }
} }
......
...@@ -278,25 +278,23 @@ void compute_callgraph(void) ...@@ -278,25 +278,23 @@ void compute_callgraph(void)
count = pset_count(callee_set); count = pset_count(callee_set);
irg->callees = NEW_ARR_F(cg_callee_entry *, count); irg->callees = NEW_ARR_F(cg_callee_entry *, count);
irg->callee_isbe = NULL; irg->callee_isbe = NULL;
callee = (cg_callee_entry*) pset_first(callee_set); j = 0;
for (j = 0; j < count; ++j) { foreach_pset(callee_set, cg_callee_entry*, callee) {
irg->callees[j] = callee; irg->callees[j++] = callee;
callee = (cg_callee_entry*) pset_next(callee_set);
} }
del_pset(callee_set); del_pset(callee_set);
assert(callee == NULL); assert(j == count);
caller_set = (pset *)irg->callers; caller_set = (pset *)irg->callers;
count = pset_count(caller_set); count = pset_count(caller_set);
irg->callers = NEW_ARR_F(ir_graph *, count); irg->callers = NEW_ARR_F(ir_graph *, count);
irg->caller_isbe = NULL; irg->caller_isbe = NULL;
c = (ir_graph*) pset_first(caller_set); j = 0;
for (j = 0; j < count; ++j) { foreach_pset(caller_set, ir_graph*, c) {
irg->callers[j] = c; irg->callers[j++] = c;
c = (ir_graph*) pset_next(caller_set);
} }
del_pset(caller_set); del_pset(caller_set);
assert(c == NULL); assert(j == count);
} }
set_irp_callgraph_state(irp_callgraph_consistent); set_irp_callgraph_state(irp_callgraph_consistent);
} }
......
...@@ -348,7 +348,7 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou ...@@ -348,7 +348,7 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou
} }
} }
#define pset_foreach(pset, irn) for (irn=(ir_node*)pset_first(pset); irn; irn=(ir_node*)pset_next(pset)) #define pset_foreach(pset, irn) foreach_pset((pset), ir_node*, (irn))
/** /**
* Search for an interference clique and an external node * Search for an interference clique and an external node
......
...@@ -247,8 +247,7 @@ static inline int get_next_clique(cliques_iter_t *it) ...@@ -247,8 +247,7 @@ static inline int get_next_clique(cliques_iter_t *it)
ir_node *irn; ir_node *irn;
/* fill the output buffer */ /* fill the output buffer */
for (irn = (ir_node*)pset_first(it->living); irn != NULL; foreach_pset(it->living, ir_node*, irn) {
irn = (ir_node*)pset_next(it->living)) {
it->buf[count++] = irn; it->buf[count++] = irn;
} }
......
...@@ -205,20 +205,14 @@ double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl) ...@@ -205,20 +205,14 @@ double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
if (tbl->int_dist) { if (tbl->int_dist) {
/* integer distribution, need min, max */ /* integer distribution, need min, max */
int min, max; if (pset_count(tbl->hash_map) == 0)
entry = (distrib_entry_t*)pset_first(tbl->hash_map);
if (! entry)
return 0.0; return 0.0;
min = int min = INT_MAX;
max = PTR_TO_INT(entry->object); int max = INT_MIN;
sum = cnt_to_dbl(&entry->cnt); sum = 0.0;
for (entry = (distrib_entry_t*)pset_next(tbl->hash_map); entry != NULL; foreach_pset(tbl->hash_map, distrib_entry_t*, entry) {
entry = (distrib_entry_t*)pset_next(tbl->hash_map)) {
int value = PTR_TO_INT(entry->object); int value = PTR_TO_INT(entry->object);
if (value < min) if (value < min)
......
...@@ -2077,8 +2077,7 @@ void stat_dump_snapshot(const char *name, const char *phase) ...@@ -2077,8 +2077,7 @@ void stat_dump_snapshot(const char *name, const char *phase)
stat_dump_init(fname); stat_dump_init(fname);
/* calculate the graph statistics */ /* calculate the graph statistics */
for (entry = (graph_entry_t*)pset_first(status->irg_hash); foreach_pset(status->irg_hash, graph_entry_t*, entry) {
entry != NULL; entry = (graph_entry_t*)pset_next(status->irg_hash)) {
if (entry->irg == NULL) { if (entry->irg == NULL) {
/* special entry for the global count */ /* special entry for the global count */
continue; continue;
...@@ -2097,8 +2096,7 @@ void stat_dump_snapshot(const char *name, const char *phase) ...@@ -2097,8 +2096,7 @@ void stat_dump_snapshot(const char *name, const char *phase)
} /* while */ } /* while */
/* dump per graph */ /* dump per graph */
for (entry = (graph_entry_t*)pset_first(status->irg_hash); foreach_pset(status->irg_hash, graph_entry_t*, entry) {
entry != NULL; entry = (graph_entry_t*)pset_next(status->irg_hash)) {
if (entry->irg == NULL) { if (entry->irg == NULL) {
/* special entry for the global count */ /* special entry for the global count */
continue; continue;
...@@ -2137,8 +2135,7 @@ void stat_dump_snapshot(const char *name, const char *phase) ...@@ -2137,8 +2135,7 @@ void stat_dump_snapshot(const char *name, const char *phase)
{ {
node_entry_t *entry; node_entry_t *entry;
for (entry = (node_entry_t*)pset_first(global->opcode_hash); foreach_pset(global->opcode_hash, node_entry_t*, entry) {
entry != NULL; entry = (node_entry_t*)pset_next(global->opcode_hash)) {
opcode_clear_entry(entry); opcode_clear_entry(entry);
} /* for */ } /* for */
/* clear all global counter */ /* clear all global counter */
......
...@@ -746,7 +746,7 @@ static void store_pattern(const char *fname) ...@@ -746,7 +746,7 @@ static void store_pattern(const char *fname)
{ {
FILE *f; FILE *f;
pattern_entry_t *entry; pattern_entry_t *entry;
size_t i, count = pset_count(status->pattern_hash); size_t count = pset_count(status->pattern_hash);
if (count <= 0) if (count <= 0)
return; return;
...@@ -760,9 +760,7 @@ static void store_pattern(const char *fname) ...@@ -760,9 +760,7 @@ static void store_pattern(const char *fname)
fwrite("FPS1", 4, 1, f); fwrite("FPS1", 4, 1, f);
fwrite(&count, sizeof(count), 1, f); fwrite(&count, sizeof(count), 1, f);
for (i = 0, entry = (pattern_entry_t*)pset_first(status->pattern_hash); foreach_pset(status->pattern_hash, pattern_entry_t*, entry) {
entry && i < count;
entry = (pattern_entry_t*)pset_next(status->pattern_hash), ++i) {
fwrite(entry, offsetof(pattern_entry_t, buf) + entry->len, 1, f); fwrite(entry, offsetof(pattern_entry_t, buf) + entry->len, 1, f);
} /* for */ } /* for */
fclose(f); fclose(f);
...@@ -844,10 +842,9 @@ static void pattern_output(const char *fname) ...@@ -844,10 +842,9 @@ static void pattern_output(const char *fname)
dump = new_vcg_dumper(fname, 100); dump = new_vcg_dumper(fname, 100);
pattern_arr = XMALLOCN(pattern_entry_t*, count); pattern_arr = XMALLOCN(pattern_entry_t*, count);
for (i = 0, entry = (pattern_entry_t*)pset_first(status->pattern_hash); i = 0;
entry && i < count; foreach_pset(status->pattern_hash, pattern_entry_t*, entry) {
entry = (pattern_entry_t*)pset_next(status->pattern_hash), ++i) { pattern_arr[i++] = entry;
pattern_arr[i] = entry;
} /* for */ } /* for */
assert(count == i); assert(count == i);
count = i; count = i;
......
...@@ -278,9 +278,7 @@ static void simple_dump_be_block_reg_pressure(dumper_t *dmp, graph_entry_t *entr ...@@ -278,9 +278,7 @@ static void simple_dump_be_block_reg_pressure(dumper_t *dmp, graph_entry_t *entr
fprintf(dmp->f, "\n"); fprintf(dmp->f, "\n");
/* print the reg pressure for all blocks and register classes */ /* print the reg pressure for all blocks and register classes */
for (/* b_entry is already initialized */ ; foreach_pset(entry->block_hash, be_block_entry_t*, b_entry) {
b_entry;
b_entry = (be_block_entry_t*)pset_next(entry->be_block_hash)) {
fprintf(dmp->f, "BLK %6ld", b_entry->block_nr); fprintf(dmp->f, "BLK %6ld", b_entry->block_nr);
foreach_pset(b_entry->reg_pressure, reg_pressure_entry_t*, rp_entry) foreach_pset(b_entry->reg_pressure, reg_pressure_entry_t*, rp_entry)
......
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