From: Beyhan Date: Tue, 13 Jul 2004 13:59:25 +0000 (+0000) Subject: removed empty entries from arrays X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=58ed1dbc91297e868c47ffb3b622c66f28065105;p=libfirm removed empty entries from arrays [r3429] --- diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index a6162da36..27ec6ddc0 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -283,10 +283,10 @@ static void prepare_irg_end(ir_graph * irg, irg_data_t * data) { for (i = get_Block_n_cfgpreds(end_block) - 1; i >= 0; --i) { if (get_irn_op(cfgpred_arr[i]) == op_Return) { if (ret_arr) { - ARR_APP1(ir_node *, ret_arr, cfgpred_arr[i]); + ARR_APP1(ir_node *, ret_arr, cfgpred_arr[i]); } else { - ret_arr = NEW_ARR_F(ir_node *, 1); - ret_arr[0] = cfgpred_arr[i]; + ret_arr = NEW_ARR_F(ir_node *, 1); + ret_arr[0] = cfgpred_arr[i]; } ++n_ret; } diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index e455c8896..398cfe22f 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -1191,7 +1191,7 @@ new_Phi_in_stack(void) { res = (Phi_in_stack *) malloc ( sizeof (Phi_in_stack)); - res->stack = NEW_ARR_F (ir_node *, 1); + res->stack = NEW_ARR_F (ir_node *, 0); res->pos = 0; return res; diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index 0c702fb31..35f28f1d1 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -37,7 +37,7 @@ INLINE void remove_irp_type_from_list (type *typ) { int i; assert(typ); #if 0 - for (i = 1; i < (ARR_LEN (irp->types)); i++) { + for (i = 0; i < (ARR_LEN (irp->types)); i++) { #else for (i = ARR_LEN (irp->types) -1; i >= 0; i--) { #endif @@ -60,8 +60,8 @@ ir_prog *new_ir_prog (void) { memset(res, 0, sizeof(res)); irp = res; /* res->obst = (struct obstack *) xmalloc (sizeof (struct obstack)); */ - res->graphs = NEW_ARR_F (ir_graph *, 1); - res->types = NEW_ARR_F (type *, 1); + res->graphs = NEW_ARR_F (ir_graph *, 0); + res->types = NEW_ARR_F (type *, 0); res->name = new_id_from_str("no_name_set"); #ifdef DEBUG_libfirm @@ -124,7 +124,7 @@ void remove_irp_irg(ir_graph *irg){ int i; assert(irg); free_ir_graph(irg); - for (i = 1; i < (ARR_LEN (irp->graphs)); i++) { + for (i = 0; i < (ARR_LEN (irp->graphs)); i++) { if (irp->graphs[i] == irg) { for(; i < (ARR_LEN (irp->graphs)) - 1; i++) { irp->graphs[i] = irp->graphs[i+1]; @@ -145,9 +145,9 @@ ir_graph *(get_irp_irg)(int pos){ void set_irp_irg(int pos, ir_graph *irg) { assert (irp && irg); - assert (pos < (ARR_LEN((irp)->graphs) - 1)); + assert (pos < (ARR_LEN((irp)->graphs))); /* Strangely the first element of the array is NULL. Why?? */ - irp->graphs[pos+1] = irg; + irp->graphs[pos] = irg; } /* Adds type to the list of types in irp. */ @@ -171,9 +171,9 @@ type *(get_irp_type) (int pos) { void set_irp_type(int pos, type *typ) { assert (irp && typ); - assert (pos < (ARR_LEN((irp)->types) - 1)); + assert (pos < (ARR_LEN((irp)->types))); /* Strangely the first element of the array is NULL. Why?? */ - irp->types[pos+1] = typ; + irp->types[pos] = typ; } #ifdef DEBUG_libfirm diff --git a/ir/ir/irprog_t.h b/ir/ir/irprog_t.h index ddaae7628..9fc9ad80e 100644 --- a/ir/ir/irprog_t.h +++ b/ir/ir/irprog_t.h @@ -68,14 +68,14 @@ static INLINE int __get_irp_n_irgs(void) { assert (irp && irp->graphs); /* Strangely the first element of the array is NULL. Why?? */ - return (ARR_LEN((irp)->graphs) - 1); + return (ARR_LEN((irp)->graphs)); } static INLINE ir_graph * __get_irp_irg(int pos){ assert (irp && irp->graphs); /* Strangely the first element of the array is NULL. Why?? */ - return irp->graphs[pos+1]; + return irp->graphs[pos]; } @@ -83,7 +83,7 @@ static INLINE int __get_irp_n_types (void) { assert (irp && irp->types); /* Strangely the first element of the array is NULL. Why?? */ - return (ARR_LEN((irp)->types) - 1); + return (ARR_LEN((irp)->types)); } static INLINE type * @@ -91,7 +91,7 @@ __get_irp_type(int pos) { assert (irp && irp->types); /* Strangely the first element of the array is NULL. Why?? */ /* Don't set the skip_tid result so that no double entries are generated. */ - return skip_tid(irp->types[pos+1]); + return skip_tid(irp->types[pos]); } #ifdef DEBUG_libfirm diff --git a/ir/tr/type.c b/ir/tr/type.c index 962d7a324..b937420f4 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -634,9 +634,9 @@ type *new_type_class (ident *name) { res = new_type(type_class, NULL, name); - res->attr.ca.members = NEW_ARR_F (entity *, 1); - res->attr.ca.subtypes = NEW_ARR_F (type *, 1); - res->attr.ca.supertypes = NEW_ARR_F (type *, 1); + res->attr.ca.members = NEW_ARR_F (entity *, 0); + res->attr.ca.subtypes = NEW_ARR_F (type *, 0); + res->attr.ca.supertypes = NEW_ARR_F (type *, 0); res->attr.ca.peculiarity = peculiarity_existent; res->attr.ca.dfn = 0; @@ -699,13 +699,13 @@ entity *get_class_member_by_name(type *clss, ident *name) { void set_class_member (type *clss, entity *member, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_members(clss)); - clss->attr.ca.members[pos+1] = member; + clss->attr.ca.members[pos] = member; } void set_class_members (type *clss, entity **members, int arity) { int i; assert(clss && (clss->type_op == type_class)); DEL_ARR_F(clss->attr.ca.members); - clss->attr.ca.members = NEW_ARR_F (entity *, 1); + clss->attr.ca.members = NEW_ARR_F (entity *, 0); for (i = 0; i < arity; i++) { set_entity_owner(members[i], clss); ARR_APP1 (entity *, clss->attr.ca.members, members[i]); @@ -714,7 +714,7 @@ void set_class_members (type *clss, entity **members, int arity) { void remove_class_member(type *clss, entity *member) { int i; assert(clss && (clss->type_op == type_class)); - for (i = 1; i < (ARR_LEN (clss->attr.ca.members)); i++) { + for (i = 0; i < (ARR_LEN (clss->attr.ca.members)); i++) { if (clss->attr.ca.members[i] == member) { for(; i < (ARR_LEN (clss->attr.ca.members)) - 1; i++) clss->attr.ca.members[i] = clss->attr.ca.members[i + 1]; @@ -736,22 +736,22 @@ void add_class_subtype (type *clss, type *subtype) { } int get_class_n_subtypes (type *clss) { assert(clss && (clss->type_op == type_class)); - return (ARR_LEN (clss->attr.ca.subtypes))-1; + return (ARR_LEN (clss->attr.ca.subtypes)); } type *get_class_subtype (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_subtypes(clss)); - return clss->attr.ca.subtypes[pos+1] = skip_tid(clss->attr.ca.subtypes[pos+1]); + return clss->attr.ca.subtypes[pos] = skip_tid(clss->attr.ca.subtypes[pos]); } void set_class_subtype (type *clss, type *subtype, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_subtypes(clss)); - clss->attr.ca.subtypes[pos+1] = subtype; + clss->attr.ca.subtypes[pos] = subtype; } void remove_class_subtype(type *clss, type *subtype) { int i; assert(clss && (clss->type_op == type_class)); - for (i = 1; i < (ARR_LEN (clss->attr.ca.subtypes)); i++) + for (i = 0; i < (ARR_LEN (clss->attr.ca.subtypes)); i++) if (clss->attr.ca.subtypes[i] == subtype) { for(; i < (ARR_LEN (clss->attr.ca.subtypes))-1; i++) clss->attr.ca.subtypes[i] = clss->attr.ca.subtypes[i+1]; @@ -773,7 +773,7 @@ void add_class_supertype (type *clss, type *supertype) { } int get_class_n_supertypes (type *clss) { assert(clss && (clss->type_op == type_class)); - return (ARR_LEN (clss->attr.ca.supertypes))-1; + return (ARR_LEN (clss->attr.ca.supertypes)); } int get_class_supertype_index(type *clss, type *super_clss) { int i; @@ -787,17 +787,17 @@ int get_class_supertype_index(type *clss, type *super_clss) { type *get_class_supertype (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_supertypes(clss)); - return clss->attr.ca.supertypes[pos+1] = skip_tid(clss->attr.ca.supertypes[pos+1]); + return clss->attr.ca.supertypes[pos] = skip_tid(clss->attr.ca.supertypes[pos]); } void set_class_supertype (type *clss, type *supertype, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_supertypes(clss)); - clss->attr.ca.supertypes[pos+1] = supertype; + clss->attr.ca.supertypes[pos] = supertype; } void remove_class_supertype(type *clss, type *supertype) { int i; assert(clss && (clss->type_op == type_class)); - for (i = 1; i < (ARR_LEN (clss->attr.ca.supertypes)); i++) + for (i = 0; i < (ARR_LEN (clss->attr.ca.supertypes)); i++) if (clss->attr.ca.supertypes[i] == supertype) { for(; i < (ARR_LEN (clss->attr.ca.supertypes))-1; i++) clss->attr.ca.supertypes[i] = clss->attr.ca.supertypes[i+1]; @@ -861,7 +861,7 @@ bool is_subclass_of(type *low, type *high) { type *new_type_struct (ident *name) { type *res; res = new_type(type_struct, NULL, name); - res->attr.sa.members = NEW_ARR_F (entity *, 1); + res->attr.sa.members = NEW_ARR_F (entity *, 0); return res; } type *new_d_type_struct (ident *name, dbg_info* db) { @@ -883,7 +883,7 @@ void free_struct_attrs (type *strct) { /* manipulate private fields of struct */ int get_struct_n_members (type *strct) { assert(strct && (strct->type_op == type_struct)); - return (ARR_LEN (strct->attr.sa.members))-1; + return (ARR_LEN (strct->attr.sa.members)); } void add_struct_member (type *strct, entity *member) { @@ -896,7 +896,7 @@ void add_struct_member (type *strct, entity *member) { entity *get_struct_member (type *strct, int pos) { assert(strct && (strct->type_op == type_struct)); assert(pos >= 0 && pos < get_struct_n_members(strct)); - return strct->attr.sa.members[pos+1]; + return strct->attr.sa.members[pos]; } int get_struct_member_index(type *strct, entity *mem) { @@ -912,12 +912,12 @@ void set_struct_member (type *strct, int pos, entity *member) { assert(strct && (strct->type_op == type_struct)); assert(pos >= 0 && pos < get_struct_n_members(strct)); assert(get_entity_type(member)->type_op != type_method);/* @@@ lowerfirm !!*/ - strct->attr.sa.members[pos+1] = member; + strct->attr.sa.members[pos] = member; } void remove_struct_member(type *strct, entity *member) { int i; assert(strct && (strct->type_op == type_struct)); - for (i = 1; i < (ARR_LEN (strct->attr.sa.members)); i++) + for (i = 0; i < (ARR_LEN (strct->attr.sa.members)); i++) if (strct->attr.sa.members[i] == member) { for(; i < (ARR_LEN (strct->attr.sa.members))-1; i++) strct->attr.sa.members[i] = strct->attr.sa.members[i+1]; @@ -1174,7 +1174,7 @@ type *new_type_union (ident *name) { res = new_type(type_union, NULL, name); /*res->attr.ua.unioned_type = (type **) xmalloc (sizeof (type *) * n_types); res->attr.ua.delim_names = (ident **) xmalloc (sizeof (ident *) * n_types); */ - res->attr.ua.members = NEW_ARR_F (entity *, 1); + res->attr.ua.members = NEW_ARR_F (entity *, 0); return res; } type *new_d_type_union (ident *name, dbg_info* db) { @@ -1226,7 +1226,7 @@ void set_union_delim_nameid (type *uni, int pos, ident *id) { #endif int get_union_n_members (type *uni) { assert(uni && (uni->type_op == type_union)); - return (ARR_LEN (uni->attr.ua.members))-1; + return (ARR_LEN (uni->attr.ua.members)); } void add_union_member (type *uni, entity *member) { assert(uni && (uni->type_op == type_union)); @@ -1235,17 +1235,17 @@ void add_union_member (type *uni, entity *member) { entity *get_union_member (type *uni, int pos) { assert(uni && (uni->type_op == type_union)); assert(pos >= 0 && pos < get_union_n_members(uni)); - return uni->attr.ua.members[pos+1]; + return uni->attr.ua.members[pos]; } void set_union_member (type *uni, int pos, entity *member) { assert(uni && (uni->type_op == type_union)); assert(pos >= 0 && pos < get_union_n_members(uni)); - uni->attr.ua.members[pos+1] = member; + uni->attr.ua.members[pos] = member; } void remove_union_member(type *uni, entity *member) { int i; assert(uni && (uni->type_op == type_union)); - for (i = 1; i < (ARR_LEN (uni->attr.ua.members)); i++) + for (i = 0; i < (ARR_LEN (uni->attr.ua.members)); i++) if (uni->attr.ua.members[i] == member) { for(; i < (ARR_LEN (uni->attr.ua.members))-1; i++) uni->attr.ua.members[i] = uni->attr.ua.members[i+1]; diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h index 4c52c8d2d..7a926f4ed 100644 --- a/ir/tr/type_t.h +++ b/ir/tr/type_t.h @@ -308,14 +308,14 @@ __is_class_type(type *clss) { static INLINE int __get_class_n_members (type *clss) { assert(clss && (clss->type_op == type_class)); - return (ARR_LEN (clss->attr.ca.members))-1; + return (ARR_LEN (clss->attr.ca.members)); } static INLINE entity * __get_class_member (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); assert(pos >= 0 && pos < get_class_n_members(clss)); - return clss->attr.ca.members[pos+1]; + return clss->attr.ca.members[pos]; } static INLINE int