* @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
* @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
* 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
* 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
* @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
* 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
* @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
* @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
/** 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);
#ifndef FIRM_IR_IRPROG_H
#define FIRM_IR_IRPROG_H
+#include <stddef.h>
#include "firm_types.h"
#include "irgraph.h"
#include "begin.h"
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.
* 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);
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);
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"
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));
/** 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);
* @date 7.2002
* @version $Id: irloop_t.h 17143 2008-01-02 20:56:33Z beck $
*/
-# include "config.h"
+#include "config.h"
#include <string.h>
#include <stdlib.h>
}
/* 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);
}
/* 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;
}
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
}
* 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
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;
/** 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);
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));
}
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. */
}
/* 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);
{
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;
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. */
*/
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 */
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;
}
}
}
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);
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);
/**
* 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];
}
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);
}
/**
* 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;
}
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);
}
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)
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;
}
#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;
// 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",
}
{
- 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;
}
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;
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;
}
}
*/
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;
}
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.
*/
void be_end_uses(be_uses_t *uses);
-#endif /* FIRM_BE_BEUSES_H */
+#endif
}
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: {
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);
}
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
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;
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);
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);
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 */
#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))
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));
}
}
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));
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));
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));
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
/* 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();
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 */
*/
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;
}
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);
}
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;
}
}
}
-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);
}
}
/* 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;
}
/*- File name / executable name or the like -*/
-void set_irp_prog_name(ident *name)
+void set_irp_prog_name(ident *name)
{
irp->name = name;
}
}
/* 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];
}
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];
#include "config.h"
#include <stdlib.h>
+#include <stdbool.h>
#include <assert.h>
#include "firm_types.h"
#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;
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;
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;
}
}
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];
}
* @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;
}
/**
* 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;
}
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;
}
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));
}
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));
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();
}
}
-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;
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 {
}
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);
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));
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]);
}
/** 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. */