becopyilp: Do not advertise the switch to dump the solution, because this is not...
[libfirm] / ir / be / bestack.c
index 17e8cc3..761e09d 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -83,7 +69,7 @@ static ir_entity *search_ent_with_offset(ir_type *t, int offset)
        return NULL;
 }
 
-static int stack_frame_compute_initial_offset(be_stack_layout_t *frame)
+static void stack_frame_compute_initial_offset(be_stack_layout_t *frame)
 {
        ir_type  *base = frame->between_type;
        ir_entity *ent = search_ent_with_offset(base, 0);
@@ -93,8 +79,6 @@ static int stack_frame_compute_initial_offset(be_stack_layout_t *frame)
        } else {
                frame->initial_offset = be_get_stack_entity_offset(frame, ent, 0);
        }
-
-       return frame->initial_offset;
 }
 
 /**
@@ -241,11 +225,10 @@ void be_abi_fix_stack_bias(ir_graph *irg)
        stack_frame_compute_initial_offset(stack_layout);
 
        /* Determine the stack bias at the end of the start block. */
-       bw.start_block_bias = process_stack_bias(get_irg_start_block(irg),
-                                                stack_layout->initial_bias);
+       bw.start_block      = get_irg_start_block(irg);
+       bw.start_block_bias = process_stack_bias(bw.start_block, stack_layout->initial_bias);
 
        /* fix the bias is all other blocks */
-       bw.start_block = get_irg_start_block(irg);
        irg_block_walk_graph(irg, stack_bias_walker, NULL, &bw);
 
        /* fix now inner functions: these still have Sel node to outer
@@ -287,34 +270,20 @@ void be_abi_fix_stack_nodes(ir_graph *irg)
        be_lv_t                   *lv       = be_get_irg_liveness(irg);
        const arch_env_t          *arch_env = be_get_irg_arch_env(irg);
        be_irg_t                  *birg     = be_birg_from_irg(irg);
-       const arch_register_req_t *sp_req   = birg->sp_req;
        const arch_register_t     *sp       = arch_env->sp;
        be_ssa_construction_env_t  senv;
        int i, len;
        ir_node **phis;
        fix_stack_walker_env_t walker_env;
 
+       arch_register_req_t const *sp_req = birg->sp_req;
        if (sp_req == NULL) {
-               struct obstack      *obst = be_get_be_obst(irg);
-               arch_register_req_t *new_sp_req;
-               unsigned            *limited_bitset;
-
-               new_sp_req        = OALLOCZ(obst, arch_register_req_t);
-               new_sp_req->type  = arch_register_req_type_limited
-                                 | arch_register_req_type_produces_sp;
-               new_sp_req->cls   = arch_env->sp->reg_class;
-               new_sp_req->width = 1;
-
-               limited_bitset = rbitset_obstack_alloc(obst, new_sp_req->cls->n_regs);
-               rbitset_set(limited_bitset, sp->index);
-               new_sp_req->limited = limited_bitset;
-
-               if (!rbitset_is_set(birg->allocatable_regs, sp->global_index)) {
-                       new_sp_req->type |= arch_register_req_type_ignore;
-               }
+               arch_register_req_type_t type = arch_register_req_type_produces_sp;
+               if (!rbitset_is_set(birg->allocatable_regs, sp->global_index))
+                       type |= arch_register_req_type_ignore;
 
-               sp_req = new_sp_req;
-               birg->sp_req = new_sp_req;
+               struct obstack *const obst = be_get_be_obst(irg);
+               birg->sp_req = sp_req = be_create_reg_req(obst, sp, type);
        }
 
        walker_env.sp_nodes = NEW_ARR_F(ir_node*, 0);