lowering.h \
nodeops.h \
opcodes.h \
+ statev.h \
timing.h \
trouts.h \
tv.h \
--- /dev/null
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Statistic events.
+ * @author Sebastian Hack
+ */
+#ifndef FIRM_STATEVENT_H
+#define FIRM_STATEVENT_H
+
+/**
+ * @defgroup statev Statistic Events
+ *
+ * The statistics system helps to evaluate the effects of compiler passes and
+ * transformations. It is typically used to collect information like the number
+ * of instruction before and behind a pass, counting specific patterns or
+ * measuring the timing of subcomponents. This can create quite a bit of data,
+ * so we provide a framework for producing such data in an organzied way and
+ * some external tools to analyse such data.
+ *
+ * The system is based on 2 concepts: Events and Contexts. A statistic-event is
+ * a pair of an event name and a double value. Events are put into a context
+ * like the compilation unit, the currently compiled function or the currently
+ * allocated register class. So contexts refine events and allow a grouping of
+ * events based on their context later. The context is managed in an
+ * hierarchic manner. You can push key/value pairs to refine the previous
+ * context or pop them again to get back to the previous broader context.
+ *
+ * @{
+ */
+
+/** Pushes a new setting on the context stack. */
+FIRM_API void stat_ev_ctx_push_fmt(const char *key, const char *fmt, ...);
+/** Pushes a new setting with a string value on the context stack. */
+FIRM_API void stat_ev_ctx_push_str(const char *key, const char *str);
+/** Pops last setting from context stack. */
+FIRM_API void stat_ev_ctx_pop(const char *key);
+/** Emits a statistic event with a double value. */
+FIRM_API void stat_ev_dbl(const char *name, double value);
+/** Emits a statistic event with an integer value. */
+FIRM_API void stat_ev_int(const char *name, int value);
+/** Emits a statistic event with an unsigned long long value. */
+FIRM_API void stat_ev_ull(const char *name, unsigned long long value);
+/** Emits a statistic event (without an additional value). */
+FIRM_API void stat_ev(const char *name);
+
+/**
+ * Initialize the stat ev machinery.
+ * @param filename_prefix The prefix of the filename (.ev or .ev.gz will be
+ * appended).
+ * @param filter All pushes, pops and events will be filtered by this.
+ * If we have regex support, you can give an extended
+ * regex here. If not, each key will be matched against
+ * this. Matched means, we look if the key starts with
+ * @p filter. If NULL is given, each key passes, ie
+ * the filter is always TRUE.
+ */
+FIRM_API void stat_ev_begin(const char *filename_prefix, const char *filter);
+
+/**
+ * Shuts down stat ev machinery
+ */
+FIRM_API void stat_ev_end(void);
+
+/**
+ * This variable indicates whether statev output is enabled.
+ */
+FIRM_API int stat_ev_enabled;
+
+/** @} */
+
+#endif
stat/pattern_dmp.h \
stat/stat_dmp.h \
stat/stat_timing.h \
- stat/statev.h \
+ stat/statev_t.h \
tr/compound_path_t.h \
tr/entity_t.h \
tr/tpop_t.h \
#include "irprintf.h"
#include "irdom_t.h"
#include "set.h"
-#include "statev.h"
+#include "statev_t.h"
#include "dfs_t.h"
#include "util.h"
#include "set.h"
#include "hashptr.h"
#include "debug.h"
-#include "statev.h"
+#include "statev_t.h"
#include "dfs_t.h"
#include "absgraph.h"
#include "irlivechk.h"
-#include "statev.h"
+#include "statev_t.h"
typedef struct bl_info_t {
const ir_node *block; /**< The block. */
#include "beirgmod.h"
#include "beifg.h"
#include "beinsn_t.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "beirg.h"
#include "beintlive_t.h"
#include "bera.h"
#include "beirgmod.h"
#include "beinsn_t.h"
#include "besched.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "benode.h"
#include "bemodule.h"
#include "belive.h"
if (perm == NULL)
return NULL;
- be_stat_ev("constr_perm", get_irn_arity(perm));
+ stat_ev_int("constr_perm", get_irn_arity(perm));
foreach_out_edge(perm, edge) {
ir_node *proj = get_edge_src_irn(edge);
arch_set_irn_register(proj, NULL);
#include "bearch.h"
#include "beifg.h"
#include "benode.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "bestat.h"
#include "bemodule.h"
#include "be_t.h"
#include "irtools.h"
#include "error.h"
#include "list.h"
-#include "statev.h"
+#include "statev_t.h"
#include "bearch.h"
#include "beifg.h"
#include "irtools.h"
#include "irprintf.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "beirg.h"
#include "bemodule.h"
#include "error.h"
lpp_solve(ienv->lp, be_options.ilp_server, be_options.ilp_solver);
- //be_stat_ev_dbl("co_ilp_objval", ienv->lp->objval);
- //be_stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound);
- be_stat_ev ("co_ilp_iter", lpp_get_iter_cnt(ienv->lp));
- be_stat_ev_dbl("co_ilp_sol_time", lpp_get_sol_time(ienv->lp));
+ //stat_ev_dbl("co_ilp_objval", ienv->lp->objval);
+ //stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound);
+ stat_ev_int("co_ilp_iter", lpp_get_iter_cnt(ienv->lp));
+ stat_ev_dbl("co_ilp_sol_time", lpp_get_sol_time(ienv->lp));
ienv->apply(ienv);
#include "bemodule.h"
#include "benode.h"
#include "besched.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "beutil.h"
#include "lc_opts.h"
co_complete_stats(co, &before);
- be_stat_ev_ull("co_aff_nodes", before.aff_nodes);
- be_stat_ev_ull("co_aff_edges", before.aff_edges);
- be_stat_ev_ull("co_max_costs", before.max_costs);
- be_stat_ev_ull("co_inevit_costs", before.inevit_costs);
- be_stat_ev_ull("co_aff_int", before.aff_int);
+ stat_ev_ull("co_aff_nodes", before.aff_nodes);
+ stat_ev_ull("co_aff_edges", before.aff_edges);
+ stat_ev_ull("co_max_costs", before.max_costs);
+ stat_ev_ull("co_inevit_costs", before.inevit_costs);
+ stat_ev_ull("co_aff_int", before.aff_int);
- be_stat_ev_ull("co_init_costs", before.costs);
- be_stat_ev_ull("co_init_unsat", before.unsatisfied_edges);
+ stat_ev_ull("co_init_costs", before.costs);
+ stat_ev_ull("co_init_unsat", before.unsatisfied_edges);
if (dump_flags & DUMP_BEFORE) {
FILE *f = my_open(cenv, "", "-before.vcg");
/* do the stats and provide the current costs */
co_complete_stats(co, &stats);
- be_stat_ev_ull("co_prepare_costs", stats.costs);
+ stat_ev_ull("co_prepare_costs", stats.costs);
}
/* perform actual copy minimization */
was_optimal = selected_copyopt->copyopt(co);
ir_timer_stop(timer);
- be_stat_ev("co_time", ir_timer_elapsed_msec(timer));
- be_stat_ev_ull("co_optimal", was_optimal);
+ stat_ev_dbl("co_time", ir_timer_elapsed_msec(timer));
+ stat_ev_ull("co_optimal", was_optimal);
ir_timer_free(timer);
if (dump_flags & DUMP_AFTER) {
fclose(f);
}
- be_stat_ev_ull("co_after_costs", after.costs);
- be_stat_ev_ull("co_after_unsat", after.unsatisfied_edges);
+ stat_ev_ull("co_after_costs", after.costs);
+ stat_ev_ull("co_after_unsat", after.unsatisfied_edges);
co_free_graph_structure(co);
co_free_ou_structure(co);
#include "irgraph_t.h"
#include "iredges_t.h"
-#include "statev.h"
+#include "statev_t.h"
#include "beirg.h"
#include "besched.h"
#include "irnodeset.h"
#include "absgraph.h"
-#include "statev.h"
+#include "statev_t.h"
#include "beutil.h"
#include "belive_t.h"
#include "irnodehashmap.h"
#include "irhooks.h"
#include "irlivechk.h"
-#include "statev.h"
+#include "statev_t.h"
#include "pset.h"
#include "bitset.h"
current_ir_graph = irg;
if (stat_ev_enabled) {
- stat_ev_ctx_push_fobj("bemain_irg", irg);
- be_stat_ev("bemain_insns_start", be_count_insns(irg));
- be_stat_ev("bemain_blocks_start", be_count_blocks(irg));
+ stat_ev_ctx_push_fmt("bemain_irg", "%+F", irg);
+ stat_ev_ull("bemain_insns_start", be_count_insns(irg));
+ stat_ev_ull("bemain_blocks_start", be_count_blocks(irg));
}
/* stop and reset timers */
if (stat_ev_enabled) {
stat_ev_dbl("bemain_costs_before_ra", be_estimate_irg_costs(irg));
- be_stat_ev("bemain_insns_before_ra", be_count_insns(irg));
- be_stat_ev("bemain_blocks_before_ra", be_count_blocks(irg));
+ stat_ev_ull("bemain_insns_before_ra", be_count_insns(irg));
+ stat_ev_ull("bemain_blocks_before_ra", be_count_blocks(irg));
}
/* Do register allocation */
dump(DUMP_FINAL, irg, "finish");
if (stat_ev_enabled) {
- be_stat_ev("bemain_insns_finish", be_count_insns(irg));
- be_stat_ev("bemain_blocks_finish", be_count_blocks(irg));
+ stat_ev_ull("bemain_insns_finish", be_count_insns(irg));
+ stat_ev_ull("bemain_blocks_finish", be_count_blocks(irg));
}
/* check schedule and register allocation */
#include "debug.h"
#include "iredges_t.h"
#include "raw_bitset.h"
-#include "statev.h"
+#include "statev_t.h"
#include "irgwalk.h"
#include "bespill.h"
#include "bespill.h"
#include "bespillslots.h"
#include "bechordal_t.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "bemodule.h"
#include "beintlive_t.h"
#include "beirg.h"
#include "belive_t.h"
#include "benode.h"
#include "bechordal_t.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "bessaconstr.h"
#include "beirg.h"
#include "beirgmod.h"
ir_node *sb = get_irg_start_block(irg);
int n_blocks = get_Block_dom_max_subtree_pre_num(sb);
- stat_ev_ctx_push_fobj("bessaconstr", irg);
+ stat_ev_ctx_push_fmt("bessaconstr", "%+F", irg);
stat_ev_tim_push();
(void) n_blocks;
#include "belive_t.h"
#include "benode.h"
#include "besched.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "beirg.h"
#include "beintlive_t.h"
}
perm = be_new_Perm(chordal_env->cls, pred_bl, n_projs, in);
- be_stat_ev("phi_perm", n_projs);
+ stat_ev_int("phi_perm", n_projs);
insert_after = pred_bl;
do {
#include "execfreq.h"
#include "firmstat_t.h"
#include "irtools.h"
-#include "statev.h"
#include "error.h"
+#include "statev_t.h"
#include "bearch.h"
#include "beirg.h"
irg_block_walk_graph(irg, stat_reg_pressure_block, NULL, &env);
average_pressure = env.regpressure / env.insn_count;
- stat_ev_emit("bechordal_average_register_pressure", average_pressure);
- stat_ev_emit("bechordal_maximum_register_pressure", env.max_pressure);
+ stat_ev_dbl("bechordal_average_register_pressure", average_pressure);
+ stat_ev_dbl("bechordal_maximum_register_pressure", env.max_pressure);
}
#include "irnodeset.h"
#include "beirg.h"
-#include "bestatevent.h"
#include "bearch.h"
typedef enum be_stat_tag_t {
+++ /dev/null
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Statistic events.
- * @author Sebastian Hack
- * @date 03.09.2006
- */
-#ifndef FIRM_BE_BESTATEVENT_H
-#define FIRM_BE_BESTATEVENT_H
-
-#include <stdio.h>
-
-#include "firm_types.h"
-#include "statev.h"
-
-#define be_stat_ev(name, val) stat_ev_dbl(name, (double)(val))
-#define be_stat_ev_l(name, val) stat_ev_dbl(name, (double)(val))
-#define be_stat_ev_dbl(name, val) stat_ev_dbl(name, (double)(val))
-#define be_stat_ev_ull(name, val) stat_ev_dbl(name, (double)(val))
-#define be_stat_ev_int(name, val) stat_ev_int(name, (int)(val))
-
-#endif /* FIRM_BE_BESTATEVENT_H */
#include "util.h"
#include "stat_timing.h"
#include "irprintf.h"
-#include "statev.h"
+#include "statev_t.h"
#include "config.h"
-#ifndef DISABLE_STATEV
-
#define MAX_TIMER 256
-static FILE* stat_ev_file = NULL;
+int (stat_ev_enabled) = 0;
-int stat_ev_enabled = 0;
-int stat_ev_timer_sp = 0;
-timing_ticks_t stat_ev_timer_elapsed[MAX_TIMER];
-timing_ticks_t stat_ev_timer_start[MAX_TIMER];
+static FILE *stat_ev_file = NULL;
+static int stat_ev_timer_sp = 0;
+static timing_ticks_t stat_ev_timer_elapsed[MAX_TIMER];
+static timing_ticks_t stat_ev_timer_start[MAX_TIMER];
-static regex_t regex;
+static regex_t regex;
static regex_t *filter = NULL;
static inline int key_matches(const char *key)
{
return regexec(filter, key, 0, NULL, 0) == 0;
}
-void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
+static void stat_ev_vprintf(char ev, const char *key, const char *fmt, va_list ap)
{
if (!key_matches(key))
return;
fprintf(stat_ev_file, "%c;%s", ev, key);
if (fmt != NULL) {
char buf[256];
- va_list args;
- va_start(args, fmt);
- ir_vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
+ ir_vsnprintf(buf, sizeof(buf), fmt, ap);
fprintf(stat_ev_file, ";%s", buf);
}
fprintf(stat_ev_file, "\n");
}
+static void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ stat_ev_vprintf(ev, key, fmt, ap);
+ va_end(ap);
+}
+
+void stat_ev_tim_push(void)
+{
+ timing_ticks_t temp;
+ int sp = stat_ev_timer_sp++;
+ timing_ticks(temp);
+ if (sp == 0) {
+ timing_enter_max_prio();
+ } else {
+ timing_ticks_sub(temp, stat_ev_timer_start[sp - 1]);
+ timing_ticks_add(stat_ev_timer_elapsed[sp - 1], temp);
+ }
+ timing_ticks_init(stat_ev_timer_elapsed[sp]);
+ timing_ticks(stat_ev_timer_start[sp]);
+}
+
+void stat_ev_tim_pop(const char *name)
+{
+ int sp;
+ timing_ticks_t temp;
+ timing_ticks(temp);
+ sp = --stat_ev_timer_sp;
+ timing_ticks_sub(temp, stat_ev_timer_start[sp]);
+ timing_ticks_add(stat_ev_timer_elapsed[sp], temp);
+ if (name != NULL && stat_ev_enabled)
+ stat_ev_printf('E', name, "%g", timing_ticks_dbl(stat_ev_timer_elapsed[sp]));
+ if (sp == 0) {
+ timing_leave_max_prio();
+ } else {
+ timing_ticks(stat_ev_timer_start[sp - 1]);
+ }
+}
+
+void do_stat_ev_ctx_push_vfmt(const char *key, const char *fmt, va_list ap)
+{
+ stat_ev_tim_push();
+ stat_ev_vprintf('P', key, fmt, ap);
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev_ctx_push_fmt)(const char *key, const char *fmt, ...)
+{
+ if (!stat_ev_enabled)
+ return;
+
+ va_list ap;
+ va_start(ap, fmt);
+ do_stat_ev_ctx_push_vfmt(key, fmt, ap);
+ va_end(ap);
+}
+
+void (stat_ev_ctx_push_str)(const char *key, const char *str)
+{
+ stat_ev_ctx_push_str_(key, str);
+}
+
+void do_stat_ev_ctx_pop(const char *key)
+{
+ stat_ev_tim_push();
+ stat_ev_printf('O', key, NULL);
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev_ctx_pop)(const char *key)
+{
+ stat_ev_ctx_pop_(key);
+}
+
+void do_stat_ev_dbl(const char *name, double value)
+{
+ stat_ev_tim_push();
+ stat_ev_printf('E', name, "%g", value);
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev_dbl)(const char *name, double value)
+{
+ stat_ev_dbl_(name, value);
+}
+
+void do_stat_ev_int(const char *name, int value)
+{
+ stat_ev_tim_push();
+ stat_ev_printf('E', name, "%d", value);
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev_int)(const char *name, int value)
+{
+ stat_ev_int_(name, value);
+}
+
+void do_stat_ev_ull(const char *name, unsigned long long value)
+{
+ stat_ev_tim_push();
+ stat_ev_printf('E', name, "%llu", value);
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev_ull)(const char *name, unsigned long long value)
+{
+ stat_ev_ull_(name, value);
+}
+
+void do_stat_ev(const char *name)
+{
+ stat_ev_tim_push();
+ stat_ev_printf('E', name, "0.0");
+ stat_ev_tim_pop(NULL);
+}
+
+void (stat_ev)(const char *name)
+{
+ stat_ev_(name);
+}
+
void stat_ev_begin(const char *prefix, const char *filt)
{
char buf[512];
if (filter != NULL)
regfree(filter);
}
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Statistic events.
- * @author Sebastian Hack
- * @date 17.06.2007
- */
-
-#ifndef FIRM_STATEVENT_H
-#define FIRM_STATEVENT_H
-
-#ifdef DISABLE_STATEV
-
-#define stat_ev_enabled 0
-#define stat_ev_dbl(name, val) ((void)0)
-#define stat_ev_int(name, val) ((void)0)
-#define stat_ev(name) ((void)0)
-#define stat_ev_emit(name, value) ((void)0)
-
-#define stat_ev_cnt_decl(var) ((void)0)
-#define stat_ev_cnt_inc(var) ((void)0)
-#define stat_ev_cnt_done(name, var) ((void)0)
-#define stat_ev_tim_push() ((void)0)
-#define stat_ev_tim_pop(name) ((void)0)
-
-#define stat_ev_ctx_push(key) ((void)0)
-#define stat_ev_ctx_push_str(key, str) ((void)0)
-#define stat_ev_ctx_push_fmt(key, fmt, value) ((void)0)
-#define stat_ev_ctx_push_fobj(key, firm_object) ((void)0)
-#define stat_ev_ctx_pop(key) ((void)0)
-#define stat_ev_flush() ((void)0)
-
-#else
-
-#include <stdio.h>
-#include "stat_timing.h"
-
-extern void stat_ev_printf(char ev_type, const char *key, const char *fmt, ...);
-
-extern int stat_ev_enabled;
-extern int stat_ev_timer_sp;
-extern timing_ticks_t stat_ev_timer_elapsed[];
-extern timing_ticks_t stat_ev_timer_start[];
-
-static inline void stat_ev_tim_push(void) {
- timing_ticks_t temp;
- int sp = stat_ev_timer_sp++;
- timing_ticks(temp);
- if (sp == 0) {
- timing_enter_max_prio();
- } else {
- timing_ticks_sub(temp, stat_ev_timer_start[sp - 1]);
- timing_ticks_add(stat_ev_timer_elapsed[sp - 1], temp);
- }
- timing_ticks_init(stat_ev_timer_elapsed[sp]);
- timing_ticks(stat_ev_timer_start[sp]);
-}
-
-static inline void stat_ev_tim_pop(const char *name) {
- int sp;
- timing_ticks_t temp;
- timing_ticks(temp);
- sp = --stat_ev_timer_sp;
- timing_ticks_sub(temp, stat_ev_timer_start[sp]);
- timing_ticks_add(stat_ev_timer_elapsed[sp], temp);
- if (name != NULL && stat_ev_enabled)
- stat_ev_printf('E', name, "%g", timing_ticks_dbl(stat_ev_timer_elapsed[sp]));
- if (sp == 0) {
- timing_leave_max_prio();
- } else {
- timing_ticks(stat_ev_timer_start[sp - 1]);
- }
-}
-
-#define stat_ev_ctx_push_fmt(key, fmt, value) \
- do { \
- if (stat_ev_enabled) { \
- stat_ev_tim_push(); \
- stat_ev_printf('P', key, fmt, (value)); \
- stat_ev_tim_pop(NULL); \
- } \
- } while(0)
-
-#define stat_ev_ctx_pop(key) \
- do { \
- if (stat_ev_enabled) { \
- stat_ev_tim_push(); \
- stat_ev_printf('O', key, NULL); \
- stat_ev_tim_pop(NULL); \
- } \
- } while(0)
-
-#define stat_ev_emit(name, value) \
- do { \
- if (stat_ev_enabled) { \
- stat_ev_tim_push(); \
- stat_ev_printf('E', name, "%g", (double) (value)); \
- stat_ev_tim_pop(NULL); \
- } \
- } while(0)
-
-#define stat_ev_ctx_push_fobj(key, firm_object) stat_ev_ctx_push_fmt((key), "%+F", (firm_object))
-#define stat_ev_ctx_push_str(key, str) stat_ev_ctx_push_fmt((key), "%s", (str))
-#define stat_ev_ctx_push(key) stat_ev_ctx_push_fmt((key), "X", NULL)
-
-#define stat_ev_dbl(name, val) stat_ev_emit((name), (val))
-#define stat_ev_int(name, val) stat_ev_dbl((name), (double) (val))
-#define stat_ev(name) stat_ev_emit((name), 0.0)
-
-#define stat_ev_cnt_decl(var) int stat_ev_cnt_var_ ## var = 0
-#define stat_ev_cnt_inc(var) do { ++stat_ev_cnt_var_ ## var; } while(0)
-#define stat_ev_cnt_done(var, name) stat_ev_emit((name), stat_ev_cnt_var_ ## var)
-
-/**
- * Initialize the stat ev machinery.
- * @param filename_prefix The prefix of the filename (.ev or .ev.gz will be appended).
- * @param filter All pushes, pops and events will be filtered by this.
- * If we have regex support, you can give an extended regex here.
- * If not, each key will be matched against this.
- * Matched means, we look if the key starts with @p filter.
- * If NULL is given, each key passes, ie thefilter is always TRUE.
- */
-void stat_ev_begin(const char *filename_prefix, const char *filter);
-void stat_ev_end(void);
-
-#define stat_ev_flush() do { if (stat_ev_enabled) fflush(stat_ev_enabled); } while(0)
-
-#endif
-
-#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Statistic events.
+ * @author Sebastian Hack
+ */
+#ifndef FIRM_STATEVENT_T_H
+#define FIRM_STATEVENT_T_H
+
+#include "statev.h"
+#include <stdarg.h>
+
+#ifdef DISABLE_STATEV
+
+#define stat_ev_enabled 0
+#define stat_ev_dbl(name, val) ((void)0)
+#define stat_ev_int(name, val) ((void)0)
+#define stat_ev_ull(name, val) ((void)0)
+#define stat_ev(name) ((void)0)
+
+#define stat_ev_cnt_decl(var) ((void)0)
+#define stat_ev_cnt_inc(var) ((void)0)
+#define stat_ev_cnt_done(name, var) ((void)0)
+#define stat_ev_tim_push() ((void)0)
+#define stat_ev_tim_pop(name) ((void)0)
+
+#define stat_ev_ctx_push(key) ((void)0)
+#define stat_ev_ctx_push_str(key, str) ((void)0)
+#define stat_ev_ctx_push_fmt(key, fmt, value) ((void)0)
+#define stat_ev_ctx_pop(key) ((void)0)
+
+#else
+
+void stat_ev_tim_push(void);
+void stat_ev_tim_pop(const char *name);
+
+void do_stat_ev_int(const char *name, int value);
+void do_stat_ev_dbl(const char *name, double value);
+void do_stat_ev_ull(const char *name, unsigned long long value);
+void do_stat_ev(const char *name);
+void do_stat_ev_ctx_push_vfmt(const char *name, const char *fmt, va_list ap);
+void do_stat_ev_ctx_pop(const char *key);
+
+static inline void stat_ev_int_(const char *name, int value)
+{
+ if (!stat_ev_enabled)
+ return;
+ (do_stat_ev_int)(name, value);
+}
+static inline void stat_ev_dbl_(const char *name, double value)
+{
+ if (!stat_ev_enabled)
+ return;
+ (do_stat_ev_dbl)(name, value);
+}
+static inline void stat_ev_ull_(const char *name, unsigned long long value)
+{
+ if (!stat_ev_enabled)
+ return;
+ (do_stat_ev_ull)(name, value);
+}
+static inline void stat_ev_(const char *name)
+{
+ if (!stat_ev_enabled)
+ return;
+ (do_stat_ev)(name);
+}
+static inline void stat_ev_ctx_push_fmt_(const char *name, const char *fmt, ...)
+{
+ if (!stat_ev_enabled)
+ return;
+ va_list ap;
+ va_start(ap, fmt);
+ do_stat_ev_ctx_push_vfmt(name, fmt, ap);
+ va_end(ap);
+}
+static inline void stat_ev_ctx_push_str_(const char *name, const char *str)
+{
+ stat_ev_ctx_push_fmt_(name, "%s", str);
+}
+static inline void stat_ev_ctx_pop_(const char *key)
+{
+ if (!stat_ev_enabled)
+ return;
+ do_stat_ev_ctx_pop(key);
+}
+#define stat_ev_int(name, value) stat_ev_int_(name, value)
+#define stat_ev_dbl(name, value) stat_ev_dbl_(name, value)
+#define stat_ev_ull(name, value) stat_ev_ull_(name, value)
+#define stat_ev(name) stat_ev_(name)
+#define stat_ev_ctx_push_fmt(name, fmt, value) \
+ stat_ev_ctx_push_fmt_(name, fmt, value)
+#define stat_ev_ctx_push_str(name, str) stat_ev_ctx_push_str_(name, str)
+#define stat_ev_ctx_pop(name) stat_ev_ctx_pop_(name)
+
+#define stat_ev_cnt_decl(var) int stat_ev_cnt_var_ ## var = 0
+#define stat_ev_cnt_inc(var) do { ++stat_ev_cnt_var_ ## var; } while(0)
+#define stat_ev_cnt_done(var, name) stat_ev_int((name), stat_ev_cnt_var_ ## var)
+
+#endif
+
+#endif