panic() instead of assert(0).
[libfirm] / ir / stat / const_stat.c
index 1b0fad0..ffa88a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -69,23 +69,33 @@ static float_classify_t classify_float_value(tarval *tv) {
        ir_mode *mode = get_tarval_mode(tv);
 
        if (tv == get_mode_null(mode))
-               return STAT_FC_1;
+               return STAT_FC_0;
        else if (tv == get_mode_one(mode))
                return STAT_FC_1;
-
+       else if (tarval_is_finite(tv) && tarval_ieee754_zero_mantissa(tv)) {
+               int exp = tarval_ieee754_get_exponent(tv);
+
+               if (! tarval_is_negative(tv)) {
+                       if (exp == 1)
+                               return STAT_FC_2;
+                       else if (exp == -1)
+                               return STAT_FC_0_5;
+               }
+               return STAT_FC_POWER_OF_TWO;
+       }
        return STAT_FC_OTHER;
 }
 
 /* return a human readable name for an float classification */
 const char *stat_fc_name(float_classify_t classification) {
        switch (classification) {
-       case STAT_FC_0:     return "0.0";
-       case STAT_FC_1:     return "1.0";
-       case STAT_FC_2:     return "2.0";
-       case STAT_FC_0_5:   return "0.5";
-       case STAT_FC_EXACT: return "exact";
-       case STAT_FC_OTHER: return "other";
-       default:            return "<UNKNOWN>";
+       case STAT_FC_0:            return "0.0";
+       case STAT_FC_1:            return "1.0";
+       case STAT_FC_2:            return "2.0";
+       case STAT_FC_0_5:          return "0.5";
+       case STAT_FC_POWER_OF_TWO: return "2.0^x";
+       case STAT_FC_OTHER:        return "other";
+       default:                   return "<UNKNOWN>";
        }
 }
 
@@ -95,6 +105,7 @@ void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
        ir_mode *mode = get_irn_mode(node);
        tarval *tv;
        unsigned bits;
+       (void) graph;
 
        if (mode_is_int(mode)) {
                tv   = get_Const_tarval(node);
@@ -121,7 +132,7 @@ void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
 
 /* clears the const statistics for a new snapshot */
 void stat_const_clear(stat_info_t *status) {
-       int i;
+       size_t i;
 
        for (i = 0; i < ARR_SIZE(status->const_info.int_bits_count); ++i)
                cnt_clr(&status->const_info.int_bits_count[i]);
@@ -134,5 +145,6 @@ void stat_const_clear(stat_info_t *status) {
 
 /* initialize the Const statistic. */
 void stat_init_const_cnt(stat_info_t *status) {
+       (void) status;
        /* currently nothing */
 }