The big committ:
[libfirm] / ir / be / beirgmod.c
index 4fbbc06..a2b2c1f 100644 (file)
@@ -1,5 +1,19 @@
+/**
+ * This file contains the following IRG modifications for be routines:
+ * - backend dominance information
+ * - SSA construction for a set of nodes
+ * - insertion of Perm nodes
+ * - empty block elimination
+ * - a simple dead node elimination (set inputs of unreachable nodes to BAD)
+ *
+ * Author:      Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
+ * Date:        04.05.2005
+ * Copyright:   (c) Universitaet Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * CVS-Id:      $Id$
+ */
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdlib.h>
@@ -40,8 +54,8 @@
 
 #include "beirgmod.h"
 
-#define DBG_MODULE "firm.be.irgmod"
 #define DBG_LEVEL SET_LEVEL_0
+DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 /*
   ____                  _
@@ -158,7 +172,6 @@ static void determine_phi_blocks(pset *copies, pset *copy_blocks, pset *phi_bloc
 {
        ir_node *bl;
        waitq *worklist = new_waitq();
-       FIRM_DBG_REGISTER(firm_dbg_module_t *dbg, DBG_MODULE);
 
        /*
         * Fill the worklist queue and the rest of the orig blocks array.
@@ -239,7 +252,6 @@ static ir_node *search_def(ir_node *usage, int pos, pset *copies, pset *copy_blo
 {
        ir_node *curr_bl;
        ir_node *start_irn;
-       FIRM_DBG_REGISTER(firm_dbg_module_t *dbg, DBG_MODULE);
 
        curr_bl = get_nodes_block(usage);
 
@@ -350,8 +362,6 @@ static void fix_usages(pset *copies, pset *copy_blocks, pset *phi_blocks, pset *
                int pos;
        } *outs;
 
-       FIRM_DBG_REGISTER(firm_dbg_module_t *dbg, DBG_MODULE);
-
        obstack_init(&obst);
 
        /*
@@ -362,9 +372,11 @@ static void fix_usages(pset *copies, pset *copy_blocks, pset *phi_blocks, pset *
        for (irn = pset_first(copies); irn; irn = pset_next(copies)) {
                const ir_edge_t *edge;
                foreach_out_edge(irn, edge) {
-                       if (!pset_find_ptr(ignore_uses, get_edge_src_irn(edge))) {
+                       ir_node *src = get_edge_src_irn(edge);
+                       /* ignore all users from ignore_uses or keep-alives (user is End node) */
+                       if (! pset_find_ptr(ignore_uses, src) && ! is_End(src)) {
                                struct out tmp;
-                               tmp.irn = get_edge_src_irn(edge);
+                               tmp.irn = src;
                                tmp.pos = get_edge_src_pos(edge);
                                obstack_grow(&obst, &tmp, sizeof(tmp));
                                n_outs++;
@@ -438,7 +450,7 @@ static void remove_odd_phis(pset *copies, pset *unused_copies)
                sched_remove(irn);
        }
 }
-#endif
+#endif /* if 0 */
 
 void be_ssa_constr_phis_ignore(be_dom_front_info_t *info, be_lv_t *lv, int n, ir_node *nodes[], pset *phis, pset *ignore_uses)
 {
@@ -470,7 +482,6 @@ void be_ssa_constr_set_phis_ignore(be_dom_front_info_t *df, be_lv_t *lv, pset *n
        int save_optimize      = get_optimize();
        int save_normalize     = get_opt_normalize();
        int phis_set_created   = 0;
-       FIRM_DBG_REGISTER(firm_dbg_module_t *dbg, DBG_MODULE);
 
        ir_node *irn;
 
@@ -563,7 +574,6 @@ ir_node *insert_Perm_after(const arch_env_t *arch_env,
        ir_node *bl     = is_Block(pos) ? pos : get_nodes_block(pos);
        ir_graph *irg   = get_irn_irg(bl);
        pset *live      = pset_new_ptr_default();
-       FIRM_DBG_REGISTER(firm_dbg_module_t *dbg, "be.node");
 
        ir_node *curr, *irn, *perm, **nodes;
        int i, n;
@@ -706,3 +716,10 @@ int be_remove_empty_blocks(ir_graph *irg) {
        }
        return changed;
 }
+
+void be_init_irgmod(void)
+{
+       FIRM_DBG_REGISTER(dbg, "firm.be.irgmod");
+}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_irgmod);