Commit a7b0fcb5 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove odd mode->index, index->mode API for statistics, ir_prog already had such an API

[r27860]
parent 2191be0d
......@@ -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
*/
......
......@@ -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 */
......
......@@ -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) */
......
......@@ -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 */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment