normalized names of functions, enums ...
[libfirm] / ir / stat / firmstat.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/stat/firmstat.h
4  * Purpose:     Statistics for Firm.
5  * Author:      Michael Beck
6  * Created:
7  * CVS-ID:      $Id$
8  * Copyright:   (c) 2004 Universität Karlsruhe
9  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
10  */
11 #ifndef _FIRMSTAT_H_
12 #define _FIRMSTAT_H_
13
14 /**
15  * @file firmstat.h
16  */
17 #include "irop.h"
18 #include "irnode.h"
19 #include "irgraph.h"
20
21 /**
22  * Statistic options, can be or'ed.
23  */
24 enum firmstat_options_t {
25   FIRMSTAT_ENABLED         = 0x00000001,        /**< enable statistics */
26   FIRMSTAT_PATTERN_ENABLED = 0x00000002         /**< enable pattern calculation */
27 };
28
29 /**
30  * Finish the statistics.
31  * Never called from libFirm should be called from user.
32  */
33 void stat_finish(void);
34
35 #ifdef FIRM_STATISTICS
36
37 typedef enum {
38   STAT_OPT_STG,         /**< straightening optimization */
39   STAT_OPT_IFSIM,       /**< if simplification */
40   STAT_OPT_ALGSIM,      /**< algebraic simplification */
41   STAT_OPT_PHI,         /**< Phi optmization */
42   STAT_OPT_WAW,         /**< Write-After-Write optimization */
43   STAT_OPT_WAR,         /**< Write-After-Read optimization */
44   STAT_OPT_RAW,         /**< Read-After-Write optimization */
45   STAT_OPT_TUPLE,       /**< Tuple optimization */
46   STAT_OPT_ID,          /**< ID optimization */
47   STAT_OPT_CONST_EVAL,  /**< constant evaluation */
48   STAT_LOWERED,         /**< lowered */
49
50   STAT_OPT_MAX
51 } stat_opt_kind;
52
53 /**
54  * initialize the statistics module.
55  *
56  * @param enable_options  Bitmask containing the statistic options
57  */
58
59 void init_stat(void);
60
61 /**
62  * Finish the statistics.
63  */
64 void stat_finish(void);
65
66 /**
67  * A new IR op is registered.
68  */
69 void stat_new_ir_op(const ir_op *op);
70
71 /**
72  * An IR op is freed.
73  */
74 void stat_free_ir_op(const ir_op *op);
75
76 /**
77  * A new node is created.
78  */
79 void stat_new_node(const ir_node *node);
80
81 /**
82  * A node is changed into a Id node
83  */
84 void stat_turn_into_id(const ir_node *node);
85
86 /**
87  * A new graph was created
88  */
89 void stat_new_graph(ir_graph *irg, entity *ent);
90
91 /**
92  * A graph was deleted
93  */
94 void stat_free_graph(ir_graph *irg);
95
96 /**
97  * A walk over a graph is initiated
98  */
99 void stat_irg_walk(ir_graph *irg, void *pre, void *post);
100
101 /**
102  * A walk over a graph in block-wise order is initiated
103  */
104 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post);
105
106 /**
107  * A walk over the graph's blocks is initiated
108  */
109 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post);
110
111 /**
112  * Some nodes were optimized into some others due to an optimization
113  */
114 void stat_merge_nodes(
115     ir_node **new_node_array, int new_num_entries,
116     ir_node **old_node_array, int old_num_entries,
117     stat_opt_kind opt);
118
119 /**
120  * A node was lowered into other nodes
121  */
122 void stat_lower(ir_node *node);
123
124 /**
125  * A graph was inlined
126  */
127 void stat_inline(ir_node *call, ir_graph *irg);
128
129 /**
130  * A graph with tail-recursions was optimized.
131  */
132 void stat_tail_rec(ir_graph *irg);
133
134 /**
135  * Start the dead node elimination.
136  */
137 void stat_dead_node_elim_start(ir_graph *irg);
138
139 /**
140  * Stops the dead node elimination.
141  */
142 void stat_dead_node_elim_stop(ir_graph *irg);
143
144 /**
145  * helper: get an ir_op from an opcode
146  *
147  * @param code  the opcode
148  *
149  * @return  The associated ir_op or NULL if the opcode could not be found.
150  */
151 ir_op *stat_get_op_from_opcode(opcode code);
152
153 #else
154
155 #define init_stat()
156 #define stat_finish()
157 #define stat_new_ir_op(op)
158 #define stat_free_ir_op(op)
159 #define stat_new_node(node)
160 #define stat_turn_into_id(node)
161 #define stat_new_graph(irg, ent)
162 #define stat_free_graph(irg)
163 #define stat_irg_walk(irg, pre, post)
164 #define stat_irg_walk_blkwise(irg, pre, post)
165 #define stat_irg_block_walk(irg, node, pre, post)
166 #define stat_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt)
167 #define stat_lower(node)
168 #define stat_inline(call, irg)
169 #define stat_tail_rec(irg)
170 #define stat_dead_node_elim_start(irg)
171 #define stat_dead_node_elim_stop(irg)
172
173 #endif
174
175 #endif /* _FIRMSTAT_H_ */