From: Götz Lindenmaier Date: Mon, 28 May 2001 15:37:26 +0000 (+0000) Subject: Rimproved interface to type array. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=603ff7b14c9f34c096ffabbed68ee2ffb48ae158;p=libfirm Rimproved interface to type array. emoved bug in xgprintf.c tav.c. aFaulty use of va_arg, became visible with new, stricter gcc 2.96. [r159] --- diff --git a/ir/tr/entity.c b/ir/tr/entity.c index fc2539274..f54ee0664 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -53,6 +53,9 @@ new_entity (type *owner, ident *name, type *type) case tpo_union: { add_union_member (owner, res); } break; + case tpo_array: { + set_array_element_entity(owner, res); + } break; default: assert(0); } @@ -91,7 +94,9 @@ inline void /* should this go into type.c? */ assert_legal_owner_of_ent(type *owner) { assert (get_type_tpop_code(owner) == tpo_class || get_type_tpop_code(owner) == tpo_union || - get_type_tpop_code(owner) == tpo_struct); + get_type_tpop_code(owner) == tpo_struct || + get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity + -- to select fields! */ } inline ident * diff --git a/ir/tr/type.c b/ir/tr/type.c index 2c6ea85eb..7e85bbdf5 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -357,12 +357,15 @@ bool is_union_type (type *uni) { /* create a new type array -- set dimension sizes independently */ -type *new_type_array (ident *name, int n_dimensions) { +type *new_type_array (ident *name, int n_dimensions, + type *element_type) { type *res; res = new_type(type_array, NULL, name); res->attr.aa.n_dimensions = n_dimensions; res->attr.aa.lower_bound = (int *) xmalloc (sizeof (int) * n_dimensions); res->attr.aa.upper_bound = (int *) xmalloc (sizeof (int) * n_dimensions); + res->attr.aa.element_type = element_type; + new_entity(res, name, element_type); return res; } @@ -401,6 +404,15 @@ type *get_array_element_type (type *array) { assert(array && (array->type_op == type_array)); return array->attr.aa.element_type; } +void set_array_element_entity (type *array, entity *ent) { + assert(array && (array->type_op == type_array)); + array->attr.aa.element_ent = ent; +} +entity *get_array_element_entity (type *array) { + assert(array && (array->type_op == type_array)); + return array->attr.aa.element_ent; +} + /* typecheck */ bool is_array_type (type *array) { assert(array); diff --git a/ir/tr/type.h b/ir/tr/type.h index 6f7e0e023..0d4b05b8c 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -308,10 +308,15 @@ void set_union_delim_nameid (type *uni, int pos, ident *id); * *lower_bound Lower bounds of dimensions. Usually all 0. * *upper_bound Upper bounds or dimensions. * *element_type The type of the array elements. + * *element_ent An entity for the array elements to be used for + * element selection with Sel. * SOURCE */ -/* create a new type array -- set dimension sizes independently */ -type *new_type_array (ident *name, int n_dimensions); +/* create a new type array -- + Set dimension sizes after call to constructor with set_* routines. + Entity for array elements is built automatically. */ +type *new_type_array (ident *name, int n_dimensions, + type *element_type); /* manipulate private fields of array type */ int get_array_n_dimensions (type *array); @@ -325,6 +330,9 @@ int get_array_upper_bound (type *array, int dimension); void set_array_element_type (type *array, type *type); type *get_array_element_type (type *array); +void set_array_element_entity (type *array, entity *ent); +entity *get_array_element_entity (type *array); + /* typecheck */ bool is_array_type (type *array); /*****/ diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h index b8e4d8d64..61f1ee79e 100644 --- a/ir/tr/type_t.h +++ b/ir/tr/type_t.h @@ -55,6 +55,8 @@ typedef struct { int *lower_bound; /* Lower bounds of dimensions. Usually all 0. */ int *upper_bound; /* Upper bounds or dimensions. */ type *element_type; /* The type of the array elements. */ + entity *element_ent; /* Entity for the array elements, to be used for + element selection with Sel. */ } arr_attr; typedef struct { diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 2db2910e6..202614358 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1500,7 +1500,6 @@ tarval_ord (tarval *tv, int *fail) } } - int tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN) @@ -1598,6 +1597,7 @@ tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN) return printed; } + ir_mode * get_tv_mode (tarval *tv) {