rewritten be_ssa_constr which isn't using sets anymore, started working on a 'state...
[libfirm] / ir / be / bestat.h
1 /**
2  * Provides several statistic functions for the backend.
3  * @author Christian Wuerdig
4  * $Id$
5  */
6
7 #ifndef _BESTAT_H_
8 #define _BESTAT_H_
9
10 #include "firm_config.h"
11 #include "be_t.h"
12 #include "benodesets.h"
13 #include "bestatevent.h"
14
15 enum {
16         STAT_TAG_FILE = 0,  /**< tag for source file name */
17         STAT_TAG_TIME = 1,  /**< tag for time */
18         STAT_TAG_IRG  = 2,  /**< tag for function name (irg) */
19         STAT_TAG_CLS  = 3,  /**< tag for register class (or "<all>") */
20         STAT_TAG_LAST
21 };
22
23 extern FILE *be_stat_file;
24 extern const char *be_stat_tags[STAT_TAG_LAST];
25
26
27 #ifdef FIRM_STATISTICS
28
29 /**
30  * Collects statistics information about register pressure.
31  * @param birg The be irg object containing the irg
32  */
33 void be_do_stat_reg_pressure(be_irg_t *birg);
34
35 /**
36  * Collect statistics about amount of ready nodes per block
37  * @param block     The block
38  * @param ready_set A set of ready nodes
39  */
40 void be_do_stat_sched_ready(ir_node *block, const ir_nodeset_t *ready_set);
41
42 /**
43  * Pass information about a perm to the statistic module.
44  *
45  * @param class_name the name of the register class
46  * @param n_regs     number of registers in the register class
47  * @param perm       the perm node
48  * @param block      the block containing the perm
49  * @param size       the size of the perm
50  * @param real_size  number of pairs with different registers
51  */
52 void be_do_stat_perm(const char *class_name, int n_regs, ir_node *perm, ir_node *block, int n, int real_size);
53
54 /**
55  * Pass information about a cycle or chain in a perm to the statistic module.
56  *
57  * @param class_name the name of the register class
58  * @param perm       the perm node
59  * @param block      the block containing the perm
60  * @param is_chain   1 if chain, 0 if cycle
61  * @param size       length of the cycle/chain
62  * @param n_ops      the number of ops representing this cycle/chain after lowering
63  */
64 void be_do_stat_permcycle(const char *class_name, ir_node *perm, ir_node *block, int is_chain, int n_elems, int n_ops);
65
66 /**
67  * Collects node statistics.
68  *
69  * @param irg      the to do statistics for
70  * @param phase    the phase to collect the statistic for
71  */
72 void be_do_stat_nodes(ir_graph *irg, const char *phase);
73
74 /**
75  * Performs initialization for be node statistics.
76  */
77 void be_stat_init_irg(const arch_env_t *arch_env, ir_graph *irg);
78
79 void be_init_stat_file(const char *filename, const char *sourcefilename);
80 void be_close_stat_file(void);
81
82 #else
83
84 #define be_stat_init_irg(arch_env, irg)
85 #define be_do_stat_nodes(irg, phase)
86 #define be_do_stat_reg_pressure(birg)
87 #define be_do_stat_sched_ready(block, ready_set)
88 #define be_do_stat_perm(class_name, n_regs, perm, block, n, real_size)
89 #define be_do_stat_permcycle(class_name, perm, block, is_chain, n_elems, n_ops)
90
91 #endif /* FIRM_STATISTICS */
92
93 /**
94  * Gives a cost estimate for the program (based on execution frequencies)
95  * and backend op_estimated_cost
96  */
97 double be_estimate_irg_costs(ir_graph *irg, const arch_env_t *arch_env, ir_exec_freq *execfreqs);
98
99 #endif /* _BESTAT_H_ */