perform_memory operand now takes a spill instead of a reload
[libfirm] / ir / be / benode.c
index a7f13d6..00d5c44 100644 (file)
@@ -89,8 +89,7 @@ typedef struct {
 /** The be_Stack attribute type. */
 typedef struct {
        be_node_attr_t node_attr;
-       int offset;           /**< The offset by which the stack shall be increased/decreased. */
-       be_stack_dir_t dir;   /**< The direction in which the stack shall be modified (expand or shrink). */
+       int offset;           /**< The offset by which the stack shall be expanded/shrinked. */
 } be_stack_attr_t;
 
 /** The be_Frame attribute type. */
@@ -380,6 +379,18 @@ ir_node *be_get_Reload_frame(const ir_node *irn)
        return get_irn_n(irn, be_pos_Reload_frame);
 }
 
+ir_node *be_get_Spill_val(const ir_node *irn)
+{
+       assert(be_is_Spill(irn));
+       return get_irn_n(irn, be_pos_Spill_val);
+}
+
+ir_node *be_get_Spill_frame(const ir_node *irn)
+{
+       assert(be_is_Spill(irn));
+       return get_irn_n(irn, be_pos_Spill_frame);
+}
+
 ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
 {
        int i;
@@ -530,7 +541,7 @@ int be_Return_get_n_rets(ir_node *ret)
        return a->num_ret_vals;
 }
 
-ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *mem, unsigned offset, be_stack_dir_t dir)
+ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *mem, int offset)
 {
        be_stack_attr_t *a;
        ir_node *irn;
@@ -540,7 +551,6 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_
        in[1]     = mem;
        irn       = new_ir_node(NULL, irg, bl, op_be_IncSP, sp->reg_class->mode, 2, in);
        a         = init_node_attr(irn, 1);
-       a->dir    = dir;
        a->offset = offset;
 
        be_node_set_flags(irn, -1, arch_irn_flags_ignore | arch_irn_flags_modify_sp);
@@ -753,7 +763,7 @@ int be_has_frame_entity(const ir_node *irn)
        }
 }
 
-entity *be_get_frame_entity(const ir_node *irn)
+entitybe_get_frame_entity(const ir_node *irn)
 {
        if(be_has_frame_entity(irn)) {
                be_frame_attr_t *a = get_irn_attr(irn);
@@ -762,16 +772,6 @@ entity *be_get_frame_entity(const ir_node *irn)
        return NULL;
 }
 
-void be_set_frame_entity(const ir_node *irn, entity* ent)
-{
-       be_frame_attr_t *a;
-
-       assert(be_has_frame_entity(irn));
-
-       a = get_irn_attr(irn);
-       a->ent = ent;
-}
-
 void be_set_MemPerm_in_entity(const ir_node *irn, int n, entity *ent)
 {
        be_memperm_attr_t *attr = get_irn_attr(irn);
@@ -912,34 +912,20 @@ ir_node *be_get_IncSP_mem(ir_node *irn) {
        return get_irn_n(irn, 1);
 }
 
-void be_set_IncSP_offset(ir_node *irn, unsigned offset)
+void be_set_IncSP_offset(ir_node *irn, int offset)
 {
        be_stack_attr_t *a = get_irn_attr(irn);
        assert(be_is_IncSP(irn));
        a->offset = offset;
 }
 
-unsigned be_get_IncSP_offset(const ir_node *irn)
+int be_get_IncSP_offset(const ir_node *irn)
 {
        be_stack_attr_t *a = get_irn_attr(irn);
        assert(be_is_IncSP(irn));
        return a->offset;
 }
 
-void be_set_IncSP_direction(ir_node *irn, be_stack_dir_t dir)
-{
-       be_stack_attr_t *a = get_irn_attr(irn);
-       assert(be_is_IncSP(irn));
-       a->dir = dir;
-}
-
-be_stack_dir_t be_get_IncSP_direction(const ir_node *irn)
-{
-       be_stack_attr_t *a = get_irn_attr(irn);
-       assert(be_is_IncSP(irn));
-       return a->dir;
-}
-
 ir_node *be_spill(const arch_env_t *arch_env, ir_node *irn)
 {
        ir_node *bl     = get_nodes_block(irn);
@@ -1065,7 +1051,7 @@ static arch_irn_class_t be_node_classify(const void *_self, const ir_node *irn)
                XXX(StackParam, stackparam);
 #undef XXX
                default:
-               return 0;
+               return arch_irn_class_normal;
        }
 
        return 0;
@@ -1082,9 +1068,14 @@ static entity *be_node_get_frame_entity(const void *self, const ir_node *irn)
        return be_get_frame_entity(irn);
 }
 
-static void be_node_set_frame_entity(const void *self, const ir_node *irn, entity *ent)
+static void be_node_set_frame_entity(const void *self, ir_node *irn, entity *ent)
 {
-       be_set_frame_entity(irn, ent);
+       be_frame_attr_t *a;
+
+       assert(be_has_frame_entity(irn));
+
+       a = get_irn_attr(irn);
+       a->ent = ent;
 }
 
 static void be_node_set_frame_offset(const void *self, ir_node *irn, int offset)
@@ -1095,6 +1086,17 @@ static void be_node_set_frame_offset(const void *self, ir_node *irn, int offset)
        }
 }
 
+static int be_node_get_sp_bias(const void *self, const ir_node *irn)
+{
+       int result = 0;
+
+       if(be_is_IncSP(irn)) {
+               result = be_get_IncSP_offset(irn);
+       }
+
+       return result;
+}
+
 /*
   ___ ____  _   _   _   _                 _ _
  |_ _|  _ \| \ | | | | | | __ _ _ __   __| | | ___ _ __
@@ -1113,6 +1115,7 @@ static const arch_irn_ops_if_t be_node_irn_ops_if = {
        be_node_get_frame_entity,
        be_node_set_frame_entity,
        be_node_set_frame_offset,
+       be_node_get_sp_bias,
        NULL,    /* get_inverse             */
        NULL,    /* get_op_estimated_cost   */
        NULL,    /* possible_memory_operand */
@@ -1236,7 +1239,7 @@ static entity *phi_get_frame_entity(const void *_self, const ir_node *irn)
        return NULL;
 }
 
-static void phi_set_frame_entity(const void *_self, const ir_node *irn, entity *ent)
+static void phi_set_frame_entity(const void *_self, ir_node *irn, entity *ent)
 {
 }
 
@@ -1244,6 +1247,11 @@ static void phi_set_frame_offset(const void *_self, ir_node *irn, int bias)
 {
 }
 
+static int phi_get_sp_bias(const void* self, const ir_node *irn)
+{
+       return 0;
+}
+
 static const arch_irn_ops_if_t phi_irn_ops = {
        phi_get_irn_reg_req,
        phi_set_irn_reg,
@@ -1253,6 +1261,7 @@ static const arch_irn_ops_if_t phi_irn_ops = {
        phi_get_frame_entity,
        phi_set_frame_entity,
        phi_set_frame_offset,
+       phi_get_sp_bias,
        NULL,    /* get_inverse             */
        NULL,    /* get_op_estimated_cost   */
        NULL,    /* possible_memory_operand */
@@ -1402,11 +1411,12 @@ static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
                        case beo_IncSP:
                                {
                                        be_stack_attr_t *a = (be_stack_attr_t *) at;
-                                       if (a->offset == BE_STACK_FRAME_SIZE)
+                                       if (a->offset == BE_STACK_FRAME_SIZE_EXPAND)
                                                fprintf(f, "offset: FRAME_SIZE\n");
+                                       else if(a->offset == BE_STACK_FRAME_SIZE_SHRINK)
+                                               fprintf(f, "offset: -FRAME SIZE\n");
                                        else
                                                fprintf(f, "offset: %u\n", a->offset);
-                                       fprintf(f, "direction: %s\n", a->dir == be_stack_dir_expand ? "expand" : "shrink");
                                }
                                break;
                        case beo_Call: