fixed MulS/Mulh generation
[libfirm] / ir / be / bessadestr.c
index 07e3bdc..ec293c8 100644 (file)
@@ -29,7 +29,7 @@
 #include "benode_t.h"
 #include "besched_t.h"
 
-static firm_dbg_module_t *dbg = NULL;
+DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 #define DUMP_GRAPHS
 
 #define get_chordal_arch(ce) ((ce)->birg->main_env->arch_env)
@@ -134,7 +134,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
                         * Create a new Perm with the arguments just collected
                         * above in the arg_set and insert it into the schedule.
                         */
-                       in = malloc(n_projs * sizeof(in[0]));
+                       in = xmalloc(n_projs * sizeof(in[0]));
                        for(pp = set_first(arg_set); pp; pp = set_next(arg_set))
                                in[pp->pos] = pp->arg;
 
@@ -222,8 +222,13 @@ static void        set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
                                 * insert it into schedule,
                                 * pin it
                                 */
-                               ir_node *dupl = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
-                               assert(get_irn_mode(phi) == get_irn_mode(dupl));
+                               ir_node *dupl  = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
+                               ir_mode *m_phi = get_irn_mode(phi), *m_dupl = get_irn_mode(dupl);
+
+                               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)));
+
                                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, chordal_env->birg->main_env->arch_env), dupl);
@@ -296,7 +301,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) {
        pmap *perm_map = pmap_create();
        ir_graph *irg = chordal_env->irg;
 
-       dbg = firm_dbg_register("ir.be.ssadestr");
+       FIRM_DBG_REGISTER(dbg, "ir.be.ssadestr");
 
        /* create a map for fast lookup of perms: block --> perm */
        chordal_env->data = perm_map;
@@ -305,13 +310,15 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) {
        DBG((dbg, LEVEL_1, "Placing perms...\n"));
        irg_block_walk_graph(irg, insert_all_perms_walker, NULL, chordal_env);
 #ifdef DUMP_GRAPHS
-       dump_ir_block_graph_sched(irg, "-ssa_destr_perms_placed");
+       be_dump(irg, "-ssa_destr_perms_placed", dump_ir_block_graph_sched);
 #endif
 
+       be_liveness(irg);
+
        DBG((dbg, LEVEL_1, "Setting regs and placing dupls...\n"));
        irg_block_walk_graph(irg, set_regs_or_place_dupls_walker, NULL, chordal_env);
 #ifdef DUMP_GRAPHS
-       dump_ir_block_graph_sched(irg, "-ssa_destr_regs_set");
+       be_dump(irg, "-ssa_destr_regs_set", dump_ir_block_graph_sched);
 #endif
 
        pmap_destroy(perm_map);