add correct compare functions for be nodes
[libfirm] / ir / be / bestatevent.c
index 70b43e1..9b74757 100644 (file)
@@ -1,11 +1,36 @@
+/*
+ * Copyright (C) 1995-2007 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.
+ */
+
 /**
-* Statistic events
-* @date 3.9.2006
-* @author Sebastian Hack
-*/
+ * @file
+ * @brief       Statistic events.
+ * @author      Sebastian Hack
+ * @date        03.09.2006
+ * @version     $Id$
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <assert.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "bestatevent.h"
 
@@ -17,7 +42,7 @@ typedef struct {
 } ev_env_t;
 
 static ev_env_t envs[STACK_SIZE];
-static int sp = 0;
+static unsigned sp = 0;
 
 void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
 {
@@ -38,21 +63,69 @@ void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
 
 void be_stat_ev_pop(void)
 {
-       if(sp > 0) {
-               envs[--sp].f = NULL;
-       }
+       if (sp == 0)
+               return;
+
+       envs[--sp].f = NULL;
 }
 
 void be_stat_ev(const char *ev, int value)
 {
-       if(sp > 0) {
-               ev_env_t *env = &envs[sp - 1];
-               if(env->f)
-                       fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
-       }
+       ev_env_t *env;
+
+       if (sp == 0)
+               return;
+
+       env = &envs[sp - 1];
+       if (env->f == NULL)
+               return;
+
+       fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
+}
+
+void be_stat_ev_l(const char *ev, long value)
+{
+       ev_env_t *env;
+
+       if (sp == 0)
+               return;
+
+       env = &envs[sp - 1];
+       if (env->f == NULL)
+               return;
+
+       fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value);
+}
+
+void be_stat_ev_dbl(const char *ev, double value)
+{
+       ev_env_t *env;
+
+       if (sp == 0)
+               return;
+
+       env = &envs[sp - 1];
+       if (env->f == NULL)
+               return;
+
+       fprintf(env->f, "%s%s;%f\n", env->tag, ev, value);
+}
+
+void be_stat_ev_ull(const char *ev, ulong64 value)
+{
+       ev_env_t *env;
+
+       if (sp == 0)
+               return;
+
+       env = &envs[sp - 1];
+       if (env->f == NULL)
+               return;
+
+       fprintf(env->f, "%s%s;%" ULL_FMT "\n", env->tag, ev, value);
 }
 
 int be_stat_ev_is_active(void)
 {
-       return sp > 0 && envs[sp - 1].f;
+       return sp > 0 && envs[sp - 1].f != NULL;
 }