Moved functions from opt_confirms.h into official header, do edgjfe can use them.
[libfirm] / ir / opt / opt_blocks.c
index 7ac82ef..0154be6 100644 (file)
@@ -27,8 +27,9 @@
  * Two block are congruent, if they contains only equal calculations.
  */
 #include "config.h"
-#include "ircons.h"
+
 #include "iroptimize.h"
+#include "ircons.h"
 #include "irgmod.h"
 #include "irgraph_t.h"
 #include "irnode_t.h"
@@ -62,7 +63,7 @@ struct opcode_key_t {
        union {
                long            proj;   /**< For Proj nodes, its proj number */
                ir_entity       *ent;   /**< For Sel nodes, its entity */
-               tarval          *tv;    /**< For Const nodes, its tarval */
+               ir_tarval       *tv;    /**< For Const nodes, its tarval */
                symconst_symbol sym;    /**< For SymConst nodes, its symbol .*/
                void            *addr;  /**< Alias all addresses. */
                int             intVal; /**< For Conv/Div nodes: strict/remainderless. */
@@ -650,7 +651,7 @@ static void *live_throughs(const block_t *bl, const ir_node *phi)
  * @param part  the partition
  * @param env   the environment
  */
-void propagate_blocks_live_troughs(partition_t *part, environment_t *env)
+static void propagate_blocks_live_troughs(partition_t *part, environment_t *env)
 {
        const ir_node   *meet_block = part->meet_block;
        block_t         *bl, *next;
@@ -705,7 +706,7 @@ void propagate_blocks_live_troughs(partition_t *part, environment_t *env)
  *
  * @param env    the environment
  */
-void propagate_live_troughs(environment_t *env)
+static void propagate_live_troughs(environment_t *env)
 {
        partition_t *part, *next;
 
@@ -961,7 +962,7 @@ static void partition_for_end_block(ir_node *end_block, environment_t *env)
        }
 
        /* collect all no-return blocks */
-       end = get_irg_end(current_ir_graph);
+       end = get_irg_end(get_irn_irg(end_block));
        for (i = get_End_n_keepalives(end) - 1; i >= 0; --i) {
                ir_node *ka    = get_End_keepalive(end, i);
                ir_node *block;
@@ -1080,7 +1081,7 @@ static void check_for_cf_meet(ir_node *block, void *ctx)
        int           i, k, n;
        pred_t        *preds;
 
-       if (block == get_irg_end_block(current_ir_graph)) {
+       if (block == get_irg_end_block(get_irn_irg(block))) {
                /* always create a partition for the end block */
                partition_for_end_block(block, env);
                return;
@@ -1197,15 +1198,11 @@ static void add_roots(ir_graph *irg, environment_t *env)
 /* Combines congruent end blocks into one. */
 int shape_blocks(ir_graph *irg)
 {
-       ir_graph      *rem;
        environment_t env;
        partition_t   *part;
        block_t       *bl;
        int           res, n;
 
-       rem = current_ir_graph;
-       current_ir_graph = irg;
-
        /* register a debug mask */
        FIRM_DBG_REGISTER(dbg, "firm.opt.blocks");
 
@@ -1274,8 +1271,6 @@ int shape_blocks(ir_graph *irg)
 
                /* Calls might be removed. */
                set_trouts_inconsistent();
-
-       //      dump_ir_block_graph(irg, "-after");
        }
 
        for (bl = env.all_blocks; bl != NULL; bl = bl->all_next) {
@@ -1285,7 +1280,6 @@ int shape_blocks(ir_graph *irg)
        DEL_ARR_F(env.live_outs);
        del_set(env.opcode2id_map);
        obstack_free(&env.obst, NULL);
-       current_ir_graph = rem;
 
        return res;
 }  /* shape_blocks */