From 69323fd50a31e8c74dd50cdc595c966118d22fa6 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 19 Apr 2004 13:10:23 +0000 Subject: [PATCH] Initial statistic implementations [r2682] --- ir/stat/Makefile.in | 37 ++++++++++++++++++++++++ ir/stat/firmstat.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ ir/stat/firmstat.h | 48 +++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ir/stat/Makefile.in create mode 100644 ir/stat/firmstat.c create mode 100644 ir/stat/firmstat.h diff --git a/ir/stat/Makefile.in b/ir/stat/Makefile.in new file mode 100644 index 000000000..d796ecf44 --- /dev/null +++ b/ir/stat/Makefile.in @@ -0,0 +1,37 @@ +# +# Project: libFIRM +# File name: ir/stat/Makefile.in +# Purpose: +# Author: Boris Boesler, Till Riedel +# Modified by: +# Created: +# CVS-ID: $Id$ +# Copyright: (c) 2004 Universität Karlsruhe +# Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. +# + +top_srcdir := @top_srcdir@ +srcdir = @srcdir@ +topdir = ../.. +subdir := ir/ir + +INSTALL_HEADERS = + +SOURCES = $(INSTALL_HEADERS) + +SOURCES += Makefile.in \ + firmstat.h + +ifeq ($(enable_statistics),yes) +SOURCES += firmstat.c +endif + +include $(topdir)/MakeRules + +CPPFLAGS += -I$(top_srcdir)/ir/adt -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \ + -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr -I$(top_srcdir)/ir/tv \ + -I$(top_srcdir)/ir/debug -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st + +include $(top_srcdir)/MakeTargets + +all: subdir.o diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c new file mode 100644 index 000000000..6d033855b --- /dev/null +++ b/ir/stat/firmstat.c @@ -0,0 +1,69 @@ +/* + * Project: libFIRM + * File name: ir/ir/firmstat.c + * Purpose: Statistics for Firm. + * Author: Michael Beck + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 2004 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +# include + +# include "irop_t.h" +# include "irnode_t.h" + +# include "xmalloc.h" + +/* + * 64 bit should be enough for now + */ +#define STAT_CNT_NUM 2 + +typedef struct _counter_t { + unsigned cnt[STAT_CNT_NUM]; +} counter_t; + + +static INLINE cnt_inc(counter_t *cnt) +{ + int i; + + for (i = 0; i < STAT_CNT_NUM; ++i) { + if (++cnt->cnt[i]) + break; +} + +static INLINE cnt_dec(counter_t *cnt) +{ + int i; + + for (i = 0; i < STAT_CNT_NUM; ++i) { + if (--cnt->cnt[i] != -1) + break; +} + +/* A new IR op is registered. */ +void stat_new_ir_op(const ir_op *op) +{ +} + +/* An IR op is freed. */ +void stat_free_ir_op(const ir_op *op) +{ +} + +/* initialize the statistics module. */ +void stat_init(void) +{ +} + +/* A new node is created. */ +void stat_new_node(const ir_node *node) +{ +} diff --git a/ir/stat/firmstat.h b/ir/stat/firmstat.h new file mode 100644 index 000000000..e6bab0579 --- /dev/null +++ b/ir/stat/firmstat.h @@ -0,0 +1,48 @@ +/* + * Project: libFIRM + * File name: ir/ir/firmstat.h + * Purpose: Statistics for Firm. + * Author: Michael Beck + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 2004 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ + + +# ifndef _FIRMSTAT_H_ +# define _FIRMSTAT_H_ + +#ifdef FIRM_STATISTICS + +/** + * initialize the statistics module. + */ +void stat_init(void); + +/** + * A new IR op is registered. + */ +void stat_new_ir_op(const ir_op *op); + +/** + * An IR op is freed. + */ +void stat_free_ir_op(const ir_op *op); + +/** + * A new node is created. + */ +void stat_new_node(const ir_node *node); + +#else + +#define stat_init() +#define stat_new_ir_op(op) +#define stat_free_ir_op(op) +#define stat_new_node(node) + +#endif + + +#endif /* _FIRMSTAT_H_ */ -- 2.20.1