unified mein file comments
[libfirm] / ir / be / bestat.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Provides several statistic functions for the backend.
23  * @author      Christian Wuerdig
24  * @version     $Id$
25  */
26 #ifndef FIRM_BE_BESTAT_H
27 #define FIRM_BE_BESTAT_H
28
29 #include "firm_config.h"
30
31 #include "irnode.h"
32 #include "irgraph.h"
33 #include "irnodeset.h"
34 #include "execfreq.h"
35
36 #include "beirg.h"
37 #include "bestatevent.h"
38 #include "bearch.h"
39
40 enum {
41         STAT_TAG_FILE = 0,  /**< tag for source file name */
42         STAT_TAG_TIME = 1,  /**< tag for time */
43         STAT_TAG_IRG  = 2,  /**< tag for function name (irg) */
44         STAT_TAG_CLS  = 3,  /**< tag for register class (or "<all>") */
45         STAT_TAG_LAST
46 };
47
48 extern FILE *be_stat_file;
49 extern const char *be_stat_tags[STAT_TAG_LAST];
50
51
52 #ifdef FIRM_STATISTICS
53
54 /**
55  * Collects statistics information about register pressure.
56  * @param birg The be irg object containing the irg
57  */
58 void be_do_stat_reg_pressure(be_irg_t *birg);
59
60 /**
61  * Collect statistics about amount of ready nodes per block
62  * @param block     The block
63  * @param ready_set A set of ready nodes
64  */
65 void be_do_stat_sched_ready(ir_node *block, const ir_nodeset_t *ready_set);
66
67 /**
68  * Pass information about a perm to the statistic module.
69  *
70  * @param class_name the name of the register class
71  * @param n_regs     number of registers in the register class
72  * @param perm       the perm node
73  * @param block      the block containing the perm
74  * @param size       the size of the perm
75  * @param real_size  number of pairs with different registers
76  */
77 void be_do_stat_perm(const char *class_name, int n_regs, ir_node *perm, ir_node *block, int n, int real_size);
78
79 /**
80  * Pass information about a cycle or chain in a perm to the statistic module.
81  *
82  * @param class_name the name of the register class
83  * @param perm       the perm node
84  * @param block      the block containing the perm
85  * @param is_chain   1 if chain, 0 if cycle
86  * @param size       length of the cycle/chain
87  * @param n_ops      the number of ops representing this cycle/chain after lowering
88  */
89 void be_do_stat_permcycle(const char *class_name, ir_node *perm, ir_node *block, int is_chain, int n_elems, int n_ops);
90
91 /**
92  * Collects node statistics.
93  *
94  * @param irg      the to do statistics for
95  * @param phase    the phase to collect the statistic for
96  */
97 void be_do_stat_nodes(ir_graph *irg, const char *phase);
98
99 /**
100  * Performs initialization for be node statistics.
101  */
102 void be_stat_init_irg(const arch_env_t *arch_env, ir_graph *irg);
103
104 void be_init_stat_file(const char *filename, const char *sourcefilename);
105 void be_close_stat_file(void);
106
107 #else /* ! FIRM_STATISTICS */
108
109 #define be_stat_init_irg(arch_env, irg)
110 #define be_do_stat_nodes(irg, phase)
111 #define be_do_stat_reg_pressure(birg)
112 #define be_do_stat_sched_ready(block, ready_set)
113 #define be_do_stat_perm(class_name, n_regs, perm, block, n, real_size)
114 #define be_do_stat_permcycle(class_name, perm, block, is_chain, n_elems, n_ops)
115
116 #endif /* FIRM_STATISTICS */
117
118 /**
119  * Gives a cost estimate for the program (based on execution frequencies)
120  * and backend op_estimated_cost
121  */
122 double be_estimate_irg_costs(ir_graph *irg, const arch_env_t *arch_env, ir_exec_freq *execfreqs);
123
124 #endif /* FIRM_BE_BESTAT_H */