cleanup: Remove pointless assert(is_${NODE}(x)) just before get_${NODE}_${FOO}(x...
[libfirm] / ir / tr / typewalk.c
index d645b12..2f07ca9 100644 (file)
@@ -21,7 +21,6 @@
  * @file    typewalk.c
  * @brief   Functionality to modify the type graph.
  * @author  Goetz Lindenmaier
- * @version $Id$
  * @brief
  *
  * Traverse the type information.  The walker walks the whole ir graph
@@ -42,6 +41,7 @@
 #include "irnode_t.h"
 #include "irgwalk.h"
 #include "error.h"
+#include "ircons.h"
 
 /**
  * The walker environment
@@ -93,7 +93,6 @@ static void do_type_walk(type_or_ent tore,
        size_t      i, n_types, n_mem;
        ir_entity   *ent = NULL;
        ir_type     *tp = NULL;
-       ir_node     *n;
        type_or_ent cont;
 
        /* marked? */
@@ -129,12 +128,6 @@ static void do_type_walk(type_or_ent tore,
                /* walk over the value types */
                if (ent->initializer != NULL) {
                        walk_initializer(ent->initializer, pre, post, env);
-               } else if (entity_has_compound_ent_values(ent)) {
-                       size_t i, n_mem = get_compound_ent_n_values(ent);
-                       for (i = 0; i < n_mem; ++i) {
-                               n = get_compound_ent_value(ent, i);
-                               irn_type_walker(n, pre, post, env);
-                       }
                }
                break;
        case k_type:
@@ -257,13 +250,12 @@ static void start_type_walk(ir_node *node, void *ctx)
        irn_type_walker(node, pre, post, envi);
 }
 
-/* walker: walks over all types */
 void type_walk(type_walk_func *pre, type_walk_func *post, void *env)
 {
        size_t      i, n_types = get_irp_n_types();
        type_or_ent cont;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        for (i = 0; i < n_types; ++i) {
                cont.typ = get_irp_type(i);
@@ -271,31 +263,7 @@ void type_walk(type_walk_func *pre, type_walk_func *post, void *env)
        }
        cont.typ = get_glob_type();
        do_type_walk(cont, pre, post, env);
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
-}
-
-void type_walk_prog(type_walk_func *pre, type_walk_func *post, void *env)
-{
-       size_t i, n_irgs = get_irp_n_irgs();
-       type_or_ent cont;
-
-       type_walk(pre, post, env);
-
-       for (i = 0; i < n_irgs; ++i) {
-               ir_graph *irg = get_irp_irg(i);
-               cont.typ = get_irg_frame_type(irg);
-               do_type_walk(cont, pre, post, env);
-
-               cont.typ = get_method_value_param_type(get_entity_type(get_irg_entity(irg)));
-               if (cont.typ)
-                       do_type_walk(cont, pre, post, env);
-       }
-
-       for (i = IR_SEGMENT_FIRST; i <= IR_SEGMENT_LAST; ++i) {
-               cont.typ = get_segment_type((ir_segment_t) i);
-               if (cont.typ)
-                       do_type_walk(cont, pre, post, env);
-       }
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 void type_walk_irg(ir_graph *irg,
@@ -324,7 +292,7 @@ void type_walk_irg(ir_graph *irg,
           Here we initially increase the flag.  We only call do_type_walk that does
           not increase the flag.
        */
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        irg_walk(get_irg_end(irg), start_type_walk, NULL, &type_env);
 
@@ -335,7 +303,7 @@ void type_walk_irg(ir_graph *irg,
        do_type_walk(cont, pre, post, env);
 
        current_ir_graph = rem;
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 static void type_walk_s2s_2(type_or_ent tore,
@@ -344,7 +312,6 @@ static void type_walk_s2s_2(type_or_ent tore,
                             void *env)
 {
        type_or_ent cont;
-       int         i, n;
 
        /* marked? */
        switch (get_kind(tore.ent)) {
@@ -367,6 +334,8 @@ static void type_walk_s2s_2(type_or_ent tore,
                        switch (get_type_tpop_code(tp)) {
                        case tpo_class:
                                {
+                                       size_t i, n;
+
                                        n = get_class_n_supertypes(tp);
                                        for (i = 0; i < n; ++i) {
                                                cont.typ = get_class_supertype(tp, i);
@@ -417,7 +386,7 @@ void type_walk_super2sub(type_walk_func *pre,
        type_or_ent cont;
        size_t      i, n_types = get_irp_n_types();
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        cont.typ = get_glob_type();
        type_walk_s2s_2(cont, pre, post, env);
@@ -425,7 +394,7 @@ void type_walk_super2sub(type_walk_func *pre,
                cont.typ = get_irp_type(i);
                type_walk_s2s_2(cont, pre, post, env);
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /*****************************************************************************/
@@ -434,7 +403,6 @@ static void type_walk_super_2(type_or_ent tore, type_walk_func *pre,
                               type_walk_func *post, void *env)
 {
        type_or_ent cont;
-       int         i, n;
 
        /* marked? */
        switch (get_kind(tore.ent)) {
@@ -459,6 +427,8 @@ static void type_walk_super_2(type_or_ent tore, type_walk_func *pre,
                        switch (get_type_tpop_code(tp)) {
                        case tpo_class:
                                {
+                                       size_t i, n;
+
                                        /* execute pre method */
                                        if (pre)
                                                pre(tore, env);
@@ -502,7 +472,7 @@ void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
        size_t      i, n_types = get_irp_n_types();
        type_or_ent cont;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        cont.typ = get_glob_type();
        type_walk_super_2(cont, pre, post, env);
@@ -510,7 +480,7 @@ void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
                cont.typ = get_irp_type(i);
                type_walk_super_2(cont, pre, post, env);
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /*****************************************************************************/
@@ -519,12 +489,11 @@ void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
 static void class_walk_s2s_2(ir_type *tp, class_walk_func *pre,
                              class_walk_func *post, void *env)
 {
-       int i, n;
+       size_t i, n;
 
        /* marked? */
        if (type_visited(tp)) return;
 
-       assert(is_Class_type(tp));
        /* Assure all supertypes are visited before */
        n = get_class_n_supertypes(tp);
        for (i = 0; i < n; ++i) {
@@ -554,28 +523,27 @@ void class_walk_super2sub(class_walk_func *pre,
        size_t i, n_types = get_irp_n_types();
        ir_type *tp;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        for (i = 0; i < n_types; i++) {
                tp = get_irp_type(i);
                if (is_Class_type(tp) &&
                    (get_class_n_supertypes(tp) == 0) &&
-                   type_not_visited(tp)) {
-                       assert(! is_frame_type(tp));
-                       assert(tp != get_glob_type());
+                   type_not_visited(tp) &&
+                   (! is_frame_type(tp)) &&
+                   (tp != get_glob_type())) {
                        class_walk_s2s_2(tp, pre, post, env);
                }
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 
-/* Walks over all entities in the type */
 void walk_types_entities(ir_type *tp,
                          entity_walk_func *doit,
                          void *env)
 {
-       int i, n;
+       size_t i, n;
 
        switch (get_type_tpop_code(tp)) {
        case tpo_class: