make statev API public
authorMatthias Braun <matze@braunis.de>
Sun, 14 Oct 2012 20:06:30 +0000 (22:06 +0200)
committerMatthias Braun <matze@braunis.de>
Wed, 24 Oct 2012 12:04:10 +0000 (14:04 +0200)
27 files changed:
include/libfirm/Makefile.am
include/libfirm/statev.h [new file with mode: 0644]
ir/Makefile.am
ir/ana/dfs.c
ir/ana/execfreq.c
ir/ana/irlivechk.c
ir/be/bechordal.c
ir/be/bechordal_common.c
ir/be/bechordal_main.c
ir/be/becopyheur4.c
ir/be/becopyilp.c
ir/be/becopyopt.c
ir/be/beintlive_t.h
ir/be/belive.c
ir/be/belive_t.h
ir/be/bemain.c
ir/be/bespill.c
ir/be/bespillslots.c
ir/be/bespillutil.c
ir/be/bessaconstr.c
ir/be/bessadestr.c
ir/be/bestat.c
ir/be/bestat.h
ir/be/bestatevent.h [deleted file]
ir/stat/statev.c
ir/stat/statev.h [deleted file]
ir/stat/statev_t.h [new file with mode: 0644]

index c27165b..8b985f4 100644 (file)
@@ -46,6 +46,7 @@ libfirminclude_HEADERS = \
        lowering.h \
        nodeops.h \
        opcodes.h \
+       statev.h \
        timing.h \
        trouts.h \
        tv.h \
diff --git a/include/libfirm/statev.h b/include/libfirm/statev.h
new file mode 100644 (file)
index 0000000..40af78d
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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
index 74e3565..fe3ed51 100644 (file)
@@ -387,7 +387,7 @@ EXTRA_DIST = \
        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 \
index 19eb9cc..091800b 100644 (file)
@@ -35,7 +35,7 @@
 #include "irprintf.h"
 #include "irdom_t.h"
 #include "set.h"
-#include "statev.h"
+#include "statev_t.h"
 #include "dfs_t.h"
 #include "util.h"
 
index e07e51b..d32569d 100644 (file)
@@ -35,7 +35,7 @@
 #include "set.h"
 #include "hashptr.h"
 #include "debug.h"
-#include "statev.h"
+#include "statev_t.h"
 #include "dfs_t.h"
 #include "absgraph.h"
 
index 8da414d..89b12f1 100644 (file)
@@ -58,7 +58,7 @@
 
 #include "irlivechk.h"
 
-#include "statev.h"
+#include "statev_t.h"
 
 typedef struct bl_info_t {
        const ir_node *block;      /**< The block. */
index ba9df02..f77b135 100644 (file)
@@ -54,7 +54,7 @@
 #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"
index 2d60273..e4cab1b 100644 (file)
@@ -37,7 +37,7 @@
 #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"
@@ -252,7 +252,7 @@ ir_node *pre_process_constraints(be_chordal_env_t *env, be_insn_t **the_insn)
        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);
index 8e6536d..7850266 100644 (file)
@@ -62,7 +62,7 @@
 #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"
index 0f7dca4..acda7f9 100644 (file)
@@ -47,7 +47,7 @@
 #include "irtools.h"
 #include "error.h"
 #include "list.h"
-#include "statev.h"
+#include "statev_t.h"
 
 #include "bearch.h"
 #include "beifg.h"
index d7cf202..e4c6ace 100644 (file)
@@ -30,7 +30,7 @@
 #include "irtools.h"
 #include "irprintf.h"
 
-#include "bestatevent.h"
+#include "statev_t.h"
 #include "beirg.h"
 #include "bemodule.h"
 #include "error.h"
@@ -280,10 +280,10 @@ lpp_sol_state_t ilp_go(ilp_env_t *ienv)
 
        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);
 
index 762a8a1..da381e6 100644 (file)
@@ -59,7 +59,7 @@
 #include "bemodule.h"
 #include "benode.h"
 #include "besched.h"
-#include "bestatevent.h"
+#include "statev_t.h"
 #include "beutil.h"
 
 #include "lc_opts.h"
@@ -1029,14 +1029,14 @@ void co_driver(be_chordal_env_t *cenv)
 
        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");
@@ -1053,7 +1053,7 @@ void co_driver(be_chordal_env_t *cenv)
 
                /* 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 */
@@ -1061,8 +1061,8 @@ void co_driver(be_chordal_env_t *cenv)
        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) {
@@ -1094,8 +1094,8 @@ void co_driver(be_chordal_env_t *cenv)
                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);
index 8b61f50..051d107 100644 (file)
@@ -15,7 +15,7 @@
 #include "irgraph_t.h"
 #include "iredges_t.h"
 
-#include "statev.h"
+#include "statev_t.h"
 
 #include "beirg.h"
 #include "besched.h"
index 8b7911d..8ab7a8d 100644 (file)
@@ -35,7 +35,7 @@
 #include "irnodeset.h"
 
 #include "absgraph.h"
-#include "statev.h"
+#include "statev_t.h"
 
 #include "beutil.h"
 #include "belive_t.h"
index a8d939d..1ebfd04 100644 (file)
@@ -32,7 +32,7 @@
 #include "irnodehashmap.h"
 #include "irhooks.h"
 #include "irlivechk.h"
-#include "statev.h"
+#include "statev_t.h"
 
 #include "pset.h"
 #include "bitset.h"
index 637fb0c..ec661f1 100644 (file)
@@ -640,9 +640,9 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                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 */
@@ -757,8 +757,8 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
 
                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 */
@@ -776,8 +776,8 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                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 */
index 7dd59cd..00e0798 100644 (file)
@@ -29,7 +29,7 @@
 #include "debug.h"
 #include "iredges_t.h"
 #include "raw_bitset.h"
-#include "statev.h"
+#include "statev_t.h"
 #include "irgwalk.h"
 
 #include "bespill.h"
index 2620ff5..ebbd0bf 100644 (file)
@@ -41,7 +41,7 @@
 #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"
index 3e0a933..1b20230 100644 (file)
@@ -53,7 +53,7 @@
 #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"
index 0533cd5..3b06648 100644 (file)
@@ -410,7 +410,7 @@ void be_ssa_construction_init(be_ssa_construction_env_t *env, ir_graph *irg)
        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;
index 13eb393..46a7c98 100644 (file)
@@ -45,7 +45,7 @@
 #include "belive_t.h"
 #include "benode.h"
 #include "besched.h"
-#include "bestatevent.h"
+#include "statev_t.h"
 #include "beirg.h"
 #include "beintlive_t.h"
 
@@ -156,7 +156,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                        }
 
                        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 {
index 189c1ab..fbc8b64 100644 (file)
@@ -33,8 +33,8 @@
 #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"
@@ -112,8 +112,8 @@ void be_do_stat_reg_pressure(ir_graph *irg, const arch_register_class_t *cls)
        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);
 }
 
 
index dcfcf34..ada6fcc 100644 (file)
@@ -29,7 +29,6 @@
 #include "irnodeset.h"
 
 #include "beirg.h"
-#include "bestatevent.h"
 #include "bearch.h"
 
 typedef enum be_stat_tag_t {
diff --git a/ir/be/bestatevent.h b/ir/be/bestatevent.h
deleted file mode 100644 (file)
index e0caacc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 */
index 3d8cc4f..972935a 100644 (file)
 #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)
 {
@@ -60,7 +58,7 @@ 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;
@@ -68,16 +66,136 @@ void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
        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];
@@ -102,5 +220,3 @@ void stat_ev_end(void)
        if (filter != NULL)
                regfree(filter);
 }
-
-#endif
diff --git a/ir/stat/statev.h b/ir/stat/statev.h
deleted file mode 100644 (file)
index 8d135df..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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
diff --git a/ir/stat/statev_t.h b/ir/stat/statev_t.h
new file mode 100644 (file)
index 0000000..2b44c27
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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