/*
- * 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.
*
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Number of Load/Store nodes that possibly access this entity. */
-FIRM_API int get_entity_n_accesses(const ir_entity *ent);
+FIRM_API size_t get_entity_n_accesses(const ir_entity *ent);
/** Load/Store node that possibly access this entity. */
FIRM_API ir_node *get_entity_access(const ir_entity *ent, int pos);
/** Number of references to an entity, in form of SymConst/Sel.
* Including references from constant entities and the like. */
-FIRM_API int get_entity_n_references(const ir_entity *ent);
+FIRM_API size_t get_entity_n_references(const ir_entity *ent);
/** References to an entity, in form of SymConst/Sel
* Including references from constants. */
-FIRM_API ir_node *get_entity_reference(const ir_entity *ent, int pos);
+FIRM_API ir_node *get_entity_reference(const ir_entity *ent, size_t pos);
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* types */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Number of Alloc nodes that create an instance of this type. */
-FIRM_API int get_type_n_allocs(const ir_type *tp);
+FIRM_API size_t get_type_n_allocs(const ir_type *tp);
/** Alloc node that create an instance of this type. */
-FIRM_API ir_node *get_type_alloc(const ir_type *tp, int pos);
+FIRM_API ir_node *get_type_alloc(const ir_type *tp, size_t pos);
/** Number of Cast nodes that cast a pointer to this type. */
-FIRM_API int get_type_n_casts(const ir_type *tp);
+FIRM_API size_t get_type_n_casts(const ir_type *tp);
/** Cast node that cast a pointer to this type. */
-FIRM_API ir_node *get_type_cast(const ir_type *tp, int pos);
+FIRM_API ir_node *get_type_cast(const ir_type *tp, size_t pos);
FIRM_API void add_type_cast(const ir_type *tp, ir_node *cast);
/** Return number of upcasts. O(\#casts). */
-FIRM_API int get_class_n_upcasts(const ir_type *clss);
+FIRM_API size_t get_class_n_upcasts(const ir_type *clss);
/** Return number of downcasts. O(\#casts). */
-FIRM_API int get_class_n_downcasts(const ir_type *clss);
+FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
/* Access all pointer types that point to tp. */
-FIRM_API int get_type_n_pointertypes_to(const ir_type *tp);
-FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, int pos);
+FIRM_API size_t get_type_n_pointertypes_to(const ir_type *tp);
+FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos);
FIRM_API void add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
/* Access all array types that contain elements of type tp.
* Does not find subarrays, e.g., int[] being element of int[][]
* for multi dimensional arrays. */
-FIRM_API int get_type_n_arraytypes_of(const ir_type *tp);
-FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, int pos);
+FIRM_API size_t get_type_n_arraytypes_of(const ir_type *tp);
+FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos);
FIRM_API void add_type_arraytype_of(const ir_type *tp, ir_type *atp);
/*------------------------------------------------------------------*/
/*
- * 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.
*
/* Access routines for entities */
/**------------------------------------------------------------------*/
-int get_entity_n_accesses(const ir_entity *ent)
+size_t get_entity_n_accesses(const ir_entity *ent)
{
ir_node ** accs;
/*------------------------------------------------------------------*/
-int get_entity_n_references(const ir_entity *ent)
+size_t get_entity_n_references(const ir_entity *ent)
{
ir_node ** refs;
return ARR_LEN(refs);
}
-ir_node *get_entity_reference(const ir_entity *ent, int pos)
+ir_node *get_entity_reference(const ir_entity *ent, size_t pos)
{
ir_node ** refs;
- assert(0 <= pos && pos < get_entity_n_references(ent));
+ assert( pos < get_entity_n_references(ent));
refs = get_entity_reference_array(ent);
return refs[pos];
/**------------------------------------------------------------------*/
/* Number of Alloc nodes that create an instance of this type */
-int get_type_n_allocs(const ir_type *tp)
+size_t get_type_n_allocs(const ir_type *tp)
{
ir_node **allocs;
}
/* Alloc node that creates an instance of this type */
-ir_node *get_type_alloc(const ir_type *tp, int pos)
+ir_node *get_type_alloc(const ir_type *tp, size_t pos)
{
ir_node **allocs;
- assert(0 <= pos && pos < get_type_n_allocs(tp));
+ assert( pos < get_type_n_allocs(tp));
allocs = get_type_alloc_array(tp);
return allocs[pos];
#endif
/* Number of Cast nodes that create an instance of this type */
-int get_type_n_casts(const ir_type *tp)
+size_t get_type_n_casts(const ir_type *tp)
{
ir_node **casts;
}
-int get_class_n_upcasts(const ir_type *clss)
+size_t get_class_n_upcasts(const ir_type *clss)
{
- int i, n_casts = get_type_n_casts(clss);
- int n_instances = 0;
+ size_t i, n_casts = get_type_n_casts(clss);
+ size_t n_instances = 0;
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_upcast(cast))
return n_instances;
}
-int get_class_n_downcasts(const ir_type *clss)
+size_t get_class_n_downcasts(const ir_type *clss)
{
- int i, n_casts = get_type_n_casts(clss);
- int n_instances = 0;
+ size_t i, n_casts = get_type_n_casts(clss);
+ size_t n_instances = 0;
for (i = 0; i < n_casts; ++i) {
ir_node *cast = get_type_cast(clss, i);
if (is_Cast_downcast(cast))
}
/* Cast node that creates an instance of this type */
-ir_node *get_type_cast(const ir_type *tp, int pos)
+ir_node *get_type_cast(const ir_type *tp, size_t pos)
{
ir_node **casts;
- assert(0 <= pos && pos < get_type_n_casts(tp));
+ assert(pos < get_type_n_casts(tp));
casts = get_type_cast_array(tp);
return casts[pos];
}
#if 0
-void set_type_cast(const ir_type *tp, int pos, ir_node *n)
+void set_type_cast(const ir_type *tp, size_t pos, ir_node *n)
{
ir_node **casts;
- assert(0 <= pos && pos < get_type_n_casts(tp));
+ assert(pos < get_type_n_casts(tp));
assert(n && is_ir_node(n));
casts = get_type_cast_array(tp);
/*------------------------------------------------------------------*/
-int get_type_n_pointertypes_to(const ir_type *tp)
+size_t get_type_n_pointertypes_to(const ir_type *tp)
{
ir_type ** pts;
return ARR_LEN(pts);
}
-ir_type *get_type_pointertype_to(const ir_type *tp, int pos)
+ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos)
{
ir_type ** pts;
- assert(0 <= pos && pos < get_type_n_pointertypes_to(tp));
+ assert(pos < get_type_n_pointertypes_to(tp));
pts = get_type_pointertype_array(tp);
return pts[pos];
/*------------------------------------------------------------------*/
-int get_type_n_arraytypes_of(const ir_type *tp)
+size_t get_type_n_arraytypes_of(const ir_type *tp)
{
ir_type ** pts;
return ARR_LEN(pts);
}
-ir_type *get_type_arraytype_of(const ir_type *tp, int pos)
+ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos)
{
ir_type ** pts;
- assert(0 <= pos && pos < get_type_n_arraytypes_of(tp));
+ assert(pos < get_type_n_arraytypes_of(tp));
pts = get_type_arraytype_array(tp);
return pts[pos];
/* compute the trouts data structures. */
void compute_trouts(void)
{
- int i;
+ size_t i;
free_trouts();
init_trouts();
/* Compute outs for IR nodes. */
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- irg_walk_graph(get_irp_irg(i), NULL, chain_accesses, NULL);
+ for (i = get_irp_n_irgs(); i > 0;) {
+ ir_graph *irg = get_irp_irg(--i);
+ irg_walk_graph(irg, NULL, chain_accesses, NULL);
}
walk_const_code(NULL, chain_accesses, NULL);
/* Compute outs for types */
- for (i = get_irp_n_types() - 1; i >= 0; --i) {
- chain_types(get_irp_type(i));
+ for (i = get_irp_n_types(); i > 0;) {
+ ir_type *type = get_irp_type(--i);
+ chain_types(type);
}
irp->trouts_state = outs_consistent;
/*
- * 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.
*
* "prefix" node16, node17\n
*/
static void dump_node_list(FILE *F, firm_kind *k, const char *prefix,
- int (*get_entity_n_nodes)(firm_kind *ent),
- ir_node *(*get_entity_node)(firm_kind *ent, int pos),
+ size_t (*get_entity_n_nodes)(firm_kind *ent),
+ ir_node *(*get_entity_node)(firm_kind *ent, size_t pos),
const char *name)
{
- int i, n_nodes = get_entity_n_nodes(k);
+ size_t i, n_nodes = get_entity_n_nodes(k);
const char *comma = "";
- fprintf(F, "%s %s (%d):", prefix, name, n_nodes);
+ ir_fprintf(F, "%s %s (%zu):", prefix, name, n_nodes);
for (i = 0; i < n_nodes; ++i) {
if (i > 7 && !(i & 7)) { /* line break every eight node. */
fprintf(F, ",\n%s ", prefix);
* "prefix" node16, node17\n
*/
static void dump_type_list(FILE *F, ir_type *tp, const char *prefix,
- int (*get_n_types)(const ir_type *tp),
- ir_type *(*get_type)(const ir_type *tp, int pos),
+ size_t (*get_n_types)(const ir_type *tp),
+ ir_type *(*get_type)(const ir_type *tp, size_t pos),
const char *name)
{
- int i, n_nodes = get_n_types(tp);
+ size_t i, n_nodes = get_n_types(tp);
const char *comma = "";
- fprintf(F, "%s %s (%d):", prefix, name, n_nodes);
+ ir_fprintf(F, "%s %s (%zu):", prefix, name, n_nodes);
for (i = 0; i < n_nodes; ++i) {
if (i > 7 && !(i & 7)) { /* line break every eight node. */
fprintf(F, ",\n%s ", prefix);
if (get_trouts_state()) {
fprintf(F, "%s Entity outs:\n", prefix);
- dump_node_list(F, (firm_kind *)ent, prefix, (int(*)(firm_kind *))get_entity_n_accesses,
- (ir_node *(*)(firm_kind *, int))get_entity_access, "Accesses");
- dump_node_list(F, (firm_kind *)ent, prefix, (int(*)(firm_kind *))get_entity_n_references,
- (ir_node *(*)(firm_kind *, int))get_entity_reference, "References");
+ dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_accesses,
+ (ir_node *(*)(firm_kind *, size_t))get_entity_access, "Accesses");
+ dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_references,
+ (ir_node *(*)(firm_kind *, size_t))get_entity_reference, "References");
}
}
case tpo_array:
if (verbosity & dump_verbosity_typeattrs) {
- int i, n_dim;
+ size_t i, n_dim;
ir_type *elem_tp = get_array_element_type(tp);
fprintf(F, "\n array ");
if (get_trouts_state()) {
fprintf(F, "\n Type outs:\n");
- dump_node_list(F, (firm_kind *)tp, " ", (int(*)(firm_kind *))get_type_n_allocs,
- (ir_node *(*)(firm_kind *, int))get_type_alloc, "Allocations");
- dump_node_list(F, (firm_kind *)tp, " ", (int(*)(firm_kind *))get_type_n_casts,
- (ir_node *(*)(firm_kind *, int))get_type_cast, "Casts");
+ dump_node_list(F, (firm_kind *)tp, " ", (size_t(*)(firm_kind *))get_type_n_allocs,
+ (ir_node *(*)(firm_kind *, size_t))get_type_alloc, "Allocations");
+ dump_node_list(F, (firm_kind *)tp, " ", (size_t(*)(firm_kind *))get_type_n_casts,
+ (ir_node *(*)(firm_kind *, size_t))get_type_cast, "Casts");
dump_type_list(F, tp, " ", get_type_n_pointertypes_to, get_type_pointertype_to, "PointerTpsTo");
}
void dump_types_as_text(FILE *out)
{
- int i;
- int n_types = get_irp_n_types();
+ size_t i, n_types = get_irp_n_types();
for (i = 0; i < n_types; ++i) {
ir_type *type = get_irp_type(i);
void dump_globals_as_text(FILE *out)
{
ir_type *global_type = get_glob_type();
- int n_members = get_class_n_members(global_type);
- int i;
+ size_t n_members = get_class_n_members(global_type);
+ size_t i;
for (i = 0; i < n_members; ++i) {
ir_entity *entity = get_class_member(global_type, i);