Commit fde2a35e authored by Michael Beck's avatar Michael Beck
Browse files

fix 64bit warnings

[r19454]
parent 3dab5244
......@@ -45,30 +45,22 @@
# include "irtools.h"
# include "array.h"
/* * *
* local values
* * */
/** dynamic array to hold all modes */
/** Obstack to hold all modes. */
static struct obstack modes;
/** number of defined modes */
/** Number of defined modes. */
static int num_modes = 0;
/** The list of all currently existing modes. */
static ir_mode **mode_list;
/* * *
* local functions
* * */
/**
* Compare modes that don't need to have their code field
* correctly set
*
* TODO: Add other fields
**/
INLINE static int modes_are_equal(const ir_mode *m, const ir_mode *n) {
static INLINE int modes_are_equal(const ir_mode *m, const ir_mode *n) {
if (m == n) return 1;
if (m->sort == n->sort &&
m->arithmetic == n->arithmetic &&
......@@ -87,17 +79,34 @@ INLINE static int modes_are_equal(const ir_mode *m, const ir_mode *n) {
* none found
*/
static ir_mode *find_mode(const ir_mode *m) {
unsigned len = ARR_LEN(mode_list);
unsigned i;
for(i = 0; i < len; ++i) {
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 n;
}
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
......
......@@ -420,8 +420,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env) {
ir_mode *mode = get_irn_mode(node);
if (mode)
/* FIXME: not 64bit save */
put_code(env->buf, (unsigned)mode);
put_code(env->buf, stat_find_mode_index(mode));
else
put_tag(env->buf, VLC_TAG_EMPTY);
} /* if */
......
......@@ -154,7 +154,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 = (ir_mode *)mode_code;
ir_mode *mode = stat_mode_for_index(mode_code);
long l = attr ? *(long *)attr : 0;
if (priv->pattern_id > priv->max_pattern)
......@@ -231,7 +231,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 = (ir_mode *)mode_code;
ir_mode *mode = stat_mode_for_index(mode_code);
(void) attr;
/* if (env->options & OPT_ENC_GRAPH) */
......
......@@ -88,4 +88,14 @@ 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