Further spread size_t.
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 11 Feb 2011 15:21:45 +0000 (15:21 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 11 Feb 2011 15:21:45 +0000 (15:21 +0000)
[r28375]

12 files changed:
include/libfirm/typerep.h
ir/ana/cgana.c
ir/ir/irargs.c
ir/ir/ircons.c
ir/ir/irgraph.c
ir/ir/irio.c
ir/lower/lower_calls.c
ir/lower/lower_mode_b.c
ir/tr/tr_inheritance.c
ir/tr/trverify.c
ir/tr/type.c
ir/tr/typewalk.c

index 3fc0608..0e895fa 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.
  *
@@ -1385,7 +1385,9 @@ FIRM_API size_t get_class_n_members(const ir_type *clss);
 /** Returns the member at position pos, 0 <= pos < n_member */
 FIRM_API ir_entity *get_class_member(const ir_type *clss, size_t pos);
 
-/** Returns index of mem in clss, -1 if not contained. */
+#define INVALID_MEMBER_INDEX ((size_t)-1)
+
+/** Returns index of mem in clss, INVALID_MEMBER_INDEX if not contained. */
 FIRM_API size_t get_class_member_index(const ir_type *clss, ir_entity *mem);
 
 /** Finds the member with name 'name'. If several members with the same
index c5d7a66..5d3c843 100644 (file)
@@ -417,16 +417,19 @@ static void free_ana_walker(ir_node *node, void *env)
                /* nothing */
                break;
        case iro_Call:
+       {
+               size_t i, n;
                /* we must handle Call nodes specially, because their call address input
                   do not expose a method address. */
                set_irn_link(node, MARK);
-               for (i = get_Call_n_params(node) - 1; i >= 0; --i) {
+               for (i = 0, n = get_Call_n_params(node); i < n; ++i) {
                        ir_node *pred = get_Call_param(node, i);
                        if (mode_is_reference(get_irn_mode(pred))) {
                                free_mark(pred, set);
                        }
                }
                break;
+       }
        default:
                /* other nodes: Alle anderen Knoten nehmen wir als Verr�ter an, bis
                 * jemand das Gegenteil implementiert. */
@@ -537,8 +540,7 @@ static void add_method_address(ir_entity *ent, eset *set)
 static size_t get_free_methods(ir_entity ***free_methods)
 {
        eset *free_set = eset_create();
-       size_t i, n;
-       int j;
+       size_t i, n, j, m;
        ir_entity **arr;
        ir_entity *ent;
        ir_graph *irg;
@@ -564,12 +566,12 @@ static size_t get_free_methods(ir_entity ***free_methods)
 
        /* insert all methods that are used in global variables initializers */
        tp = get_glob_type();
-       for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
+       for (j = 0, m = get_class_n_members(tp); j < m; ++j) {
                ent = get_class_member(tp, j);
                add_method_address(ent, free_set);
        }
        tp = get_tls_type();
-       for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
+       for (j = 0, m = get_class_n_members(tp); j < m; ++j) {
                ent = get_class_member(tp, j);
                add_method_address(ent, free_set);
        }
index b36138b..17b320a 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.
  *
@@ -118,7 +118,7 @@ static int firm_emit(lc_appendable_t *app,
 
        void *X = (void*)arg->v_ptr;
        firm_kind *obj = (firm_kind*)X;
-       int i, n;
+       size_t i, n;
        ir_node *block;
        char add[64];
        char buf[256];
index 15bcc23..0e02e3c 100644 (file)
@@ -645,12 +645,13 @@ void set_value(int pos, ir_node *value)
 
 int r_find_value(ir_graph *irg, ir_node *value)
 {
-       int i;
+       size_t i;
        ir_node *bl = irg->current_block;
 
-       for (i = ARR_LEN(bl->attr.block.graph_arr) - 1; i >= 1; --i)
-               if (bl->attr.block.graph_arr[i] == value)
+       for (i = ARR_LEN(bl->attr.block.graph_arr); i > 1;) {
+               if (bl->attr.block.graph_arr[--i] == value)
                        return i - 1;
+       }
        return -1;
 }
 
@@ -736,8 +737,8 @@ void irg_finalize_cons(ir_graph *irg)
 
 void irp_finalize_cons(void)
 {
-       int i;
-       for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+       size_t i, n;
+       for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
                irg_finalize_cons(get_irp_irg(i));
        }
        irp->phase_state = phase_high;
index d9b9774..c5b4a9c 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.
  *
@@ -742,8 +742,8 @@ void (set_irg_loopinfo_inconsistent)(ir_graph *irg)
 
 void set_irp_loopinfo_inconsistent(void)
 {
-       int i;
-       for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+       size_t i, n;
+       for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
                set_irg_loopinfo_inconsistent(get_irp_irg(i));
        }
 }
index d8f97cf..81a0239 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2009 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -35,6 +35,7 @@
 #include "irnode_t.h"
 #include "irprog.h"
 #include "irgraph_t.h"
+#include "irprintf.h"
 #include "ircons.h"
 #include "irgmod.h"
 #include "irflag_t.h"
@@ -545,7 +546,7 @@ static void export_type_pre(io_env_t *env, ir_type *tp)
 static void export_type_post(io_env_t *env, ir_type *tp)
 {
        FILE *f = env->file;
-       int i;
+       size_t i;
 
        /* skip types already handled by pre walker */
        switch (get_type_tpop_code(tp)) {
@@ -569,8 +570,8 @@ static void export_type_post(io_env_t *env, ir_type *tp)
 
        switch (get_type_tpop_code(tp)) {
        case tpo_array: {
-               int n = get_array_n_dimensions(tp);
-               fprintf(f, "%d %ld ", n, get_type_nr(get_array_element_type(tp)));
+               size_t n = get_array_n_dimensions(tp);
+               ir_fprintf(f, "%zu %ld ", n, get_type_nr(get_array_element_type(tp)));
                for (i = 0; i < n; i++) {
                        ir_node *lower = get_array_lower_bound(tp, i);
                        ir_node *upper = get_array_upper_bound(tp, i);
@@ -591,16 +592,15 @@ static void export_type_post(io_env_t *env, ir_type *tp)
        }
 
        case tpo_method: {
-               int nparams  = get_method_n_params(tp);
-               int nresults = get_method_n_ress(tp);
-               fprintf(f, "%u %u %d %d ", get_method_calling_convention(tp),
+               size_t nparams  = get_method_n_params(tp);
+               size_t nresults = get_method_n_ress(tp);
+               ir_fprintf(f, "%u %u %zu %zu ", get_method_calling_convention(tp),
                        get_method_additional_properties(tp), nparams, nresults);
                for (i = 0; i < nparams; i++)
                        write_long(env, get_type_nr(get_method_param_type(tp, i)));
                for (i = 0; i < nresults; i++)
                        write_long(env, get_type_nr(get_method_res_type(tp, i)));
-               fprintf(f, "%lu ",
-                       (unsigned long) get_method_first_variadic_param_index(tp));
+               ir_fprintf(f, "%zu ", get_method_first_variadic_param_index(tp));
                break;
        }
 
@@ -670,9 +670,9 @@ static void export_entity(io_env_t *env, ir_entity *ent)
                fputs("initializer ", env->file);
                write_initializer(env, get_entity_initializer(ent));
        } else if (entity_has_compound_ent_values(ent)) {
-               int i, n = get_compound_ent_n_values(ent);
+               size_t i, n = get_compound_ent_n_values(ent);
                fputs("compoundgraph ", env->file);
-               fprintf(env->file, "%d ", n);
+               ir_fprintf(env->file, "%zu ", n);
                for (i = 0; i < n; i++) {
                        ir_entity *member = get_compound_ent_value_member(ent, i);
                        ir_node   *irn    = get_compound_ent_value(ent, i);
@@ -825,7 +825,7 @@ static const char *get_mode_sort_name(ir_mode_sort sort)
 
 static void export_modes(io_env_t *env)
 {
-       int i, n_modes = get_irp_n_modes();
+       size_t i, n_modes = get_irp_n_modes();
 
        fputs("modes {\n", env->file);
 
@@ -901,7 +901,7 @@ void ir_export(const char *filename)
 void ir_export_file(FILE *file, const char *outputname)
 {
        io_env_t env;
-       int i, n_irgs = get_irp_n_irgs();
+       size_t i, n_irgs = get_irp_n_irgs();
 
        (void) outputname;
        env.file = file;
@@ -1240,7 +1240,7 @@ static ir_entity *read_entity(io_env_t *env)
 static ir_mode *read_mode(io_env_t *env)
 {
        char *str = read_word(env);
-       int i, n;
+       size_t i, n;
 
        n = get_irp_n_modes();
        for (i = 0; i < n; i++) {
@@ -1874,7 +1874,7 @@ void ir_import_file(FILE *input, const char *inputname)
        firm_verification_t oldver = get_node_verification_mode();
        io_env_t ioenv;
        io_env_t *env = &ioenv;
-       int i, n;
+       size_t i, n;
 
        symtbl_init();
 
index 59bb85f..9e15504 100644 (file)
@@ -77,9 +77,9 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
 {
        ir_type *lowered, *ptr_tp, *value_type;
        ir_type **params, **results, *res_tp;
-       int     *param_map;
+       size_t  *param_map;
        ir_mode *modes[MAX_REGISTER_RET_VAL];
-       int n_ress, n_params, nn_ress, nn_params, i, first_variadic;
+       size_t  n_ress, n_params, nn_ress, nn_params, i, first_variadic;
        add_hidden hidden_params;
        int        changed = 0;
        ir_variadicity var;
@@ -99,7 +99,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
        n_params = get_method_n_params(mtp);
        NEW_ARR_A(ir_type *, params, n_params + n_ress);
 
-       NEW_ARR_A(int, param_map, n_params + n_ress);
+       NEW_ARR_A(size_t, param_map, n_params + n_ress);
 
        first_variadic = get_method_first_variadic_param_index(mtp);
 
@@ -128,7 +128,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                                           address will be transmitted as a hidden parameter. */
                                        ptr_tp = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
                                        params[nn_params]    = ptr_tp;
-                                       param_map[nn_params] = -1 - i;
+                                       param_map[nn_params] = n_params + i;
                                        ++nn_params;
                                        changed++;
                                        if (lp->flags & LF_RETURN_HIDDEN)
@@ -162,7 +162,7 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
 
                        if (is_compound_type(res_tp)) {
                                params[nn_params] = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
-                               param_map[nn_params] = -1 - i;
+                               param_map[nn_params] = n_params + i;
                                ++nn_params;
                        } else {
                                results[nn_ress++] = res_tp;
@@ -196,11 +196,11 @@ static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
                /* set new param positions */
                for (i = 0; i < nn_params; ++i) {
                        ir_entity *ent = get_method_value_param_ent(lowered, i);
-                       int       pos  = param_map[i];
+                       size_t    pos  = param_map[i];
                        ident     *id;
 
                        set_entity_link(ent, INT_TO_PTR(pos));
-                       if (pos < 0) {
+                       if (pos >= n_params) {
                                /* formally return value, ignore for now */
                                continue;
                        }
@@ -232,8 +232,8 @@ struct cl_entry {
  * Walker environment for fix_args_and_collect_calls().
  */
 typedef struct wlk_env_t {
-       int                  arg_shift;        /**< The Argument index shift for parameters. */
-       int                  first_hidden;     /**< The index of the first hidden argument. */
+       size_t               arg_shift;        /**< The Argument index shift for parameters. */
+       size_t               first_hidden;     /**< The index of the first hidden argument. */
        struct obstack       obst;             /**< An obstack to allocate the data on. */
        cl_entry             *cl_list;         /**< The call list. */
        pmap                 *dummy_map;       /**< A map for finding the dummy arguments. */
@@ -327,7 +327,6 @@ static void check_ptr(ir_node *ptr, wlk_env *env)
 static void fix_args_and_collect_calls(ir_node *n, void *ctx)
 {
        wlk_env *env = (wlk_env*)ctx;
-       int      i;
        ir_type *ctp;
        ir_node *ptr;
 
@@ -337,7 +336,7 @@ static void fix_args_and_collect_calls(ir_node *n, void *ctx)
                        ir_entity *ent = get_Sel_entity(n);
 
                        if (get_entity_owner(ent) == env->value_params) {
-                               int pos = get_struct_member_index(env->value_params, ent) + env->arg_shift;
+                               size_t pos = get_struct_member_index(env->value_params, ent) + env->arg_shift;
                                ir_entity *new_ent;
 
                                new_ent = get_method_value_param_ent(env->lowered_mtp, pos);
@@ -374,7 +373,8 @@ static void fix_args_and_collect_calls(ir_node *n, void *ctx)
                ctp = get_Call_type(n);
                if (env->params->flags & LF_COMPOUND_RETURN) {
                        /* check for compound returns */
-                       for (i = get_method_n_ress(ctp) -1; i >= 0; --i) {
+                       size_t i, n_res;
+                       for (i = 0, n_res = get_method_n_ress(ctp); i < n_res; ++i) {
                                if (is_compound_type(get_method_res_type(ctp, i))) {
                                        /*
                                         * This is a call with a compound return. As the result
@@ -532,12 +532,12 @@ static ir_node *get_dummy_sel(ir_graph *irg, ir_node *block, ir_type *tp, wlk_en
  * @param entry  the call list
  * @param env    the environment
  */
-static void add_hidden_param(ir_graph *irg, int n_com, ir_node **ins, cl_entry *entry, wlk_env *env)
+static void add_hidden_param(ir_graph *irg, size_t n_com, ir_node **ins, cl_entry *entry, wlk_env *env)
 {
        ir_node *p, *n, *src, *mem, *blk;
        ir_entity *ent;
        ir_type *owner;
-       int n_args;
+       size_t n_args;
 
        n_args = 0;
        for (p = entry->copyb; p; p = n) {
@@ -605,7 +605,7 @@ static void fix_call_list(ir_graph *irg, wlk_env *env)
        ir_node *call, **new_in;
        ir_type *ctp, *lowered_mtp;
        add_hidden hidden_params;
-       int i, n_params, n_com, pos;
+       size_t i, n_res, n_params, n_com, pos;
 
        new_in = NEW_ARR_F(ir_node *, 0);
        for (p = env->cl_list; p; p = p->next) {
@@ -622,7 +622,7 @@ static void fix_call_list(ir_graph *irg, wlk_env *env)
                n_params = get_Call_n_params(call);
 
                n_com = 0;
-               for (i = get_method_n_ress(ctp) - 1; i >= 0; --i) {
+               for (i = 0, n_res = get_method_n_ress(ctp); i < n_res; ++i) {
                        if (is_compound_type(get_method_res_type(ctp, i)))
                                ++n_com;
                }
@@ -661,7 +661,7 @@ static void transform_irg(const lower_params_t *lp, ir_graph *irg)
        ir_graph   *rem = current_ir_graph;
        ir_entity  *ent = get_irg_entity(irg);
        ir_type    *mtp, *lowered_mtp, *tp, *ft;
-       int        i, j, k, n_ress = 0, n_ret_com = 0;
+       size_t     i, j, k, n_ress = 0, n_ret_com = 0;
        size_t     n_cr_opt;
        ir_node    **new_in, *ret, *endbl, *bl, *mem, *copy;
        cr_pair    *cr_opt;
@@ -733,6 +733,8 @@ static void transform_irg(const lower_params_t *lp, ir_graph *irg)
        }
 
        if (n_ret_com) {
+               int idx;
+
                /*
                 * Now fix the Return node of the current graph.
                 */
@@ -741,8 +743,8 @@ static void transform_irg(const lower_params_t *lp, ir_graph *irg)
                /* STEP 1: find the return. This is simple, we have normalized the graph. */
                endbl = get_irg_end_block(irg);
                ret = NULL;
-               for (i = get_Block_n_cfgpreds(endbl) - 1; i >= 0; --i) {
-                       ir_node *pred = get_Block_cfgpred(endbl, i);
+               for (idx = get_Block_n_cfgpreds(endbl) - 1; idx >= 0; --idx) {
+                       ir_node *pred = get_Block_cfgpred(endbl, idx);
 
                        if (is_Return(pred)) {
                                ret = pred;
@@ -844,7 +846,7 @@ static void transform_irg(const lower_params_t *lp, ir_graph *irg)
  */
 static int must_be_lowered(const lower_params_t *lp, ir_type *tp)
 {
-  int i, n_ress;
+  size_t i, n_ress;
   ir_type *res_tp;
 
   if (is_Method_type(tp)) {
index 4dcd711..c541e1f 100644 (file)
@@ -158,9 +158,9 @@ ir_node *ir_create_cond_set(ir_node *cond_value, ir_mode *dest_mode)
 
 static void adjust_method_type(ir_type *method_type)
 {
-       int i;
-       int n_params;
-       int n_res;
+       size_t i;
+       size_t n_params;
+       size_t n_res;
 
        n_params = get_method_n_params(method_type);
        for (i = 0; i < n_params; ++i) {
index 4778f96..03bc472 100644 (file)
@@ -236,7 +236,7 @@ static pset *get_type_map(const ir_type *tp, dir d)
 static void compute_down_closure(ir_type *tp)
 {
        pset *myset, *subset;
-       int i, n_subtypes, n_members, n_supertypes;
+       size_t i, n_subtypes, n_members, n_supertypes;
        ir_visited_t master_visited = get_master_type_visited();
 
        assert(is_Class_type(tp));
@@ -265,7 +265,7 @@ static void compute_down_closure(ir_type *tp)
        n_members = get_class_n_members(tp);
        for (i = 0; i < n_members; ++i) {
                ir_entity *mem = get_class_member(tp, i);
-               int j, n_overwrittenby = get_entity_n_overwrittenby(mem);
+               size_t j, n_overwrittenby = get_entity_n_overwrittenby(mem);
 
                myset = get_entity_map(mem, d_down);
                for (j = 0; j < n_overwrittenby; ++j) {
@@ -291,7 +291,7 @@ static void compute_down_closure(ir_type *tp)
 static void compute_up_closure(ir_type *tp)
 {
        pset *myset, *subset;
-       int i, n_subtypes, n_members, n_supertypes;
+       size_t i, n_subtypes, n_members, n_supertypes;
        ir_visited_t master_visited = get_master_type_visited();
 
        assert(is_Class_type(tp));
@@ -320,7 +320,7 @@ static void compute_up_closure(ir_type *tp)
        n_members = get_class_n_members(tp);
        for (i = 0; i < n_members; ++i) {
                ir_entity *mem = get_class_member(tp, i);
-               int j, n_overwrites = get_entity_n_overwrites(mem);
+               size_t j, n_overwrites = get_entity_n_overwrites(mem);
 
                myset = get_entity_map(mem, d_up);
                for (j = 0; j < n_overwrites; ++j) {
@@ -360,7 +360,7 @@ void compute_inh_transitive_closure(void)
        for (i = 0; i < n_types; ++i) {
                ir_type *tp = get_irp_type(i);
                if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
-                       int j, n_subtypes = get_class_n_subtypes(tp);
+                       size_t j, n_subtypes = get_class_n_subtypes(tp);
                        int has_unmarked_subtype = 0;
 
                        assert(get_type_visited(tp) < get_master_type_visited()-1);
@@ -384,7 +384,7 @@ void compute_inh_transitive_closure(void)
        for (i = 0; i < n_types; ++i) {
                ir_type *tp = get_irp_type(i);
                if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
-                       int j, n_supertypes = get_class_n_supertypes(tp);
+                       size_t j, n_supertypes = get_class_n_supertypes(tp);
                        int has_unmarked_supertype = 0;
 
                        assert(get_type_visited(tp) < get_master_type_visited()-1);
@@ -494,7 +494,7 @@ ir_entity *get_entity_trans_overwrites_next(const ir_entity *ent)
 /** Returns true if low is subclass of high. */
 static int check_is_SubClass_of(ir_type *low, ir_type *high)
 {
-       int i, n_subtypes;
+       size_t i, n_subtypes;
 
        /* depth first search from high downwards. */
        n_subtypes = get_class_n_subtypes(high);
@@ -542,7 +542,7 @@ int is_SubClass_ptr_of(ir_type *low, ir_type *high)
 
 int is_overwritten_by(ir_entity *high, ir_entity *low)
 {
-       int i, n_overwrittenby;
+       size_t i, n_overwrittenby;
        assert(is_entity(low) && is_entity(high));
 
        if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
@@ -571,7 +571,7 @@ int is_overwritten_by(ir_entity *high, ir_entity *low)
  */
 static ir_entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent)
 {
-       int i, n_overwrittenby;
+       size_t i, n_overwrittenby;
 
        if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
 
index 0d679da..d3ac10e 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.
  *
@@ -153,10 +153,9 @@ static void show_ent_overwrite_cnt(ir_entity *ent)
  */
 static int check_class(ir_type *tp)
 {
-       int i, j, k;
-       int found;
+       size_t i, n, j, m;
 
-       for (i = get_class_n_members(tp) - 1; i >= 0; --i) {
+       for (i = 0, n = get_class_n_members(tp); i < n; ++i) {
                ir_entity *mem = get_class_member(tp, i);
 
                ASSERT_AND_RET_DBG(
@@ -169,7 +168,7 @@ static int check_class(ir_type *tp)
                        mem,
                        "NULL members not allowed",
                        error_null_mem,
-                       ir_fprintf(stderr, "Type verification error:\n%+F member %d is NULL\n", tp, i)
+                       ir_fprintf(stderr, "Type verification error:\n%+F member %zu is NULL\n", tp, i)
                );
 
                ASSERT_AND_RET_DBG(
@@ -179,24 +178,23 @@ static int check_class(ir_type *tp)
                        show_ent_overwrite_cnt(mem)
                );
 
-               for (j = get_entity_n_overwrites(mem) - 1; j >= 0; --j) {
+               for (j = 0, m = get_entity_n_overwrites(mem); j < m; ++j) {
                        ir_entity *ovw = get_entity_overwrites(mem, j);
-                       /*printf(" overwrites: "); DDME(ovw);*/
+                       size_t    k, n_super;
+
                        /* Check whether ovw is member of one of tp's supertypes. If so,
-                       the representation is correct. */
-                       found = 0;
-                       for (k = get_class_n_supertypes(tp) - 1; k >= 0; --k) {
-                               if (get_class_member_index(get_class_supertype(tp, k), ovw) != (size_t)-1) {
-                                       found = 1;
+                          the representation is correct. */
+                       for (k = 0, n_super = get_class_n_supertypes(tp); k < n_super; ++k) {
+                               if (get_class_member_index(get_class_supertype(tp, k), ovw) != INVALID_MEMBER_INDEX) {
+                                       ASSERT_AND_RET_DBG(
+                                               0,
+                                               "overwrites an entity not contained in direct supertype",
+                                               error_ent_not_cont,
+                                               show_ent_not_supertp(mem, ovw)
+                                       );
                                        break;
                                }
                        }
-                       ASSERT_AND_RET_DBG(
-                               found,
-                               "overwrites an entity not contained in direct supertype",
-                               error_ent_not_cont,
-                               show_ent_not_supertp(mem, ovw)
-                       );
                }
        }
        return 0;
@@ -205,16 +203,16 @@ static int check_class(ir_type *tp)
 /**
  * Check an array.
  */
-static int check_array(ir_type *tp)
+static int check_array(const ir_type *tp)
 {
-       int i, n_dim = get_array_n_dimensions(tp);
+       size_t i, n_dim = get_array_n_dimensions(tp);
 
        for (i = 0; i < n_dim; ++i) {
                ASSERT_AND_RET_DBG(
                        has_array_lower_bound(tp, i) || has_array_upper_bound(tp, i),
                        "array bound missing",
                        1,
-                       ir_fprintf(stderr, "%+F in dimension %d\n", tp, i)
+                       ir_fprintf(stderr, "%+F in dimension %zu\n", tp, i)
                );
        }
        return 0;
@@ -434,7 +432,7 @@ int tr_verify(void)
        ir_type      *constructors;
        ir_type      *destructors;
        ir_type      *thread_locals;
-       int           i;
+       size_t        i, n;
        ir_segment_t  s;
 
        if (empty == NULL)
@@ -455,7 +453,7 @@ int tr_verify(void)
        }
 
        constructors = get_segment_type(IR_SEGMENT_CONSTRUCTORS);
-       for (i = get_compound_n_members(constructors)-1; i >= 0; --i) {
+       for (i = 0, n = get_compound_n_members(constructors); i < n; ++i) {
                const ir_entity *entity = get_compound_member(constructors, i);
                ASSERT_AND_RET(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER,
                               "entity without LINKAGE_HIDDEN_USER in constructors is pointless",
@@ -465,7 +463,7 @@ int tr_verify(void)
                               "entity in constructors should have ld_ident=''", 1);
        }
        destructors = get_segment_type(IR_SEGMENT_DESTRUCTORS);
-       for (i = get_compound_n_members(destructors)-1; i >= 0; --i) {
+       for (i = 0, n = get_compound_n_members(destructors); i < n; ++i) {
                const ir_entity *entity = get_compound_member(destructors, i);
                ASSERT_AND_RET(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER,
                               "entity without LINKAGE_HIDDEN_USER in destructors is pointless",
@@ -475,7 +473,7 @@ int tr_verify(void)
                               "entity in destructors should have ld_ident=''", 1);
        }
        thread_locals = get_segment_type(IR_SEGMENT_THREAD_LOCAL);
-       for (i = get_compound_n_members(thread_locals)-1; i >= 0; --i) {
+       for (i = 0, n = get_compound_n_members(thread_locals); i < n; ++i) {
                const ir_entity *entity = get_compound_member(thread_locals, i);
                /* this is odd and should not be allowed I think */
                ASSERT_AND_RET(!is_method_entity(entity),
index 43a4d62..3c22704 100644 (file)
@@ -303,7 +303,7 @@ unsigned get_type_alignment_bytes(ir_type *tp)
        else if (is_Array_type(tp))
                align = get_type_alignment_bytes(get_array_element_type(tp));
        else if (is_compound_type(tp)) {
-               int i, n = get_compound_n_members(tp);
+               size_t i, n = get_compound_n_members(tp);
 
                align = 0;
                for (i = 0; i < n; ++i) {
@@ -763,9 +763,9 @@ ir_type *new_type_class(ident *name)
 
 void free_class_entities(ir_type *clss)
 {
-       int i;
+       size_t i, n;
        assert(clss && (clss->type_op == type_class));
-       for (i = get_class_n_members(clss) - 1; i >= 0; --i)
+       for (i = 0, n = get_class_n_members(clss); i < n; ++i)
                free_entity(get_class_member(clss, i));
        /* do NOT free the type info here. It belongs to another class */
 }
@@ -811,7 +811,7 @@ size_t get_class_member_index(const ir_type *clss, ir_entity *mem)
                if (get_class_member(clss, i) == mem)
                        return i;
        }
-       return (size_t)-1;
+       return INVALID_MEMBER_INDEX;
 }
 
 ir_entity *(get_class_member)(const ir_type *clss, size_t pos)
@@ -821,12 +821,13 @@ ir_entity *(get_class_member)(const ir_type *clss, size_t pos)
 
 ir_entity *get_class_member_by_name(ir_type *clss, ident *name)
 {
-       int i, n_mem;
+       size_t i, n_mem;
        assert(clss && (clss->type_op == type_class));
        n_mem = get_class_n_members(clss);
        for (i = 0; i < n_mem; ++i) {
                ir_entity *mem = get_class_member(clss, i);
-               if (get_entity_ident(mem) == name) return mem;
+               if (get_entity_ident(mem) == name)
+                       return mem;
        }
        return NULL;
 }
@@ -1074,9 +1075,9 @@ ir_type *new_type_struct(ident *name)
 
 void free_struct_entities(ir_type *strct)
 {
-       int i;
+       size_t i, n;
        assert(strct && (strct->type_op == type_struct));
-       for (i = get_struct_n_members(strct)-1; i >= 0; --i)
+       for (i = 0, n = get_struct_n_members(strct); i < n; ++i)
                free_entity(get_struct_member(strct, i));
 }
 
@@ -1173,14 +1174,14 @@ void set_struct_size(ir_type *tp, unsigned size)
  * @param len     number of fields
  * @param tps     array of field types with length len
  */
-static ir_type *build_value_type(char const* name, int len, tp_ent_pair *tps)
+static ir_type *build_value_type(char const* name, size_t len, tp_ent_pair *tps)
 {
-       int i;
+       size_t i;
        ir_type *res = new_type_struct(new_id_from_str(name));
        res->flags |= tf_value_param_type;
        /* Remove type from type list.  Must be treated differently than other types. */
        remove_irp_type(res);
-       for (i = 0; i < len; i++) {
+       for (i = 0; i < len; ++i) {
                ident *id = tps[i].param_name;
 
                /* use res as default if corresponding type is not yet set. */
@@ -1534,9 +1535,9 @@ ir_type *new_type_union(ident *name)
 
 void free_union_entities(ir_type *uni)
 {
-       int i;
+       size_t i, n;
        assert(uni && (uni->type_op == type_union));
-       for (i = get_union_n_members(uni) - 1; i >= 0; --i)
+       for (i = 0, n = get_union_n_members(uni); i < n; ++i)
                free_entity(get_union_member(uni, i));
 }
 
@@ -2183,7 +2184,7 @@ ir_type *new_type_frame(void)
 ir_type *clone_frame_type(ir_type *type)
 {
        ir_type *res;
-       int     i, n;
+       size_t  i, n;
 
        assert(is_frame_type(type));
        /* the entity link resource should be allocated if this function is called */
@@ -2262,7 +2263,7 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
        ident *name;
        char buf[32];
        unsigned frame_align;
-       int i, offset, frame_size;
+       int offset, frame_size;
        static unsigned area_cnt = 0;
        static ir_type *a_byte = NULL;
 
@@ -2287,8 +2288,9 @@ ir_entity *frame_alloc_area(ir_type *frame_type, int size, unsigned alignment,
 
        frame_size = get_type_size_bytes(frame_type);
        if (at_start) {
+               size_t i, n;
                /* fix all offsets so far */
-               for (i = get_class_n_members(frame_type) - 1; i >= 0; --i) {
+               for (i = 0, n = get_class_n_members(frame_type); i < n; ++i) {
                        ir_entity *ent = get_class_member(frame_type, i);
 
                        set_entity_offset(ent, get_entity_offset(ent) + size);
index 71b0028..d645b12 100644 (file)
@@ -90,7 +90,7 @@ static void do_type_walk(type_or_ent tore,
                          type_walk_func *post,
                          void *env)
 {
-       int         i, n_types, n_mem;
+       size_t      i, n_types, n_mem;
        ir_entity   *ent = NULL;
        ir_type     *tp = NULL;
        ir_node     *n;