fixed gen_Store: take immediate addresses
[libfirm] / ir / be / bestat.c
1 /**
2  * This file calls the corresponding statistic functions for
3  * some backend statistics.
4  * $Id$
5  */
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9
10 #ifdef FIRM_STATISTICS
11
12 #include "irnode_t.h"
13 #include "irprintf.h"
14 #include "irgwalk.h"
15 #include "irhooks.h"
16 #include "dbginfo_t.h"
17 #include "firmstat_t.h"
18
19 #include "bestat.h"
20 #include "belive_t.h"
21 #include "besched.h"
22
23 #undef MIN
24 #define MIN(a, b) (a < b ? a : b)
25
26 /**
27  * Collect reg pressure statistics per block and per class.
28  */
29 static void stat_reg_pressure_block(ir_node *block, void *env) {
30         be_irg_t         *birg = env;
31         const arch_env_t *aenv = birg->main_env->arch_env;
32         int i, n = arch_isa_get_n_reg_class(aenv->isa);
33
34         for (i = 0; i < n; i++) {
35                 const arch_register_class_t *cls = arch_isa_get_reg_class(aenv->isa, i);
36                 ir_node  *irn;
37                 pset     *live_nodes = pset_new_ptr(64);
38                 int       max_live;
39
40                 live_nodes = be_liveness_end_of_block(aenv, cls, block, live_nodes);
41                 max_live   = pset_count(live_nodes);
42
43                 sched_foreach_reverse(block, irn) {
44                         int cnt;
45
46                         live_nodes = be_liveness_transfer(aenv, cls, irn, live_nodes);
47                         cnt        = pset_count(live_nodes);
48
49                         max_live = cnt < max_live ? max_live : cnt;
50                 }
51
52                 stat_be_block_regpressure(birg->irg, block, max_live, cls->name);
53         }
54 }
55
56 void be_do_stat_reg_pressure(be_irg_t *birg) {
57         /* Collect register pressure information for each block */
58         irg_block_walk_graph(birg->irg, stat_reg_pressure_block, NULL, birg);
59 }
60
61 /**
62  * Notify statistic module about amount of ready nodes.
63  */
64 void be_do_stat_sched_ready(ir_node *block, nodeset *ready_set) {
65         stat_be_block_sched_ready(get_irn_irg(block), block, nodeset_count(ready_set));
66 }
67
68 #else
69
70 void (be_do_stat_reg_pressure)(be_irg_t *birg) {}
71 void (be_do_stat_sched_ready)(ir_node *block, nodeset *ready_set) {}
72
73 #endif /* FIRM_STATISTICS */