Add a wrapper macro for ir_nodehashmap_get(), which has the return type as additional...
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 13 Jul 2012 20:57:54 +0000 (22:57 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 13 Jul 2012 21:03:59 +0000 (23:03 +0200)
12 files changed:
ir/be/bedump.c
ir/be/belive.c
ir/be/belive_t.h
ir/be/belower.c
ir/be/bestate.c
ir/be/beverify.c
ir/ir/irnodehashmap.c
ir/ir/irnodehashmap.h
ir/opt/cfopt.c
ir/opt/gvn_pre.c
ir/opt/ldstopt.c
ir/opt/opt_ldst.c

index 4952fd2..1e43f38 100644 (file)
@@ -152,7 +152,7 @@ void be_dump_liveness_block(void *context, FILE *F, const ir_node *bl)
 {
        if (is_Block(bl)) {
                be_lv_t *lv = (be_lv_t*)context;
-               be_lv_info_t *info = (be_lv_info_t*)ir_nodehashmap_get(&lv->map, bl);
+               be_lv_info_t *info = ir_nodehashmap_get(be_lv_info_t, &lv->map, bl);
 
                fprintf(F, "liveness:\n");
                if (info != NULL) {
index 643d9fa..76da51c 100644 (file)
@@ -122,7 +122,7 @@ be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *bl,
        be_lv_info_node_t *res = NULL;
 
        stat_ev_tim_push();
-       irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl);
+       irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl);
        if (irn_live != NULL) {
                unsigned idx = get_irn_idx(irn);
 
@@ -144,7 +144,7 @@ be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *bl,
 static be_lv_info_node_t *be_lv_get_or_set(be_lv_t *li, ir_node *bl,
                                            ir_node *irn)
 {
-       be_lv_info_t *irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl);
+       be_lv_info_t *irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl);
        if (irn_live == NULL) {
                irn_live = OALLOCNZ(&li->obst, be_lv_info_t, LV_STD_SIZE);
                irn_live[0].head.n_size = LV_STD_SIZE-1;
@@ -203,7 +203,7 @@ static be_lv_info_node_t *be_lv_get_or_set(be_lv_t *li, ir_node *bl,
 static int be_lv_remove(be_lv_t *li, const ir_node *bl,
                         const ir_node *irn)
 {
-       be_lv_info_t *irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl);
+       be_lv_info_t *irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl);
 
        if (irn_live != NULL) {
                unsigned n   = irn_live[0].head.n_members;
index 9a49c98..8482d5b 100644 (file)
@@ -67,7 +67,7 @@ union be_lv_info_t {
 static inline int _be_lv_next_irn(const be_lv_t *lv, const ir_node *block,
                                   unsigned flags, int i)
 {
-       be_lv_info_t *arr = (be_lv_info_t*)ir_nodehashmap_get(&lv->map, block);
+       be_lv_info_t *arr = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
        if (arr != NULL) {
                int n_members = (int) arr[0].head.n_members;
                while(i < n_members) {
@@ -84,7 +84,7 @@ static inline int _be_lv_next_irn(const be_lv_t *lv, const ir_node *block,
 static inline ir_node *_be_lv_get_irn(const be_lv_t *lv, const ir_node *block,
                                       int i)
 {
-       be_lv_info_t *arr = (be_lv_info_t*)ir_nodehashmap_get(&lv->map, block);
+       be_lv_info_t *arr = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
        return get_idx_irn(lv->irg, arr[i + 1].node.idx);
 }
 
index 3082c80..39bdcfa 100644 (file)
@@ -553,7 +553,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
        sched_add_after(skip_Proj(irn), keep);
 
        /* insert the other different and its copies into the map */
-       entry = (op_copy_assoc_t*)ir_nodehashmap_get(op_set, other_different);
+       entry = ir_nodehashmap_get(op_copy_assoc_t, op_set, other_different);
        if (! entry) {
                entry      = OALLOC(&env->obst, op_copy_assoc_t);
                entry->cls = cls;
index adf7859..e609532 100644 (file)
@@ -110,8 +110,7 @@ static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st
 
 static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node)
 {
-       spill_info_t *spill_info
-               = (spill_info_t*) ir_nodehashmap_get(&env->spill_infos, node);
+       spill_info_t *spill_info = ir_nodehashmap_get(spill_info_t, &env->spill_infos, node);
        //ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info);
        return spill_info;
 }
index 04f3de2..a0c3f89 100644 (file)
@@ -951,8 +951,8 @@ static void lv_check_walker(ir_node *bl, void *data)
        be_lv_t *lv    = w->lv;
        be_lv_t *fresh = (be_lv_t*)w->data;
 
-       be_lv_info_t *curr = (be_lv_info_t*)ir_nodehashmap_get(&fresh->map, bl);
-       be_lv_info_t *fr   = (be_lv_info_t*)ir_nodehashmap_get(&fresh->map, bl);
+       be_lv_info_t *curr = ir_nodehashmap_get(be_lv_info_t, &fresh->map, bl);
+       be_lv_info_t *fr   = ir_nodehashmap_get(be_lv_info_t, &fresh->map, bl);
 
        if (!fr && curr && curr[0].head.n_members > 0) {
                unsigned i;
index 87e8e5e..6c74dbd 100644 (file)
@@ -73,7 +73,7 @@ void ir_nodehashmap_init(ir_nodehashmap_t *nodehashmap)
        ir_nodehashmap_init_size(nodehashmap, 16);
 }
 
-void *ir_nodehashmap_get(const ir_nodehashmap_t *self, const ir_node *node)
+void *(ir_nodehashmap_get)(const ir_nodehashmap_t *self, const ir_node *node)
 {
        ir_nodehashmap_entry_t *entry = ir_nodehashmap_find_(self, node);
        return entry->data;
index 57420ae..1660af5 100644 (file)
@@ -101,6 +101,8 @@ void ir_nodehashmap_remove(ir_nodehashmap_t *nodehashmap, const ir_node *node);
 void *ir_nodehashmap_get(const ir_nodehashmap_t *nodehashmap,
                          const ir_node *node);
 
+#define ir_nodehashmap_get(type, self, node) ((type*)ir_nodehashmap_get((self), (node)))
+
 /**
  * Returns the number of pointers contained in the nodehashmap
  *
index f681765..477c32d 100644 (file)
@@ -572,13 +572,13 @@ typedef enum block_flags_t {
 static bool get_block_flag(const ir_nodehashmap_t *infos, const ir_node *block,
                            int flag)
 {
-       return PTR_TO_INT(ir_nodehashmap_get(infos, block)) & flag;
+       return PTR_TO_INT(ir_nodehashmap_get(void, infos, block)) & flag;
 }
 
 static void set_block_flag(ir_nodehashmap_t *infos, ir_node *block,
                            block_flags_t flag)
 {
-       int data = PTR_TO_INT(ir_nodehashmap_get(infos, block));
+       int data = PTR_TO_INT(ir_nodehashmap_get(void, infos, block));
        data |= flag;
        ir_nodehashmap_insert(infos, block, INT_TO_PTR(data));
 }
index fa7f3b2..019ddd6 100644 (file)
@@ -282,7 +282,7 @@ static ir_node *get_translated(ir_node *node, ir_node *block)
                return node;
 
        bi    = get_block_info(block);
-       trans = (ir_node *)ir_nodehashmap_get(bi->trans, node);
+       trans = ir_nodehashmap_get(ir_node, bi->trans, node);
        return trans;
 }
 
index 3667f26..1bbd0c7 100644 (file)
@@ -1545,7 +1545,7 @@ typedef struct loop_env {
 */
 static node_entry *get_irn_ne(ir_node *irn, loop_env *env)
 {
-       node_entry *e = (node_entry*)ir_nodehashmap_get(&env->map, irn);
+       node_entry *e = ir_nodehashmap_get(node_entry, &env->map, irn);
 
        if (e == NULL) {
                e = OALLOC(&env->obst, node_entry);
index 24891e5..438aace 100644 (file)
@@ -311,7 +311,7 @@ restart:
                goto restart;
        }
 
-       entry = (address_entry*)ir_nodehashmap_get(&env.adr_map, adr);
+       entry = ir_nodehashmap_get(address_entry, &env.adr_map, adr);
 
        if (entry == NULL) {
                /* new address */