Rimproved interface to type array.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 28 May 2001 15:37:26 +0000 (15:37 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 28 May 2001 15:37:26 +0000 (15:37 +0000)
emoved bug in xgprintf.c
tav.c.
aFaulty use of va_arg, became visible with new, stricter gcc 2.96.

[r159]

ir/tr/entity.c
ir/tr/type.c
ir/tr/type.h
ir/tr/type_t.h
ir/tv/tv.c

index fc25392..f54ee06 100644 (file)
@@ -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 *
index 2c6ea85..7e85bbd 100644 (file)
@@ -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);
index 6f7e0e0..0d4b05b 100644 (file)
@@ -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);
 /*****/
index b8e4d8d..61f1ee7 100644 (file)
@@ -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 {
index 2db2910..2026143 100644 (file)
@@ -1500,7 +1500,6 @@ tarval_ord (tarval *tv, int *fail)
   }
 }
 
-
 \f
 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)
 {