Move current_ir_graph from ir_graph to ir_cons
authorMatthias Braun <matze@braunis.de>
Mon, 12 Dec 2011 18:45:12 +0000 (19:45 +0100)
committerMatthias Braun <matze@braunis.de>
Wed, 14 Dec 2011 00:51:47 +0000 (01:51 +0100)
It should only be used by construction algorithms

27 files changed:
include/libfirm/ircons.h
include/libfirm/irgraph.h
ir/ana/ircfscc.c
ir/ana/irextbb_t.h
ir/ana/irouts.c
ir/ana/irscc.c
ir/ana/irtypeinfo.c
ir/ana/vrp.c
ir/be/arm/arm_emitter.c
ir/be/beinfo.c
ir/be/beinfo.h
ir/be/bemain.c
ir/be/bestat.c
ir/be/ia32/ia32_address_mode.c
ir/be/ia32/ia32_emitter.c
ir/be/sparc/sparc_emitter.c
ir/ir/irgopt.c
ir/ir/irgwalk.c
ir/ir/irgwalk_blk.c
ir/ir/irnode.c
ir/ir/irpass.c
ir/ir/irprog.c
ir/ir/irverify.c
ir/stat/dags.c
ir/stat/firmstat.c
ir/tr/trverify.c
ir/tr/typewalk.c

index 6fb4fef..cf836dc 100644 (file)
@@ -810,6 +810,17 @@ FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
  * @{
  */
 
+/** Global variable holding the current ir graph.
+ *
+ *  This global variable is used by the ir construction
+ *  interface in ircons and by the optimizations.
+ *  Further it is set by all walker functions.
+ */
+FIRM_API ir_graph *current_ir_graph;
+
+FIRM_API ir_graph *get_current_ir_graph(void);
+FIRM_API void set_current_ir_graph(ir_graph *graph);
+
 /** Create an immature Block.
  *
  * An immature Block has an unknown number of predecessors.  Predecessors
index 2c6fb5b..3e956ce 100644 (file)
  * @{
  */
 
-/** Global variable holding the current ir graph.
- *
- *  This global variable is used by the ir construction
- *  interface in ircons and by the optimizations.
- *  Further it is set by all walker functions.
- */
-FIRM_API ir_graph *current_ir_graph;
-
-FIRM_API ir_graph *get_current_ir_graph(void);
-FIRM_API void set_current_ir_graph(ir_graph *graph);
-
 /**
  * Create a new ir graph to build ir for a procedure.
  *
index e069082..b8155ac 100644 (file)
@@ -37,6 +37,7 @@
 #include "irgwalk.h"
 #include "irprog_t.h"
 #include "irdump.h"
+#include "ircons_t.h"
 
 #define NO_CFLOOPS_WITHOUT_HEAD 1
 
index 363493f..5023516 100644 (file)
@@ -29,6 +29,7 @@
 #include "irgraph_t.h"
 #include "irextbb.h"
 #include "irtools.h"
+#include "ircons.h"
 
 /**
  * An extended block.
index 81e7f02..ae59f06 100644 (file)
@@ -36,6 +36,7 @@
 #include "util.h"
 #include "irprintf.h"
 #include "error.h"
+#include "ircons.h"
 
 /*--------------------------------------------------------------------*/
 /** Accessing the out datastructures                                 **/
index 88caa5b..a37b057 100644 (file)
@@ -40,6 +40,7 @@
 #include "irdump.h"
 #include "array.h"
 #include "pmap.h"
+#include "ircons.h"
 
 /* A variant of the loop tree that avoids loops without head.
    This reduces the depth of the loop tree. */
index a83d641..d361c38 100644 (file)
@@ -133,7 +133,7 @@ ir_type *get_irn_typeinfo_type(const ir_node *n)
 
 void set_irn_typeinfo_type(ir_node *n, ir_type *tp)
 {
-       assert(get_irg_typeinfo_state(current_ir_graph) != ir_typeinfo_none);
+       assert(get_irg_typeinfo_state(get_irn_irg(n)) != ir_typeinfo_none);
 
        pmap_insert(type_node_map, (void *)n, (void *)tp);
 }
index 1c7953d..8165fc2 100644 (file)
@@ -515,7 +515,7 @@ static void vrp_first_pass(ir_node *n, void *e)
 
        vrp_update_node(env->info, n);
 
-       assure_irg_outs(get_current_ir_graph());
+       assure_irg_outs(get_irn_irg(n));
        for (i = get_irn_n_outs(n) - 1; i >=0; --i) {
                ir_node *succ = get_irn_out(n, i);
                if (bitset_is_set(env->visited, get_irn_idx(succ))) {
index 40d414e..7aa0a41 100644 (file)
@@ -833,7 +833,7 @@ static void arm_emit_node(const ir_node *irn)
                (*emit)(irn);
        } else {
                panic("Error: No emit handler for node %+F (graph %+F)\n",
-                     irn, current_ir_graph);
+                     irn, get_irn_irg(irn));
        }
 }
 
index 53aca77..56f5964 100644 (file)
@@ -36,7 +36,7 @@
 
 static copy_attr_func old_phi_copy_attr;
 
-void be_info_new_node(ir_node *node)
+void be_info_new_node(ir_graph *irg, ir_node *node)
 {
        struct obstack *obst;
        backend_info_t *info;
@@ -45,7 +45,7 @@ void be_info_new_node(ir_node *node)
        if (is_Proj(node))
                return;
 
-       obst = be_get_be_obst(current_ir_graph);
+       obst = be_get_be_obst(irg);
        info = OALLOCZ(obst, backend_info_t);
 
        assert(node->backend_info == NULL);
@@ -124,8 +124,9 @@ int be_nodes_equal(const ir_node *node1, const ir_node *node2)
 
 static void init_walker(ir_node *node, void *data)
 {
+       ir_graph *irg = get_irn_irg(node);
        (void) data;
-       be_info_new_node(node);
+       be_info_new_node(irg, node);
 }
 
 static bool initialized = false;
index 18e225b..c421ea3 100644 (file)
@@ -60,7 +60,7 @@ static inline backend_info_t *be_get_info(const ir_node *node)
 void be_info_init(void);
 void be_info_free(void);
 void be_info_init_irg(ir_graph *irg);
-void be_info_new_node(ir_node *node);
+void be_info_new_node(ir_graph *irg, ir_node *node);
 void be_info_duplicate(const ir_node *old_node, ir_node *new_node);
 int be_info_initialized(const ir_graph *irg);
 
index 45917af..ddf438b 100644 (file)
@@ -49,6 +49,7 @@
 #include "execfreq.h"
 #include "irprofile.h"
 #include "irpass_t.h"
+#include "ircons.h"
 
 #include "bearch.h"
 #include "be_t.h"
index bdc8d9d..1fc426d 100644 (file)
@@ -238,7 +238,7 @@ unsigned long be_count_insns(ir_graph *irg)
 static void block_count_walker(ir_node *node, void *data)
 {
        unsigned long *cnt = (unsigned long*)data;
-       if (node == get_irg_end_block(current_ir_graph))
+       if (node == get_irg_end_block(get_irn_irg(node)))
                return;
        (*cnt)++;
 }
index a401c72..78c9084 100644 (file)
@@ -66,7 +66,7 @@ static bool do_is_immediate(const ir_node *node, int *symconsts, bool negate)
 #ifdef DEBUG_libfirm
                        ir_fprintf(stderr,
                                   "Optimisation warning tarval of %+F(%+F) is not a long.\n",
-                                  node, current_ir_graph);
+                                  node, get_irn_irg(node));
 #endif
                        return false;
                }
index 65f4f50..d63111f 100644 (file)
@@ -60,6 +60,7 @@
 #include "raw_bitset.h"
 #include "dbginfo.h"
 #include "lc_opts.h"
+#include "ircons.h"
 
 #include "besched.h"
 #include "benode.h"
index 108547c..50f6e70 100644 (file)
@@ -1251,7 +1251,7 @@ static void sparc_emit_node(const ir_node *node)
                (*func) (node);
        } else {
                panic("No emit handler for node %+F (graph %+F)\n", node,
-                     current_ir_graph);
+                     get_irn_irg(node));
        }
 }
 
index 9bf1bd6..068e2be 100644 (file)
@@ -35,6 +35,7 @@
 #include "irgopt.h"
 #include "irgmod.h"
 #include "irgwalk.h"
+#include "ircons.h"
 
 #include "adt/pdeq.h"
 
index 02fdb5d..48b8165 100644 (file)
@@ -36,6 +36,7 @@
 #include "irgwalk.h"
 #include "irhooks.h"
 #include "entity_t.h"
+#include "ircons.h"
 
 #include "error.h"
 #include "pset_new.h"
index 2ad7f91..e58a843 100644 (file)
@@ -31,6 +31,7 @@
 #include "irhooks.h"
 #include "array.h"
 #include "hashptr.h"
+#include "ircons.h"
 
 #define _get_walk_arity(env, node) \
        ((env)->follow_deps ? get_irn_ins_or_deps((node)) : get_irn_arity((node)))
index a241e2c..530ebf1 100644 (file)
@@ -183,7 +183,7 @@ ir_node *new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op,
 
        hook_new_node(irg, res);
        if (get_irg_phase_state(irg) == phase_backend) {
-               be_info_new_node(res);
+               be_info_new_node(irg, res);
        }
 
        return res;
index 5ccf062..705eb5b 100644 (file)
@@ -31,6 +31,7 @@
 #include "irprog_t.h"
 #include "irdump.h"
 #include "irverify.h"
+#include "ircons.h"
 #include "xmalloc.h"
 
 typedef void (*void_pass_func_irg)(ir_graph *irg);
index d4b3a2c..09022ea 100644 (file)
@@ -35,6 +35,7 @@
 #include "obst.h"
 #include "irop_t.h"
 #include "irmemory.h"
+#include "ircons.h"
 
 /** The initial name of the irp program. */
 #define INITAL_PROG_NAME "no_name_set"
index 4811add..d919256 100644 (file)
@@ -36,6 +36,7 @@
 #include "irflag_t.h"
 #include "irpass_t.h"
 #include "irnodeset.h"
+#include "ircons.h"
 
 /** if this flag is set, verify entity types in Load & Store nodes */
 static int verify_entities = 0;
index d27013d..c9e283d 100644 (file)
@@ -30,6 +30,7 @@
 #include "irdump.h"
 #include "dags.h"
 #include "irtools.h"
+#include "ircons.h"
 
 enum dag_counting_options_t {
        FIRMSTAT_COPY_CONSTANTS = 0x00000001,  /**< if set, constants will be treated as they are in
index 4af0307..9ea6d3a 100644 (file)
@@ -39,6 +39,7 @@
 #include "xmalloc.h"
 #include "irhooks.h"
 #include "util.h"
+#include "ircons.h"
 
 /*
  * need this to be static:
index 8a576f4..6ba2524 100644 (file)
@@ -31,6 +31,7 @@
 #include "irgwalk.h"
 #include "error.h"
 #include "tv.h"
+#include "ircons.h"
 
 #ifdef NDEBUG
 /*
index 50055c3..523b1fe 100644 (file)
@@ -41,6 +41,7 @@
 #include "irnode_t.h"
 #include "irgwalk.h"
 #include "error.h"
+#include "ircons.h"
 
 /**
  * The walker environment