Call new interference function in phi_ops_interfere
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Thu, 13 Jan 2005 14:41:20 +0000 (14:41 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Thu, 13 Jan 2005 14:41:20 +0000 (14:41 +0000)
Added additional live_end set for all values that are live at the end
and not live out

ir/be/Makefile.in
ir/be/bechordal.c
ir/be/belive.c
ir/be/belive.h
ir/be/belive_t.h
ir/be/beutil.c

index 1303dda..f59562f 100644 (file)
@@ -22,7 +22,7 @@ SOURCES = $(INSTALL_HEADERS)
 SOURCES +=     Makefile.in besched.h belistsched.h belistsched.c \
        beutil.h bemain.c besched.c bemain.c belive.c belive.h benumb.h \
        benumb_t.h benumb.c bechordal.c bera.c beutil.c phistat.c \
-       bephiopt.c bephicongr.c bephicoal.c domtree.c
+       bephiopt.c bephicongr.c bephicoal.c domtree.c bera.h
 
 include $(topdir)/MakeRules
 
index b26a868..8338767 100644 (file)
@@ -131,11 +131,11 @@ static void draw_interval_graphs(ir_node *block,
                                int pos = last_pos - seen[nr];
                                int end_pos = last_pos - b->step;
                                int live_in = is_live_in(block, irn);
-                               int live_out = is_live_out(block, irn);
+                               int live_end = is_live_end(block, irn);
                                int y_val = y_dist * col;
 
                                int red = 0;
-                               int green = live_out;
+                               int green = live_end;
                                int blue = live_in;
 
                                fprintf(f, "0 0 0 setrgbcolor\n");
@@ -211,7 +211,7 @@ static void block_alloc(ir_node *block, void *env_ptr)
        border_t *b;
        struct list_head head;
        pset *live_in = get_live_in(block);
-       pset *live_out = get_live_out(block);
+       pset *live_end = get_live_end(block);
        ir_node *idom = get_Block_idom(block);
 
        /*
@@ -240,7 +240,7 @@ static void block_alloc(ir_node *block, void *env_ptr)
         * Make final uses of all values live out of the block.
         * They are neccessary to build up real intervals.
         */
-       for(irn = pset_first(live_out); irn; irn = pset_next(live_out)) {
+       for(irn = pset_first(live_end); irn; irn = pset_next(live_end)) {
                DBG((dbg, LEVEL_3, "Making live: %n/%d\n", irn, get_irn_graph_nr(irn)));
                bitset_set(live, get_irn_graph_nr(irn));
                if(!is_Phi(irn) && is_allocatable_irn(irn))
@@ -447,6 +447,12 @@ void be_ra_chordal_done(ir_graph *irg)
        free(env);
 }
 
+int phi_ops_interfere(const ir_node *a, const ir_node *b)
+{
+       return values_interfere(a, b);
+}
+
+#if 0
 int phi_ops_interfere(const ir_node *a, const ir_node *b)
 {
        ir_graph *irg = get_irn_irg(a);
@@ -456,3 +462,4 @@ int phi_ops_interfere(const ir_node *a, const ir_node *b)
 
        return are_connected(env, get_irn_graph_nr(a), get_irn_graph_nr(b));
 }
+#endif
index 113584b..8ebcdff 100644 (file)
 #include "beutil.h"
 #include "belive_t.h"
 
+#define DEFAULT_LIVE_SET_SIZE                          8
+
 FIRM_IMPL2(is_live_in, int, const ir_node *, const ir_node *)
 FIRM_IMPL2(is_live_out, int, const ir_node *, const ir_node *)
+FIRM_IMPL2(is_live_end, int, const ir_node *, const ir_node *)
 
 /** The offset of the liveness information in a firm node. */
 size_t live_irn_data_offset = 0;
@@ -38,6 +41,12 @@ static INLINE void mark_live_out(ir_node *block, const ir_node *irn)
        pset_insert_ptr(info->out, irn);
 }
 
+static INLINE void mark_live_end(ir_node *block, const ir_node *irn)
+{
+       block_live_info_t *info = get_block_live_info(block);
+       pset_insert_ptr(info->end, irn);
+}
+
 /**
  * Mark a node (value) live out at a certain block. Do this also
  * transitively, i.e. if the block is not the block of the value's
@@ -45,14 +54,20 @@ static INLINE void mark_live_out(ir_node *block, const ir_node *irn)
  * @param def The node (value).
  * @param block The block to mark the value live out of.
  * @param visited A set were all visited blocks are recorded.
+ * @param is_true_out Is the node real out there or only live at the end
+ * of the block.
  */
-static void live_out_at_block(ir_node *def, ir_node *block, pset *visited)
+static void live_end_at_block(ir_node *def, ir_node *block,
+               pset *visited, int is_true_out)
 {
        if(pset_find_ptr(visited, block))
                return;
 
        pset_insert_ptr(visited, block);
-       mark_live_out(block, def);
+       mark_live_end(block, def);
+
+       if(is_true_out)
+               mark_live_out(block, def);
 
        /*
         * If this block is not the definition block, we have to go up
@@ -64,7 +79,7 @@ static void live_out_at_block(ir_node *def, ir_node *block, pset *visited)
                mark_live_in(block, def);
 
                for(i = 0, n = get_irn_arity(block); i < n; ++i)
-                       live_out_at_block(def, get_nodes_block(get_irn_n(block, i)), visited);
+                       live_end_at_block(def, get_nodes_block(get_irn_n(block, i)), visited, 1);
        }
 }
 
@@ -124,7 +139,7 @@ static void liveness_for_node(ir_node *irn, void *env)
                        for(i = 0, n = get_irn_arity(use); i < n; ++i) {
                                if(get_irn_n(use, i) == irn) {
                                        ir_node *pred_block = get_nodes_block(get_irn_n(use_block, i));
-                                       live_out_at_block(irn, pred_block, visited);
+                                       live_end_at_block(irn, pred_block, visited, 0);
                                }
                        }
                }
@@ -140,7 +155,7 @@ static void liveness_for_node(ir_node *irn, void *env)
 
                        for(i = 0, n = get_irn_arity(use_block); i < n; ++i) {
                                ir_node *pred_block = get_nodes_block(get_irn_n(use_block, i));
-                               live_out_at_block(irn, pred_block, visited);
+                               live_end_at_block(irn, pred_block, visited, 1);
                        }
                }
        }
@@ -151,8 +166,9 @@ static void liveness_for_node(ir_node *irn, void *env)
 static void create_sets(ir_node *block, void *env)
 {
        block_live_info_t *info = get_block_live_info(block);
-       info->in = pset_new_ptr(128);
-       info->out = pset_new_ptr(128);
+       info->in = pset_new_ptr(DEFAULT_LIVE_SET_SIZE);
+       info->out = pset_new_ptr(DEFAULT_LIVE_SET_SIZE);
+       info->end = pset_new_ptr(DEFAULT_LIVE_SET_SIZE);
 }
 
 
@@ -165,6 +181,7 @@ static void liveness_dump(ir_node *block, void *env)
        ir_fprintf(f, "liveness at block %n\n", block);
        ir_fprintf(f, "\tlive  in: %*n\n", pset_iterator, info->in);
        ir_fprintf(f, "\tlive out: %*n\n", pset_iterator, info->out);
+       ir_fprintf(f, "\tlive end: %*n\n", pset_iterator, info->end);
 }
 
 void be_liveness_dump(FILE *f, ir_graph *irg)
index 0b100f9..fcc1268 100644 (file)
@@ -38,5 +38,12 @@ int (is_live_in)(const ir_node *block, const ir_node *irn);
  */
 int (is_live_out)(const ir_node *block, const ir_node *irn);
 
+/**
+ * Check, if a node is live at the end of a block.
+ * @param block The block.
+ * @param irn The node to check for.
+ * @return 1, if @p irn is live at the end of the block, 0 if not.
+ */
+int (is_live_end)(const ir_node *block, const ir_node *irn);
 
 #endif
index 5d446ca..61ce412 100644 (file)
@@ -15,6 +15,8 @@
 typedef struct _block_live_info_t {
        pset *in;                               /**< The set of all values live in at that block. */
        pset *out;                              /**< The set of all values live out. */
+       pset *end;                              /**< The set of all values live at the end
+                                                                                       of the block (contains all live out). */
 } block_live_info_t;
 
 typedef struct _node_live_info_t {
@@ -58,6 +60,14 @@ static INLINE int __is_live_out(const ir_node *block, const ir_node *irn)
        return pset_find_ptr(info->out, irn) != NULL;
 }
 
+static INLINE int __is_live_end(const ir_node *block, const ir_node *irn)
+{
+       block_live_info_t *info = get_block_live_info(block);
+
+       assert(is_Block(block) && "Need a block here");
+       return pset_find_ptr(info->end, irn) != NULL;
+}
+
 static INLINE pset *__get_live_in(const ir_node *block)
 {
        assert(is_Block(block) && "Need a block here");
@@ -70,11 +80,19 @@ static INLINE pset *__get_live_out(const ir_node *block)
        return get_block_live_info(block)->out;
 }
 
+static INLINE pset *__get_live_end(const ir_node *block)
+{
+       assert(is_Block(block) && "Need a block here");
+       return get_block_live_info(block)->end;
+}
+
 #define is_phi_operand(irn)                    __is_phi_operand(irn)
 #define is_live_in(bl,irn)                     __is_live_in(bl, irn)
 #define is_live_out(bl,irn)            __is_live_out(bl, irn)
+#define is_live_end(bl,irn)            __is_live_end(bl, irn)
 #define get_live_in(bl)                                        __get_live_in(bl)
 #define get_live_out(bl)                               __get_live_out(bl)
+#define get_live_end(bl)                               __get_live_end(bl)
 
 /**
  * Initialize the liveness module.
index ea0a0fe..a25aa9c 100644 (file)
@@ -76,7 +76,7 @@ static void localize_const_walker(ir_node *irn, void *data)
 
                                /* Special treatment for phi nodes, because phi-usage is different */
                                tgt_block = get_nodes_block(irn);
-                               if (is_Phi(irn))
+                               if(is_Phi(irn))
                                        tgt_block = get_nodes_block(get_irn_n(tgt_block, i));
 
                                /*