From 0a4048fbaae21a969b0f03b066dde30a06968814 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 8 Feb 2011 18:08:39 +0000 Subject: [PATCH] further spread size_t [r28337] --- include/libfirm/compound_path.h | 32 +++++----- include/libfirm/irloop.h | 18 +++--- include/libfirm/irprog.h | 25 ++++---- ir/ana/interval_analysis.c | 2 +- ir/ana/ircfscc.c | 2 +- ir/ana/irloop.c | 51 ++++++++-------- ir/ana/irloop_t.h | 22 +++---- ir/ana/irscc.c | 4 +- ir/be/beabi.c | 10 ++-- ir/be/beabihelper.c | 34 +++++------ ir/be/beinfo.c | 7 ++- ir/be/beuses.c | 34 ++++++----- ir/be/beuses.h | 11 ++-- ir/ir/irargs.c | 4 +- ir/ir/irdump.c | 14 +++-- ir/ir/irdump_t.h | 2 +- ir/ir/irdumptxt.c | 10 ++-- ir/ir/irgraph.c | 2 +- ir/ir/irgwalk.c | 4 +- ir/ir/irpass.c | 9 ++- ir/ir/irprog.c | 34 +++++------ ir/ir/irprog_t.h | 27 +++++---- ir/tr/compound_path.c | 101 ++++++++++++++++---------------- ir/tr/compound_path_t.h | 6 +- 24 files changed, 242 insertions(+), 223 deletions(-) diff --git a/include/libfirm/compound_path.h b/include/libfirm/compound_path.h index 251530f13..ad415fe0b 100644 --- a/include/libfirm/compound_path.h +++ b/include/libfirm/compound_path.h @@ -36,7 +36,7 @@ typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path * @deprecated * Creates a new compound graph path of given length. */ -FIRM_API compound_graph_path *new_compound_graph_path(ir_type *tp, int length); +FIRM_API compound_graph_path *new_compound_graph_path(ir_type *tp, size_t length); /** * @deprecated @@ -54,32 +54,32 @@ FIRM_API void free_compound_graph_path(compound_graph_path *gr); * @deprecated * Returns the length of a graph path */ -FIRM_API int get_compound_graph_path_length(const compound_graph_path *gr); +FIRM_API size_t get_compound_graph_path_length(const compound_graph_path *gr); /** * @deprecated * Get the entity node of an compound graph path at position pos. */ -ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos); +ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, size_t pos); /** * @deprecated * Set the entity node of an compound graph path at position pos. */ -FIRM_API void set_compound_graph_path_node(compound_graph_path *gr, int pos, +FIRM_API void set_compound_graph_path_node(compound_graph_path *gr, size_t pos, ir_entity *node); /** * @deprecated * Get the index of an compound graph path at position pos. */ -FIRM_API int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos); +FIRM_API long get_compound_graph_path_array_index(const compound_graph_path *gr, size_t pos); /** * @deprecated * Set the index of an compound graph path at position pos. */ -FIRM_API void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index); +FIRM_API void set_compound_graph_path_array_index(compound_graph_path *gr, size_t pos, long index); /** * @deprecated @@ -92,7 +92,7 @@ FIRM_API ir_type *get_compound_graph_path_type(const compound_graph_path *gr); * Checks whether the path up to pos is correct. If the path contains a NULL, * assumes the path is not complete and returns non-zero. */ -FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, int pos); +FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, size_t pos); /** * @deprecated @@ -100,13 +100,13 @@ FIRM_API int is_proper_compound_graph_path(compound_graph_path *gr, int pos); * corresponding access path to the member of the compound. */ FIRM_API void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path); -FIRM_API void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, int pos); +FIRM_API void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, size_t pos); /** * @deprecated * Returns the access path for value at position pos. */ -FIRM_API compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, int pos); +FIRM_API compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, size_t pos); /** * @deprecated @@ -137,14 +137,14 @@ FIRM_API void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *me * @deprecated * Returns the last member in the path */ -FIRM_API ir_entity *get_compound_ent_value_member(const ir_entity *ent, int pos); +FIRM_API ir_entity *get_compound_ent_value_member(const ir_entity *ent, size_t pos); /** * @deprecated * Sets the path at pos 0 */ FIRM_API void set_compound_ent_value(ir_entity *ent, ir_node *val, - ir_entity *member, int pos); + ir_entity *member, size_t pos); /** * @deprecated @@ -155,7 +155,7 @@ FIRM_API void set_compound_ent_value(ir_entity *ent, ir_node *val, * fits into the given array size. Does not test whether the * values have the proper mode for the array. */ -FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, int num_vals); +FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, size_t num_vals); /** * @deprecated @@ -166,7 +166,7 @@ FIRM_API void set_array_entity_values(ir_entity *ent, ir_tarval **values, int nu * @param ent Any entity of compound type with at least pos initialization values. * @param pos The position of the value for which the offset is requested. */ -FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, int pos); +FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, size_t pos); /** * @deprecated @@ -178,20 +178,20 @@ FIRM_API unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *e * @param ent Any entity of compound type with at least pos initialization values. * @param pos The position of the value for which the offset is requested. */ -FIRM_API unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos); +FIRM_API unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, size_t pos); /** * @deprecated * Returns the number of constant values needed to initialize the entity. * Asserts if the entity has variability_uninitialized. */ -FIRM_API int get_compound_ent_n_values(const ir_entity *ent); +FIRM_API size_t get_compound_ent_n_values(const ir_entity *ent); /** * @deprecated * Returns a constant value given the position. */ -FIRM_API ir_node *get_compound_ent_value(const ir_entity *ent, int pos); +FIRM_API ir_node *get_compound_ent_value(const ir_entity *ent, size_t pos); /** * @deprecated diff --git a/include/libfirm/irloop.h b/include/libfirm/irloop.h index 5b91b2fe0..5efa631fa 100644 --- a/include/libfirm/irloop.h +++ b/include/libfirm/irloop.h @@ -81,38 +81,38 @@ FIRM_API ir_loop *get_irn_loop(const ir_node *n); /** Returns outer loop, itself if outermost. */ FIRM_API ir_loop *get_loop_outer_loop(const ir_loop *loop); /** Returns nesting depth of this loop */ -FIRM_API int get_loop_depth(const ir_loop *loop); +FIRM_API unsigned get_loop_depth(const ir_loop *loop); /* Sons are the inner loops contained in this loop. */ /** Returns the number of inner loops */ -FIRM_API int get_loop_n_sons(const ir_loop *loop); +FIRM_API size_t get_loop_n_sons(const ir_loop *loop); /** Returns the pos`th son loop (inner loop) of a loop. Returns NULL if there is not a pos`th loop_node. */ -FIRM_API ir_loop *get_loop_son(ir_loop *loop, int pos); +FIRM_API ir_loop *get_loop_son(ir_loop *loop, size_t pos); /** Returns the number of nodes contained in loop. */ -FIRM_API int get_loop_n_nodes(const ir_loop *loop); +FIRM_API size_t get_loop_n_nodes(const ir_loop *loop); /** Returns the pos`th ir_node of a loop. Returns NULL if there is not a pos`th ir_node. */ -FIRM_API ir_node *get_loop_node(const ir_loop *loop, int pos); +FIRM_API ir_node *get_loop_node(const ir_loop *loop, size_t pos); /** Returns the number of elements contained in loop. */ -FIRM_API int get_loop_n_elements(const ir_loop *loop); +FIRM_API size_t get_loop_n_elements(const ir_loop *loop); /** Returns a loop element. A loop element can be interpreted as a kind pointer, an ir_node* or an ir_loop*. */ -FIRM_API loop_element get_loop_element(const ir_loop *loop, int pos); +FIRM_API loop_element get_loop_element(const ir_loop *loop, size_t pos); /** Returns the element number of the loop son in loop. * Returns -1 if not found. O(|elements|). */ -FIRM_API int get_loop_element_pos(const ir_loop *loop, void *le); +FIRM_API size_t get_loop_element_pos(const ir_loop *loop, void *le); /** Returns a unique node number for the loop node to make output readable. If libfirm_debug is not set it returns the loop cast to int. */ -FIRM_API int get_loop_loop_nr(const ir_loop *loop); +FIRM_API long get_loop_loop_nr(const ir_loop *loop); /** A field to connect additional information to a loop. */ FIRM_API void set_loop_link(ir_loop *loop, void *link); diff --git a/include/libfirm/irprog.h b/include/libfirm/irprog.h index 28f6bd93b..0a0fb1e7e 100644 --- a/include/libfirm/irprog.h +++ b/include/libfirm/irprog.h @@ -41,6 +41,7 @@ #ifndef FIRM_IR_IRPROG_H #define FIRM_IR_IRPROG_H +#include #include "firm_types.h" #include "irgraph.h" #include "begin.h" @@ -142,13 +143,13 @@ FIRM_API void remove_irp_irg(ir_graph *irg); FIRM_API int get_irp_last_idx(void); /** Returns the number of ir graphs in the irp. */ -FIRM_API int get_irp_n_irgs(void); +FIRM_API size_t get_irp_n_irgs(void); /** Returns the ir graph at position pos in the irp. */ -FIRM_API ir_graph *get_irp_irg(int pos); +FIRM_API ir_graph *get_irp_irg(size_t pos); /** Sets the ir graph at position pos. */ -FIRM_API void set_irp_irg(int pos, ir_graph *irg); +FIRM_API void set_irp_irg(size_t pos, ir_graph *irg); /** * Returns the type containing the entities for a segment. @@ -188,25 +189,25 @@ FIRM_API void remove_irp_type(ir_type *typ); * Returns the number of all types in the irp. * @deprecated */ -FIRM_API int get_irp_n_types(void); +FIRM_API size_t get_irp_n_types(void); /** * Returns the type at position pos in the irp. * @deprecated */ -FIRM_API ir_type *get_irp_type(int pos); +FIRM_API ir_type *get_irp_type(size_t pos); /** * Overwrites the type at position pos with another type. * @deprecated */ -FIRM_API void set_irp_type(int pos, ir_type *typ); +FIRM_API void set_irp_type(size_t pos, ir_type *typ); /** Returns the number of all modes in the irp. */ -FIRM_API int get_irp_n_modes(void); +FIRM_API size_t get_irp_n_modes(void); /** Returns the mode at position pos in the irp. */ -FIRM_API ir_mode *get_irp_mode(int pos); +FIRM_API ir_mode *get_irp_mode(size_t pos); /** Adds opcode to the list of opcodes in irp. */ FIRM_API void add_irp_opcode(ir_op *opcode); @@ -216,10 +217,10 @@ FIRM_API void add_irp_opcode(ir_op *opcode); FIRM_API void remove_irp_opcode(ir_op *opcode); /** Returns the number of all opcodes in the irp. */ -FIRM_API int get_irp_n_opcodes(void); +FIRM_API size_t get_irp_n_opcodes(void); /** Returns the opcode at position pos in the irp. */ -FIRM_API ir_op *get_irp_opcode(int pos); +FIRM_API ir_op *get_irp_opcode(size_t pos); /** Sets the generic function pointer of all opcodes to NULL */ FIRM_API void clear_irp_opcodes_generic_func(void); @@ -277,10 +278,10 @@ FIRM_API ir_label_t get_irp_next_label_nr(void); FIRM_API void add_irp_asm(ident *asm_string); /** Return the number of global asm includes. */ -FIRM_API int get_irp_n_asms(void); +FIRM_API size_t get_irp_n_asms(void); /** Return the global asm include at position pos. */ -FIRM_API ident *get_irp_asm(int pos); +FIRM_API ident *get_irp_asm(size_t pos); #include "end.h" diff --git a/ir/ana/interval_analysis.c b/ir/ana/interval_analysis.c index 2d0ad8ec0..e5bc705c1 100644 --- a/ir/ana/interval_analysis.c +++ b/ir/ana/interval_analysis.c @@ -580,7 +580,7 @@ static void dump_interval_loop(FILE *F, ir_loop *l) fprintf(F, "graph: { title: \""); PRINT_LOOPID(l); - fprintf(F, "\" label: \"loop %d", get_loop_loop_nr(l)); + fprintf(F, "\" label: \"loop %ld", get_loop_loop_nr(l)); fprintf(F, " freq: %9.4lf", get_region_exec_freq(l)); fprintf(F, " n_outs: %d", get_region_n_outs(l)); fprintf(F, " n_exc_outs: %d", get_region_n_exc_outs(l)); diff --git a/ir/ana/ircfscc.c b/ir/ana/ircfscc.c index 5a1667895..38372a484 100644 --- a/ir/ana/ircfscc.c +++ b/ir/ana/ircfscc.c @@ -53,7 +53,7 @@ static int loop_node_cnt = 0; /** Counter to generate depth first numbering of visited nodes. */ static int current_dfn = 1; -static int max_loop_depth = 0; +static unsigned max_loop_depth = 0; void link_to_reg_end(ir_node *n, void *env); diff --git a/ir/ana/irloop.c b/ir/ana/irloop.c index 81306df21..a17008409 100644 --- a/ir/ana/irloop.c +++ b/ir/ana/irloop.c @@ -24,7 +24,7 @@ * @date 7.2002 * @version $Id: irloop_t.h 17143 2008-01-02 20:56:33Z beck $ */ -# include "config.h" +#include "config.h" #include #include @@ -95,13 +95,13 @@ ir_loop *(get_loop_outer_loop)(const ir_loop *loop) } /* Returns nesting depth of this loop */ -int (get_loop_depth)(const ir_loop *loop) +unsigned (get_loop_depth)(const ir_loop *loop) { return _get_loop_depth(loop); } /* Returns the number of inner loops */ -int (get_loop_n_sons)(const ir_loop *loop) +size_t (get_loop_n_sons)(const ir_loop *loop) { return _get_loop_n_sons(loop); } @@ -109,78 +109,75 @@ int (get_loop_n_sons)(const ir_loop *loop) /* Returns the pos`th loop_node-child * * TODO: This method isn`t very efficient ! * * Returns NULL if there isn`t a pos`th loop_node */ -ir_loop *get_loop_son(ir_loop *loop, int pos) +ir_loop *get_loop_son(ir_loop *loop, size_t pos) { size_t child_nr = 0; - int loop_nr = -1; + size_t loop_nr = 0; assert(loop && loop->kind == k_ir_loop); for (child_nr = 0; child_nr < ARR_LEN(loop->children); ++child_nr) { - if (*(loop->children[child_nr].kind) == k_ir_loop) - loop_nr++; + if (*(loop->children[child_nr].kind) != k_ir_loop) + continue; if (loop_nr == pos) return loop->children[child_nr].son; + loop_nr++; } return NULL; } /* Returns the number of nodes in the loop */ -int get_loop_n_nodes(const ir_loop *loop) +size_t get_loop_n_nodes(const ir_loop *loop) { - assert(loop); assert(loop->kind == k_ir_loop); + assert(loop); + assert(loop->kind == k_ir_loop); return loop->n_nodes; } /* Returns the pos'th ir_node-child * * TODO: This method isn't very efficient ! * * Returns NULL if there isn't a pos'th ir_node */ -ir_node *get_loop_node(const ir_loop *loop, int pos) +ir_node *get_loop_node(const ir_loop *loop, size_t pos) { + size_t node_nr = 0; size_t child_nr; - int node_nr = -1; assert(loop && loop->kind == k_ir_loop); assert(pos < get_loop_n_nodes(loop)); for (child_nr = 0; child_nr < ARR_LEN(loop->children); ++child_nr) { - if (*(loop->children[child_nr].kind) == k_ir_node) - node_nr++; + if (*(loop->children[child_nr].kind) != k_ir_node) + continue; if (node_nr == pos) return loop -> children[child_nr].node; + node_nr++; } - panic("no child at pos found"); } /* Returns the number of elements contained in loop. */ -int get_loop_n_elements(const ir_loop *loop) +size_t get_loop_n_elements(const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); return(ARR_LEN(loop->children)); } -/* -Returns the pos`th loop element. -This may be a loop_node or a ir_node. The caller of this function has -to check the *(loop_element.kind) field for "k_ir_node" or "k_ir_loop" -and then select the appropriate "loop_element.node" or "loop_element.son". -*/ -loop_element get_loop_element(const ir_loop *loop, int pos) +loop_element get_loop_element(const ir_loop *loop, size_t pos) { assert(loop && loop->kind == k_ir_loop && pos < ARR_LEN(loop->children)); return(loop -> children[pos]); } -int get_loop_element_pos(const ir_loop *loop, void *le) +size_t get_loop_element_pos(const ir_loop *loop, void *le) { - int i, n; + size_t n; + size_t i; assert(loop && loop->kind == k_ir_loop); n = get_loop_n_elements(loop); for (i = 0; i < n; i++) if (get_loop_element(loop, i).node == le) return i; - return -1; + return (size_t)-1; } @@ -197,13 +194,13 @@ ir_loop *(get_irn_loop)(const ir_node *n) return _get_irn_loop(n); } -int get_loop_loop_nr(const ir_loop *loop) +long get_loop_loop_nr(const ir_loop *loop) { assert(loop && loop->kind == k_ir_loop); #ifdef DEBUG_libfirm return loop->loop_nr; #else - return (int)loop; + return (long)loop; #endif } diff --git a/ir/ana/irloop_t.h b/ir/ana/irloop_t.h index 661ea7bd5..8996a0a14 100644 --- a/ir/ana/irloop_t.h +++ b/ir/ana/irloop_t.h @@ -61,17 +61,17 @@ typedef enum loop_flags { * nodes in the loop. */ struct ir_loop { - firm_kind kind; /**< A type tag, set to k_ir_loop. */ - int depth; /**< Nesting depth */ - int n_sons; /**< Number of ir_nodes in array "children" */ - int n_nodes; /**< Number of loop_nodes in array "children" */ - unsigned flags; /**< a set of loop_flags_t */ + firm_kind kind; /**< A type tag, set to k_ir_loop. */ + unsigned depth; /**< Nesting depth */ + size_t n_sons; /**< Number of ir_nodes in array "children" */ + size_t n_nodes; /**< Number of loop_nodes in array "children" */ + unsigned flags; /**< a set of loop_flags_t */ struct ir_loop *outer_loop; /**< The outer loop */ loop_element *children; /**< Mixed flexible array: Contains sons and loop_nodes */ - ir_tarval *loop_iter_start; /**< counting loop: the start value */ - ir_tarval *loop_iter_end; /**< counting loop: the last value reached */ - ir_tarval *loop_iter_increment; /**< counting loop: the increment */ - ir_node *loop_iter_variable; /**< The iteration variable of counting loop.*/ + ir_tarval *loop_iter_start; /**< counting loop: the start value */ + ir_tarval *loop_iter_end; /**< counting loop: the last value reached */ + ir_tarval *loop_iter_increment; /**< counting loop: the increment */ + ir_node *loop_iter_variable; /**< The iteration variable of counting loop.*/ void *link; /**< link field. */ #ifdef DEBUG_libfirm @@ -129,13 +129,13 @@ static inline ir_loop *_get_loop_outer_loop(const ir_loop *loop) return loop->outer_loop; } -static inline int _get_loop_depth(const ir_loop *loop) +static inline unsigned _get_loop_depth(const ir_loop *loop) { assert(_is_ir_loop(loop)); return loop->depth; } -static inline int _get_loop_n_sons(const ir_loop *loop) +static inline size_t _get_loop_n_sons(const ir_loop *loop) { assert(_is_ir_loop(loop)); return loop->n_sons; diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index aa8b4fb42..8fa6b4145 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -58,7 +58,7 @@ static int loop_node_cnt = 0; /** Counter to generate depth first numbering of visited nodes. */ static int current_dfn = 1; -static int max_loop_depth = 0; +static unsigned max_loop_depth = 0; void link_to_reg_end(ir_node *n, void *env); void set_projx_link(ir_node *cb_projx, ir_node *end_projx); @@ -824,7 +824,7 @@ void free_loop_information(ir_graph *irg) void free_all_loop_information(void) { - int i; + size_t i; for (i = 0; i < get_irp_n_irgs(); i++) { free_loop_information(get_irp_irg(i)); } diff --git a/ir/be/beabi.c b/ir/be/beabi.c index 2adfa3af0..c6c37fa9e 100644 --- a/ir/be/beabi.c +++ b/ir/be/beabi.c @@ -363,6 +363,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) int *reg_param_idxs; int *stack_param_idx; int i, n, destroy_all_regs; + size_t s; dbg_info *dbgi; /* Let the isa fill out the abi description for that call node. */ @@ -580,8 +581,8 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) } /* add state registers ins */ - for (i = 0; i < ARR_LEN(states); ++i) { - const arch_register_t *reg = states[i]; + for (s = 0; s < ARR_LEN(states); ++s) { + const arch_register_t *reg = states[s]; const arch_register_class_t *cls = arch_register_get_class(reg); #if 0 ir_node *regnode = be_abi_reg_map_get(env->regs, reg); @@ -697,6 +698,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) { ir_node **in, *keep; int i; + size_t d; int n = 0; int curr_res_proj = pn_be_Call_first_res + n_reg_results; int n_ins; @@ -708,8 +710,8 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) set_irn_link(curr_sp, (void*) sp); in[n++] = curr_sp; - for (i = 0; i < ARR_LEN(destroyed_regs); ++i) { - const arch_register_t *reg = destroyed_regs[i]; + for (d = 0; d < ARR_LEN(destroyed_regs); ++d) { + const arch_register_t *reg = destroyed_regs[d]; ir_node *proj = new_r_Proj(low_call, reg->reg_class->mode, curr_res_proj); /* memorize the register in the link field. we need afterwards to set the register class of the keep correctly. */ diff --git a/ir/be/beabihelper.c b/ir/be/beabihelper.c index d511f915c..95c0635a4 100644 --- a/ir/be/beabihelper.c +++ b/ir/be/beabihelper.c @@ -52,7 +52,7 @@ typedef struct reg_flag_t { */ typedef struct register_state_mapping_t { ir_node **value_map; /**< mapping of state indices to values */ - int **reg_index_map; /**< mapping of regclass,regnum to an index + size_t **reg_index_map; /**< mapping of regclass,regnum to an index into the value_map */ reg_flag_t *regs; /**< registers (and memory values) that form a state */ @@ -90,15 +90,15 @@ static void prepare_rsm(register_state_mapping_t *rsm, ARR_APP1(reg_flag_t, rsm->regs, memory); rsm->value_map = NULL; - rsm->reg_index_map = XMALLOCN(int*, n_reg_classes); + rsm->reg_index_map = XMALLOCN(size_t*, n_reg_classes); for (c = 0; c < n_reg_classes; ++c) { const arch_register_class_t *cls = &arch_env->register_classes[c]; unsigned n_regs = arch_register_class_n_regs(cls); unsigned r; - rsm->reg_index_map[c] = XMALLOCN(int, n_regs); + rsm->reg_index_map[c] = XMALLOCN(size_t, n_regs); for (r = 0; r < n_regs; ++r) { - rsm->reg_index_map[c][r] = -1; + rsm->reg_index_map[c][r] = (size_t)-1; } } } @@ -150,7 +150,7 @@ static void rsm_clear_regs(register_state_mapping_t *rsm, unsigned r; for (r = 0; r < n_regs; ++r) { - rsm->reg_index_map[c][r] = -1; + rsm->reg_index_map[c][r] = (size_t)-1; } } ARR_RESIZE(reg_flag_t, rsm->regs, 0); @@ -170,13 +170,13 @@ static int rsm_add_reg(register_state_mapping_t *rsm, const arch_register_t *reg, arch_register_req_type_t flags) { - int input_idx = ARR_LEN(rsm->regs); + size_t input_idx = ARR_LEN(rsm->regs); int cls_idx = reg->reg_class->index; int reg_idx = reg->index; reg_flag_t regflag = { reg, flags }; /* we must not have used get_value yet */ - assert(rsm->reg_index_map[cls_idx][reg_idx] == -1); + assert(rsm->reg_index_map[cls_idx][reg_idx] == (size_t)-1); rsm->reg_index_map[cls_idx][reg_idx] = input_idx; ARR_APP1(reg_flag_t, rsm->regs, regflag); @@ -190,9 +190,9 @@ static int rsm_add_reg(register_state_mapping_t *rsm, /** * Retrieve the ir_node stored at the given index in the register state map. */ -static ir_node *rsm_get_value(register_state_mapping_t *rsm, int index) +static ir_node *rsm_get_value(register_state_mapping_t *rsm, size_t index) { - assert(0 <= index && index < ARR_LEN(rsm->value_map)); + assert(index < ARR_LEN(rsm->value_map)); return rsm->value_map[index]; } @@ -202,9 +202,9 @@ static ir_node *rsm_get_value(register_state_mapping_t *rsm, int index) static ir_node *rsm_get_reg_value(register_state_mapping_t *rsm, const arch_register_t *reg) { - int cls_idx = reg->reg_class->index; - int reg_idx = reg->index; - int input_idx = rsm->reg_index_map[cls_idx][reg_idx]; + int cls_idx = reg->reg_class->index; + int reg_idx = reg->index; + size_t input_idx = rsm->reg_index_map[cls_idx][reg_idx]; return rsm_get_value(rsm, input_idx); } @@ -212,10 +212,10 @@ static ir_node *rsm_get_reg_value(register_state_mapping_t *rsm, /** * Enter a ir_node at the given index in the register state map. */ -static void rsm_set_value(register_state_mapping_t *rsm, int index, +static void rsm_set_value(register_state_mapping_t *rsm, size_t index, ir_node *value) { - assert(0 <= index && index < ARR_LEN(rsm->value_map)); + assert(index < ARR_LEN(rsm->value_map)); rsm->value_map[index] = value; } @@ -225,9 +225,9 @@ static void rsm_set_value(register_state_mapping_t *rsm, int index, static void rsm_set_reg_value(register_state_mapping_t *rsm, const arch_register_t *reg, ir_node *value) { - int cls_idx = reg->reg_class->index; - int reg_idx = reg->index; - int input_idx = rsm->reg_index_map[cls_idx][reg_idx]; + int cls_idx = reg->reg_class->index; + int reg_idx = reg->index; + size_t input_idx = rsm->reg_index_map[cls_idx][reg_idx]; rsm_set_value(rsm, input_idx, value); } diff --git a/ir/be/beinfo.c b/ir/be/beinfo.c index 953458fdc..51f4327b1 100644 --- a/ir/be/beinfo.c +++ b/ir/be/beinfo.c @@ -80,7 +80,8 @@ int be_nodes_equal(ir_node *node1, ir_node *node2) const backend_info_t *info1 = be_get_info(node1); const backend_info_t *info2 = be_get_info(node2); size_t len = ARR_LEN(info1->out_infos); - size_t arity = get_irn_arity(node1); + int arity = get_irn_arity(node1); + int in; size_t i; if (ARR_LEN(info2->out_infos) != len) @@ -88,8 +89,8 @@ int be_nodes_equal(ir_node *node1, ir_node *node2) assert(arity == get_irn_arity(node2)); - for (i = 0; i < arity; ++i) { - if (info1->in_reqs[i] != info2->in_reqs[i]) + for (in = 0; in < arity; ++in) { + if (info1->in_reqs[in] != info2->in_reqs[in]) return false; } diff --git a/ir/be/beuses.c b/ir/be/beuses.c index 40849aee3..497c13605 100644 --- a/ir/be/beuses.c +++ b/ir/be/beuses.c @@ -50,10 +50,12 @@ #include "bearch.h" #include "beuses.h" +#define UNKNOWN_OUTERMOST_LOOP ((unsigned)-1) + typedef struct be_use_t { const ir_node *block; const ir_node *node; - int outermost_loop; + unsigned outermost_loop; unsigned next_use; ir_visited_t visited; } be_use_t; @@ -108,17 +110,17 @@ static const be_use_t *get_or_set_use_block(be_uses_t *env, // insert templ first as we might end in a loop in the get_next_use // call otherwise temp.next_use = USES_INFINITY; - temp.outermost_loop = -1; + temp.outermost_loop = UNKNOWN_OUTERMOST_LOOP; temp.visited = 0; result = (be_use_t*)set_insert(env->uses, &temp, sizeof(temp), hash); } - if (result->outermost_loop < 0 && result->visited < env->visited_counter) { + if (result->outermost_loop == UNKNOWN_OUTERMOST_LOOP && result->visited < env->visited_counter) { be_next_use_t next_use; result->visited = env->visited_counter; next_use = get_next_use(env, sched_first(block), def, 0); - if (next_use.outermost_loop >= 0) { + if (next_use.outermost_loop != UNKNOWN_OUTERMOST_LOOP) { result->next_use = next_use.time; result->outermost_loop = next_use.outermost_loop; DBG((env->dbg, LEVEL_5, "Setting nextuse of %+F in block %+F to %u (outermostloop %d)\n", @@ -279,15 +281,15 @@ static be_next_use_t get_next_use(be_uses_t *env, ir_node *from, } { - unsigned next_use = USES_INFINITY; - int outermost_loop; + unsigned next_use = USES_INFINITY; + unsigned outermost_loop; be_next_use_t result; - ir_loop *loop = get_irn_loop(block); - int loopdepth = get_loop_depth(loop); - int found_visited = 0; - int found_use = 0; - ir_graph *irg = get_irn_irg(block); - ir_node *startblock = get_irg_start_block(irg); + ir_loop *loop = get_irn_loop(block); + unsigned loopdepth = get_loop_depth(loop); + int found_visited = 0; + int found_use = 0; + ir_graph *irg = get_irn_irg(block); + ir_node *startblock = get_irg_start_block(irg); result.before = NULL; outermost_loop = loopdepth; @@ -308,10 +310,10 @@ static be_next_use_t get_next_use(be_uses_t *env, ir_node *from, } use = get_or_set_use_block(env, succ_block, def); - DBG((env->dbg, LEVEL_5, "Found %u (loopdepth %d) (we're in block %+F)\n", use->next_use, + DBG((env->dbg, LEVEL_5, "Found %u (loopdepth %u) (we're in block %+F)\n", use->next_use, use->outermost_loop, block)); if (USES_IS_INFINITE(use->next_use)) { - if (use->outermost_loop < 0) { + if (use->outermost_loop == UNKNOWN_OUTERMOST_LOOP) { found_visited = 1; } continue; @@ -344,9 +346,9 @@ static be_next_use_t get_next_use(be_uses_t *env, ir_node *from, if (!found_use && found_visited) { // the current result is correct for the current search, but isn't // generally correct, so mark it - result.outermost_loop = -1; + result.outermost_loop = UNKNOWN_OUTERMOST_LOOP; } - DBG((env->dbg, LEVEL_5, "Result: %d (outerloop: %d)\n", result.time, result.outermost_loop)); + DBG((env->dbg, LEVEL_5, "Result: %d (outerloop: %u)\n", result.time, result.outermost_loop)); return result; } } diff --git a/ir/be/beuses.h b/ir/be/beuses.h index f033061be..290961b0e 100644 --- a/ir/be/beuses.h +++ b/ir/be/beuses.h @@ -35,19 +35,20 @@ */ typedef struct be_next_use_t { unsigned time; - int outermost_loop; + unsigned outermost_loop; + /* point of the next use is at the beginning of this node. */ const ir_node *before; } be_next_use_t; #define USES_INFINITY 10000000 #define USES_PENDING 9999999 -static inline int USES_IS_INFINITE(unsigned time) +static inline bool USES_IS_INFINITE(unsigned time) { return time >= USES_INFINITY; } -static inline int USES_IS_PENDING(unsigned time) +static inline bool USES_IS_PENDING(unsigned time) { return time == USES_PENDING; } @@ -55,7 +56,7 @@ static inline int USES_IS_PENDING(unsigned time) typedef struct be_uses_t be_uses_t; be_next_use_t be_get_next_use(be_uses_t *uses, ir_node *from, - const ir_node *def, int skip_from_uses); + const ir_node *def, int skip_from_uses); /** * Creates a new uses environment for a graph. @@ -72,4 +73,4 @@ be_uses_t *be_begin_uses(ir_graph *irg, const be_lv_t *lv); */ void be_end_uses(be_uses_t *uses); -#endif /* FIRM_BE_BEUSES_H */ +#endif diff --git a/ir/ir/irargs.c b/ir/ir/irargs.c index d08a93d53..b36138b62 100644 --- a/ir/ir/irargs.c +++ b/ir/ir/irargs.c @@ -210,7 +210,7 @@ static int firm_emit(lc_appendable_t *app, } case k_ir_loop: { ir_loop *loop = (ir_loop*)X; - snprintf(buf, sizeof(buf), "loop[%d:%d]", get_loop_loop_nr(loop), get_loop_depth(loop)); + snprintf(buf, sizeof(buf), "loop[%ld:%u]", get_loop_loop_nr(loop), get_loop_depth(loop)); break; } case k_ir_op: { @@ -228,7 +228,7 @@ static int firm_emit(lc_appendable_t *app, strncat(buf, ".", sizeof(buf)-1); strncat(buf, get_entity_name(ent), sizeof(buf)-1); if (is_Array_type(get_entity_owner(ent))) { - snprintf(add, sizeof(add), "[%d]", + snprintf(add, sizeof(add), "[%ld]", get_compound_graph_path_array_index(path, i)); strncat(buf, add, sizeof(buf)-1); } diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index f371e045c..22e1fa158 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -2039,7 +2039,7 @@ static void dump_loop_label(FILE *F, ir_loop *loop) static void dump_loop_info(FILE *F, ir_loop *loop) { fprintf(F, " info1: \""); - fprintf(F, " loop nr: %d", get_loop_loop_nr(loop)); + fprintf(F, " loop nr: %ld", get_loop_loop_nr(loop)); #ifdef DEBUG_libfirm /* GL @@@ debug analyses */ fprintf(F, "\n The loop was analyzed %d times.", PTR_TO_INT(get_loop_link(loop))); #endif @@ -2464,7 +2464,8 @@ void dump_class_hierarchy(FILE *out) static void dump_loops_standalone(FILE *F, ir_loop *loop) { - int i = 0, loop_node_started = 0, son_number = 0, first = 0; + size_t i; + int loop_node_started = 0, son_number = 0, first = 0; loop_element le; ir_loop *son = NULL; @@ -2566,7 +2567,9 @@ void dump_callgraph_loop_tree(FILE *out) static void collect_nodeloop(FILE *F, ir_loop *loop, eset *loopnodes) { - int i, son_number = 0, node_number = 0; + size_t i; + int son_number = 0; + int node_number = 0; if (flags & ir_dump_flag_loops) dump_loop_node(F, loop); @@ -2589,7 +2592,8 @@ static void collect_nodeloop(FILE *F, ir_loop *loop, eset *loopnodes) static void collect_nodeloop_external_nodes(ir_loop *loop, eset *loopnodes, eset *extnodes) { - int i, j, start; + size_t i; + int j, start; for (i = 0; i < get_loop_n_elements(loop); i++) { loop_element le = get_loop_element(loop, i); @@ -2619,7 +2623,7 @@ void dump_loop(FILE *F, ir_loop *l) ir_node *n, *b; char name[50]; - snprintf(name, sizeof(name), "loop_%d", get_loop_loop_nr(l)); + snprintf(name, sizeof(name), "loop_%ld", get_loop_loop_nr(l)); dump_vcg_header(F, name, NULL, NULL); /* collect all nodes to dump */ diff --git a/ir/ir/irdump_t.h b/ir/ir/irdump_t.h index 98b58f98d..cab01e4a2 100644 --- a/ir/ir/irdump_t.h +++ b/ir/ir/irdump_t.h @@ -137,7 +137,7 @@ typedef enum { #define PRINT_IRGID(X) fprintf(F, "g%ld", get_irg_graph_nr(X)) #define PRINT_CONSTID(X,Y) fprintf(F, "\"n%ldn%ld\"", get_irn_node_nr(X),get_irn_node_nr(Y)) #define PRINT_CONSTBLKID(X,Y) fprintf(F, "n%ldb%ld", get_irn_node_nr(X),get_irn_node_nr(Y)) -#define PRINT_LOOPID(X) fprintf(F, "l%d", get_loop_loop_nr(X)) +#define PRINT_LOOPID(X) fprintf(F, "l%ld", get_loop_loop_nr(X)) #define PRINT_ITEMID(X,Y) fprintf(F, "i%ldT%d", get_type_nr(X), (Y)) #define PRINT_EXTBBID(X) fprintf(F, "x%ld", get_irn_node_nr(X)) diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index bb27d6eaf..594361330 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -123,8 +123,8 @@ void dump_irnode_to_file(FILE *F, ir_node *n) if (get_irg_loopinfo_state(irg) & loopinfo_valid) { ir_loop *loop = get_irn_loop(n); if (loop != NULL) { - fprintf(F, " in loop %d with depth %d\n", - get_loop_loop_nr(loop), get_loop_depth(loop)); + fprintf(F, " in loop %ld with depth %u\n", + get_loop_loop_nr(loop), get_loop_depth(loop)); } } @@ -448,7 +448,7 @@ static void dump_entity_linkage(FILE *F, const ir_entity *entity) static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *prefix) { - int i, j; + int i; ir_type *owner, *type; assert(is_entity(ent)); @@ -572,8 +572,10 @@ static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *pref need_nl = 1; dump_ir_initializers_to_file(F, prefix, initializer, get_entity_type(ent)); } else if (entity_has_compound_ent_values(ent)) { + size_t i; fprintf(F, "%s compound values:", prefix); for (i = 0; i < get_compound_ent_n_values(ent); ++i) { + size_t j; compound_graph_path *path = get_compound_ent_value_path(ent, i); ir_entity *ent0 = get_compound_graph_path_node(path, 0); fprintf(F, "\n%s %3d:%u ", prefix, get_entity_offset(ent0), get_entity_offset_bits_remainder(ent0)); @@ -584,7 +586,7 @@ static void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, const char *pref ir_entity *node = get_compound_graph_path_node(path, j); fprintf(F, ".%s", get_entity_name(node)); if (is_Array_type(get_entity_owner(node))) - fprintf(F, "[%d]", get_compound_graph_path_array_index(path, j)); + fprintf(F, "[%ld]", get_compound_graph_path_array_index(path, j)); } fprintf(F, "\t = "); dump_node_opcode(F, get_compound_ent_value(ent, i)); diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 3e066fe86..d9b977413 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -837,7 +837,7 @@ void set_max_irg_visited(int val) ir_visited_t inc_max_irg_visited(void) { #ifndef NDEBUG - int i; + size_t i; for (i = 0; i < get_irp_n_irgs(); i++) assert(max_irg_visited >= get_irg_visited(get_irp_irg(i))); #endif diff --git a/ir/ir/irgwalk.c b/ir/ir/irgwalk.c index 104ca3552..7f42f880e 100644 --- a/ir/ir/irgwalk.c +++ b/ir/ir/irgwalk.c @@ -488,9 +488,11 @@ static void walk_entity(ir_entity *ent, void *env) /* Walks over all code in const_code_irg. */ void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env) { - int i, j, n_types; + int j; walk_env my_env; ir_segment_t s; + size_t i; + size_t n_types; ir_graph *rem = current_ir_graph; current_ir_graph = get_const_code_irg(); diff --git a/ir/ir/irpass.c b/ir/ir/irpass.c index 7c1ef7555..3626d2155 100644 --- a/ir/ir/irpass.c +++ b/ir/ir/irpass.c @@ -171,7 +171,8 @@ static void create_suffix(char *suffix, size_t n, const char *pass_name) int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr) { ir_graph_pass_t *pass; - int i, res = 0; + size_t i; + int res = 0; ir_graph *rem = current_ir_graph; /* on all graphs: beware: number of irgs might be changed */ @@ -213,9 +214,11 @@ int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr) */ static int irp_verify_irgs(void) { - int i, res = 1; + int res = 1; + size_t i; + size_t n_irgs = get_irp_n_irgs(); - for (i = get_irp_n_irgs() - 1; i >= 0; --i) + for (i = 0; i < n_irgs; ++i) res &= irg_verify(get_irp_irg(i), 0); return res; } diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index 0beceda4a..8f252a955 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -236,12 +236,12 @@ void remove_irp_irg(ir_graph *irg) remove_irp_irg_from_list(irg); } -int (get_irp_n_irgs)(void) +size_t (get_irp_n_irgs)(void) { return _get_irp_n_irgs(); } -ir_graph *(get_irp_irg)(int pos) +ir_graph *(get_irp_irg)(size_t pos) { return _get_irp_irg(pos); } @@ -251,10 +251,10 @@ int get_irp_last_idx(void) return irp->max_irg_idx; } -void set_irp_irg(int pos, ir_graph *irg) +void set_irp_irg(size_t pos, ir_graph *irg) { assert(irp && irg); - assert(pos < (ARR_LEN(irp->graphs))); + assert(pos < ARR_LEN(irp->graphs)); irp->graphs[pos] = irg; } @@ -284,31 +284,31 @@ void remove_irp_type(ir_type *typ) } } -int (get_irp_n_types) (void) +size_t (get_irp_n_types) (void) { return _get_irp_n_types(); } -ir_type *(get_irp_type) (int pos) +ir_type *(get_irp_type) (size_t pos) { return _get_irp_type(pos); } -void set_irp_type(int pos, ir_type *typ) +void set_irp_type(size_t pos, ir_type *typ) { assert(irp && typ); - assert(pos < (ARR_LEN((irp)->types))); + assert(pos < ARR_LEN((irp)->types)); irp->types[pos] = typ; } /* Returns the number of all modes in the irp. */ -int (get_irp_n_modes)(void) +size_t (get_irp_n_modes)(void) { return _get_irp_n_modes(); } /* Returns the mode at position pos in the irp. */ -ir_mode *(get_irp_mode)(int pos) +ir_mode *(get_irp_mode)(size_t pos) { return _get_irp_mode(pos); } @@ -347,19 +347,19 @@ void remove_irp_opcode(ir_op *opcode) } /* Returns the number of all opcodes in the irp. */ -int (get_irp_n_opcodes)(void) +size_t (get_irp_n_opcodes)(void) { return _get_irp_n_opcodes(); } /* Returns the opcode at position pos in the irp. */ -ir_op *(get_irp_opcode)(int pos) +ir_op *(get_irp_opcode)(size_t pos) { return _get_irp_opcode(pos); } /* Sets the generic function pointer of all opcodes to NULL */ -void clear_irp_opcodes_generic_func(void) +void clear_irp_opcodes_generic_func(void) { int i; @@ -370,7 +370,7 @@ void clear_irp_opcodes_generic_func(void) } /*- File name / executable name or the like -*/ -void set_irp_prog_name(ident *name) +void set_irp_prog_name(ident *name) { irp->name = name; } @@ -493,15 +493,15 @@ void add_irp_asm(ident *asm_string) } /* Return the number of global asm includes. */ -int get_irp_n_asms(void) +size_t get_irp_n_asms(void) { return ARR_LEN(irp->global_asms); } /* Return the global asm include at position pos. */ -ident *get_irp_asm(int pos) +ident *get_irp_asm(size_t pos) { - assert(0 <= pos && pos < get_irp_n_asms()); + assert(pos < get_irp_n_asms()); return irp->global_asms[pos]; } diff --git a/ir/ir/irprog_t.h b/ir/ir/irprog_t.h index 599b90e9e..00a25970c 100644 --- a/ir/ir/irprog_t.h +++ b/ir/ir/irprog_t.h @@ -58,50 +58,51 @@ static inline ir_type *_get_tls_type(void) return _get_segment_type(IR_SEGMENT_THREAD_LOCAL); } -static inline int _get_irp_n_irgs(void) +static inline size_t _get_irp_n_irgs(void) { assert(irp && irp->graphs); - return (int)ARR_LEN(irp->graphs); + return ARR_LEN(irp->graphs); } -static inline ir_graph *_get_irp_irg(int pos) +static inline ir_graph *_get_irp_irg(size_t pos) { - assert(0 <= pos && pos <= (int)ARR_LEN(irp->graphs)); + assert(pos < ARR_LEN(irp->graphs)); return irp->graphs[pos]; } -static inline int _get_irp_n_types(void) +static inline size_t _get_irp_n_types(void) { assert(irp && irp->types); - return (int)ARR_LEN(irp->types); + return ARR_LEN(irp->types); } -static inline ir_type *_get_irp_type(int pos) +static inline ir_type *_get_irp_type(size_t pos) { assert(irp->types); + assert(pos < ARR_LEN(irp->types)); /* Don't set the skip_tid result so that no double entries are generated. */ return irp->types[pos]; } -static inline int _get_irp_n_modes(void) +static inline size_t _get_irp_n_modes(void) { assert(irp->modes); - return (int)ARR_LEN(irp->modes); + return ARR_LEN(irp->modes); } -static inline ir_mode *_get_irp_mode(int pos) +static inline ir_mode *_get_irp_mode(size_t pos) { assert(irp && irp->modes); return irp->modes[pos]; } -static inline int _get_irp_n_opcodes(void) +static inline size_t _get_irp_n_opcodes(void) { assert(irp && irp->opcodes); - return (int)ARR_LEN(irp->opcodes); + return ARR_LEN(irp->opcodes); } -static inline ir_op *_get_irp_opcode(int pos) +static inline ir_op *_get_irp_opcode(size_t pos) { assert(irp && irp->opcodes); return irp->opcodes[pos]; diff --git a/ir/tr/compound_path.c b/ir/tr/compound_path.c index 1236b3a98..6ac2ac540 100644 --- a/ir/tr/compound_path.c +++ b/ir/tr/compound_path.c @@ -25,6 +25,7 @@ #include "config.h" #include +#include #include #include "firm_types.h" @@ -36,7 +37,7 @@ #include "irgraph_t.h" #include "ircons.h" -compound_graph_path *new_compound_graph_path(ir_type *tp, int length) +compound_graph_path *new_compound_graph_path(ir_type *tp, size_t length) { compound_graph_path *res; @@ -64,9 +65,9 @@ int is_compound_graph_path(const void *thing) return get_kind(thing) == k_ir_compound_graph_path; } -int is_proper_compound_graph_path(compound_graph_path *gr, int pos) +int is_proper_compound_graph_path(compound_graph_path *gr, size_t pos) { - int i; + size_t i; ir_entity *node; ir_type *owner = gr->tp; @@ -85,41 +86,42 @@ int is_proper_compound_graph_path(compound_graph_path *gr, int pos) return 1; } -int get_compound_graph_path_length(const compound_graph_path *gr) +size_t get_compound_graph_path_length(const compound_graph_path *gr) { assert(gr && is_compound_graph_path(gr)); return gr->len; } -ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos) +ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, + size_t pos) { assert(gr && is_compound_graph_path(gr)); - assert(pos >= 0 && pos < gr->len); + assert(pos < gr->len); return gr->list[pos].node; } -void set_compound_graph_path_node(compound_graph_path *gr, int pos, +void set_compound_graph_path_node(compound_graph_path *gr, size_t pos, ir_entity *node) { assert(gr && is_compound_graph_path(gr)); - assert(pos >= 0 && pos < gr->len); + assert(pos < gr->len); assert(is_entity(node)); gr->list[pos].node = node; assert(is_proper_compound_graph_path(gr, pos)); } -int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos) +long get_compound_graph_path_array_index(const compound_graph_path *gr, size_t pos) { assert(gr && is_compound_graph_path(gr)); - assert(pos >= 0 && pos < gr->len); + assert(pos < gr->len); return gr->list[pos].index; } -void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, - int index) +void set_compound_graph_path_array_index(compound_graph_path *gr, size_t pos, + long index) { assert(gr && is_compound_graph_path(gr)); - assert(pos >= 0 && pos < gr->len); + assert(pos < gr->len); gr->list[pos].index = index; } @@ -149,20 +151,21 @@ void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, } void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, - compound_graph_path *path, int pos) + compound_graph_path *path, size_t pos) { assert(is_compound_entity(ent)); assert(is_compound_graph_path(path)); - assert(0 <= pos && pos < ARR_LEN(ent->attr.cmpd_attr.values)); + assert(pos < ARR_LEN(ent->attr.cmpd_attr.values)); ent->attr.cmpd_attr.values[pos] = val; ent->attr.cmpd_attr.val_paths[pos] = path; } -compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, int pos) +compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, + size_t pos) { assert(is_compound_entity(ent)); assert(ent->initializer == NULL); - assert(0 <= pos && pos < ARR_LEN(ent->attr.cmpd_attr.val_paths)); + assert(pos < ARR_LEN(ent->attr.cmpd_attr.val_paths)); return ent->attr.cmpd_attr.val_paths[pos]; } @@ -172,30 +175,30 @@ compound_graph_path *get_compound_ent_value_path(const ir_entity *ent, int pos) * @param path1 the first path * @param path2 the second path */ -static int equal_paths(compound_graph_path *path1, compound_graph_path *path2) +static bool equal_paths(compound_graph_path *path1, compound_graph_path *path2) { - int i; - int len1 = get_compound_graph_path_length(path1); - int len2 = get_compound_graph_path_length(path2); + size_t i; + size_t len1 = get_compound_graph_path_length(path1); + size_t len2 = get_compound_graph_path_length(path2); - if (len2 != len1) return 0; + if (len2 != len1) return false; for (i = 0; i < len1; i++) { ir_type *tp; ir_entity *node1 = get_compound_graph_path_node(path1, i); ir_entity *node2 = get_compound_graph_path_node(path2, i); - if (node1 != node2) return 0; + if (node1 != node2) return false; tp = get_entity_owner(node1); if (is_Array_type(tp)) { - int index1 = get_compound_graph_path_array_index(path1, i); - int index2 = get_compound_graph_path_array_index(path2, i); + size_t index1 = get_compound_graph_path_array_index(path1, i); + size_t index2 = get_compound_graph_path_array_index(path2, i); if (index1 != index2) - return 0; + return false; } } - return 1; + return true; } /** @@ -206,24 +209,24 @@ static int equal_paths(compound_graph_path *path1, compound_graph_path *path2) * and should be replaced when the new tree oriented * value representation is finally implemented. */ -static int get_compound_ent_pos_by_path(const ir_entity *ent, - compound_graph_path *path) +static size_t get_compound_ent_pos_by_path(const ir_entity *ent, + compound_graph_path *path) { - int i, n_paths = get_compound_ent_n_values(ent); + size_t i, n_paths = get_compound_ent_n_values(ent); for (i = 0; i < n_paths; i ++) { compound_graph_path *gr = get_compound_ent_value_path(ent, i); if (equal_paths(gr, path)) return i; } - return -1; + return (size_t)-1; } ir_node *get_compound_ent_value_by_path(const ir_entity *ent, compound_graph_path *path) { - int pos = get_compound_ent_pos_by_path(ent, path); - if (pos >= 0) + size_t pos = get_compound_ent_pos_by_path(ent, path); + if (pos != (size_t)-1) return get_compound_ent_value(ent, pos); return NULL; } @@ -257,13 +260,13 @@ void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member) path = new_compound_graph_path(get_entity_type(ent), 1); path->list[0].node = member; if (is_Array_type(owner_tp)) { - int max; - int i, n; + long max; + size_t i, n; assert(get_array_n_dimensions(owner_tp) == 1 && has_array_lower_bound(owner_tp, 0)); max = get_array_lower_bound_int(owner_tp, 0) -1; for (i = 0, n = get_compound_ent_n_values(ent); i < n; ++i) { - int index = get_compound_graph_path_array_index(get_compound_ent_value_path(ent, i), 0); + long index = get_compound_graph_path_array_index(get_compound_ent_value_path(ent, i), 0); if (index > max) { max = index; } @@ -273,7 +276,7 @@ void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member) add_compound_ent_value_w_path(ent, val, path); } -ir_entity *get_compound_ent_value_member(const ir_entity *ent, int pos) +ir_entity *get_compound_ent_value_member(const ir_entity *ent, size_t pos) { compound_graph_path *path; assert(is_compound_entity(ent)); @@ -283,7 +286,7 @@ ir_entity *get_compound_ent_value_member(const ir_entity *ent, int pos) } void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, - int pos) + size_t pos) { compound_graph_path *path; assert(is_compound_entity(ent)); @@ -292,9 +295,9 @@ void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, set_compound_ent_value_w_path(ent, val, path, pos); } -void set_array_entity_values(ir_entity *ent, ir_tarval **values, int num_vals) +void set_array_entity_values(ir_entity *ent, ir_tarval **values, size_t num_vals) { - int i; + size_t i; ir_type *arrtp = get_entity_type(ent); ir_node *val; ir_graph *irg = get_const_code_irg(); @@ -312,10 +315,10 @@ void set_array_entity_values(ir_entity *ent, ir_tarval **values, int num_vals) } } -unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos) +unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, size_t pos) { compound_graph_path *path; - int path_len, i; + size_t path_len, i; unsigned offset = 0; ir_type *curr_tp; @@ -330,14 +333,14 @@ unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos) ir_type *elem_type = get_array_element_type(curr_tp); unsigned size = get_type_size_bytes(elem_type); unsigned align = get_type_alignment_bytes(elem_type); - int idx; + size_t idx; assert(size > 0); if (size % align > 0) { size += align - (size % align); } idx = get_compound_graph_path_array_index(path, i); - assert(idx >= 0); + assert(idx != (size_t)-1); offset += size * idx; curr_tp = elem_type; } else { @@ -351,10 +354,10 @@ unsigned get_compound_ent_value_offset_bytes(const ir_entity *ent, int pos) } unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, - int pos) + size_t pos) { compound_graph_path *path; - int path_len; + size_t path_len; ir_entity *last_node; assert(get_type_state(get_entity_type(ent)) == layout_fixed); @@ -369,7 +372,7 @@ unsigned get_compound_ent_value_offset_bit_remainder(const ir_entity *ent, return get_entity_offset_bits_remainder(last_node); } -int get_compound_ent_n_values(const ir_entity *ent) +size_t get_compound_ent_n_values(const ir_entity *ent) { assert(ent->initializer == NULL); assert(is_compound_entity(ent)); @@ -377,11 +380,11 @@ int get_compound_ent_n_values(const ir_entity *ent) return ARR_LEN(ent->attr.cmpd_attr.values); } -ir_node *get_compound_ent_value(const ir_entity *ent, int pos) +ir_node *get_compound_ent_value(const ir_entity *ent, size_t pos) { assert(is_compound_entity(ent)); assert(ent->initializer == NULL); - assert(0 <= pos && pos < ARR_LEN(ent->attr.cmpd_attr.values)); + assert(pos < ARR_LEN(ent->attr.cmpd_attr.values)); return skip_Id(ent->attr.cmpd_attr.values[pos]); } diff --git a/ir/tr/compound_path_t.h b/ir/tr/compound_path_t.h index 6de828ce9..89d3c07a8 100644 --- a/ir/tr/compound_path_t.h +++ b/ir/tr/compound_path_t.h @@ -31,10 +31,10 @@ /** A path in a compound graph. */ struct compound_graph_path { firm_kind kind; /**< The dynamic type tag for compound graph path. */ - ir_type *tp; /**< The type this path belongs to. */ - int len; /**< The length of the path. */ + ir_type *tp; /**< The type this path belongs to. */ + size_t len; /**< The length of the path. */ struct tuple { - int index; /**< Array index. To compute position of array elements */ + long index; /**< Array index. To compute position of array elements */ ir_entity *node; /**< The accessed entity. */ } list[1]; /**< List of entity/index tuple of length len to express the access path. */ -- 2.20.1