dags implemented, ProjM, COUNT_DELETED
[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   FIRMSTAT_COUNT_STRONG_OP = 0x00000004,        /**< if set, count Mul/Div/Mod/DivMod by constant */
28   FIRMSTAT_COUNT_DAG       = 0x00000008,        /**< if set, count DAG statistics */
29   FIRMSTAT_COUNT_DELETED   = 0x00000010,        /**< if set, count deleted graphs */
30   FIRMSTAT_CSV_OUTPUT      = 0x10000000         /**< CSV output of some mini-statistic */
31 };
32
33 /**
34  * Finish the statistics.
35  * Never called from libFirm should be called from user.
36  *
37  * @param name   basename of the statistic output file
38  */
39 void stat_finish(const char *name);
40
41 #ifdef FIRM_STATISTICS
42
43 typedef enum {
44   STAT_OPT_STG,                 /**< straightening optimization */
45   STAT_OPT_IFSIM,               /**< if simplification */
46   STAT_OPT_CONST_EVAL,          /**< constant evaluation */
47   STAT_OPT_ALGSIM,              /**< algebraic simplification */
48   STAT_OPT_PHI,                 /**< Phi optmization */
49   STAT_OPT_WAW,                 /**< Write-After-Write optimization */
50   STAT_OPT_WAR,                 /**< Write-After-Read optimization */
51   STAT_OPT_RAW,                 /**< Read-After-Write optimization */
52   STAT_OPT_RAR,                 /**< Read-After-Read optimization */
53   STAT_OPT_RC,                  /**< Read-a-Const optimization */
54   STAT_OPT_TUPLE,               /**< Tuple optimization */
55   STAT_OPT_ID,                  /**< ID optimization */
56   STAT_OPT_CSE,                 /**< common subexpression elimination */
57   STAT_OPT_STRENGTH_RED,        /**< strenght reduction */
58   STAT_OPT_ARCH_DEP,            /**< architecture dependant optimization */
59   STAT_OPT_REASSOC,             /**< reassociation */
60   STAT_OPT_POLY_CALL,           /**< polymorphic call optimization */
61   STAT_LOWERED,                 /**< lowered */
62
63   STAT_OPT_MAX
64 } stat_opt_kind;
65
66 /**
67  * initialize the statistics module.
68  *
69  * @param enable_options  Bitmask containing the statistic options
70  */
71 void init_stat(unsigned enable_options);
72
73 /**
74  * A new IR op is registered.
75  */
76 void stat_new_ir_op(const ir_op *op);
77
78 /**
79  * An IR op is freed.
80  */
81 void stat_free_ir_op(const ir_op *op);
82
83 /**
84  * A new node is created.
85  */
86 void stat_new_node(ir_node *node);
87
88 /**
89  * A node is changed into a Id node
90  */
91 void stat_turn_into_id(ir_node *node);
92
93 /**
94  * A new graph was created
95  */
96 void stat_new_graph(ir_graph *irg, entity *ent);
97
98 /**
99  * A graph was deleted
100  */
101 void stat_free_graph(ir_graph *irg);
102
103 /**
104  * A walk over a graph is initiated
105  */
106 void stat_irg_walk(ir_graph *irg, void *pre, void *post);
107
108 /**
109  * A walk over a graph in block-wise order is initiated
110  */
111 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post);
112
113 /**
114  * A walk over the graph's blocks is initiated
115  */
116 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post);
117
118 /**
119  * Some nodes were optimized into some others due to an optimization
120  */
121 void stat_merge_nodes(
122     ir_node **new_node_array, int new_num_entries,
123     ir_node **old_node_array, int old_num_entries,
124     stat_opt_kind opt);
125
126 /**
127  * Reassociation of nodes started/stopped.
128  */
129 void stat_reassociate(int start);
130
131 /**
132  * A node was lowered into other nodes
133  */
134 void stat_lower(ir_node *node);
135
136 /**
137  * A graph was inlined
138  */
139 void stat_inline(ir_node *call, ir_graph *irg);
140
141 /**
142  * A graph with tail-recursions was optimized.
143  */
144 void stat_tail_rec(ir_graph *irg);
145
146 /**
147  * Strength reduction was performed on an iteration variable.
148  */
149 void stat_strength_red(ir_graph *irg, ir_node *strong, ir_node *cmp);
150
151 /**
152  * Start the dead node elimination.
153  */
154 void stat_dead_node_elim_start(ir_graph *irg);
155
156 /**
157  * Stops the dead node elimination.
158  */
159 void stat_dead_node_elim_stop(ir_graph *irg);
160
161 /**
162  * A multiply was replaced by a series of Shifts/Adds/Subs
163  */
164 void stat_arch_dep_replace_mul_with_shifts(ir_node *mul);
165
166 /**
167  * A division was replaced by a series of Shifts/Muls
168  */
169 void stat_arch_dep_replace_div_by_const(ir_node *div);
170
171 /**
172  * A modulo was replaced by a series of Shifts/Muls
173  */
174 void stat_arch_dep_replace_mod_by_const(ir_node *mod);
175
176 /**
177  * A Divod was replaced by a series of Shifts/Muls
178  */
179 void stat_arch_dep_replace_DivMod_by_const(ir_node *divmod);
180
181 /**
182  * helper: get an ir_op from an opcode
183  *
184  * @param code  the opcode
185  *
186  * @return  The associated ir_op or NULL if the opcode could not be found.
187  */
188 ir_op *stat_get_op_from_opcode(opcode code);
189
190 #else
191
192 #define init_stat(enable_options)
193 #define stat_finish(name)
194 #define stat_new_ir_op(op)
195 #define stat_free_ir_op(op)
196 #define stat_new_node(node)
197 #define stat_turn_into_id(node)
198 #define stat_new_graph(irg, ent)
199 #define stat_free_graph(irg)
200 #define stat_irg_walk(irg, pre, post)
201 #define stat_irg_walk_blkwise(irg, pre, post)
202 #define stat_irg_block_walk(irg, node, pre, post)
203 #define stat_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt)
204 #define stat_reassociate(start)
205 #define stat_lower(node)
206 #define stat_inline(call, irg)
207 #define stat_tail_rec(irg)
208 #define stat_strength_red(irg, strong, cmp)
209 #define stat_dead_node_elim_start(irg)
210 #define stat_dead_node_elim_stop(irg)
211 #define stat_arch_dep_replace_mul_with_shifts(irn)
212 #define stat_arch_dep_replace_div_by_const(irn)
213 #define stat_arch_dep_replace_mod_by_const(irn)
214 #define stat_arch_dep_replace_DivMod_by_const(irn)
215
216 #endif
217
218 #endif /* _FIRMSTAT_H_ */