be: fix phi constraints double width values
authorMatthias Braun <matze@braunis.de>
Thu, 26 Jan 2012 17:13:44 +0000 (18:13 +0100)
committerMatthias Braun <matze@braunis.de>
Thu, 9 Feb 2012 17:01:52 +0000 (18:01 +0100)
ir/be/benode.c
ir/be/benode.h
ir/be/beprefalloc.c
ir/be/bespillutil.c
ir/be/bessaconstr.c
ir/be/bessaconstr.h
ir/be/bestate.c

index 1035223..e93b648 100644 (file)
@@ -1075,9 +1075,8 @@ static const arch_irn_ops_t dummy_be_irn_ops = {
 
 
 ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
-                    const arch_register_class_t *cls)
+                    const arch_register_req_t *req)
 {
-       const arch_register_req_t *req;
        ir_graph       *irg  = get_irn_irg(block);
        struct obstack *obst = be_get_be_obst(irg);
        backend_info_t *info;
@@ -1089,11 +1088,6 @@ ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
        memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
        info->in_reqs = OALLOCN(obst, const arch_register_req_t*, n_ins);
 
-       if (cls == NULL) {
-               req = arch_no_register_req;
-       } else {
-               req = cls->class_req;
-       }
        info->out_infos[0].req = req;
        for (i = 0; i < n_ins; ++i) {
                info->in_reqs[i] = req;
index 003cad1..65ff335 100644 (file)
@@ -450,7 +450,7 @@ void be_dump_phi_reg_reqs(FILE *out, const ir_node *node, dump_reason_t reason);
  * Creates a new phi with associated backend informations
  */
 ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
-                    const arch_register_class_t *cls);
+                    const arch_register_req_t *req);
 
 /**
  * Search for output of start node with a specific register
index 338b7a4..ffc442c 100644 (file)
@@ -1769,7 +1769,8 @@ static void allocate_coalesce_block(ir_node *block, void *data)
 
                if (need_phi) {
                        ir_mode *mode = get_irn_mode(node);
-                       ir_node *phi  = be_new_Phi(block, n_preds, phi_ins, mode, cls);
+                       ir_node *phi  = be_new_Phi(block, n_preds, phi_ins, mode,
+                                                  cls->class_req);
 
                        DB((dbg, LEVEL_3, "Create Phi %+F (for %+F) -", phi, node));
 #ifdef DEBUG_libfirm
index a390ca2..fa103f1 100644 (file)
@@ -462,7 +462,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
        /* override or replace spills list... */
        spill         = OALLOC(&env->obst, spill_t);
        spill->after  = determine_spill_point(phi);
-       spill->spill  = be_new_Phi(block, arity, ins, mode_M, NULL);
+       spill->spill  = be_new_Phi(block, arity, ins, mode_M, arch_no_register_req);
        spill->next   = NULL;
        sched_add_after(block, spill->spill);
 
index 0cb6df9..59d03b9 100644 (file)
@@ -245,7 +245,7 @@ static ir_node *insert_dummy_phi(be_ssa_construction_env_t *env, ir_node *block)
        for (i = 0; i < n_preds; ++i) {
                ins[i] = dummy;
        }
-       phi = be_new_Phi(block, n_preds, ins, env->mode, env->phi_cls);
+       phi = be_new_Phi(block, n_preds, ins, env->mode, env->phi_req);
        sched_add_after(block, phi);
        ARR_APP1(ir_node*, env->new_phis, phi);
 
@@ -458,6 +458,24 @@ void be_ssa_construction_destroy(be_ssa_construction_env_t *env)
        stat_ev_ctx_pop("bessaconstr");
 }
 
+static void determine_phi_req(be_ssa_construction_env_t *env, ir_node *value)
+{
+       const arch_register_req_t *req   = arch_get_irn_register_req(value);
+       env->mode = get_irn_mode(value);
+       if (req->width == 1) {
+               env->phi_req = req->cls->class_req;
+       } else {
+               /* construct a new register req... */
+               ir_graph            *irg     = get_irn_irg(value);
+               struct obstack      *obst    = be_get_be_obst(irg);
+               arch_register_req_t *new_req = OALLOCZ(obst, arch_register_req_t);
+               new_req->cls   = req->cls;
+               new_req->type  = req->type & arch_register_req_type_aligned;
+               new_req->width = req->width;
+               env->phi_req = new_req;
+       }
+}
+
 void be_ssa_construction_add_copy(be_ssa_construction_env_t *env,
                                   ir_node *copy)
 {
@@ -466,8 +484,7 @@ void be_ssa_construction_add_copy(be_ssa_construction_env_t *env,
        assert(env->iterated_domfront_calculated == 0);
 
        if (env->mode == NULL) {
-               env->mode    = get_irn_mode(copy);
-               env->phi_cls = arch_get_irn_reg_class(copy);
+               determine_phi_req(env, copy);
        } else {
                assert(env->mode == get_irn_mode(copy));
        }
@@ -488,8 +505,7 @@ void be_ssa_construction_add_copies(be_ssa_construction_env_t *env,
        assert(env->iterated_domfront_calculated == 0);
 
        if (env->mode == NULL) {
-               env->mode    = get_irn_mode(copies[0]);
-               env->phi_cls = arch_get_irn_reg_class(copies[0]);
+               determine_phi_req(env, copies[0]);
        }
 
        for (i = 0; i < copies_len; ++i) {
index 832d21f..c44ee65 100644 (file)
@@ -62,7 +62,7 @@ typedef struct be_ssa_construction_env_t {
        ir_graph                    *irg;
        const be_dom_front_info_t   *domfronts;
        ir_mode                     *mode;
-       const arch_register_class_t *phi_cls;
+       const arch_register_req_t   *phi_req;
        waitq                       *worklist;
        const ir_nodeset_t          *ignore_uses;
        ir_node                    **new_phis;
index 1e3bf3e..3c57ae3 100644 (file)
@@ -182,7 +182,8 @@ static void spill_phi(minibelady_env_t *env, ir_node *phi)
        DBG((dbg, LEVEL_2, "\tcreate Phi-M for %+F\n", phi));
 
        /* create a Phi-M */
-       spill_info->spill = be_new_Phi(block, arity, phi_in, mode_M, NULL);
+       spill_info->spill = be_new_Phi(block, arity, phi_in, mode_M,
+                                      arch_no_register_req);
        sched_add_after(block, spill_info->spill);
 
        if (spill_to_kill != NULL) {