2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Statistic events.
9 * @author Sebastian Hack
11 #ifndef FIRM_STATEVENT_H
12 #define FIRM_STATEVENT_H
15 * @defgroup statev Statistic Events
17 * The statistics system helps to evaluate the effects of compiler passes and
18 * transformations. It is typically used to collect information like the number
19 * of instruction before and behind a pass, counting specific patterns or
20 * measuring the timing of subcomponents. This can create quite a bit of data,
21 * so we provide a framework for producing such data in an organzied way and
22 * some external tools to analyse such data.
24 * The system is based on 2 concepts: Events and Contexts. A statistic-event is
25 * a pair of an event name and a double value. Events are put into a context
26 * like the compilation unit, the currently compiled function or the currently
27 * allocated register class. So contexts refine events and allow a grouping of
28 * events based on their context later. The context is managed in an
29 * hierarchic manner. You can push key/value pairs to refine the previous
30 * context or pop them again to get back to the previous broader context.
35 /** Pushes a new setting on the context stack. */
36 FIRM_API void stat_ev_ctx_push_fmt(const char *key, const char *fmt, ...);
37 /** Pushes a new setting with a string value on the context stack. */
38 FIRM_API void stat_ev_ctx_push_str(const char *key, const char *str);
39 /** Pops last setting from context stack. */
40 FIRM_API void stat_ev_ctx_pop(const char *key);
41 /** Emits a statistic event with a double value. */
42 FIRM_API void stat_ev_dbl(const char *name, double value);
43 /** Emits a statistic event with an integer value. */
44 FIRM_API void stat_ev_int(const char *name, int value);
45 /** Emits a statistic event with an unsigned long long value. */
46 FIRM_API void stat_ev_ull(const char *name, unsigned long long value);
47 /** Emits a statistic event (without an additional value). */
48 FIRM_API void stat_ev(const char *name);
51 * Initialize the stat ev machinery.
52 * @param filename_prefix The prefix of the filename (.ev or .ev.gz will be
54 * @param filter All pushes, pops and events will be filtered by this.
55 * If we have regex support, you can give an extended
56 * regex here. If not, each key will be matched against
57 * this. Matched means, we look if the key starts with
58 * @p filter. If NULL is given, each key passes, ie
59 * the filter is always TRUE.
61 FIRM_API void stat_ev_begin(const char *filename_prefix, const char *filter);
64 * Shuts down stat ev machinery
66 FIRM_API void stat_ev_end(void);
69 * This variable indicates whether statev output is enabled.
71 FIRM_API int stat_ev_enabled;