Commit 9d4e2306 authored by Michael Beck's avatar Michael Beck
Browse files

Further spread size_t.

[r28338]
parent 0a4048fb
/*
* 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.
*
......@@ -105,8 +105,10 @@ FIRM_API size_t get_loop_n_elements(const ir_loop *loop);
kind pointer, an ir_node* or an ir_loop*. */
FIRM_API loop_element get_loop_element(const ir_loop *loop, size_t pos);
#define INVALID_LOOP_POS ((size_t)-1)
/** Returns the element number of the loop son in loop.
* Returns -1 if not found. O(|elements|). */
* Returns INVALID_LOOP_POS if not found. O(|elements|). */
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
......
......@@ -299,7 +299,7 @@ static int graph_cmp(const void *elt, const void *key)
/* Construct and destruct the callgraph. */
void compute_callgraph(void)
{
int i, n_irgs;
size_t i, n_irgs;
/* initialize */
free_callgraph();
......@@ -357,7 +357,7 @@ void compute_callgraph(void)
/* Destruct the callgraph. */
void free_callgraph(void)
{
int i, n_irgs = get_irp_n_irgs();
size_t i, n_irgs = get_irp_n_irgs();
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
if (irg->callees) DEL_ARR_F(irg->callees);
......@@ -400,7 +400,7 @@ static void do_walk(ir_graph *irg, callgraph_walk_func *pre, callgraph_walk_func
void callgraph_walk(callgraph_walk_func *pre, callgraph_walk_func *post, void *env)
{
int i, n_irgs = get_irp_n_irgs();
size_t i, n_irgs = get_irp_n_irgs();
++master_cg_visited;
/* roots are methods which have no callers in the current program */
......@@ -663,8 +663,7 @@ static ir_loop *new_loop(void)
static void init_scc(struct obstack *obst)
{
int i;
int n_irgs;
size_t i, n_irgs;
current_dfn = 1;
loop_node_cnt = 0;
......@@ -918,7 +917,7 @@ static void cgscc(ir_graph *n)
*/
static void reset_isbe(void)
{
int i, n_irgs = get_irp_n_irgs();
size_t i, n_irgs = get_irp_n_irgs();
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
......@@ -1151,7 +1150,7 @@ static void compute_method_execution_frequency(ir_graph *irg, void *env)
/* Compute the backedges that represent recursions. */
void find_callgraph_recursions(void)
{
int i, n_irgs;
size_t i, n_irgs;
struct obstack temp;
reset_isbe();
......
......@@ -227,12 +227,12 @@ static void sel_methods_walker(ir_node *node, void *env)
*/
static void sel_methods_init(void)
{
int i;
size_t i, n;
pmap *ldname_map = pmap_create(); /* Map entity names to entities: to replace
SymConst(name) by SymConst(ent). */
assert(entities == NULL);
entities = eset_create();
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_entity * ent = get_irg_entity(get_irp_irg(i));
/* only external visible methods are allowed to call by a SymConst_ptr_name */
if (entity_is_externally_visible(ent)) {
......@@ -507,12 +507,10 @@ static void add_method_address_inititializer(ir_initializer_t *initializer,
*/
static void add_method_address(ir_entity *ent, eset *set)
{
ir_node *n;
ir_type *tp;
int i;
/* ignore methods: these of course reference it's address
* TODO: remove this later once this incorrect self-intialisation is gone
* TODO: remove this later once this incorrect self-initialisation is gone
*/
tp = get_entity_type(ent);
if (is_Method_type(tp))
......@@ -521,12 +519,13 @@ static void add_method_address(ir_entity *ent, eset *set)
if (ent->initializer != NULL) {
add_method_address_inititializer(get_entity_initializer(ent), set);
} else if (entity_has_compound_ent_values(ent)) {
for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
n = get_compound_ent_value(ent, i);
size_t i, n;
for (i = 0, n = get_compound_ent_n_values(ent); i < n; ++i) {
ir_node *irn = get_compound_ent_value(ent, i);
/* let's check if it's the address of a function */
if (is_Global(n)) {
ir_entity *ent = get_Global_entity(n);
if (is_Global(irn)) {
ir_entity *ent = get_Global_entity(irn);
if (is_Method_type(get_entity_type(ent)))
eset_insert(set, ent);
......@@ -548,21 +547,21 @@ 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();
int i;
size_t i, n;
int j;
ir_entity **arr;
ir_entity *ent;
ir_graph *irg;
ir_type *tp;
size_t length;
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_linkage linkage;
irg = get_irp_irg(i);
ent = get_irg_entity(irg);
linkage = get_entity_linkage(ent);
if (entity_is_externally_visible(ent)
|| (linkage & IR_LINKAGE_HIDDEN_USER)) {
if ((linkage & IR_LINKAGE_HIDDEN_USER) || entity_is_externally_visible(ent)) {
eset_insert(free_set, ent);
}
......@@ -575,13 +574,13 @@ 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 (i = get_class_n_members(tp) - 1; i >= 0; --i) {
ent = get_class_member(tp, i);
for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
ent = get_class_member(tp, j);
add_method_address(ent, free_set);
}
tp = get_tls_type();
for (i = get_class_n_members(tp) - 1; i >= 0; --i) {
ent = get_class_member(tp, i);
for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
ent = get_class_member(tp, j);
add_method_address(ent, free_set);
}
......@@ -776,9 +775,9 @@ static void remove_Tuples(ir_node *proj, void *env)
*/
static void callee_ana(void)
{
int i;
size_t i, n;
/* analyse all graphs */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *irg = get_irp_irg(i);
irg_walk_graph(irg, callee_walker, remove_Tuples, NULL);
set_irg_callee_info_state(irg, irg_callee_info_consistent);
......@@ -841,8 +840,8 @@ void free_callee_info(ir_graph *irg)
void free_irp_callee_info(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) {
free_callee_info(get_irp_irg(i));
}
}
......
......@@ -386,7 +386,7 @@ static void compute_frequency(int default_loop_weight)
while (!pdeq_empty(block_worklist)) {
ir_loop *l = (ir_loop *)pdeq_getl(block_worklist);
int i, n_elems = get_loop_n_elements(l);
size_t i, n_elems = get_loop_n_elements(l);
/* The header is initialized with the frequency of the full loop times the iteration weight. */
check_proper_head(l, get_loop_element(l, 0).son);
......@@ -433,7 +433,7 @@ void compute_execution_frequency(ir_graph *irg, int default_loop_weight, double
void compute_execution_frequencies(int default_loop_weight, double exception_probability)
{
int i, n_irgs = get_irp_n_irgs();
size_t i, n_irgs = get_irp_n_irgs();
free_intervals();
for (i = 0; i < n_irgs; ++i) {
compute_execution_frequency(get_irp_irg(i), default_loop_weight, exception_probability);
......@@ -444,7 +444,7 @@ void compute_execution_frequencies(int default_loop_weight, double exception_pro
/** free occupied memory, reset */
void free_execution_frequency(void)
{
int i, n_irgs = get_irp_n_irgs();
size_t i, n_irgs = get_irp_n_irgs();
free_intervals();
del_set(exec_freq_set);
......@@ -485,13 +485,13 @@ exec_freq_state get_irp_exec_freq_state(void)
/* Sets irp and all irg exec freq states to inconsistent if it is set to consistent. */
void set_irp_exec_freq_state_inconsistent(void)
{
if (get_irp_exec_freq_state() != exec_freq_none) {
int i, n_irgs = get_irp_n_irgs();
set_irp_exec_freq_state(exec_freq_inconsistent);
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
if (get_irg_exec_freq_state(irg) != exec_freq_none)
irg->execfreq_state = exec_freq_inconsistent;
}
}
if (get_irp_exec_freq_state() != exec_freq_none) {
size_t i, n_irgs = get_irp_n_irgs();
set_irp_exec_freq_state(exec_freq_inconsistent);
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
if (get_irg_exec_freq_state(irg) != exec_freq_none)
irg->execfreq_state = exec_freq_inconsistent;
}
}
}
/*
* 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.
*
......@@ -198,7 +198,7 @@ static int find_outer_loop(ir_loop *inner, ir_loop *outer, ir_node *blk, ir_node
*/
static int test_loop_nest(ir_node *blk, ir_loop *loop)
{
int i, n_elems = get_loop_n_elements(loop);
size_t i, n_elems = get_loop_n_elements(loop);
for (i = 0; i < n_elems; ++i) {
loop_element e = get_loop_element(loop, i);
......@@ -231,7 +231,7 @@ static int test_loop_nest(ir_node *blk, ir_loop *loop)
*/
static int find_inner_loop(ir_node *blk, ir_loop *l, ir_node *pred, ir_node *cfop)
{
int i, n_elems = get_loop_n_elements(l);
size_t i, n_elems = get_loop_n_elements(l);
int found = 0;
for (i = 0; i < n_elems; ++i) {
......@@ -275,14 +275,14 @@ static int find_previous_loop(ir_loop *l, ir_loop *pred_l, ir_node *b,
ir_node *pred_b, ir_node *cfop)
{
ir_loop *outer = get_loop_outer_loop(l);
int found, i;
int l_pos = get_loop_element_pos(outer, l);
int found;
size_t i, l_pos = get_loop_element_pos(outer, l);
(void) pred_l;
assert(l_pos > -1);
assert(l_pos != INVALID_LOOP_POS);
assert(l_pos > 0 && "Is this a necessary condition? There could be a perfect nest ...");
for (i = l_pos -1, found = 0; i > -1 && !found; --i) {
ir_loop *k = get_loop_element(outer, i).son;
for (i = l_pos, found = 0; i > 0;) {
ir_loop *k = get_loop_element(outer, --i).son;
if (is_ir_loop(k)) {
found = test_loop_nest(pred_b, k);
if (found) {
......@@ -291,6 +291,7 @@ static int find_previous_loop(ir_loop *l, ir_loop *pred_l, ir_node *b,
add_loop_cfop(l, cfop);
/* placeholder: the edge is in the loop region */
add_region_in(b, NULL);
break;
}
}
}
......@@ -402,7 +403,7 @@ static void construct_interval_block(ir_node *blk, ir_loop *l)
*/
static void construct_interval_edges(ir_loop *l)
{
int i, n_elems = get_loop_n_elements(l);
size_t i, n_elems = get_loop_n_elements(l);
for (i = 0; i < n_elems; ++i) {
loop_element e = get_loop_element(l, i);
switch (*e.kind) {
......@@ -576,7 +577,7 @@ static void dump_interval_block(FILE *F, ir_node *block)
static void dump_interval_loop(FILE *F, ir_loop *l)
{
int i, n_elems = get_loop_n_elements(l);
size_t i, n_elems = get_loop_n_elements(l);
fprintf(F, "graph: { title: \"");
PRINT_LOOPID(l);
......
/*
* 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.
*
......@@ -217,7 +217,7 @@ static inline void pop_scc_to_loop(ir_node *n)
can't they have two loops as sons? Does it never get that far? ) */
static void close_loop(ir_loop *l)
{
int last = get_loop_n_elements(l) - 1;
size_t last = get_loop_n_elements(l) - 1;
loop_element lelement = get_loop_element(l, last);
ir_loop *last_son = lelement.son;
......
......@@ -76,10 +76,10 @@ void mature_loops(ir_loop *loop, struct obstack *obst)
if (loop->n_sons > 0) {
/* we have child loops, mature them */
int i;
size_t i;
for (i = ARR_LEN(new_children) - 1; i >= 0; --i) {
loop_element child = new_children[i];
for (i = ARR_LEN(new_children); i > 0;) {
loop_element child = new_children[--i];
if (*child.kind == k_ir_loop) {
mature_loops(child.son, obst);
......@@ -177,7 +177,7 @@ size_t get_loop_element_pos(const ir_loop *loop, void *le)
for (i = 0; i < n; i++)
if (get_loop_element(loop, i).node == le)
return i;
return (size_t)-1;
return INVALID_LOOP_POS;
}
......
......@@ -1115,9 +1115,6 @@ static void check_initializer_nodes(ir_initializer_t *initializer)
*/
static void check_initializer(ir_entity *ent)
{
ir_node *n;
int i;
/* Beware: Methods are always initialized with "themself". This does not
* count as a taken address.
* TODO: this initialisation with "themself" is wrong and should be removed
......@@ -1128,12 +1125,14 @@ static void check_initializer(ir_entity *ent)
if (ent->initializer != NULL) {
check_initializer_nodes(ent->initializer);
} else if (entity_has_compound_ent_values(ent)) {
for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
n = get_compound_ent_value(ent, i);
size_t i, n;
for (i = 0, n = get_compound_ent_n_values(ent); i < n; ++i) {
ir_node *irn = get_compound_ent_value(ent, i);
/* let's check if it's an address */
if (is_Global(n)) {
ir_entity *ent = get_Global_entity(n);
if (is_Global(irn)) {
ir_entity *ent = get_Global_entity(irn);
set_entity_usage(ent, ir_usage_unknown);
}
}
......@@ -1214,7 +1213,7 @@ static void check_global_address(ir_node *irn, void *env)
*/
static void analyse_irp_globals_entity_usage(void)
{
int i;
size_t i, n;
ir_segment_t s;
for (s = IR_SEGMENT_FIRST; s <= IR_SEGMENT_LAST; ++s) {
......@@ -1227,7 +1226,7 @@ static void analyse_irp_globals_entity_usage(void)
check_initializers(type);
}
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *irg = get_irp_irg(i);
assure_irg_outs(irg);
......@@ -1325,7 +1324,7 @@ static void update_calls_to_private(ir_node *call, void *env)
/* Mark all private methods, i.e. those of which all call sites are known. */
void mark_private_methods(void)
{
int i;
size_t i, n;
int changed = 0;
assure_irp_globals_entity_usage_computed();
......@@ -1333,13 +1332,12 @@ void mark_private_methods(void)
mtp_map = pmap_create();
/* first step: change the calling conventions of the local non-escaped entities */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *irg = get_irp_irg(i);
ir_entity *ent = get_irg_entity(irg);
ir_entity_usage flags = get_entity_usage(ent);
if (!entity_is_externally_visible(ent) &&
!(flags & ir_usage_address_taken)) {
if (!(flags & ir_usage_address_taken) && !entity_is_externally_visible(ent)) {
ir_type *mtp = get_entity_type(ent);
add_entity_additional_properties(ent, mtp_property_private);
......
......@@ -479,15 +479,15 @@ void assure_irg_outs(ir_graph *irg)
void compute_irp_outs(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)
compute_irg_outs(get_irp_irg(i));
}
void free_irp_outs(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)
free_irg_outs(get_irp_irg(i));
}
......
......@@ -69,7 +69,7 @@ ir_type *initial_type = NULL;
*/
void init_irtypeinfo(void)
{
int i;
size_t i, n;
if (initial_type == NULL)
initial_type = new_type_class(new_id_from_str("initial_type"));
......@@ -79,7 +79,7 @@ void init_irtypeinfo(void)
pmap_destroy(type_node_map);
type_node_map = pmap_create();
for (i = get_irp_n_irgs() - 1; i >= 0; --i)
for (i = 0, n = get_irp_n_irgs(); i < n; ++i)
set_irg_typeinfo_state(get_irp_irg(i), ir_typeinfo_none);
}
......
/*
* 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.
*
......@@ -185,7 +185,7 @@ static bool rta_fill_graph(ir_graph* graph)
*/
static int rta_fill_incremental(void)
{
int i;
size_t i, n;
int n_runs = 0;
bool rerun = true;
......@@ -193,15 +193,13 @@ static int rta_fill_incremental(void)
/* Need to take care of graphs that are externally
visible or sticky. Pretend that they are called: */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *graph = get_irp_irg(i);
ir_entity *ent = get_irg_entity(graph);
ir_linkage linkage = get_entity_linkage(ent);
if (entity_is_externally_visible(ent)
|| (linkage & IR_LINKAGE_HIDDEN_USER)) {
if ((linkage & IR_LINKAGE_HIDDEN_USER) || entity_is_externally_visible(ent))
pset_new_insert(_live_graphs, graph);
}
}
while (rerun) {
......@@ -237,12 +235,12 @@ static int rta_fill_incremental(void)
/**
* Count the number of graphs that we have found to be live.
*/
static int stats(void)
static size_t stats(void)
{
int i;
int n_live_graphs = 0;
size_t i, n;
size_t n_live_graphs = 0;
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *graph = get_irp_irg(i);
if (rta_is_alive_graph(graph))
......@@ -323,8 +321,8 @@ void rta_init(void)
n_runs = rta_fill_incremental();
DB((dbg, LEVEL_1, "RTA: n_graphs = %i\n", get_irp_n_irgs()));
DB((dbg, LEVEL_1, "RTA: n_live_graphs = %i\n", stats()));
DB((dbg, LEVEL_1, "RTA: n_graphs = %zu\n", get_irp_n_irgs()));
DB((dbg, LEVEL_1, "RTA: n_live_graphs = %zu\n", stats()));
DB((dbg, LEVEL_1, "RTA: n_runs = %i\n", n_runs));
# ifdef DEBUG_libfirm
......
......@@ -1115,7 +1115,7 @@ ir_reg_tree *construct_region_tree(ir_graph *irg)
*/
static void region_tree_walk2(ir_region *reg, irg_reg_walk_func *pre, irg_reg_walk_func *post, void *env)
{
int i, n;
size_t i, n;
if (pre)
pre(reg, env);
......
/*
* 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.
*
......@@ -190,7 +190,7 @@ void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void
current_ir_graph. */
void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env)
{
int i, n;
size_t i, n;
ir_graph *irg;
for (i = 0, n = get_irp_n_irgs(); i < n; i++) {
......@@ -478,7 +478,7 @@ static void walk_entity(ir_entity *ent, void *env)
if (ent->initializer != NULL) {
walk_initializer(ent->initializer, my_env);
} else if (entity_has_compound_ent_values(ent)) {
int i, n_vals = get_compound_ent_n_values(ent);
size_t i, n_vals = get_compound_ent_n_values(ent);
for (i = 0; i < n_vals; i++)
irg_walk(get_compound_ent_value(ent, i), my_env->pre, my_env->post, my_env->env);
......
/*
* 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.
*
......@@ -99,20 +99,20 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx)
*/
static void traverse_block_pre(ir_node *block, block_entry_t *entry, irg_walk_func *pre, void *env)
{
int j;
size_t j;
for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) {
ir_node *node = entry->cf_list[j];
for (j = ARR_LEN(entry->cf_list); j > 0;) {
ir_node *node = entry->cf_list[--j];
pre(node, env);
}
for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) {
ir_node *node = entry->df_list[j];
for (j = ARR_LEN(entry->df_list); j > 0;) {
ir_node *node = entry->df_list[--j];
pre(node, env);
}
for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) {
ir_node *node = entry->phi_list[j];
for (j = ARR_LEN(entry->phi_list); j > 0;) {
ir_node *node = entry->phi_list[--j];
pre(node, env);
}
......@@ -125,7 +125,7 @@ static void traverse_block_pre(ir_node *block, block_entry_t *entry, irg_walk_fu
static void traverse_block_post(ir_node *block, block_entry_t *entry,
irg_walk_func *post, void *env)
{
int j, n;
size_t j, n;
post(block, env);
......@@ -150,10 +150,10 @@ static void traverse_block_post(ir_node *block, block_entry_t *entry,
*/
static void traverse_pre(blk_collect_data_t *blks, irg_walk_func *pre, void *env)
{
int i;
size_t i;
for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) {
ir_node *block = blks->blk_list[i];
for (i = ARR_LEN(blks->blk_list); i > 0;) {
ir_node *block = blks->blk_list[--i];
block_entry_t *entry = block_find_entry(block, blks);
traverse_block_pre(block, entry, pre, env);
......@@ -170,7 +170,7 @@ static void traverse_pre(blk_collect_data_t *blks, irg_walk_func *pre, void *env
*/
static void traverse_post(blk_collect_data_t *blks, irg_walk_func *post, void *env)
{