fixed decimal number parsing
[libfirm] / ir / stat / const_stat.c
index 3fa94cc..1561306 100644 (file)
@@ -8,15 +8,17 @@
  * Copyright:   (c) 2004 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "firmstat_t.h"
 #include "tv_t.h"
 
-static stat_info_t *status;
-
 /**
- * calculated the dual logarithmus of |value|
+ * calculated the dual logarithm of |value|
  */
-static unsigned log2(long value) {
+static unsigned log2abs(long value) {
   unsigned res = 0;
 
   if (value < 0)
@@ -74,12 +76,7 @@ const char *stat_fc_name(float_classify_t classification)
   }
 }
 
-/**
- * update info on Consts
- *
- * @param node   The Const node
- * @param graph  The graph entry containing the call
- */
+/* update info on Consts */
 void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
 {
   ir_mode *mode = get_irn_mode(node);
@@ -88,7 +85,12 @@ void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
 
   if (mode_is_int(mode)) {
     tv   = get_Const_tarval(node);
-    bits = log2(get_tarval_long(tv));
+
+    /* FIXME: */
+    if (! tarval_is_long(tv))
+      return;
+
+    bits = log2abs(get_tarval_long(tv));
 
     if (bits > ARR_SIZE(status->const_info.int_bits_count))
       bits = ARR_SIZE(status->const_info.int_bits_count);