Added statistic events
[libfirm] / ir / stat / statev.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       Statistic events.
23  * @author      Sebastian Hack
24  * @date        17.06.2007
25  * @version     $Id$
26  */
27
28 #ifndef FIRM_STATEVENT_H
29 #define FIRM_STATEVENT_H
30
31 #ifndef FIRM_STATISTICS
32
33 #define stat_ev_cnt_decl(var)
34 #define stat_ev_cnt_inc(var)
35 #define stat_ev_cnt_done(name, var)
36 #define stat_ev(name)
37
38 #define stat_ev_ctx_push_fobj(key, firm_object)
39 #define stat_ev_ctx_push(key, value)
40 #define stat_ev_ctx_pop()
41 #define stat_ev_begin(prefix, blub)
42 #define stat_ev_end()
43
44 #else
45
46 extern int stat_ev_enabled;
47
48 #define stat_ev_do(expr)            (stat_ev_enabled ? ((expr), 1) : 0)
49
50 #define stat_ev_dbl(name, val)      if (stat_ev_enabled) { stat_ev_emit(name, val); }
51
52 #define stat_ev_cnt_decl(var)       int stat_ev_cnt_var_ ## var = 0
53 #define stat_ev_cnt_inc(var)        (void) ++stat_ev_cnt_var_ ## var
54 #define stat_ev_cnt_done(var, name) stat_ev_dbl((name), stat_ev_cnt_var_ ## var)
55
56 #define stat_ev(name)               stat_ev_dbl((name), 0.0)
57
58 void stat_ev_ctx_push_fobj(const char *key, const void *firm_object);
59 void stat_ev_ctx_push(const char *key, const char *value);
60 void stat_ev_ctx_pop(void);
61 void stat_ev_emit(const char *name, double val);
62 void stat_ev_begin(const char *prefix);
63 void stat_ev_end(void);
64
65 #endif
66
67 #endif /* FIRM_STATEVENT_H */