query firmstat options through lc_opt system
[libfirm] / include / libfirm / statev.h
1 /*
2  * Copyright (C) 1995-2008 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  */
25 #ifndef FIRM_STATEVENT_H
26 #define FIRM_STATEVENT_H
27
28 /**
29  * @defgroup statev Statistic Events
30  *
31  * The statistics system helps to evaluate the effects of compiler passes and
32  * transformations. It is typically used to collect information like the number
33  * of instruction before and behind a pass, counting specific patterns or
34  * measuring the timing of subcomponents. This can create quite a bit of data,
35  * so we provide a framework for producing such data in an organzied way and
36  * some external tools to analyse such data.
37  *
38  * The system is based on 2 concepts: Events and Contexts. A statistic-event is
39  * a pair of an event name and a double value. Events are put into a context
40  * like the compilation unit, the currently compiled function or the currently
41  * allocated register class. So contexts refine events and allow a grouping of
42  * events based on their context later. The context is managed in an
43  * hierarchic manner. You can push key/value pairs to refine the previous
44  * context or pop them again to get back to the previous broader context.
45  *
46  * @{
47  */
48
49 /** Pushes a new setting on the context stack. */
50 FIRM_API void stat_ev_ctx_push_fmt(const char *key, const char *fmt, ...);
51 /** Pushes a new setting with a string value on the context stack. */
52 FIRM_API void stat_ev_ctx_push_str(const char *key, const char *str);
53 /** Pops last setting from context stack. */
54 FIRM_API void stat_ev_ctx_pop(const char *key);
55 /** Emits a statistic event with a double value. */
56 FIRM_API void stat_ev_dbl(const char *name, double value);
57 /** Emits a statistic event with an integer value. */
58 FIRM_API void stat_ev_int(const char *name, int value);
59 /** Emits a statistic event with an unsigned long long value. */
60 FIRM_API void stat_ev_ull(const char *name, unsigned long long value);
61 /** Emits a statistic event (without an additional value). */
62 FIRM_API void stat_ev(const char *name);
63
64 /**
65  * Initialize the stat ev machinery.
66  * @param filename_prefix  The prefix of the filename (.ev or .ev.gz will be
67  *                         appended).
68  * @param filter           All pushes, pops and events will be filtered by this.
69  *                         If we have regex support, you can give an extended
70  *                         regex here. If not, each key will be matched against
71  *                         this. Matched means, we look if the key starts with
72  *                         @p filter. If NULL is given, each key passes, ie
73  *                         the filter is always TRUE.
74  */
75 FIRM_API void stat_ev_begin(const char *filename_prefix, const char *filter);
76
77 /**
78  * Shuts down stat ev machinery
79  */
80 FIRM_API void stat_ev_end(void);
81
82 /**
83  * This variable indicates whether statev output is enabled.
84  */
85 FIRM_API int stat_ev_enabled;
86
87 /** @} */
88
89 #endif