From: Matthias Braun Date: Mon, 2 Aug 2010 11:50:39 +0000 (+0000) Subject: remove odd mode->index, index->mode API for statistics, ir_prog already had such... X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=a7b0fcb597948823737e6d65f0adaa79f0bc8eef;p=libfirm remove odd mode->index, index->mode API for statistics, ir_prog already had such an API [r27860] --- diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index 786a20de9..0489827e9 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -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 */ diff --git a/ir/stat/pattern.c b/ir/stat/pattern.c index d116f2ddc..871e12e26 100644 --- a/ir/stat/pattern.c +++ b/ir/stat/pattern.c @@ -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 */ diff --git a/ir/stat/pattern_dmp.c b/ir/stat/pattern_dmp.c index ef7136a6c..a68e80a79 100644 --- a/ir/stat/pattern_dmp.c +++ b/ir/stat/pattern_dmp.c @@ -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) */ diff --git a/ir/stat/pattern_dmp.h b/ir/stat/pattern_dmp.h index 244eb3ac6..95202512e 100644 --- a/ir/stat/pattern_dmp.h +++ b/ir/stat/pattern_dmp.h @@ -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 */