- removed Psi nodes, Mux nodes are used again ...
[libfirm] / ir / ir / irgwalk.c
index a972a02..237c07c 100644 (file)
 #endif
 
 #include "irnode_t.h"
-#include "irgraph_t.h" /* visited flag */
+#include "irgraph_t.h"
 #include "irprog.h"
 #include "irgwalk.h"
 #include "irhooks.h"
 #include "ircgcons.h"
+#include "entity_t.h"
 
+#include "error.h"
 #include "pset_new.h"
 #include "array.h"
 
@@ -273,14 +275,13 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
                pset_new_destroy(&irg_set);
        } else {
 #endif
-               set_using_visited(current_ir_graph);
+               set_using_irn_visited(current_ir_graph);
                inc_irg_visited(current_ir_graph);
                nodes_touched = irg_walk_2(node, pre, post, env);
-               clear_using_visited(current_ir_graph);
+               clear_using_irn_visited(current_ir_graph);
 #ifdef INTERPROCEDURAL_VIEW
        }
 #endif
-       return;
 }
 
 /*
@@ -425,12 +426,11 @@ void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
        if (get_interprocedural_view()) {
                assert(0 && "This is not yet implemented.");
        } else {
-               set_using_visited(current_ir_graph);
+               set_using_irn_visited(current_ir_graph);
                inc_irg_visited(current_ir_graph);
                nodes_touched = irg_walk_in_or_dep_2(node, pre, post, env);
-               clear_using_visited(current_ir_graph);
+               clear_using_irn_visited(current_ir_graph);
        }
-       return;
 }
 
 /*
@@ -494,7 +494,6 @@ cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
 
                if (post) post(node, env);
        }
-       return;
 }
 
 #ifdef INTERPROCEDURAL_VIEW
@@ -563,15 +562,12 @@ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) {
 
 /* Walks back from n until it finds a real cf op. */
 static ir_node *get_cf_op(ir_node *n) {
-       ir_node *pred;
-
-       n = skip_Id(n);
-       n = skip_Tuple(n);
-       pred = skip_Proj(n);
-       if (!(is_cfop(pred) || is_fragile_op(pred) || is_Bad(pred)))
-               n = get_cf_op(n);
-
-       return skip_Proj(n);
+       while (!is_cfop(n) && !is_fragile_op(n) && !is_Bad(n)) {
+               n = skip_Id(n);
+               n = skip_Tuple(n);
+               n = skip_Proj(n);
+       }
+       return n;
 }
 
 static void irg_block_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
@@ -675,6 +671,29 @@ typedef struct walk_env {
        void *env;
 } walk_env;
 
+static void walk_initializer(ir_initializer_t *initializer, walk_env *env)
+{
+       switch(initializer->kind) {
+    case IR_INITIALIZER_CONST:
+       irg_walk(initializer->consti.value, env->pre, env->post, env->env);
+        return;
+    case IR_INITIALIZER_TARVAL:
+    case IR_INITIALIZER_NULL:
+        return;
+
+    case IR_INITIALIZER_COMPOUND: {
+        size_t i;
+        for(i = 0; i < initializer->compound.n_initializers; ++i) {
+            ir_initializer_t *subinitializer
+                = initializer->compound.initializers[i];
+            walk_initializer(subinitializer, env);
+        }
+        return;
+    }
+       }
+       panic("invalid initializer found");
+}
+
 /**
  * Walk to all constant expressions in this entity.
  */
@@ -683,7 +702,9 @@ static void walk_entity(ir_entity *ent, void *env)
        walk_env *my_env = (walk_env *)env;
 
        if (get_entity_variability(ent) != variability_uninitialized) {
-               if (is_atomic_entity(ent)) {
+               if (ent->has_initializer) {
+                       walk_initializer(ent->attr.initializer, my_env);
+               } else if (is_atomic_entity(ent)) {
                        irg_walk(get_atomic_ent_value(ent), my_env->pre, my_env->post, my_env->env);
                } else {
                        int i, n_vals = get_compound_ent_n_values(ent);