6 #include "becopystat.h"
10 struct list_head chain;
13 int interferers, lb, max;
17 typedef struct _all_stat_t {
19 struct list_head irgs;
22 static all_stat_t *all_stats = NULL;
24 #define irg_list_entry(lh) list_entry(lh, irg_stat_t, chain)
26 irg_stat_t *new_irg_stat(copy_opt_t *co) {
27 irg_stat_t *is, *curr;
30 all_stats = calloc(1, sizeof(*all_stats));
31 //TODO all_stats->unit_name = ??? */
32 INIT_LIST_HEAD(&all_stats->irgs);
33 is = calloc(1, sizeof(*is));
34 is->irg_name = "CUMULATIVE";
35 list_add_tail(&is->chain, &all_stats->irgs);
38 /* look if we had this irg already */
39 list_for_each_entry(irg_stat_t, curr, &all_stats->irgs, chain)
40 if (curr->irg == co->irg)
43 /* else create a new entry */
44 is = calloc(1, sizeof(*is));
46 is->irg_name = get_entity_name(get_irg_entity(co->irg));
47 list_add_tail(&is->chain, &all_stats->irgs);
51 void irg_stat_count(irg_stat_t *is, copy_opt_t *co, int phase) {
53 int max = 0, copies = 0;
55 list_for_each_entry(unit_t, curr, &co->units, units) {
57 max += curr->interf + curr->node_count - 1;
58 const ir_node *root = curr->nodes[0];
59 int root_color = get_irn_color(root);
60 copies += curr->interf;
61 for (i=1; i<curr->node_count; ++i) {
62 const ir_node *arg = curr->nodes[i];
63 if (root_color != get_irn_color(arg))
68 is->copies[phase] += copies;
72 is->interferers += co_get_interferer_count(co);
73 is->lb += co_get_lower_bound(co);
77 void irg_stat_print(irg_stat_t *is) {
78 printf("Irg %s: %3d %3d %3d %3d %3d %3d", is->irg_name, is->interferers, is->lb, is->copies[0], is->copies[1], is->copies[2], is->max);
81 void all_stat_dump(void) {
83 irg_stat_t *cuml, *curr;
84 /* Compute cumulative values */
85 cuml = irg_list_entry(all_stats->irgs.next);
86 cuml->interferers = 0;
92 list_for_each_entry(irg_stat_t, curr, &all_stats->irgs, chain) {
94 cuml->interferers += curr->interferers;
96 cuml->max += curr->max;
98 cuml->copies[i] += curr->copies[i];
102 out = ffopen(all_stats->unit_name, "stats", "wt");
103 list_for_each_entry(irg_stat_t, curr, &all_stats->irgs, chain)
104 fprintf(out, "%15s %3d %3d %3d %3d %3d %3d", curr->irg_name, curr->interferers, curr->lb, curr->copies[0], curr->copies[1], curr->copies[2], curr->max);