remove odd mode->index, index->mode API for statistics, ir_prog already had such...
authorMatthias Braun <matze@braunis.de>
Mon, 2 Aug 2010 11:50:39 +0000 (11:50 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 2 Aug 2010 11:50:39 +0000 (11:50 +0000)
[r27860]

ir/ir/irmode.c
ir/stat/pattern.c
ir/stat/pattern_dmp.c
ir/stat/pattern_dmp.h

index 786a20d..0489827 100644 (file)
@@ -99,28 +99,6 @@ static ir_mode *find_mode(const ir_mode *m)
        return NULL;
 }
 
-#ifdef FIRM_STATISTICS
-/* return the mode index, only needed for statistics */
-int stat_find_mode_index(const ir_mode *m)
-{
-       int i;
-       for (i = ARR_LEN(mode_list) - 1; i >= 0; --i) {
-               ir_mode *n = mode_list[i];
-               if (modes_are_equal(n, m))
-                       return i;
-       }
-       return -1;
-}
-
-/* return the mode for a given index, only needed for statistics */
-ir_mode *stat_mode_for_index(int idx)
-{
-       if (0 <= idx  && idx < ARR_LEN(mode_list))
-               return mode_list[idx];
-       return NULL;
-}
-#endif
-
 /**
  * sets special values of modes
  */
index d116f2d..871e12e 100644 (file)
@@ -395,6 +395,18 @@ static int addr_cmp(const void *p1, const void *p2, size_t size)
        return e1->addr != e2->addr;
 }  /* addr_cmp */
 
+static unsigned find_mode_index(const ir_mode *mode)
+{
+       int n = get_irp_n_modes();
+       int i;
+
+       for (i = 0; i < n; ++i) {
+               if (get_irp_mode(i) == mode)
+                       return i;
+       }
+       return -1;
+}
+
 /**
  * Encodes an IR-node, recursive worker.
  *
@@ -434,7 +446,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env)
                ir_mode *mode = get_irn_mode(node);
 
                if (mode)
-                       put_code(env->buf, stat_find_mode_index(mode));
+                       put_code(env->buf, find_mode_index(mode));
                else
                        put_tag(env->buf, VLC_TAG_EMPTY);
        }  /* if */
index ef7136a..a68e80a 100644 (file)
@@ -150,7 +150,7 @@ static void vcg_dump_node(pattern_dumper_t *self, unsigned id,
 {
        vcg_private_t *priv = self->data;
        ir_op *op           = stat_get_op_from_opcode(op_code);
-       ir_mode *mode       = stat_mode_for_index(mode_code);
+       ir_mode *mode       = get_irp_mode(mode_code);
        long l              = attr ? *(long *)attr : 0;
 
        if (priv->pattern_id > priv->max_pattern)
@@ -227,7 +227,7 @@ static void stdout_dump_node(pattern_dumper_t *self, unsigned id, unsigned op_co
 {
        FILE *f       = self->data;
        ir_op *op     = stat_get_op_from_opcode(op_code);
-       ir_mode *mode = stat_mode_for_index(mode_code);
+       ir_mode *mode = get_irp_mode(mode_code);
        (void) attr;
 
        /* if (env->options & OPT_ENC_GRAPH) */
index 244eb3a..9520251 100644 (file)
@@ -88,14 +88,4 @@ pattern_dumper_t *new_text_dumper(void);
  */
 pattern_dumper_t *new_vcg_dumper(const char *vcg_name, unsigned max_pattern);
 
-/**
- * return the mode index, only needed for statistics
- */
-int stat_find_mode_index(const ir_mode *m);
-
-/**
- * return the mode for a given index, only needed for statistics
- */
-ir_mode *stat_mode_for_index(int idx);
-
 #endif /* FIRM_STAT_PATTERN_DMP_H */