From c719c20ba0a93056a054bd07f46de3f3a8838672 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Thu, 12 Jul 2012 12:56:49 +0200 Subject: [PATCH] Add a wrapper macro for ir_nodemap_get(), which has the return type as additional parameter. --- ir/ana/heights.c | 4 ++-- ir/ana/irlivechk.c | 2 +- ir/ana/vrp.c | 4 ++-- ir/be/beabihelper.c | 2 +- ir/be/becopyheur2.c | 4 ++-- ir/be/becopyheur4.c | 2 +- ir/be/bessaconstr.c | 4 ++-- ir/ir/irnodemap.h | 2 ++ ir/opt/loop.c | 6 +++--- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ir/ana/heights.c b/ir/ana/heights.c index 7b8b8c266..5c4ac030c 100644 --- a/ir/ana/heights.c +++ b/ir/ana/heights.c @@ -53,13 +53,13 @@ typedef struct { static irn_height_t *maybe_get_height_data(const ir_heights_t *heights, const ir_node *node) { - irn_height_t *height = (irn_height_t*)ir_nodemap_get(&heights->data, node); + irn_height_t *height = ir_nodemap_get(irn_height_t, &heights->data, node); return height; } static irn_height_t *get_height_data(ir_heights_t *heights, const ir_node *node) { - irn_height_t *height = (irn_height_t*)ir_nodemap_get(&heights->data, node); + irn_height_t *height = ir_nodemap_get(irn_height_t, &heights->data, node); if (height == NULL) { height = OALLOCZ(&heights->obst, irn_height_t); ir_nodemap_insert(&heights->data, node, height); diff --git a/ir/ana/irlivechk.c b/ir/ana/irlivechk.c index 34c89c7e9..2c1a31f19 100644 --- a/ir/ana/irlivechk.c +++ b/ir/ana/irlivechk.c @@ -85,7 +85,7 @@ struct lv_chk_t { static bl_info_t *get_block_info(lv_chk_t *lv, const ir_node *block) { - bl_info_t *info = (bl_info_t*)ir_nodemap_get(&lv->block_infos, block); + bl_info_t *info = ir_nodemap_get(bl_info_t, &lv->block_infos, block); if (info == NULL) { info = OALLOC(&lv->obst, bl_info_t); info->id = get_Block_dom_tree_pre_num(block); diff --git a/ir/ana/vrp.c b/ir/ana/vrp.c index 097b73ee9..ac200f40d 100644 --- a/ir/ana/vrp.c +++ b/ir/ana/vrp.c @@ -51,7 +51,7 @@ typedef struct vrp_env_t { static vrp_attr *vrp_get_or_set_info(ir_vrp_info *info, const ir_node *node) { - vrp_attr *attr = (vrp_attr*)ir_nodemap_get(&info->infos, node); + vrp_attr *attr = ir_nodemap_get(vrp_attr, &info->infos, node); if (attr == NULL) { ir_mode *mode = get_irn_mode(node); assert(mode_is_int(mode)); @@ -73,7 +73,7 @@ vrp_attr *vrp_get_info(const ir_node *node) ir_graph *irg = get_irn_irg(node); if (irg->vrp.infos.data == NULL) return NULL; - return (vrp_attr*) ir_nodemap_get(&irg->vrp.infos, node); + return ir_nodemap_get(vrp_attr, &irg->vrp.infos, node); } static int vrp_update_node(ir_vrp_info *info, ir_node *node) diff --git a/ir/be/beabihelper.c b/ir/be/beabihelper.c index 82790bee5..a5a66ec36 100644 --- a/ir/be/beabihelper.c +++ b/ir/be/beabihelper.c @@ -665,7 +665,7 @@ be_stackorder_t *be_collect_stacknodes(ir_graph *irg) ir_node *be_get_stack_pred(const be_stackorder_t *env, const ir_node *node) { - return (ir_node*)ir_nodemap_get(&env->stack_order, node); + return ir_nodemap_get(ir_node, &env->stack_order, node); } void be_free_stackorder(be_stackorder_t *env) diff --git a/ir/be/becopyheur2.c b/ir/be/becopyheur2.c index c69e65a8d..41c531fad 100644 --- a/ir/be/becopyheur2.c +++ b/ir/be/becopyheur2.c @@ -178,7 +178,7 @@ typedef struct { static co2_irn_t *get_co2_irn(co2_t *env, const ir_node *node) { - co2_irn_t *ci = (co2_irn_t*)ir_nodemap_get(&env->map, node); + co2_irn_t *ci = ir_nodemap_get(co2_irn_t, &env->map, node); if (ci == NULL) { ci = OALLOCZ(&env->obst, co2_irn_t); @@ -196,7 +196,7 @@ static co2_irn_t *get_co2_irn(co2_t *env, const ir_node *node) static co2_cloud_irn_t *get_co2_cloud_irn(co2_t *env, const ir_node *node) { - co2_cloud_irn_t *ci = (co2_cloud_irn_t*)ir_nodemap_get(&env->map, node); + co2_cloud_irn_t *ci = ir_nodemap_get(co2_cloud_irn_t, &env->map, node); if (ci == NULL) { ci = OALLOCZ(&env->obst, co2_cloud_irn_t); diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c index bf46a30b0..47ceb989d 100644 --- a/ir/be/becopyheur4.c +++ b/ir/be/becopyheur4.c @@ -201,7 +201,7 @@ static co_mst_irn_t *co_mst_irn_init(co_mst_env_t *env, const ir_node *irn) static co_mst_irn_t *get_co_mst_irn(co_mst_env_t *env, const ir_node *node) { - co_mst_irn_t *res = (co_mst_irn_t*)ir_nodemap_get(&env->map, node); + co_mst_irn_t *res = ir_nodemap_get(co_mst_irn_t, &env->map, node); if (res == NULL) { res = co_mst_irn_init(env, node); ir_nodemap_insert(&env->map, node, res); diff --git a/ir/be/bessaconstr.c b/ir/be/bessaconstr.c index 38c1cdc74..7421805fc 100644 --- a/ir/be/bessaconstr.c +++ b/ir/be/bessaconstr.c @@ -101,7 +101,7 @@ static bool has_definition(const ir_node *block) static constr_info *get_or_set_info(be_ssa_construction_env_t *env, const ir_node *node) { - constr_info *info = (constr_info*)ir_nodemap_get(&env->infos, node); + constr_info *info = ir_nodemap_get(constr_info, &env->infos, node); if (info == NULL) { info = OALLOCZ(&env->obst, constr_info); ir_nodemap_insert(&env->infos, node, info); @@ -112,7 +112,7 @@ static constr_info *get_or_set_info(be_ssa_construction_env_t *env, static constr_info *get_info(const be_ssa_construction_env_t *env, const ir_node *node) { - return (constr_info*)ir_nodemap_get(&env->infos, node); + return ir_nodemap_get(constr_info, &env->infos, node); } /** diff --git a/ir/ir/irnodemap.h b/ir/ir/irnodemap.h index e4ccbacdb..fa4bfeef7 100644 --- a/ir/ir/irnodemap.h +++ b/ir/ir/irnodemap.h @@ -109,6 +109,8 @@ static inline void *ir_nodemap_get(const ir_nodemap *nodemap, return nodemap->data[idx]; } +#define ir_nodemap_get(type, nodemap, node) ((type*)ir_nodemap_get(nodemap, node)) + /** * Get mapping for @p node (fast version). Returns NULL if nothing is mapped. * diff --git a/ir/opt/loop.c b/ir/opt/loop.c index d8c38ce2a..cb8c06866 100644 --- a/ir/opt/loop.c +++ b/ir/opt/loop.c @@ -494,7 +494,7 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp) unrolling_node_info *info; assert(nr != 0 && "0 reserved"); - info = (unrolling_node_info*)ir_nodemap_get(&map, n); + info = ir_nodemap_get(unrolling_node_info, &map, n); if (! info) { ir_node **arr = NEW_ARR_D(ir_node*, &obst, unroll_nr); memset(arr, 0, unroll_nr * sizeof(ir_node*)); @@ -513,7 +513,7 @@ static void set_unroll_copy(ir_node *n, int nr, ir_node *cp) static ir_node *get_unroll_copy(ir_node *n, int nr) { ir_node *cp; - unrolling_node_info *info = (unrolling_node_info *)ir_nodemap_get(&map, n); + unrolling_node_info *info = ir_nodemap_get(unrolling_node_info, &map, n); if (! info) return NULL; @@ -533,7 +533,7 @@ static void set_inversion_copy(ir_node *n, ir_node *cp) /* Getter of copy of n for inversion */ static ir_node *get_inversion_copy(ir_node *n) { - ir_node *cp = (ir_node *)ir_nodemap_get(&map, n); + ir_node *cp = ir_nodemap_get(ir_node, &map, n); return cp; } -- 2.20.1