sparc: matching rules for andn and orn
[libfirm] / ir / be / bessadestr.c
index 48a9bf1..cb917ac 100644 (file)
@@ -26,6 +26,8 @@
  */
 #include "config.h"
 
+#include "bessadestr.h"
+
 #include "debug.h"
 #include "set.h"
 #include "pmap.h"
@@ -110,17 +112,17 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
        insert_all_perms_env_t *env = data;
        be_chordal_env_t *chordal_env = env->chordal_env;
        pmap *perm_map = env->perm_map;
-       be_lv_t *lv = chordal_env->birg->lv;
+       be_lv_t *lv = be_get_irg_liveness(chordal_env->irg);
        int i, n;
 
        assert(is_Block(bl));
 
        /* If the link flag is NULL, this block has no phis. */
-       if(!get_irn_link(bl))
+       if (!get_irn_link(bl))
                return;
 
        /* Look at all predecessors of the phi block */
-       for(i = 0, n = get_irn_arity(bl); i < n; ++i) {
+       for (i = 0, n = get_irn_arity(bl); i < n; ++i) {
                ir_node *phi, *perm, *insert_after, **in;
                perm_proj_t *pp;
                set *arg_set     = new_set(cmp_perm_proj, chordal_env->cls->n_regs);
@@ -133,15 +135,11 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                 * Note that all phis in the list are in the same
                 * register class by construction.
                 */
-               for(phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) {
+               for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) {
                        ir_node                   *arg = get_irn_n(phi, i);
-                       const arch_register_req_t *req = arch_get_register_req_out(arg);
                        unsigned                   hash;
                        perm_proj_t                templ;
 
-                       if (req->type & arch_register_req_type_ignore)
-                               continue;
-
                        hash = hash_irn(arg);
                        templ.arg  = arg;
                        pp         = set_find(arg_set, &templ, sizeof(templ), hash);
@@ -153,7 +151,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                         * interferes with the phi and must thus not be member of a
                         * Perm. A copy will be inserted for this argument later on.
                         */
-                       if(!pp && !be_is_live_in(lv, bl, arg)) {
+                       if (!pp && !be_is_live_in(lv, bl, arg)) {
                                templ.pos = n_projs++;
                                set_insert(arg_set, &templ, sizeof(templ), hash);
                        }
@@ -166,7 +164,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                         * above in the arg_set and insert it into the schedule.
                         */
                        in = XMALLOCN(ir_node*, n_projs);
-                       for(pp = set_first(arg_set); pp; pp = set_next(arg_set))
+                       for (pp = set_first(arg_set); pp; pp = set_next(arg_set))
                                in[pp->pos] = pp->arg;
 
                        perm = be_new_Perm(chordal_env->cls, pred_bl, n_projs, in);
@@ -181,8 +179,8 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                         * arguments to the projs (new phi arguments).
                         */
                        insert_after = perm;
-                       for(pp = set_first(arg_set); pp; pp = set_next(arg_set)) {
-                               ir_node *proj = new_r_Proj(pred_bl, perm, get_irn_mode(pp->arg), pp->pos);
+                       for (pp = set_first(arg_set); pp; pp = set_next(arg_set)) {
+                               ir_node *proj = new_r_Proj(perm, get_irn_mode(pp->arg), pp->pos);
                                pp->proj = proj;
                                assert(get_reg(pp->arg));
                                set_reg(proj, get_reg(pp->arg));
@@ -193,7 +191,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
                        /*
                         * Set the phi nodes to their new arguments: The Projs of the Perm
                         */
-                       for(phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) {
+                       for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) {
                                perm_proj_t templ;
 
                                templ.arg = get_irn_n(phi, i);
@@ -233,7 +231,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data)
 static void    set_regs_or_place_dupls_walker(ir_node *bl, void *data)
 {
        be_chordal_env_t *chordal_env = data;
-       be_lv_t *lv = chordal_env->birg->lv;
+       be_lv_t *lv = be_get_irg_liveness(chordal_env->irg);
        ir_node *phi;
 
        /* Consider all phis of this block */
@@ -249,13 +247,9 @@ static void        set_regs_or_place_dupls_walker(ir_node *bl, void *data)
                /* process all arguments of the phi */
                for (i = 0, max = get_irn_arity(phi); i < max; ++i) {
                        ir_node                   *arg = get_irn_n(phi, i);
-                       const arch_register_req_t *req = arch_get_register_req_out(arg);
                        const arch_register_t     *arg_reg;
                        ir_node                   *arg_block;
 
-                       if (req->type & arch_register_req_type_ignore)
-                               continue;
-
                        arg_block = get_Block_cfgpred_block(phi_block, i);
                        arg_reg   = get_reg(arg);
 
@@ -263,6 +257,15 @@ static void        set_regs_or_place_dupls_walker(ir_node *bl, void *data)
 
                        DBG((dbg, LEVEL_1, "  for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name));
 
+                       if (phi_reg == arg_reg
+                                       || (arg_reg->type & arch_register_type_joker)
+                                       || (arg_reg->type & arch_register_type_virtual)) {
+                               /* Phi and arg have the same register, so pin and continue */
+                               pin_irn(arg, phi_block);
+                               DBG((dbg, LEVEL_1, "      arg has same reg: pin %+F(%s)\n", arg, get_reg(arg)->name));
+                               continue;
+                       }
+
                        if (be_values_interfere(lv, phi, arg)) {
                                /*
                                        Insert a duplicate in arguments block,
@@ -273,19 +276,6 @@ static void        set_regs_or_place_dupls_walker(ir_node *bl, void *data)
                                */
                                ir_node *dupl  = be_new_Copy(cls, arg_block, arg);
 
-                               /* this is commented out because it will fail in case of unknown float */
-#if 0
-                               ir_mode *m_phi = get_irn_mode(phi), *m_dupl = get_irn_mode(dupl);
-
-                               /*
-                                       Conv signed <-> unsigned is killed on ia32
-                                       check for: (both int OR both float) AND equal mode sizes
-                               */
-                               assert(((mode_is_int(m_phi) && mode_is_int(m_dupl)) ||
-                                       (mode_is_float(m_phi) && mode_is_float(m_dupl))) &&
-                                       (get_mode_size_bits(m_phi) == get_mode_size_bits(m_dupl)));
-#endif /* if 0 */
-
                                set_irn_n(phi, i, dupl);
                                set_reg(dupl, phi_reg);
                                sched_add_after(sched_skip(sched_last(arg_block), 0, sched_skip_cf_predicator, NULL), dupl);
@@ -296,13 +286,6 @@ static void        set_regs_or_place_dupls_walker(ir_node *bl, void *data)
                                continue; /* with next argument */
                        }
 
-                       if (phi_reg == arg_reg) {
-                               /* Phi and arg have the same register, so pin and continue */
-                               pin_irn(arg, phi_block);
-                               DBG((dbg, LEVEL_1, "      arg has same reg: pin %+F(%s)\n", arg, get_reg(arg)->name));
-                               continue;
-                       }
-
                        DBG((dbg, LEVEL_1, "    they do not interfere\n"));
                        assert(is_Proj(arg));
                        /*
@@ -318,7 +301,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data)
 
                                DBG((dbg, LEVEL_1, "      searching for phi with same arg having args register\n"));
 
-                               for(other_phi = get_irn_link(phi_block); other_phi; other_phi = get_irn_link(other_phi)) {
+                               for (other_phi = get_irn_link(phi_block); other_phi; other_phi = get_irn_link(other_phi)) {
 
                                        assert(is_Phi(other_phi)                               &&
                                                get_nodes_block(phi) == get_nodes_block(other_phi) &&
@@ -344,24 +327,11 @@ static void       set_regs_or_place_dupls_walker(ir_node *bl, void *data)
                                ir_node *dupl = be_new_Copy(cls, arg_block, arg);
                                ir_node *ins;
 
-                               /* this is commented out because it will fail in case of unknown float */
-#if 0
-                               ir_mode *m_phi    = get_irn_mode(phi);
-                               ir_mode *m_dupl   = get_irn_mode(dupl);
-
-                               /*
-                                       Conv signed <-> unsigned is killed on ia32
-                                       check for: (both int OR both float) AND equal mode sizes
-                               */
-                               assert(((mode_is_int(m_phi) && mode_is_int(m_dupl)) ||
-                                       (mode_is_float(m_phi) && mode_is_float(m_dupl))) &&
-                                       (get_mode_size_bits(m_phi) == get_mode_size_bits(m_dupl)));
-#endif /* if 0 */
-
                                set_irn_n(phi, i, dupl);
                                set_reg(dupl, phi_reg);
                                /* skip the Perm's Projs and insert the copies behind. */
-                               for(ins = sched_next(perm); is_Proj(ins); ins = sched_next(ins));
+                               for (ins = sched_next(perm); is_Proj(ins); ins = sched_next(ins)) {
+                               }
                                sched_add_before(ins, dupl);
                                pin_irn(dupl, phi_block);
                                be_liveness_introduce(lv, dupl);
@@ -383,9 +353,9 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data)
 void be_ssa_destruction(be_chordal_env_t *chordal_env)
 {
        insert_all_perms_env_t insert_perms_env;
-       pmap *perm_map = pmap_create();
-       ir_graph *irg  = chordal_env->irg;
-       be_lv_t *lv    = be_assure_liveness(chordal_env->birg);
+       pmap     *perm_map = pmap_create();
+       ir_graph *irg      = chordal_env->irg;
+       be_lv_t  *lv       = be_assure_liveness(irg);
 
        FIRM_DBG_REGISTER(dbg, "ir.be.ssadestr");
 
@@ -404,7 +374,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env)
        be_liveness_invalidate(lv);
 
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR)
-               be_dump(irg, "-ssa_destr_perms_placed", dump_ir_block_graph_sched);
+               dump_ir_graph(irg, "ssa_destr_perms_placed");
 
        be_liveness_assure_chk(lv);
 
@@ -415,7 +385,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env)
        be_liveness_invalidate(lv);
 
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR)
-               be_dump(irg, "-ssa_destr_regs_set", dump_ir_block_graph_sched);
+               dump_ir_graph(irg, "ssa_destr_regs_set");
 
        pmap_destroy(perm_map);
 }