void pset_insert_pset_ptr(pset *target, pset *src)
{
void *elt;
- for (elt = pset_first(src); elt; elt = pset_next(src)) {
+ foreach_pset(src, void*, elt) {
pset_insert_ptr(target, elt);
}
}
count = pset_count(callee_set);
irg->callees = NEW_ARR_F(cg_callee_entry *, count);
irg->callee_isbe = NULL;
- callee = (cg_callee_entry*) pset_first(callee_set);
- for (j = 0; j < count; ++j) {
- irg->callees[j] = callee;
- callee = (cg_callee_entry*) pset_next(callee_set);
+ j = 0;
+ foreach_pset(callee_set, cg_callee_entry*, callee) {
+ irg->callees[j++] = callee;
}
del_pset(callee_set);
- assert(callee == NULL);
+ assert(j == count);
caller_set = (pset *)irg->callers;
count = pset_count(caller_set);
irg->callers = NEW_ARR_F(ir_graph *, count);
irg->caller_isbe = NULL;
- c = (ir_graph*) pset_first(caller_set);
- for (j = 0; j < count; ++j) {
- irg->callers[j] = c;
- c = (ir_graph*) pset_next(caller_set);
+ j = 0;
+ foreach_pset(caller_set, ir_graph*, c) {
+ irg->callers[j++] = c;
}
del_pset(caller_set);
- assert(c == NULL);
+ assert(j == count);
}
set_irp_callgraph_state(irp_callgraph_consistent);
}
}
}
-#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
ir_node *irn;
/* fill the output buffer */
- for (irn = (ir_node*)pset_first(it->living); irn != NULL;
- irn = (ir_node*)pset_next(it->living)) {
+ foreach_pset(it->living, ir_node*, irn) {
it->buf[count++] = irn;
}
if (tbl->int_dist) {
/* integer distribution, need min, max */
- int min, max;
-
- entry = (distrib_entry_t*)pset_first(tbl->hash_map);
-
- if (! entry)
+ if (pset_count(tbl->hash_map) == 0)
return 0.0;
- min =
- max = PTR_TO_INT(entry->object);
- sum = cnt_to_dbl(&entry->cnt);
-
+ int min = INT_MAX;
+ int max = INT_MIN;
+ sum = 0.0;
- for (entry = (distrib_entry_t*)pset_next(tbl->hash_map); entry != NULL;
- entry = (distrib_entry_t*)pset_next(tbl->hash_map)) {
+ foreach_pset(tbl->hash_map, distrib_entry_t*, entry) {
int value = PTR_TO_INT(entry->object);
if (value < min)
stat_dump_init(fname);
/* calculate the graph statistics */
- for (entry = (graph_entry_t*)pset_first(status->irg_hash);
- entry != NULL; entry = (graph_entry_t*)pset_next(status->irg_hash)) {
+ foreach_pset(status->irg_hash, graph_entry_t*, entry) {
if (entry->irg == NULL) {
/* special entry for the global count */
continue;
} /* while */
/* dump per graph */
- for (entry = (graph_entry_t*)pset_first(status->irg_hash);
- entry != NULL; entry = (graph_entry_t*)pset_next(status->irg_hash)) {
+ foreach_pset(status->irg_hash, graph_entry_t*, entry) {
if (entry->irg == NULL) {
/* special entry for the global count */
continue;
{
node_entry_t *entry;
- for (entry = (node_entry_t*)pset_first(global->opcode_hash);
- entry != NULL; entry = (node_entry_t*)pset_next(global->opcode_hash)) {
+ foreach_pset(global->opcode_hash, node_entry_t*, entry) {
opcode_clear_entry(entry);
} /* for */
/* clear all global counter */
{
FILE *f;
pattern_entry_t *entry;
- size_t i, count = pset_count(status->pattern_hash);
+ size_t count = pset_count(status->pattern_hash);
if (count <= 0)
return;
fwrite("FPS1", 4, 1, f);
fwrite(&count, sizeof(count), 1, f);
- for (i = 0, entry = (pattern_entry_t*)pset_first(status->pattern_hash);
- entry && i < count;
- entry = (pattern_entry_t*)pset_next(status->pattern_hash), ++i) {
+ foreach_pset(status->pattern_hash, pattern_entry_t*, entry) {
fwrite(entry, offsetof(pattern_entry_t, buf) + entry->len, 1, f);
} /* for */
fclose(f);
dump = new_vcg_dumper(fname, 100);
pattern_arr = XMALLOCN(pattern_entry_t*, count);
- for (i = 0, entry = (pattern_entry_t*)pset_first(status->pattern_hash);
- entry && i < count;
- entry = (pattern_entry_t*)pset_next(status->pattern_hash), ++i) {
- pattern_arr[i] = entry;
+ i = 0;
+ foreach_pset(status->pattern_hash, pattern_entry_t*, entry) {
+ pattern_arr[i++] = entry;
} /* for */
assert(count == i);
count = i;
fprintf(dmp->f, "\n");
/* print the reg pressure for all blocks and register classes */
- for (/* b_entry is already initialized */ ;
- b_entry;
- b_entry = (be_block_entry_t*)pset_next(entry->be_block_hash)) {
+ foreach_pset(entry->block_hash, be_block_entry_t*, b_entry) {
fprintf(dmp->f, "BLK %6ld", b_entry->block_nr);
foreach_pset(b_entry->reg_pressure, reg_pressure_entry_t*, rp_entry)