all backends have decreasing stack
authorMatthias Braun <matze@braunis.de>
Tue, 5 Apr 2011 14:59:36 +0000 (16:59 +0200)
committerMatthias Braun <matze@braunis.de>
Fri, 8 Apr 2011 09:20:42 +0000 (11:20 +0200)
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/amd64/bearch_amd64.c
ir/be/arm/arm_transform.c
ir/be/arm/bearch_arm.c
ir/be/beabi.c
ir/be/bearch.h
ir/be/beirg.h
ir/be/bestack.c
ir/be/ia32/bearch_ia32.c
ir/be/sparc/bearch_sparc.c
ir/be/sparc/sparc_transform.c

index 035ee58..e0f6fdf 100644 (file)
@@ -148,7 +148,6 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = {
                &TEMPLATE_registers[REG_SP],  /* stack pointer register */
                &TEMPLATE_registers[REG_BP],  /* base pointer register */
                &TEMPLATE_reg_classes[CLASS_TEMPLATE_gp],  /* link pointer register class */
-               -1,                          /* stack direction */
                2,                           /* power of two stack alignment for calls, 2^2 == 4 */
                NULL,                        /* main environment */
                7,                           /* costs for a spill instruction */
index 10bfeb5..2a76477 100644 (file)
@@ -295,7 +295,6 @@ static amd64_isa_t amd64_isa_template = {
                &amd64_registers[REG_RSP],  /* stack pointer register */
                &amd64_registers[REG_RBP],  /* base pointer register */
                &amd64_reg_classes[CLASS_amd64_gp],  /* link pointer register class */
-               -1,                          /* stack direction */
                3,                           /* power of two stack alignment for calls, 2^2 == 4 */
                NULL,                        /* main environment */
                7,                           /* costs for a spill instruction */
index beb766f..8918ee2 100644 (file)
@@ -1707,7 +1707,6 @@ static void create_stacklayout(ir_graph *irg)
        layout->param_map      = NULL; /* TODO */
        layout->initial_offset = 0;
        layout->initial_bias   = 0;
-       layout->stack_dir      = -1;
        layout->sp_relative    = true;
 
        assert(N_FRAME_TYPES == 3);
index dcc6139..3e391e9 100644 (file)
@@ -428,7 +428,6 @@ static arm_isa_t arm_isa_template = {
                &arm_registers[REG_SP],  /* stack pointer */
                &arm_registers[REG_R11], /* base pointer */
                &arm_reg_classes[CLASS_arm_gp],  /* static link pointer class */
-               -1,                    /* stack direction */
                2,                     /* power of two stack alignment for calls, 2^2 == 4 */
                NULL,                  /* main environment */
                7,                     /* spill costs */
index 294e2f2..b35e96e 100644 (file)
@@ -280,13 +280,12 @@ static void be_abi_call_free(be_abi_call_t *call)
  * @param args      the stack argument layout type
  * @param between   the between layout type
  * @param locals    the method frame type
- * @param stack_dir the stack direction: < 0 decreasing, > 0 increasing addresses
  * @param param_map an array mapping method argument positions to the stack argument type
  *
  * @return the initialized stack layout
  */
 static be_stack_layout_t *stack_frame_init(be_stack_layout_t *frame, ir_type *args,
-                                           ir_type *between, ir_type *locals, int stack_dir,
+                                           ir_type *between, ir_type *locals,
                                            ir_entity *param_map[])
 {
        frame->arg_type       = args;
@@ -294,19 +293,13 @@ static be_stack_layout_t *stack_frame_init(be_stack_layout_t *frame, ir_type *ar
        frame->frame_type     = locals;
        frame->initial_offset = 0;
        frame->initial_bias   = 0;
-       frame->stack_dir      = stack_dir;
        frame->order[1]       = between;
        frame->param_map      = param_map;
 
-       if (stack_dir > 0) {
-               frame->order[0] = args;
-               frame->order[2] = locals;
-       } else {
-               /* typical decreasing stack: locals have the
-                * lowest addresses, arguments the highest */
-               frame->order[0] = locals;
-               frame->order[2] = args;
-       }
+       /* typical decreasing stack: locals have the
+        * lowest addresses, arguments the highest */
+       frame->order[0] = locals;
+       frame->order[2] = args;
        return frame;
 }
 
@@ -339,7 +332,6 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
        ir_node *curr_mem          = get_Call_mem(irn);
        ir_node *bl                = get_nodes_block(irn);
        int stack_size             = 0;
-       int stack_dir              = arch_env->stack_dir;
        const arch_register_t *sp  = arch_env->sp;
        be_abi_call_t *call        = be_abi_call_new(sp->reg_class);
        ir_mode *mach_mode         = sp->reg_class->mode;
@@ -404,7 +396,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
         * Note: we also have to do this for stack_size == 0, because we may have
         * to adjust stack alignment for the call.
         */
-       if (stack_dir < 0 && !do_seq && !no_alloc) {
+       if (!do_seq && !no_alloc) {
                curr_sp = be_new_IncSP(sp, bl, curr_sp, stack_size, 1);
        }
 
@@ -420,7 +412,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
                 * We must them reverse again if they are pushed (not stored) and the stack
                 * direction is downwards.
                 */
-               if (call->flags.bits.left_to_right ^ (do_seq && stack_dir < 0)) {
+               if (call->flags.bits.left_to_right ^ do_seq) {
                        for (i = 0; i < n_stack_params >> 1; ++i) {
                                int other  = n_stack_params - i - 1;
                                int tmp    = stack_param_idx[i];
@@ -1146,9 +1138,8 @@ static ir_type *compute_arg_type(be_abi_irg_t *env, ir_graph *irg,
                                                                 ir_type *method_type, ir_type *val_param_tp,
                                                                 ir_entity ***param_map)
 {
-       const arch_env_t *arch_env = be_get_irg_arch_env(irg);
        int dir  = env->call->flags.bits.left_to_right ? 1 : -1;
-       int inc  = arch_env->stack_dir * dir;
+       int inc  = -dir;
        int n    = get_method_n_params(method_type);
        int curr = inc > 0 ? 0 : n - 1;
        struct obstack *obst = be_get_be_obst(irg);
@@ -1755,7 +1746,7 @@ static void modify_irg(ir_graph *irg)
 
        bet_type = call->cb->get_between_type(env->cb);
        stack_frame_init(stack_layout, arg_type, bet_type,
-                        get_irg_frame_type(irg), arch_env->stack_dir, param_map);
+                        get_irg_frame_type(irg), param_map);
        stack_layout->sp_relative = call->flags.bits.try_omit_fp;
 
        /* Count the register params and add them to the number of Projs for the RegParams node */
index 9c56e52..6a68866 100644 (file)
@@ -618,8 +618,6 @@ struct arch_env_t {
        const arch_register_t *bp;               /**< The base pointer register. */
        const arch_register_class_t *link_class; /**< The static link pointer
                                                      register class. */
-       int                    stack_dir;        /**< -1 for decreasing, 1 for
-                                                     increasing. */
        int                    stack_alignment;  /**< power of 2 stack alignment */
        const be_main_env_t   *main_env;         /**< the be main environment */
        int                    spill_cost;       /**< cost for a be_Spill node */
index 1b7c1a8..dc5f7cb 100644 (file)
@@ -65,7 +65,6 @@ struct be_stack_layout_t {
        ir_entity **param_map;         /**< An array mapping type parameters to arg_type entries */
        int initial_offset;            /**< the initial difference between stack pointer and frame pointer */
        int initial_bias;              /**< the initial stack bias */
-       int stack_dir;                 /**< -1 for decreasing, 1 for increasing. */
        bool sp_relative : 1;          /**< entities are addressed relative to
                                            stack pointer (omit-fp mode) */
 };
index 1e42e8b..90b8407 100644 (file)
@@ -86,12 +86,11 @@ static ir_entity *search_ent_with_offset(ir_type *t, int offset)
 
 static int stack_frame_compute_initial_offset(be_stack_layout_t *frame)
 {
-       ir_type  *base = frame->stack_dir < 0 ? frame->between_type : frame->frame_type;
+       ir_type  *base = frame->between_type;
        ir_entity *ent = search_ent_with_offset(base, 0);
 
        if (ent == NULL) {
-               frame->initial_offset
-                       = frame->stack_dir < 0 ? get_type_size_bytes(frame->frame_type) : get_type_size_bytes(frame->between_type);
+               frame->initial_offset = get_type_size_bytes(frame->frame_type);
        } else {
                frame->initial_offset = be_get_stack_entity_offset(frame, ent, 0);
        }
index c26e948..37dd38d 100644 (file)
@@ -1466,7 +1466,6 @@ static ia32_isa_t ia32_isa_template = {
                &ia32_registers[REG_ESP],  /* stack pointer register */
                &ia32_registers[REG_EBP],  /* base pointer register */
                &ia32_reg_classes[CLASS_ia32_gp],  /* static link pointer register class */
-               -1,                      /* stack direction */
                2,                       /* power of two stack alignment, 2^2 == 4 */
                NULL,                    /* main environment */
                7,                       /* costs for a spill instruction */
index 5a819db..f95d8f8 100644 (file)
@@ -310,7 +310,6 @@ static sparc_isa_t sparc_isa_template = {
                &sparc_registers[REG_SP],           /* stack pointer register */
                &sparc_registers[REG_FRAME_POINTER],/* base pointer register */
                &sparc_reg_classes[CLASS_sparc_gp], /* link pointer register class */
-               -1,                                 /* stack direction */
                3,                                  /* power of two stack alignment
                                                       for calls */
                NULL,                               /* main environment */
index 9075a69..1e325f3 100644 (file)
@@ -1279,7 +1279,6 @@ static void create_stacklayout(ir_graph *irg)
        layout->arg_type       = arg_type;
        layout->initial_offset = 0;
        layout->initial_bias   = 0;
-       layout->stack_dir      = -1;
        layout->sp_relative    = cconv->omit_fp;
 
        assert(N_FRAME_TYPES == 3);