rbitset: Let rbitset_alloca() return the new raw bitset.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 25 Nov 2012 16:05:24 +0000 (17:05 +0100)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sun, 25 Nov 2012 16:06:53 +0000 (17:06 +0100)
ir/adt/raw_bitset.h
ir/be/beabihelper.c
ir/be/becopyilp.c
ir/be/becopyilp2.c
ir/be/beprefalloc.c
ir/be/bespill.c
ir/be/bespillslots.c
ir/opt/return.c

index 8d9ba95..3c6e432 100644 (file)
@@ -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.
index 6a4f27e..75ca7e8 100644 (file)
@@ -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);
index c45b7c4..340d97d 100644 (file)
@@ -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 */
index cf819a5..0f95251 100644 (file)
@@ -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;
 
index 52becc9..dfe76e3 100644 (file)
@@ -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);
index a6dbcbd..ff361f6 100644 (file)
@@ -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;
index ebbd0bf..ff2df9f 100644 (file)
@@ -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;
index 572ba2b..cdaddda 100644 (file)
@@ -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);