From 9e31d4eab3ffb00fae7791ed224ea27fbca2eade Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Sun, 6 Mar 2011 01:34:36 +0100 Subject: [PATCH] Fixed size_t related warnings. --- ir/be/arm/bearch_arm.c | 3 +-- ir/be/bedomfront.c | 10 +++++----- ir/be/begnuas.c | 8 ++++---- ir/be/beloopana.c | 6 +++--- ir/be/bemain.c | 11 ++++++----- ir/be/benode.c | 2 +- ir/be/beprefalloc.c | 14 +++++++------- ir/be/ia32/bearch_ia32.c | 11 +++++------ ir/be/sparc/bearch_sparc.c | 3 +-- ir/ident/mangle.c | 11 ++++++----- ir/opt/ircgopt.c | 6 +++--- ir/opt/opt_frame.c | 14 ++++++++------ 12 files changed, 50 insertions(+), 49 deletions(-) diff --git a/ir/be/arm/bearch_arm.c b/ir/be/arm/bearch_arm.c index 89c4a91d4..dd03ae51a 100644 --- a/ir/be/arm/bearch_arm.c +++ b/ir/be/arm/bearch_arm.c @@ -538,8 +538,7 @@ static int arm_is_valid_clobber(const char *clobber) static void arm_lower_for_target(void) { - int i; - int n_irgs = get_irp_n_irgs(); + size_t i, n_irgs = get_irp_n_irgs(); lower_params_t params = { 4, /* def_ptr_alignment */ diff --git a/ir/be/bedomfront.c b/ir/be/bedomfront.c index dd54d1d74..6736b3487 100644 --- a/ir/be/bedomfront.c +++ b/ir/be/bedomfront.c @@ -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. * @@ -72,7 +72,7 @@ static ir_node **compute_df(ir_node *blk, be_dom_front_info_t *info) const ir_edge_t *edge; ir_node **df_list = NEW_ARR_F(ir_node *, 0); ir_node **df; - int len; + size_t len; /* Add local dominance frontiers */ foreach_block_succ(blk, edge) { @@ -89,11 +89,11 @@ static ir_node **compute_df(ir_node *blk, be_dom_front_info_t *info) * dominated by the given block. */ for (c = get_Block_dominated_first(blk); c; c = get_Block_dominated_next(c)) { - int i; + size_t i; ir_node **df_c_list = compute_df(c, info); - for (i = ARR_LEN(df_c_list) - 1; i >= 0; --i) { - ir_node *w = df_c_list[i]; + for (i = ARR_LEN(df_c_list); i > 0;) { + ir_node *w = df_c_list[--i]; if (get_idom(w) != blk) ARR_APP1(ir_node *, df_list, w); } diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c index 6c2165bb1..f09bddba0 100644 --- a/ir/be/begnuas.c +++ b/ir/be/begnuas.c @@ -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. * @@ -977,9 +977,9 @@ static size_t get_initializer_size(const ir_initializer_t *initializer, if (!is_type_variable_size(type)) { return get_type_size_bytes(type); } else { - unsigned n_entries + size_t n_entries = get_initializer_compound_n_entries(initializer); - unsigned i; + size_t i; unsigned initializer_size = get_type_size_bytes(type); for (i = 0; i < n_entries; ++i) { ir_entity *entity = get_compound_member(type, i); @@ -1620,7 +1620,7 @@ static void emit_global(be_gas_decl_env_t *env, const ir_entity *entity) */ static void be_gas_emit_globals(ir_type *gt, be_gas_decl_env_t *env) { - int i, n = get_compound_n_members(gt); + size_t i, n = get_compound_n_members(gt); for (i = 0; i < n; i++) { ir_entity *ent = get_compound_member(gt, i); diff --git a/ir/be/beloopana.c b/ir/be/beloopana.c index 9074beecd..9c33d7673 100644 --- a/ir/be/beloopana.c +++ b/ir/be/beloopana.c @@ -114,11 +114,11 @@ static unsigned be_compute_block_pressure(const ir_graph *irg, static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop, const arch_register_class_t *cls) { - int i, max; + size_t i, max; unsigned pressure; be_loop_info_t *entry, key; - DBG((dbg, LEVEL_1, "\nProcessing Loop %d\n", loop->loop_nr)); + DBG((dbg, LEVEL_1, "\nProcessing Loop %ld\n", loop->loop_nr)); assert(get_loop_n_elements(loop) > 0); pressure = 0; @@ -136,7 +136,7 @@ static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop, pressure = MAX(pressure, son_pressure); } - DBG((dbg, LEVEL_1, "Done with loop %d, pressure %u for class %s\n", loop->loop_nr, pressure, cls->name)); + DBG((dbg, LEVEL_1, "Done with loop %ld, pressure %u for class %s\n", loop->loop_nr, pressure, cls->name)); /* update info in set */ key.loop = loop; diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 72ffb7b13..77d5337dd 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -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. * @@ -469,12 +469,12 @@ ir_timer_t *be_timers[T_LAST+1]; void be_lower_for_target(void) { - int i; + size_t i; isa_if->lower_for_target(); /* set the phase to low */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - ir_graph *irg = get_irp_irg(i); + for (i = get_irp_n_irgs(); i > 0;) { + ir_graph *irg = get_irp_irg(--i); set_irg_phase_state(irg, phase_low); } set_irp_phase_state(phase_low); @@ -492,7 +492,8 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) { static const char suffix[] = ".prof"; - int i, num_birgs, stat_active = 0; + size_t i, num_birgs; + int stat_active = 0; be_main_env_t env; char prof_filename[256]; be_irg_t *birgs; diff --git a/ir/be/benode.c b/ir/be/benode.c index 55080153b..8a515635f 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -1234,7 +1234,7 @@ static void copy_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node) new_info->flags = old_info->flags; if (old_info->out_infos != NULL) { - unsigned n_outs = ARR_LEN(old_info->out_infos); + size_t n_outs = ARR_LEN(old_info->out_infos); /* need dyanmic out infos? */ if (be_is_Perm(new_node)) { new_info->out_infos = NEW_ARR_F(reg_out_info_t, n_outs); diff --git a/ir/be/beprefalloc.c b/ir/be/beprefalloc.c index ec4c89477..d3ce882d7 100644 --- a/ir/be/beprefalloc.c +++ b/ir/be/beprefalloc.c @@ -93,7 +93,7 @@ static unsigned n_regs; static unsigned *normal_regs; static int *congruence_classes; static ir_node **block_order; -static int n_block_order; +static size_t n_block_order; static int create_preferences = true; static int create_congruence_classes = true; static int propagate_phi_registers = true; @@ -1736,13 +1736,13 @@ static int cmp_block_costs(const void *d1, const void *d2) static void determine_block_order(void) { - int i; + size_t i; ir_node **blocklist = be_get_cfgpostorder(irg); - int n_blocks = ARR_LEN(blocklist); + size_t n_blocks = ARR_LEN(blocklist); int dfs_num = 0; pdeq *worklist = new_pdeq(); ir_node **order = XMALLOCN(ir_node*, n_blocks); - int order_p = 0; + size_t order_p = 0; /* clear block links... */ for (i = 0; i < n_blocks; ++i) { @@ -1753,9 +1753,9 @@ static void determine_block_order(void) /* walk blocks in reverse postorder, the costs for each block are the * sum of the costs of its predecessors (excluding the costs on backedges * which we can't determine) */ - for (i = n_blocks-1; i >= 0; --i) { + for (i = n_blocks; i > 0;) { block_costs_t *cost_info; - ir_node *block = blocklist[i]; + ir_node *block = blocklist[--i]; float execfreq = (float)get_block_execfreq(execfreqs, block); float costs = execfreq; @@ -1840,7 +1840,7 @@ static void determine_block_order(void) */ static void be_pref_alloc_cls(void) { - int i; + size_t i; lv = be_assure_liveness(irg); be_liveness_assure_sets(lv); diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index 5dabcb23a..0dd54ba9f 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -1426,10 +1426,10 @@ static const tarval_mode_info mo_integer = { */ static void set_tarval_output_modes(void) { - int i; + size_t i; - for (i = get_irp_n_modes() - 1; i >= 0; --i) { - ir_mode *mode = get_irp_mode(i); + for (i = get_irp_n_modes(); i > 0;) { + ir_mode *mode = get_irp_mode(--i); if (mode_is_int(mode)) set_tarval_mode_output_option(mode, &mo_integer); @@ -1518,7 +1518,7 @@ static void init_asm_constraints(void) static arch_env_t *ia32_init(FILE *file_handle) { ia32_isa_t *isa = XMALLOC(ia32_isa_t); - int i, n; + size_t i, n; set_tarval_output_modes(); @@ -2033,8 +2033,7 @@ static ir_node *ia32_create_set(ir_node *cond) static void ia32_lower_for_target(void) { - int n_irgs = get_irp_n_irgs(); - int i; + size_t i, n_irgs = get_irp_n_irgs(); lower_mode_b_config_t lower_mode_b_config = { mode_Iu, /* lowered mode */ ia32_create_set, diff --git a/ir/be/sparc/bearch_sparc.c b/ir/be/sparc/bearch_sparc.c index 3adab3684..b5a16a1f1 100644 --- a/ir/be/sparc/bearch_sparc.c +++ b/ir/be/sparc/bearch_sparc.c @@ -537,8 +537,7 @@ static ir_node *sparc_create_set(ir_node *cond) static void sparc_lower_for_target(void) { - int i; - int n_irgs = get_irp_n_irgs(); + size_t i, n_irgs = get_irp_n_irgs(); lower_mode_b_config_t lower_mode_b_config = { mode_Iu, sparc_create_set, diff --git a/ir/ident/mangle.c b/ir/ident/mangle.c index 28a5e3d6c..41177fd72 100644 --- a/ir/ident/mangle.c +++ b/ir/ident/mangle.c @@ -29,6 +29,7 @@ #include "ident_t.h" #include "obst.h" +#include "irprintf.h" /* Make types visible to allow most efficient access */ #include "entity_t.h" @@ -132,17 +133,17 @@ ident *id_decorate_win32_c_fkt(const ir_entity *ent, ident *id) ir_type *tp = get_entity_type(ent); unsigned cc_mask = get_method_calling_convention(tp); char buf[16]; - int size, i; if (IS_CDECL(cc_mask)) return id_mangle3("_", id, ""); else if (IS_STDCALL(cc_mask)) { - size = 0; - for (i = get_method_n_params(tp) - 1; i >= 0; --i) { - size += get_type_size_bytes(get_method_param_type(tp, i)); + size_t i, size = 0; + + for (i = get_method_n_params(tp); i > 0;) { + size += get_type_size_bytes(get_method_param_type(tp, --i)); } - snprintf(buf, sizeof(buf), "@%d", size); + ir_snprintf(buf, sizeof(buf), "@%zu", size); if (cc_mask & cc_reg_param) return id_mangle3("@", id, buf); diff --git a/ir/opt/ircgopt.c b/ir/opt/ircgopt.c index 7d35a7707..c95e0a52a 100644 --- a/ir/opt/ircgopt.c +++ b/ir/opt/ircgopt.c @@ -102,11 +102,11 @@ void gc_irgs(size_t n_keep, ir_entity ** keep_arr) /* iterate calls */ for (node = (ir_node*)get_irn_link(node); node != NULL; node = (ir_node*)get_irn_link(node)) { - int i; + size_t i; assert(is_Call(node)); - for (i = get_Call_n_callees(node) - 1; i >= 0; --i) { - ir_entity *ent = get_Call_callee(node, i); + for (i = get_Call_n_callees(node); i > 0;) { + ir_entity *ent = get_Call_callee(node, --i); if (get_entity_irg(ent) && get_entity_link(ent) != MARK) { set_entity_link(ent, MARK); diff --git a/ir/opt/opt_frame.c b/ir/opt/opt_frame.c index f614f1bdc..258d4aebb 100644 --- a/ir/opt/opt_frame.c +++ b/ir/opt/opt_frame.c @@ -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. * @@ -44,7 +44,7 @@ void opt_frame_irg(ir_graph *irg) ir_type *frame_tp = get_irg_frame_type(irg); ir_entity *ent, *list; ir_node *frame, *sel; - int i, n = get_class_n_members(frame_tp); + size_t i, n = get_class_n_members(frame_tp); if (n <= 0) return; @@ -52,8 +52,8 @@ void opt_frame_irg(ir_graph *irg) irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK); /* clear all entity links */ - for (i = n - 1; i >= 0; --i) { - ent = get_class_member(frame_tp, i); + for (i = n; i > 0;) { + ent = get_class_member(frame_tp, --i); set_entity_link(ent, NULL); } @@ -72,6 +72,8 @@ void opt_frame_irg(ir_graph *irg) } } } else { + int i; + /* use traditionally out edges */ assure_irg_outs(irg); @@ -89,8 +91,8 @@ void opt_frame_irg(ir_graph *irg) /* link unused ones */ list = NULL; - for (i = n - 1; i >= 0; --i) { - ent = get_class_member(frame_tp, i); + for (i = n; i > 0;) { + ent = get_class_member(frame_tp, --i); /* beware of inner functions: those are NOT unused */ if (get_entity_link(ent) == NULL && !is_method_entity(ent)) { set_entity_link(ent, list); -- 2.20.1