added statistics for blocks
[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  * Finish the statistics.
23  * Never called from libFirm should be called from user.
24  */
25 void stat_finish(void);
26
27 #ifdef FIRM_STATISTICS
28
29 typedef enum {
30   STAT_OPT_STG,         /**< straightening optimization */
31   STAT_OPT_IFSIM,       /**< if simplification */
32   STAT_OPT_ALGSIM,      /**< algebraic simplification */
33   STAT_OPT_PHI,         /**< Phi optmization */
34   STAT_OPT_WAW,         /**< Write-After-Write optimization */
35   STAT_OPT_WAR,         /**< Write-After-Read optimization */
36   STAT_OPT_RAW,         /**< Read-After-Write optimization */
37   STAT_OPT_TUPLE,       /**< Tuple optimization */
38   STAT_OPT_ID,          /**< ID optimization */
39   STAT_OPT_CONST_EVAL,  /**< constant evaluation */
40   STAT_LOWERED,         /**< lowered */
41
42   STAT_OPT_MAX
43 } stat_opt_kind;
44
45 /**
46  * initialize the statistics module.
47  */
48 void stat_init(void);
49
50 /**
51  * A new IR op is registered.
52  */
53 void stat_new_ir_op(const ir_op *op);
54
55 /**
56  * An IR op is freed.
57  */
58 void stat_free_ir_op(const ir_op *op);
59
60 /**
61  * A new node is created.
62  */
63 void stat_new_node(const ir_node *node);
64
65 /**
66  * A node is changed into a Id node
67  */
68 void stat_turn_into_id(const ir_node *node);
69
70 /**
71  * A new graph was created
72  */
73 void stat_new_graph(ir_graph *irg, entity *ent);
74
75 /**
76  * A graph was deleted
77  */
78 void stat_free_graph(ir_graph *irg);
79
80 /**
81  * A walk over a graph is initiated
82  */
83 void stat_irg_walk(ir_graph *irg, void *pre, void *post);
84
85 /**
86  * A walk over a graph in block-wise order is initiated
87  */
88 void stat_irg_walk_blkwise(ir_graph *irg, void *pre, void *post);
89
90 /**
91  * A walk over the graph's blocks is initiated
92  */
93 void stat_irg_block_walk(ir_graph *irg, const ir_node *node, void *pre, void *post);
94
95 /**
96  * Some nodes were optimized into some others due to an optimization
97  */
98 void stat_merge_nodes(
99     ir_node **new_node_array, int new_num_entries,
100     ir_node **old_node_array, int old_num_entries,
101     stat_opt_kind opt);
102
103 /**
104  * A node was lowered into other nodes
105  */
106 void stat_lower(ir_node *node);
107
108 /**
109  * A graph was inlined
110  */
111 void stat_inline(ir_node *call, ir_graph *irg);
112
113 /**
114  * A graph with tail-recursions was optimized.
115  */
116 void stat_tail_rec(ir_graph *irg);
117
118 /**
119  * Start the dead node elimination.
120  */
121 void stat_dead_node_elim_start(ir_graph *irg);
122
123 /**
124  * Stops the dead node elimination.
125  */
126 void stat_dead_node_elim_stop(ir_graph *irg);
127
128 /**
129  * helper: get an ir_op from an opcode
130  *
131  * @param code  the opcode
132  *
133  * @return  The associated ir_op or NULL if the opcode could not be found.
134  */
135 ir_op *stat_get_op_from_opcode(opcode code);
136
137 #else
138
139 #define stat_init()
140 #define stat_new_ir_op(op)
141 #define stat_free_ir_op(op)
142 #define stat_new_node(node)
143 #define stat_turn_into_id(node)
144 #define stat_new_graph(irg, ent)
145 #define stat_free_graph(irg)
146 #define stat_irg_walk(irg, pre, post)
147 #define stat_irg_walk_blkwise(irg, pre, post)
148 #define stat_irg_block_walk(irg, node, pre, post)
149 #define stat_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt)
150 #define stat_lower(node)
151 #define stat_inline(call, irg)
152 #define stat_tail_rec(irg)
153 #define stat_dead_node_elim_start(irg)
154 #define stat_dead_node_elim_stop(irg)
155
156 #endif
157
158 #endif /* _FIRMSTAT_H_ */