update automake stuff for release
[libfirm] / ir / ana / trouts.c
index 9809a23..8d17939 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
  */
 #include "config.h"
 
-#include "irnode.h"
 #include "trouts.h"
 
 #include "array.h"
 #include "pmap.h"
 
+#include "irnode_t.h"
 #include "irprog_t.h"
 #include "irgwalk.h"
 #include "irnode.h"
@@ -69,7 +69,7 @@ static ir_node **get_entity_access_array(const ir_entity *ent)
 
 static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
 {
-       ir_node **old = pmap_get(entity_access_map, ent);
+       ir_node **old = (ir_node**)pmap_get(entity_access_map, ent);
        if (old != accs)
                pmap_insert(entity_access_map, ent, (void *)accs);
 }
@@ -95,7 +95,7 @@ static ir_node **get_entity_reference_array(const ir_entity *ent)
 
 static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
 {
-       ir_node **old = pmap_get(entity_reference_map, ent);
+       ir_node **old = (ir_node**)pmap_get(entity_reference_map, ent);
        if (old != refs)
                pmap_insert(entity_reference_map, ent, (void *)refs);
 }
@@ -121,7 +121,7 @@ static ir_node **get_type_alloc_array(const ir_type *tp)
 
 static void set_type_alloc_array(const ir_type *tp, ir_node **alls)
 {
-       ir_node **old = pmap_get(type_alloc_map, tp);
+       ir_node **old = (ir_node**)pmap_get(type_alloc_map, tp);
        if (old != alls)
                pmap_insert(type_alloc_map, tp, (void *)alls);
 }
@@ -146,7 +146,7 @@ static ir_node **get_type_cast_array(const ir_type *tp)
 
 static void set_type_cast_array(const ir_type *tp, ir_node **alls)
 {
-       ir_node **old = pmap_get(type_cast_map, tp);
+       ir_node **old = (ir_node**)pmap_get(type_cast_map, tp);
        if (old != alls)
                pmap_insert(type_cast_map, tp, (void *)alls);
 }
@@ -172,7 +172,7 @@ static ir_type **get_type_pointertype_array(const ir_type *tp)
 
 static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
 {
-       ir_type **old = pmap_get(type_pointertype_map, tp);
+       ir_type **old = (ir_type**)pmap_get(type_pointertype_map, tp);
        if (old != pts)
                pmap_insert(type_pointertype_map, tp, (void *)pts);
 }
@@ -196,9 +196,9 @@ static ir_type **get_type_arraytype_array(const ir_type *tp)
        return res;
 }
 
-void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
+static void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
 {
-       ir_type **old = pmap_get(type_arraytype_map, tp);
+       ir_type **old = (ir_type**)pmap_get(type_arraytype_map, tp);
        if (old != pts)
                pmap_insert(type_arraytype_map, tp, (void *)pts);
 }
@@ -213,7 +213,7 @@ void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
 /*   Access routines for entities                                    */
 /**------------------------------------------------------------------*/
 
-int get_entity_n_accesses(const ir_entity *ent)
+size_t get_entity_n_accesses(const ir_entity *ent)
 {
        ir_node ** accs;
 
@@ -223,11 +223,11 @@ int get_entity_n_accesses(const ir_entity *ent)
        return ARR_LEN(accs);
 }
 
-ir_node *get_entity_access(const ir_entity *ent, int pos)
+ir_node *get_entity_access(const ir_entity *ent, size_t pos)
 {
        ir_node ** accs;
 
-       assert(0 <= pos && pos < get_entity_n_accesses(ent));
+       assert(pos < get_entity_n_accesses(ent));
 
        accs = get_entity_access_array(ent);
        return accs[pos];
@@ -245,6 +245,7 @@ static void add_entity_access(const ir_entity *ent, ir_node *n)
        set_entity_access_array(ent, accs);
 }
 
+#if 0
 void set_entity_access(const ir_entity *ent, int pos, ir_node *n)
 {
        ir_node ** accs;
@@ -255,10 +256,11 @@ void set_entity_access(const ir_entity *ent, int pos, ir_node *n)
        accs = get_entity_access_array(ent);
        accs[pos] = n;
 }
+#endif
 
 /*------------------------------------------------------------------*/
 
-int get_entity_n_references(const ir_entity *ent)
+size_t get_entity_n_references(const ir_entity *ent)
 {
        ir_node ** refs;
 
@@ -268,11 +270,11 @@ int get_entity_n_references(const ir_entity *ent)
        return ARR_LEN(refs);
 }
 
-ir_node *get_entity_reference(const ir_entity *ent, int pos)
+ir_node *get_entity_reference(const ir_entity *ent, size_t pos)
 {
        ir_node ** refs;
 
-       assert(0 <= pos && pos < get_entity_n_references(ent));
+       assert( pos < get_entity_n_references(ent));
 
        refs = get_entity_reference_array(ent);
        return refs[pos];
@@ -290,6 +292,7 @@ static void add_entity_reference(const ir_entity *ent, ir_node *n)
        set_entity_reference_array(ent, refs);
 }
 
+#if 0
 void set_entity_reference(const ir_entity *ent, int pos, ir_node *n)
 {
        ir_node ** refs;
@@ -300,14 +303,14 @@ void set_entity_reference(const ir_entity *ent, int pos, ir_node *n)
        refs = get_entity_reference_array(ent);
        refs[pos] = n;
 }
-
+#endif
 
 /**------------------------------------------------------------------*/
 /*   Access routines for types                                       */
 /**------------------------------------------------------------------*/
 
 /* Number of Alloc nodes that create an instance of this type */
-int get_type_n_allocs(const ir_type *tp)
+size_t get_type_n_allocs(const ir_type *tp)
 {
        ir_node **allocs;
 
@@ -318,10 +321,10 @@ int get_type_n_allocs(const ir_type *tp)
 }
 
 /* Alloc node that creates an instance of this type */
-ir_node *get_type_alloc(const ir_type *tp, int pos)
+ir_node *get_type_alloc(const ir_type *tp, size_t pos)
 {
        ir_node **allocs;
-       assert(0 <= pos && pos < get_type_n_allocs(tp));
+       assert( pos < get_type_n_allocs(tp));
 
        allocs = get_type_alloc_array(tp);
        return allocs[pos];
@@ -339,6 +342,7 @@ static void add_type_alloc(const ir_type *tp, ir_node *n)
        set_type_alloc_array(tp, allocs);
 }
 
+#if 0
 void set_type_alloc(const ir_type *tp, int pos, ir_node *n)
 {
        ir_node **allocs;
@@ -349,9 +353,10 @@ void set_type_alloc(const ir_type *tp, int pos, ir_node *n)
        allocs = get_type_alloc_array(tp);
        allocs[pos] = n;
 }
+#endif
 
 /* Number of Cast nodes that create an instance of this type */
-int get_type_n_casts(const ir_type *tp)
+size_t get_type_n_casts(const ir_type *tp)
 {
        ir_node **casts;
 
@@ -362,10 +367,10 @@ int get_type_n_casts(const ir_type *tp)
 }
 
 
-int get_class_n_upcasts(const ir_type *clss)
+size_t get_class_n_upcasts(const ir_type *clss)
 {
-       int i, n_casts = get_type_n_casts(clss);
-       int n_instances = 0;
+       size_t i, n_casts = get_type_n_casts(clss);
+       size_t n_instances = 0;
        for (i = 0; i < n_casts; ++i) {
                ir_node *cast = get_type_cast(clss, i);
                if (is_Cast_upcast(cast))
@@ -374,10 +379,10 @@ int get_class_n_upcasts(const ir_type *clss)
        return n_instances;
 }
 
-int get_class_n_downcasts(const ir_type *clss)
+size_t get_class_n_downcasts(const ir_type *clss)
 {
-       int i, n_casts = get_type_n_casts(clss);
-       int n_instances = 0;
+       size_t i, n_casts = get_type_n_casts(clss);
+       size_t n_instances = 0;
        for (i = 0; i < n_casts; ++i) {
                ir_node *cast = get_type_cast(clss, i);
                if (is_Cast_downcast(cast))
@@ -387,10 +392,10 @@ int get_class_n_downcasts(const ir_type *clss)
 }
 
 /* Cast node that creates an instance of this type */
-ir_node *get_type_cast(const ir_type *tp, int pos)
+ir_node *get_type_cast(const ir_type *tp, size_t pos)
 {
        ir_node **casts;
-       assert(0 <= pos && pos < get_type_n_casts(tp));
+       assert(pos < get_type_n_casts(tp));
 
        casts = get_type_cast_array(tp);
        return casts[pos];
@@ -408,20 +413,22 @@ void add_type_cast(const ir_type *tp, ir_node *n)
        set_type_cast_array(tp, casts);
 }
 
-void set_type_cast(const ir_type *tp, int pos, ir_node *n)
+#if 0
+void set_type_cast(const ir_type *tp, size_t pos, ir_node *n)
 {
        ir_node **casts;
 
-       assert(0 <= pos && pos < get_type_n_casts(tp));
+       assert(pos < get_type_n_casts(tp));
        assert(n && is_ir_node(n));
 
        casts = get_type_cast_array(tp);
        casts[pos] = n;
 }
+#endif
 
 /*------------------------------------------------------------------*/
 
-int get_type_n_pointertypes_to(const ir_type *tp)
+size_t get_type_n_pointertypes_to(const ir_type *tp)
 {
        ir_type ** pts;
 
@@ -431,11 +438,11 @@ int get_type_n_pointertypes_to(const ir_type *tp)
        return ARR_LEN(pts);
 }
 
-ir_type *get_type_pointertype_to(const ir_type *tp, int pos)
+ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos)
 {
        ir_type ** pts;
 
-       assert(0 <= pos && pos < get_type_n_pointertypes_to(tp));
+       assert(pos < get_type_n_pointertypes_to(tp));
 
        pts = get_type_pointertype_array(tp);
        return pts[pos];
@@ -449,10 +456,11 @@ void add_type_pointertype_to(const ir_type *tp, ir_type *ptp)
        assert(ptp && is_Pointer_type(ptp));
 
        pts = get_type_pointertype_array(tp);
-       ARR_APP1(ir_node *, pts, ptp);
+       ARR_APP1(ir_type*, pts, ptp);
        set_type_pointertype_array(tp, pts);
 }
 
+#if 0
 void set_type_pointertype_to(const ir_type *tp, int pos, ir_type *ptp)
 {
        ir_type ** pts;
@@ -463,11 +471,11 @@ void set_type_pointertype_to(const ir_type *tp, int pos, ir_type *ptp)
        pts = get_type_pointertype_array(tp);
        pts[pos] = ptp;
 }
-
+#endif
 
 /*------------------------------------------------------------------*/
 
-int get_type_n_arraytypes_of(const ir_type *tp)
+size_t get_type_n_arraytypes_of(const ir_type *tp)
 {
        ir_type ** pts;
 
@@ -477,11 +485,11 @@ int get_type_n_arraytypes_of(const ir_type *tp)
        return ARR_LEN(pts);
 }
 
-ir_type *get_type_arraytype_of(const ir_type *tp, int pos)
+ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos)
 {
        ir_type ** pts;
 
-       assert(0 <= pos && pos < get_type_n_arraytypes_of(tp));
+       assert(pos < get_type_n_arraytypes_of(tp));
 
        pts = get_type_arraytype_array(tp);
        return pts[pos];
@@ -495,10 +503,11 @@ void  add_type_arraytype_of(const ir_type *tp, ir_type *atp)
        assert(atp && is_Array_type(atp));
 
        pts = get_type_arraytype_array(tp);
-       ARR_APP1(ir_node *, pts, atp);
+       ARR_APP1(ir_type*, pts, atp);
        set_type_arraytype_array(tp, pts);
 }
 
+#if 0
 void  set_type_arraytype_of(const ir_type *tp, int pos, ir_type *atp)
 {
        ir_type ** pts;
@@ -509,6 +518,7 @@ void  set_type_arraytype_of(const ir_type *tp, int pos, ir_type *atp)
        pts = get_type_arraytype_array(tp);
        pts[pos] = atp;
 }
+#endif
 
 /*------------------------------------------------------------------*/
 /* Building and Removing the out datastructure                      */
@@ -640,20 +650,22 @@ void set_trouts_inconsistent(void)
 /* compute the trouts data structures. */
 void compute_trouts(void)
 {
-       int i;
+       size_t i;
 
        free_trouts();
        init_trouts();
 
        /* Compute outs for IR nodes. */
-       for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
-               irg_walk_graph(get_irp_irg(i), NULL, chain_accesses, NULL);
+       for (i = get_irp_n_irgs(); i > 0;) {
+               ir_graph *irg = get_irp_irg(--i);
+               irg_walk_graph(irg, NULL, chain_accesses, NULL);
        }
        walk_const_code(NULL, chain_accesses, NULL);
 
        /* Compute outs for types */
-       for (i = get_irp_n_types() - 1; i >= 0; --i) {
-               chain_types(get_irp_type(i));
+       for (i = get_irp_n_types(); i > 0;) {
+               ir_type *type = get_irp_type(--i);
+               chain_types(type);
        }
 
        irp->trouts_state = outs_consistent;
@@ -665,8 +677,9 @@ void free_trouts(void)
                ir_node **accs;
                for (accs = (ir_node **)pmap_first(entity_access_map);
                        accs;
-                       accs = (ir_node **)pmap_next(entity_access_map))
-                       ; //DEL_ARR_F(accs);
+                       accs = (ir_node **)pmap_next(entity_access_map)) {
+                       /* DEL_ARR_F(accs); */
+               }
                pmap_destroy(entity_access_map);
                entity_access_map = NULL;
        }
@@ -675,8 +688,9 @@ void free_trouts(void)
                ir_node **refs;
                for (refs = (ir_node **)pmap_first(entity_reference_map);
                        refs;
-                       refs = (ir_node **)pmap_next(entity_reference_map))
-                       ; //DEL_ARR_F(refs);
+                       refs = (ir_node **)pmap_next(entity_reference_map)) {
+                       /* DEL_ARR_F(refs); */
+               }
                pmap_destroy(entity_reference_map);
                entity_reference_map = NULL;
        }
@@ -685,8 +699,9 @@ void free_trouts(void)
                ir_node **alls;
                for (alls = (ir_node **)pmap_first(type_alloc_map);
                        alls;
-                       alls = (ir_node **)pmap_next(type_alloc_map))
-                       ; //DEL_ARR_F(alls);
+                       alls = (ir_node **)pmap_next(type_alloc_map)) {
+                       /* DEL_ARR_F(alls); */
+               }
                pmap_destroy(type_alloc_map);
                type_alloc_map = NULL;
        }
@@ -695,8 +710,9 @@ void free_trouts(void)
                ir_node **casts;
                for (casts = (ir_node **)pmap_first(type_cast_map);
                        casts;
-                       casts = (ir_node **)pmap_next(type_cast_map))
-                       ; //DEL_ARR_F(alls);
+                       casts = (ir_node **)pmap_next(type_cast_map)) {
+                       /* DEL_ARR_F(alls); */
+               }
                pmap_destroy(type_cast_map);
                type_cast_map = NULL;
        }
@@ -705,8 +721,9 @@ void free_trouts(void)
                ir_node **pts;
                for (pts = (ir_node **)pmap_first(type_pointertype_map);
                        pts;
-                       pts = (ir_node **)pmap_next(type_pointertype_map))
-                       ; //DEL_ARR_F(pts);
+                       pts = (ir_node **)pmap_next(type_pointertype_map)) {
+                       /* DEL_ARR_F(pts); */
+               }
                pmap_destroy(type_pointertype_map);
                type_pointertype_map = NULL;
        }
@@ -715,8 +732,9 @@ void free_trouts(void)
                ir_node **pts;
                for (pts = (ir_node **)pmap_first(type_arraytype_map);
                        pts;
-                       pts = (ir_node **)pmap_next(type_arraytype_map))
-                       ; //DEL_ARR_F(pts);
+                       pts = (ir_node **)pmap_next(type_arraytype_map)) {
+                       /* DEL_ARR_F(pts); */
+               }
                pmap_destroy(type_arraytype_map);
                type_arraytype_map = NULL;
        }