Remove the unused parameter const arch_env_t *arch_env from be_set_phi_flags().
[libfirm] / ir / be / benode.c
index 4199e8f..a0457f9 100644 (file)
@@ -42,6 +42,8 @@
 #include "offset.h"
 #include "bitfiddle.h"
 #include "raw_bitset.h"
+#include "error.h"
+#include "array_t.h"
 
 #include "irop_t.h"
 #include "irmode_t.h"
@@ -358,10 +360,9 @@ static be_reg_data_t *retrieve_reg_data(const ir_node *node)
 }
 
 static void
-be_node_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
+be_node_set_irn_reg(ir_node *irn, const arch_register_t *reg)
 {
        be_reg_data_t *r = retrieve_reg_data(irn);
-       (void) self;
        r->reg = reg;
 }
 
@@ -440,17 +441,18 @@ ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *b
 
 void be_Perm_reduce(ir_node *perm, int new_size, int *map)
 {
-       ir_graph *irg           = get_irn_irg(perm);
-       int            arity    = get_irn_arity(perm);
-       be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0]));
-       be_node_attr_t *attr    = get_irn_attr(perm);
-       ir_node **new_in        = NEW_ARR_D(ir_node *, irg->obst, new_size);
+       int            arity     = get_irn_arity(perm);
+       be_reg_data_t  *old_data = alloca(arity * sizeof(old_data[0]));
+       be_node_attr_t *attr     = get_irn_attr(perm);
+       ir_node        **new_in;
 
        int i;
 
        assert(be_is_Perm(perm));
        assert(new_size <= arity);
 
+       NEW_ARR_A(ir_node *, new_in, new_size);
+
        /* save the old register data */
        memcpy(old_data, attr->reg_data, arity * sizeof(old_data[0]));
 
@@ -468,9 +470,9 @@ ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl,
 {
        int i;
        ir_node *frame = get_irg_frame(irg);
-       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
+       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1);
        ir_node *irn;
-       const arch_register_t *sp = arch_env->isa->sp;
+       const arch_register_t *sp = arch_env->sp;
        be_memperm_attr_t *attr;
        ir_node **real_in;
 
@@ -690,7 +692,7 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl,
        /* Set output constraint to stack register. */
        be_node_set_reg_class(irn, 0, sp->reg_class);
        be_set_constr_single_reg(irn, BE_OUT_POS(0), sp);
-       be_node_set_irn_reg(NULL, irn, sp);
+       be_node_set_irn_reg(irn, sp);
 
        return irn;
 }
@@ -700,7 +702,7 @@ ir_node *be_new_AddSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_
        be_node_attr_t *a;
        ir_node *irn;
        ir_node *in[be_pos_AddSP_last];
-       const arch_register_class_t *class;
+       const arch_register_class_t *cls;
 
        in[be_pos_AddSP_old_sp] = old_sp;
        in[be_pos_AddSP_size]   = sz;
@@ -717,8 +719,8 @@ ir_node *be_new_AddSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_
        be_set_constr_single_reg(irn, OUT_POS(pn_be_AddSP_sp), sp);
        a->reg_data[pn_be_AddSP_sp].reg = sp;
 
-       class = arch_register_get_class(sp);
-       be_node_set_reg_class(irn, OUT_POS(pn_be_AddSP_res), class);
+       cls = arch_register_get_class(sp);
+       be_node_set_reg_class(irn, OUT_POS(pn_be_AddSP_res), cls);
 
        return irn;
 }
@@ -760,29 +762,6 @@ ir_node *be_new_RegParams(ir_graph *irg, ir_node *bl, int n_outs)
        return res;
 }
 
-ir_node *be_RegParams_append_out_reg(ir_node *regparams,
-                                     const arch_env_t *arch_env,
-                                     const arch_register_t *reg)
-{
-       ir_graph *irg = get_irn_irg(regparams);
-       ir_node *block = get_nodes_block(regparams);
-       be_node_attr_t *attr = get_irn_attr(regparams);
-       const arch_register_class_t *cls = arch_register_get_class(reg);
-       ir_mode *mode = arch_register_class_mode(cls);
-       int n = ARR_LEN(attr->reg_data);
-       ir_node *proj;
-
-       assert(be_is_RegParams(regparams));
-       proj = new_r_Proj(irg, block, regparams, mode, n);
-       add_register_req(regparams);
-       be_set_constr_single_reg(regparams, BE_OUT_POS(n), reg);
-       arch_set_irn_register(arch_env, proj, reg);
-
-       /* TODO decide, whether we need to set ignore/modify sp flags here? */
-
-       return proj;
-}
-
 ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_graph *irg, ir_node *bl, ir_node *frame, ir_entity *ent)
 {
        be_frame_attr_t *a;
@@ -985,7 +964,7 @@ void be_set_constr_limited(ir_node *node, int pos, const arch_register_req_t *re
        arch_register_req_t *r = get_req(node, pos);
 
        assert(arch_register_req_is(req, limited));
-       assert(! (req->type & (arch_register_req_type_should_be_same | arch_register_req_type_should_be_different)));
+       assert(!(req->type & (arch_register_req_type_should_be_same | arch_register_req_type_must_be_different)));
        memcpy(r, req, sizeof(r[0]));
        r->limited = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
 }
@@ -1052,32 +1031,32 @@ int be_get_IncSP_align(const ir_node *irn)
        return a->align;
 }
 
-ir_node *be_spill(const arch_env_t *arch_env, ir_node *block, ir_node *irn)
+ir_node *be_spill(ir_node *block, ir_node *irn)
 {
        ir_graph                    *irg       = get_irn_irg(block);
        ir_node                     *frame     = get_irg_frame(irg);
-       const arch_register_class_t *cls       = arch_get_irn_reg_class(arch_env, irn, -1);
-       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
+       const arch_register_class_t *cls       = arch_get_irn_reg_class(irn, -1);
+       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1);
        ir_node                     *spill;
 
        spill = be_new_Spill(cls, cls_frame, irg, block, frame, irn);
        return spill;
 }
 
-ir_node *be_reload(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_node *insert, ir_mode *mode, ir_node *spill)
+ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert, ir_mode *mode, ir_node *spill)
 {
        ir_node  *reload;
        ir_node  *bl    = is_Block(insert) ? insert : get_nodes_block(insert);
        ir_graph *irg   = get_irn_irg(bl);
        ir_node  *frame = get_irg_frame(irg);
-       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
+       const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1);
 
        assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
 
        reload = be_new_Reload(cls, cls_frame, irg, bl, frame, spill, mode);
 
        if (is_Block(insert)) {
-               insert = sched_skip(insert, 0, sched_skip_cf_predicator, (void *) arch_env);
+               insert = sched_skip(insert, 0, sched_skip_cf_predicator, NULL);
                sched_add_after(insert, reload);
        } else {
                sched_add_before(insert, reload);
@@ -1121,11 +1100,10 @@ arch_register_req_t *get_in_reg_req(const ir_node *irn, int pos)
 }
 
 static const arch_register_req_t *
-be_node_get_irn_reg_req(const void *self, const ir_node *irn, int pos)
+be_node_get_irn_reg_req(const ir_node *irn, int pos)
 {
        int out_pos = pos;
 
-       (void) self;
        if (pos < 0) {
                if (get_irn_mode(irn) == mode_T)
                        return arch_no_register_req;
@@ -1149,21 +1127,18 @@ be_node_get_irn_reg_req(const void *self, const ir_node *irn, int pos)
 }
 
 const arch_register_t *
-be_node_get_irn_reg(const void *self, const ir_node *irn)
+be_node_get_irn_reg(const ir_node *irn)
 {
        be_reg_data_t *r;
 
-       (void) self;
        if (get_irn_mode(irn) == mode_T)
                return NULL;
        r = retrieve_reg_data(irn);
        return r->reg;
 }
 
-static arch_irn_class_t be_node_classify(const void *self, const ir_node *irn)
+static arch_irn_class_t be_node_classify(const ir_node *irn)
 {
-       (void) self;
-
 restart:
        switch (get_irn_opcode(irn)) {
 #define XXX(a,b) case a: return b
@@ -1188,11 +1163,10 @@ restart:
        return 0;
 }
 
-static arch_irn_flags_t be_node_get_flags(const void *self, const ir_node *node)
+static arch_irn_flags_t be_node_get_flags(const ir_node *node)
 {
        be_req_t *bereq;
        int pos = -1;
-       (void) self;
 
        if(is_Proj(node)) {
                pos = OUT_POS(get_Proj_proj(node));
@@ -1204,16 +1178,14 @@ static arch_irn_flags_t be_node_get_flags(const void *self, const ir_node *node)
        return bereq->flags;
 }
 
-static ir_entity *be_node_get_frame_entity(const void *self, const ir_node *irn)
+static ir_entity *be_node_get_frame_entity(const ir_node *irn)
 {
-       (void) self;
        return be_get_frame_entity(irn);
 }
 
-static void be_node_set_frame_entity(const void *self, ir_node *irn, ir_entity *ent)
+static void be_node_set_frame_entity(ir_node *irn, ir_entity *ent)
 {
        be_frame_attr_t *a;
-       (void) self;
 
        assert(be_has_frame_entity(irn));
 
@@ -1221,18 +1193,16 @@ static void be_node_set_frame_entity(const void *self, ir_node *irn, ir_entity *
        a->ent = ent;
 }
 
-static void be_node_set_frame_offset(const void *self, ir_node *irn, int offset)
+static void be_node_set_frame_offset(ir_node *irn, int offset)
 {
-       (void) self;
        if(be_has_frame_entity(irn)) {
                be_frame_attr_t *a = get_irn_attr(irn);
                a->offset = offset;
        }
 }
 
-static int be_node_get_sp_bias(const void *self, const ir_node *irn)
+static int be_node_get_sp_bias(const ir_node *irn)
 {
-       (void) self;
        if(be_is_IncSP(irn))
                return be_get_IncSP_offset(irn);
        if(be_is_Call(irn))
@@ -1322,7 +1292,7 @@ const arch_register_req_t *get_Phi_reg_req_recursive(const ir_node *phi,
                /* Matze: don't we unnecessary constraint our phis with this?
                 * we only need to take the regclass IMO*/
                if(!is_Phi(op))
-                       return arch_get_register_req(phi_handler.arch_env, op, BE_OUT_POS(0));
+                       return arch_get_register_req(op, BE_OUT_POS(0));
        }
 
        /*
@@ -1346,11 +1316,9 @@ const arch_register_req_t *get_Phi_reg_req_recursive(const ir_node *phi,
 }
 
 static
-const arch_register_req_t *phi_get_irn_reg_req(const void *self,
-                                               const ir_node *irn, int pos)
+const arch_register_req_t *phi_get_irn_reg_req(const ir_node *irn, int pos)
 {
        phi_attr_t *attr;
-       (void) self;
        (void) pos;
 
        if(!mode_is_datab(get_irn_mode(irn)))
@@ -1374,11 +1342,9 @@ const arch_register_req_t *phi_get_irn_reg_req(const void *self,
        return &attr->req;
 }
 
-void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
-                        const arch_register_req_t *req)
+void be_set_phi_reg_req(ir_node *node, const arch_register_req_t *req)
 {
        phi_attr_t *attr;
-       (void) arch_env;
 
        assert(mode_is_datab(get_irn_mode(node)));
 
@@ -1386,11 +1352,9 @@ void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
        memcpy(&attr->req, req, sizeof(req[0]));
 }
 
-void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
-                      arch_irn_flags_t flags)
+void be_set_phi_flags(ir_node *node, arch_irn_flags_t flags)
 {
        phi_attr_t *attr;
-       (void) arch_env;
 
        assert(mode_is_datab(get_irn_mode(node)));
 
@@ -1398,68 +1362,52 @@ void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
        attr->flags = flags;
 }
 
-static
-void phi_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
+static void phi_set_irn_reg(ir_node *irn, const arch_register_t *reg)
 {
        phi_attr_t *attr = get_Phi_attr(irn);
-       (void) self;
        attr->reg = reg;
 }
 
-static
-const arch_register_t *phi_get_irn_reg(const void *self, const ir_node *irn)
+static const arch_register_t *phi_get_irn_reg(const ir_node *irn)
 {
        phi_attr_t *attr = get_Phi_attr(irn);
-       (void) self;
        return attr->reg;
 }
 
-static
-arch_irn_class_t phi_classify(const void *self, const ir_node *irn)
+static arch_irn_class_t phi_classify(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return arch_irn_class_normal;
 }
 
-static
-arch_irn_flags_t phi_get_flags(const void *self, const ir_node *irn)
+static arch_irn_flags_t phi_get_flags(const ir_node *irn)
 {
        phi_attr_t *attr = get_Phi_attr(irn);
-       (void) self;
        return attr->flags;
 }
 
-static
-ir_entity *phi_get_frame_entity(const void *self, const ir_node *irn)
+static ir_entity *phi_get_frame_entity(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return NULL;
 }
 
-static
-void phi_set_frame_entity(const void *self, ir_node *irn, ir_entity *ent)
+static void phi_set_frame_entity(ir_node *irn, ir_entity *ent)
 {
-       (void) self;
        (void) irn;
        (void) ent;
-       assert(0);
+       panic("phi_set_frame_entity() should not be called");
 }
 
-static
-void phi_set_frame_offset(const void *self, ir_node *irn, int bias)
+static void phi_set_frame_offset(ir_node *irn, int bias)
 {
-       (void) self;
        (void) irn;
        (void) bias;
-       assert(0);
+       panic("phi_set_frame_offset() should not be called");
 }
 
-static
-int phi_get_sp_bias(const void* self, const ir_node *irn)
+static int phi_get_sp_bias(const ir_node *irn)
 {
-       (void) self;
        (void) irn;
        return 0;
 }
@@ -1482,7 +1430,7 @@ static const arch_irn_ops_t phi_irn_ops = {
 
 void be_phi_handler_new(be_main_env_t *env)
 {
-       phi_handler.arch_env  = &env->arch_env;
+       phi_handler.arch_env  = env->arch_env;
        phi_handler.phi_attrs = pmap_create();
        op_Phi->ops.be_ops    = &phi_irn_ops;
 }
@@ -1706,6 +1654,10 @@ static void copy_attr(const ir_node *old_node, ir_node *new_node)
 }
 
 static const ir_op_ops be_node_op_ops = {
+       firm_default_hash,
+       NULL,
+       NULL,
+       NULL,
        NULL,
        NULL,
        NULL,