From: Christoph Mallon Date: Sun, 25 Nov 2012 16:05:24 +0000 (+0100) Subject: rbitset: Let rbitset_alloca() return the new raw bitset. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=0e5195711161c7a5d6b841cb614c10f58b216fa8;p=libfirm rbitset: Let rbitset_alloca() return the new raw bitset. --- diff --git a/ir/adt/raw_bitset.h b/ir/adt/raw_bitset.h index 8d9ba9558..3c6e432d4 100644 --- a/ir/adt/raw_bitset.h +++ b/ir/adt/raw_bitset.h @@ -63,15 +63,10 @@ static inline unsigned *rbitset_malloc(size_t size) /** * Allocate an empty raw bitset on the stack. * - * @param res will contain the newly allocated bitset * @param size number of bits in the bitset */ -#define rbitset_alloca(res, size) \ -do { \ - size_t size_bytes = BITSET_SIZE_BYTES(size); \ - res = (unsigned*)alloca(size_bytes); \ - memset(res, 0, size_bytes); \ -} while(0) +#define rbitset_alloca(size) \ + ((unsigned*)memset(alloca(BITSET_SIZE_BYTES(size)), 0, BITSET_SIZE_BYTES(size))) /** * Allocate an empty raw bitset on an obstack. diff --git a/ir/be/beabihelper.c b/ir/be/beabihelper.c index 6a4f27ece..75ca7e893 100644 --- a/ir/be/beabihelper.c +++ b/ir/be/beabihelper.c @@ -414,10 +414,8 @@ static ir_node *add_to_keep(ir_node *last_keep, void be_add_missing_keeps_node(ir_node *node) { int n_outs, i; - unsigned *found_projs; ir_mode *mode = get_irn_mode(node); ir_node *last_keep; - ir_node **existing_projs; if (mode != mode_T) { if (!has_real_user(node)) { @@ -437,8 +435,8 @@ void be_add_missing_keeps_node(ir_node *node) if (n_outs <= 0) return; - rbitset_alloca(found_projs, n_outs); - existing_projs = ALLOCANZ(ir_node*, n_outs); + unsigned *const found_projs = rbitset_alloca(n_outs); + ir_node **const existing_projs = ALLOCANZ(ir_node*, n_outs); foreach_out_edge(node, edge) { ir_node *succ = get_edge_src_irn(edge); ir_mode *mode = get_irn_mode(succ); diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index c45b7c413..340d97de5 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -168,13 +168,11 @@ void sr_reinsert(size_red_t *sr) ir_graph *irg = sr->co->irg; be_ifg_t *ifg = sr->co->cenv->ifg; unsigned n_regs = arch_register_class_n_regs(sr->co->cls); - unsigned *possible_cols; - unsigned *allocatable_cols; - rbitset_alloca(allocatable_cols, n_regs); + unsigned *const allocatable_cols = rbitset_alloca(n_regs); be_set_allocatable_regs(irg, sr->co->cls, allocatable_cols); - rbitset_alloca(possible_cols, n_regs); + unsigned *const possible_cols = rbitset_alloca(n_regs); neighbours_iter_t iter; /* color the removed nodes in right order */ diff --git a/ir/be/becopyilp2.c b/ir/be/becopyilp2.c index cf819a595..0f9525125 100644 --- a/ir/be/becopyilp2.c +++ b/ir/be/becopyilp2.c @@ -91,12 +91,10 @@ static void build_coloring_cstr(ilp_env_t *ienv) unsigned n_regs = arch_register_class_n_regs(ienv->co->cls); const unsigned *allocatable_colors = lenv->allocatable_colors; nodes_iter_t iter; - unsigned *colors; ir_node *irn; char buf[32]; - rbitset_alloca(colors, n_regs); - + unsigned *const colors = rbitset_alloca(n_regs); be_ifg_foreach_node(ifg, &iter, irn) { const arch_register_req_t *req; unsigned col; @@ -617,7 +615,6 @@ static void ilp2_apply(ilp_env_t *ienv) */ static int co_solve_ilp2(copy_opt_t *co) { - unsigned *allocatable_colors; unsigned n_regs = arch_register_class_n_regs(co->cls); lpp_sol_state_t sol_state; ilp_env_t *ienv; @@ -630,7 +627,7 @@ static int co_solve_ilp2(copy_opt_t *co) my.last_x_var = -1; FIRM_DBG_REGISTER(dbg, "firm.be.coilp2"); - rbitset_alloca(allocatable_colors, n_regs); + unsigned *const allocatable_colors = rbitset_alloca(n_regs); be_set_allocatable_regs(co->irg, co->cls, allocatable_colors); my.allocatable_colors = allocatable_colors; diff --git a/ir/be/beprefalloc.c b/ir/be/beprefalloc.c index 52becc9f6..dfe76e39a 100644 --- a/ir/be/beprefalloc.c +++ b/ir/be/beprefalloc.c @@ -1206,7 +1206,7 @@ static void enforce_constraints(ir_nodeset_t *live_nodes, ir_node *node, if (! (req_->type & arch_register_req_type_limited)) continue; if (live_through_regs == NULL) { - rbitset_alloca(live_through_regs, n_regs); + live_through_regs = rbitset_alloca(n_regs); determine_live_through_regs(live_through_regs, node); } rbitset_or(forbidden_regs, req_->limited, n_regs); @@ -1219,7 +1219,7 @@ static void enforce_constraints(ir_nodeset_t *live_nodes, ir_node *node, /* create these arrays if we haven't yet */ if (live_through_regs == NULL) { - rbitset_alloca(live_through_regs, n_regs); + live_through_regs = rbitset_alloca(n_regs); } if (double_width) { @@ -1649,9 +1649,8 @@ static void allocate_coalesce_block(ir_node *block, void *data) ir_nodeset_insert(&live_nodes, node); } - unsigned *forbidden_regs; /**< collects registers which must - not be used for optimistic splits */ - rbitset_alloca(forbidden_regs, n_regs); + /** Collects registers which must not be used for optimistic splits. */ + unsigned *const forbidden_regs = rbitset_alloca(n_regs); /* handle phis... */ assign_phi_registers(block); diff --git a/ir/be/bespill.c b/ir/be/bespill.c index a6dbcbd04..ff361f623 100644 --- a/ir/be/bespill.c +++ b/ir/be/bespill.c @@ -60,7 +60,6 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) const ir_graph *irg = env->irg; be_irg_t *birg = be_birg_from_irg(irg); be_lv_t *lv = be_get_irg_liveness(irg); - unsigned *tmp = NULL; unsigned *def_constr = NULL; int arity = get_irn_arity(node); @@ -155,7 +154,7 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) if (! (req_->type & arch_register_req_type_limited)) continue; if (def_constr == NULL) { - rbitset_alloca(def_constr, cls->n_regs); + def_constr = rbitset_alloca(cls->n_regs); } rbitset_or(def_constr, req_->limited, cls->n_regs); ); @@ -169,7 +168,7 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node) * insert copies for all constrained arguments living through the node * and being constrained to a register which also occurs in out constraints. */ - rbitset_alloca(tmp, cls->n_regs); + unsigned *const tmp = rbitset_alloca(cls->n_regs); for (i = 0; i < arity; ++i) { const arch_register_req_t *req; ir_node *in; diff --git a/ir/be/bespillslots.c b/ir/be/bespillslots.c index ebbd0bf39..ff2df9f19 100644 --- a/ir/be/bespillslots.c +++ b/ir/be/bespillslots.c @@ -677,11 +677,9 @@ static unsigned count_spillslots(const be_fec_env_t *env) { size_t spillcount = ARR_LEN(env->spills); unsigned slotcount = 0; - unsigned *counted; size_t s; - rbitset_alloca(counted, spillcount); - + unsigned *const counted = rbitset_alloca(spillcount); for (s = 0; s < spillcount; ++s) { spill_t *spill = env->spills[s]; int spillslot = spill->spillslot; diff --git a/ir/opt/return.c b/ir/opt/return.c index 572ba2b78..cdaddda4a 100644 --- a/ir/opt/return.c +++ b/ir/opt/return.c @@ -64,7 +64,6 @@ void normalize_one_return(ir_graph *irg) int n_rets = 0; bool filter_dbgi = false; dbg_info *combined_dbgi = NULL; - unsigned *returns; int i, j, k, n, last_idx; ir_node **in, **retvals, **endbl_in; ir_node *block; @@ -79,8 +78,7 @@ void normalize_one_return(ir_graph *irg) return; } - rbitset_alloca(returns, n); - + unsigned *const returns = rbitset_alloca(n); for (i = 0; i < n; ++i) { ir_node *node = get_Block_cfgpred(endbl, i);