Fixed some size_t related warnings.
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Jan 2011 23:49:31 +0000 (23:49 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Jan 2011 23:49:31 +0000 (23:49 +0000)
[r28254]

ir/be/beabi.c
ir/be/bestabs.c
ir/opt/combo.c
ir/opt/opt_blocks.c
ir/opt/opt_ldst.c
ir/opt/parallelize_mem.c
ir/stat/distrib.c
ir/stat/pattern.c
ir/stat/stat_dmp.c

index 154daf2..167d197 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -1199,8 +1199,8 @@ static int cmp_regs(const void *a, const void *b)
 static void reg_map_to_arr(reg_node_map_t *res, pmap *reg_map)
 {
        pmap_entry *ent;
-       int n = pmap_count(reg_map);
-       int i = 0;
+       size_t n = pmap_count(reg_map);
+       size_t i = 0;
 
        foreach_pmap(reg_map, ent) {
                res[i].reg = (const arch_register_t*)ent->key;
@@ -1291,7 +1291,7 @@ static ir_node *create_be_return(be_abi_irg_t *env, ir_node *irn, ir_node *bl,
        dbg_info *dbgi;
        pmap *reg_map  = pmap_create();
        ir_node *keep  = (ir_node*)pmap_get(env->keep_map, bl);
-       int in_max;
+       size_t in_max;
        ir_node *ret;
        int i, n;
        unsigned pop;
index 5c89635..a96c8ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -143,7 +143,7 @@ static unsigned get_type_number(stabs_handle *h, ir_type *tp)
                num = h->next_type_nr++;
                pmap_insert(h->type_map, tp, INT_TO_PTR(num));
        } else {
-               num = PTR_TO_INT(entry->value);
+               num = (unsigned)PTR_TO_INT(entry->value);
        }
        return num;
 }  /* get_type_number */
index 9d465de..497a20a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -83,6 +83,7 @@
 #include "irnodeset.h"
 #include "irpass.h"
 #include "tv_t.h"
+#include "irtools.h"
 
 #include "irprintf.h"
 #include "irdump.h"
@@ -596,7 +597,7 @@ static listmap_entry_t *listmap_find(listmap_t *map, void *id)
  */
 static unsigned opcode_hash(const opcode_key_t *entry)
 {
-       return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.ptr) + entry->arity;
+       return (unsigned)(PTR_TO_INT(entry->mode) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.ptr) + entry->arity);
 }  /* opcode_hash */
 
 /**
index 9e2235e..5e88fe4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -40,6 +40,7 @@
 #include "set.h"
 #include "irpass.h"
 #include "debug.h"
+#include "irtools.h"
 
 /* define this for general block shaping: congruent blocks
    are found not only before the end block but anywhere in the graph */
@@ -261,7 +262,7 @@ static listmap_entry_t *listmap_find(listmap_t *map, void *id)
 static unsigned opcode_hash(const opcode_key_t *entry)
 {
        /* assume long >= int */
-       return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.addr) + entry->arity;
+       return (unsigned)(PTR_TO_INT(entry->mode) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.addr) + entry->arity);
 }  /* opcode_hash */
 
 /**
index dcf7513..6c75e32 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -125,7 +125,7 @@ typedef struct ldst_env_t {
        memop_t         **curr_id_2_memop; /**< current map of address ids to memops */
        unsigned        curr_adr_id;       /**< number for address mapping */
        unsigned        n_mem_ops;         /**< number of memory operations (Loads/Stores) */
-       unsigned        rbs_size;          /**< size of all bitsets in bytes */
+       size_t          rbs_size;          /**< size of all bitsets in bytes */
        int             max_cfg_preds;     /**< maximum number of block cfg predecessors */
        int             changed;           /**< Flags for changed graph state */
 #ifdef DEBUG_libfirm
@@ -180,9 +180,9 @@ static void dump_block_list(ldst_env *env)
  */
 static void dump_curr(block_t *bl, const char *s)
 {
-       unsigned end = env.rbs_size - 1;
-       unsigned pos;
-       int      i;
+       size_t end = env.rbs_size - 1;
+       size_t pos;
+       int    i;
 
        DB((dbg, LEVEL_2, "%s[%+F] = {", s, bl->block));
        i = 0;
@@ -1379,8 +1379,8 @@ static void kill_all(void)
  */
 static void kill_memops(const value_t *value)
 {
-       unsigned end = env.rbs_size - 1;
-       unsigned pos;
+       size_t end = env.rbs_size - 1;
+       size_t pos;
 
        for (pos = rbitset_next(env.curr_set, 0, 1); pos < end; pos = rbitset_next(env.curr_set, pos + 1, 1)) {
                memop_t *op = env.curr_id_2_memop[pos];
@@ -1601,8 +1601,8 @@ static int backward_antic(block_t *bl)
                ir_node  *succ    = get_Block_cfg_out(block, 0);
                block_t  *succ_bl = get_block_entry(succ);
                int      pred_pos = get_Block_cfgpred_pos(succ, block);
-               unsigned end      = env.rbs_size - 1;
-               unsigned pos;
+               size_t   end      = env.rbs_size - 1;
+               size_t   pos;
 
                kill_all();
 
@@ -1940,8 +1940,8 @@ static int insert_Load(block_t *bl)
 {
        ir_node  *block = bl->block;
        int      i, n = get_Block_n_cfgpreds(block);
-       unsigned end = env.rbs_size - 1;
-       unsigned pos;
+       size_t   end = env.rbs_size - 1;
+       size_t   pos;
 
        DB((dbg, LEVEL_3, "processing %+F\n", block));
 
@@ -1979,9 +1979,9 @@ static int insert_Load(block_t *bl)
                }
                /*
                 * Ensure that all values are in the map: build Phi's if necessary:
-                * Note: the last bit is the sentinel and ALWAYS set, so start with -2.
+                * Note: the last bit is the sentinel and ALWAYS set, so end with -2.
                 */
-               for (pos = env.rbs_size - 2; pos >= 0; --pos) {
+               for (pos = 0; pos < env.rbs_size - 1; ++pos) {
                        if (! rbitset_is_set(env.curr_set, pos))
                                env.curr_id_2_memop[pos] = NULL;
                        else {
index f0030dd..57bd0f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -151,7 +151,7 @@ static void walker(ir_node *proj, void *env)
        ir_node          *mem_op;
        ir_node          *pred;
        ir_node          *block;
-       int               n;
+       size_t            n;
        parallelize_info  pi;
 
        (void)env;
index e145b3e..02e60d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -201,7 +201,7 @@ int stat_get_count_distrib_tbl(distrib_tbl_t *tbl)
 double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
 {
        distrib_entry_t *entry;
-       unsigned count;
+       size_t count;
        double sum;
 
        if (tbl->int_dist) {
@@ -248,7 +248,7 @@ double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
 double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl)
 {
        distrib_entry_t *entry;
-       unsigned        count = 0;
+       size_t          count = 0;
        double          sum   = 0.0;
 
        if (tbl->int_dist) {
index fa8fcde..95d78fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -40,6 +40,7 @@
 #include "pattern_dmp.h"
 #include "hashptr.h"
 #include "error.h"
+#include "lc_printf.h"
 
 #ifdef FIRM_STATISTICS
 
@@ -91,7 +92,7 @@ enum vlc_code_t {
  */
 typedef struct pattern_entry_t {
        counter_t   count;        /**< Amount of pattern occurance. */
-       unsigned    len;          /**< The length of the VLC encoded buffer. */
+       size_t      len;          /**< The length of the VLC encoded buffer. */
        BYTE        buf[1];       /**< The buffer containing the VLC encoded pattern. */
 } pattern_entry_t;
 
@@ -147,12 +148,11 @@ static int pattern_cmp(const void *elt, const void *key)
 {
        const pattern_entry_t *e1 = (const pattern_entry_t*)elt;
        const pattern_entry_t *e2 = (const pattern_entry_t*)key;
-       int diff = e1->len - e2->len;
 
-       if (diff)
-               return diff;
+       if (e1->len == e2->len)
+               return memcmp(e1->buf, e2->buf, e1->len);
 
-       return memcmp(e1->buf, e2->buf, e1->len);
+       return e1->len < e2->len ? -1 : +1;
 }  /* pattern_cmp */
 
 /**
@@ -162,7 +162,7 @@ static int pattern_cmp(const void *elt, const void *key)
  * @param data  a buffer address
  * @param len   the length of the data buffer
  */
-static void init_buf(CODE_BUFFER *buf, BYTE *data, unsigned len)
+static void init_buf(CODE_BUFFER *buf, BYTE *data, size_t len)
 {
        buf->start   =
        buf->next    = data;
@@ -196,7 +196,7 @@ static inline void put_byte(CODE_BUFFER *buf, BYTE byte)
  *
  * @return  the length of the buffer content
  */
-static unsigned buf_lenght(const CODE_BUFFER *buf)
+static size_t buf_lenght(const CODE_BUFFER *buf)
 {
        return buf->next - buf->start;
 }  /* buf_lenght */
@@ -634,7 +634,7 @@ static void _decode_node(unsigned parent, int position, codec_env_t *env)
 /**
  * Decode an IR-node.
  */
-static void decode_node(BYTE *b, unsigned len, pattern_dumper_t *dump)
+static void decode_node(BYTE *b, size_t len, pattern_dumper_t *dump)
 {
        codec_env_t env;
        CODE_BUFFER buf;
@@ -677,7 +677,7 @@ typedef struct pattern_env {
 static pattern_entry_t *pattern_get_entry(CODE_BUFFER *buf, pset *set)
 {
        pattern_entry_t *key, *elem;
-       unsigned len = buf_lenght(buf);
+       size_t len = buf_lenght(buf);
        unsigned hash;
 
        key = OALLOCF(&status->obst, pattern_entry_t, buf, len);
@@ -731,7 +731,7 @@ static void calc_nodes_pattern(ir_node *node, void *ctx)
        depth = encode_node(node, &buf, env->max_depth);
 
        if (buf_overrun(&buf)) {
-               fprintf(stderr, "Pattern store: buffer overrun at size %u. Pattern ignored.\n", (unsigned) sizeof(buffer));
+               lc_fprintf(stderr, "Pattern store: buffer overrun at size %zu. Pattern ignored.\n", sizeof(buffer));
        } else
                count_pattern(&buf, depth);
 }  /* calc_nodes_pattern */
@@ -745,7 +745,7 @@ static void store_pattern(const char *fname)
 {
        FILE *f;
        pattern_entry_t *entry;
-       int i, count = pset_count(status->pattern_hash);
+       size_t i, count = pset_count(status->pattern_hash);
 
        if (count <= 0)
                return;
@@ -776,7 +776,7 @@ static HASH_MAP(pattern_entry_t) *read_pattern(const char *fname)
 {
        FILE *f;
        pattern_entry_t *entry, tmp;
-       int i, count;
+       size_t i, count;
        unsigned j;
        char magic[4];
        HASH_MAP(pattern_entry_t) *pattern_hash = new_pset(pattern_cmp, 8);
@@ -809,7 +809,7 @@ static HASH_MAP(pattern_entry_t) *read_pattern(const char *fname)
        }  /* for */
        fclose(f);
 
-       printf("Read %d pattern from %s\n", count, fname);
+       lc_printf("Read %zu pattern from %s\n", count, fname);
        assert(pset_count(pattern_hash) == count);
 
        return pattern_hash;
@@ -825,11 +825,11 @@ static void pattern_output(const char *fname)
        pattern_entry_t  *entry;
        pattern_entry_t  **pattern_arr;
        pattern_dumper_t *dump;
-       int i, count = pset_count(status->pattern_hash);
+       size_t i, count = pset_count(status->pattern_hash);
 
-       printf("\n%d pattern detected\n", count);
+       lc_printf("\n%zu pattern detected\n", count);
 
-       if (count <= 0)
+       if (count == 0)
                return;
 
        /* creates a dumper */
index 8595944..b343fe4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -329,7 +329,7 @@ static void add_distrib_entry(const distrib_entry_t *entry, void *env)
 {
        distrib_tbl_t *sum_tbl = (distrib_tbl_t*)env;
 
-       stat_add_int_distrib_tbl(sum_tbl, PTR_TO_INT(entry->object), &entry->cnt);
+       stat_add_int_distrib_tbl(sum_tbl, (int)PTR_TO_INT(entry->object), &entry->cnt);
 }  /* add_distrib_entry */
 
 /**
@@ -553,7 +553,7 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
 
        /* effects of optimizations */
        if (dump_opts) {
-               size_t i;
+               int i;
 
                simple_dump_real_func_calls(dmp, &entry->cnt[gcnt_acc_real_func_call]);
                simple_dump_tail_recursion(dmp, entry->num_tail_recursion);