Further pushed size_t: trouts functions uses size_t now.
authorMichael Beck <mm.beck@gmx.net>
Wed, 2 Mar 2011 08:30:52 +0000 (09:30 +0100)
committerMichael Beck <mm.beck@gmx.net>
Wed, 2 Mar 2011 08:30:52 +0000 (09:30 +0100)
include/libfirm/trouts.h
ir/ana/trouts.c
ir/ir/irdumptxt.c

index bafb4b0..ab8709a 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.
  *
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
 /** Number of Load/Store nodes that possibly access this entity. */
-FIRM_API int get_entity_n_accesses(const ir_entity *ent);
+FIRM_API size_t get_entity_n_accesses(const ir_entity *ent);
 /** Load/Store node that possibly access this entity. */
 FIRM_API ir_node *get_entity_access(const ir_entity *ent, int pos);
 
 /** Number of references to an entity, in form of SymConst/Sel.
  *  Including references from constant entities and the like. */
-FIRM_API int get_entity_n_references(const ir_entity *ent);
+FIRM_API size_t get_entity_n_references(const ir_entity *ent);
 /** References to an entity, in form of SymConst/Sel
  *  Including references from constants. */
-FIRM_API ir_node *get_entity_reference(const ir_entity *ent, int pos);
+FIRM_API ir_node *get_entity_reference(const ir_entity *ent, size_t pos);
 
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 /* types                                                           */
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
 /** Number of Alloc nodes that create an instance of this type. */
-FIRM_API int get_type_n_allocs(const ir_type *tp);
+FIRM_API size_t get_type_n_allocs(const ir_type *tp);
 /** Alloc node that create an instance of this type. */
-FIRM_API ir_node *get_type_alloc(const ir_type *tp, int pos);
+FIRM_API ir_node *get_type_alloc(const ir_type *tp, size_t pos);
 
 /** Number of Cast nodes that cast a pointer to this type. */
-FIRM_API int get_type_n_casts(const ir_type *tp);
+FIRM_API size_t get_type_n_casts(const ir_type *tp);
 /** Cast node that cast a pointer to this type. */
-FIRM_API ir_node *get_type_cast(const ir_type *tp, int pos);
+FIRM_API ir_node *get_type_cast(const ir_type *tp, size_t pos);
 FIRM_API void add_type_cast(const ir_type *tp, ir_node *cast);
 /** Return number of upcasts. O(\#casts). */
-FIRM_API int get_class_n_upcasts(const ir_type *clss);
+FIRM_API size_t get_class_n_upcasts(const ir_type *clss);
 /** Return number of downcasts. O(\#casts). */
-FIRM_API int get_class_n_downcasts(const ir_type *clss);
+FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
 
 /* Access all pointer types that point to tp. */
-FIRM_API int     get_type_n_pointertypes_to(const ir_type *tp);
-FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, int pos);
+FIRM_API size_t  get_type_n_pointertypes_to(const ir_type *tp);
+FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos);
 FIRM_API void    add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
 
 /* Access all array types that contain elements of type tp.
  * Does not find subarrays, e.g., int[] being element of int[][]
  * for multi dimensional arrays. */
-FIRM_API int     get_type_n_arraytypes_of(const ir_type *tp);
-FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, int pos);
+FIRM_API size_t  get_type_n_arraytypes_of(const ir_type *tp);
+FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos);
 FIRM_API void    add_type_arraytype_of(const ir_type *tp, ir_type *atp);
 
 /*------------------------------------------------------------------*/
index 485285f..ae16c5b 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.
  *
@@ -213,7 +213,7 @@ static 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;
 
@@ -260,7 +260,7 @@ void set_entity_access(const ir_entity *ent, int pos, ir_node *n)
 
 /*------------------------------------------------------------------*/
 
-int get_entity_n_references(const ir_entity *ent)
+size_t get_entity_n_references(const ir_entity *ent)
 {
        ir_node ** refs;
 
@@ -270,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];
@@ -310,7 +310,7 @@ void set_entity_reference(const ir_entity *ent, int pos, ir_node *n)
 /**------------------------------------------------------------------*/
 
 /* 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;
 
@@ -321,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];
@@ -356,7 +356,7 @@ void set_type_alloc(const ir_type *tp, int pos, ir_node *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;
 
@@ -367,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))
@@ -379,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))
@@ -392,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];
@@ -414,11 +414,11 @@ void add_type_cast(const ir_type *tp, ir_node *n)
 }
 
 #if 0
-void set_type_cast(const ir_type *tp, int pos, ir_node *n)
+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);
@@ -428,7 +428,7 @@ void set_type_cast(const ir_type *tp, int pos, ir_node *n)
 
 /*------------------------------------------------------------------*/
 
-int get_type_n_pointertypes_to(const ir_type *tp)
+size_t get_type_n_pointertypes_to(const ir_type *tp)
 {
        ir_type ** pts;
 
@@ -438,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];
@@ -475,7 +475,7 @@ void set_type_pointertype_to(const ir_type *tp, int pos, ir_type *ptp)
 
 /*------------------------------------------------------------------*/
 
-int get_type_n_arraytypes_of(const ir_type *tp)
+size_t get_type_n_arraytypes_of(const ir_type *tp)
 {
        ir_type ** pts;
 
@@ -485,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];
@@ -650,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;
index 2c64e6a..d1a5815 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.
  *
@@ -319,14 +319,14 @@ void dump_graph_as_text(FILE *out, ir_graph *irg)
  *  "prefix"    node16, node17\n
  */
 static void dump_node_list(FILE *F, firm_kind *k, const char *prefix,
-                           int (*get_entity_n_nodes)(firm_kind *ent),
-                           ir_node *(*get_entity_node)(firm_kind *ent, int pos),
+                           size_t (*get_entity_n_nodes)(firm_kind *ent),
+                           ir_node *(*get_entity_node)(firm_kind *ent, size_t pos),
                            const char *name)
 {
-       int i, n_nodes = get_entity_n_nodes(k);
+       size_t i, n_nodes = get_entity_n_nodes(k);
        const char *comma = "";
 
-       fprintf(F, "%s  %s (%d):", prefix, name, n_nodes);
+       ir_fprintf(F, "%s  %s (%zu):", prefix, name, n_nodes);
        for (i = 0; i < n_nodes; ++i) {
                if (i > 7 && !(i & 7)) { /* line break every eight node. */
                        fprintf(F, ",\n%s   ", prefix);
@@ -346,14 +346,14 @@ static void dump_node_list(FILE *F, firm_kind *k, const char *prefix,
  *  "prefix"    node16, node17\n
  */
 static void dump_type_list(FILE *F, ir_type *tp, const char *prefix,
-                           int (*get_n_types)(const ir_type *tp),
-                           ir_type *(*get_type)(const ir_type *tp, int pos),
+                           size_t (*get_n_types)(const ir_type *tp),
+                           ir_type *(*get_type)(const ir_type *tp, size_t pos),
                            const char *name)
 {
-       int i, n_nodes = get_n_types(tp);
+       size_t i, n_nodes = get_n_types(tp);
        const char *comma = "";
 
-       fprintf(F, "%s  %s (%d):", prefix, name, n_nodes);
+       ir_fprintf(F, "%s  %s (%zu):", prefix, name, n_nodes);
        for (i = 0; i < n_nodes; ++i) {
                if (i > 7 && !(i & 7)) { /* line break every eight node. */
                        fprintf(F, ",\n%s   ", prefix);
@@ -623,10 +623,10 @@ static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *pref
 
        if (get_trouts_state()) {
                fprintf(F, "%s  Entity outs:\n", prefix);
-               dump_node_list(F, (firm_kind *)ent, prefix, (int(*)(firm_kind *))get_entity_n_accesses,
-                       (ir_node *(*)(firm_kind *, int))get_entity_access, "Accesses");
-               dump_node_list(F, (firm_kind *)ent, prefix, (int(*)(firm_kind *))get_entity_n_references,
-                       (ir_node *(*)(firm_kind *, int))get_entity_reference, "References");
+               dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_accesses,
+                       (ir_node *(*)(firm_kind *, size_t))get_entity_access, "Accesses");
+               dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_references,
+                       (ir_node *(*)(firm_kind *, size_t))get_entity_reference, "References");
        }
 }
 
@@ -719,7 +719,7 @@ void dump_type_to_file(FILE *F, ir_type *tp)
 
        case tpo_array:
                if (verbosity & dump_verbosity_typeattrs) {
-                       int i, n_dim;
+                       size_t i, n_dim;
                        ir_type *elem_tp = get_array_element_type(tp);
 
                        fprintf(F, "\n  array ");
@@ -820,10 +820,10 @@ void dump_type_to_file(FILE *F, ir_type *tp)
 
        if (get_trouts_state()) {
                fprintf(F, "\n  Type outs:\n");
-               dump_node_list(F, (firm_kind *)tp, "  ", (int(*)(firm_kind *))get_type_n_allocs,
-                       (ir_node *(*)(firm_kind *, int))get_type_alloc, "Allocations");
-               dump_node_list(F, (firm_kind *)tp, "  ", (int(*)(firm_kind *))get_type_n_casts,
-                       (ir_node *(*)(firm_kind *, int))get_type_cast, "Casts");
+               dump_node_list(F, (firm_kind *)tp, "  ", (size_t(*)(firm_kind *))get_type_n_allocs,
+                       (ir_node *(*)(firm_kind *, size_t))get_type_alloc, "Allocations");
+               dump_node_list(F, (firm_kind *)tp, "  ", (size_t(*)(firm_kind *))get_type_n_casts,
+                       (ir_node *(*)(firm_kind *, size_t))get_type_cast, "Casts");
                dump_type_list(F, tp, "  ", get_type_n_pointertypes_to, get_type_pointertype_to, "PointerTpsTo");
        }
 
@@ -832,8 +832,7 @@ void dump_type_to_file(FILE *F, ir_type *tp)
 
 void dump_types_as_text(FILE *out)
 {
-       int i;
-       int n_types = get_irp_n_types();
+       size_t i, n_types = get_irp_n_types();
 
        for (i = 0; i < n_types; ++i) {
                ir_type *type = get_irp_type(i);
@@ -844,8 +843,8 @@ void dump_types_as_text(FILE *out)
 void dump_globals_as_text(FILE *out)
 {
        ir_type *global_type = get_glob_type();
-       int      n_members   = get_class_n_members(global_type);
-       int      i;
+       size_t   n_members   = get_class_n_members(global_type);
+       size_t   i;
 
        for (i = 0; i < n_members; ++i) {
                ir_entity *entity = get_class_member(global_type, i);