Added routine remove_irp_irg.
[libfirm] / ir / tr / type.h
index 6f7e0e0..66c41ec 100644 (file)
 typedef struct entity entity;
 #endif
 
+#ifndef _IR_NODE_TYPEDEF_
+#define _IR_NODE_TYPEDEF_
+typedef struct ir_node ir_node;
+#endif
+
 /****s* type/type
  *
  * NAME
@@ -87,6 +92,8 @@ typedef struct entity entity;
  */
 typedef struct type type;
 
+void*       get_type_link(type *tp);
+void        set_type_link(type *tp, void *l);
 tp_op*      get_type_tpop(type *tp);
 ident*      get_type_tpop_nameid(type *tp);
 const char* get_type_tpop_name(type *tp);
@@ -100,8 +107,28 @@ void        set_type_nameid(type *tp, ident* id);
 const char* get_type_name(type *tp);
 
 int         get_type_size(type *tp);
+/* For primitives and pointer types the size is always fixed.
+   This call is legal but has no effect. */
 void        set_type_size(type *tp, int size);
 
+typedef enum {
+  layout_undefined,    /* The layout of this type is not defined.
+                         Address computation to access fields is not
+                         possible, fields must be accessed by Sel nodes.
+                         This is the default value except for pointer and
+                         primitive types. */
+  layout_fixed         /* The layout is fixed, all component/member entities
+                         have an offset assigned.  Size of the type is known.
+                         Arrays can be accessed by explicit address
+                         computation. Default for pointer and primitive types.
+                      */
+} type_state;
+
+type_state  get_type_state(type *tp);
+/* For primitives and pointer types the layout is always fixed.
+   This call is legal but has no effect. */
+void        set_type_state(type *tp, type_state state);
+
 unsigned long get_type_visited(type *tp);
 void        set_type_visited(type *tp, unsigned long num);
 /* Sets visited field in type to type_visited. */
@@ -165,21 +192,50 @@ int is_type            (void *thing);
 /* create a new class type */
 type   *new_type_class (ident *name);
 
-/* manipulate private fields of class type  */
+/** manipulate private fields of class type  **/
+/* Adds the entity as member of the class.  */
 void    add_class_member   (type *clss, entity *member);
+/* Returns the number of members of this class. */
 int     get_class_n_member (type *clss);
+/* Returns the member at position pos, 0 <= pos < n_member */
 entity *get_class_member   (type *clss, int pos);
+/* Overwrites the member at position pos, 0 <= pos < n_member with
+   the passed entity. */
 void    set_class_member   (type *clss, entity *member, int pos);
+/* Finds member in the list of members and overwrites it with NULL */
+void    remove_class_member(type *clss, entity *member);
 
+
+/* Adds subtype as subtype to clss.
+   Checks whether clss is a supertype of subtype.  If not
+   adds also clss as supertype to subtype.  */
 void    add_class_subtype   (type *clss, type *subtype);
+/* Returns the number of subtypes */
 int     get_class_n_subtype (type *clss);
+/* Gets the subtype at position pos, 0 <= pos < n_subtype. */
 type   *get_class_subtype   (type *clss, int pos);
+/* Sets the subtype at positioin pos, 0 <= pos < n_subtype.  Does not
+   set the corresponding supertype relation for subtype: this might
+   be a different position! */
 void    set_class_subtype   (type *clss, type *subtype, int pos);
+/* Finds subtype in the list of subtypes and overwrites it with NULL */
+void    remove_class_subtype(type *clss, type *subtype);
+
 
+/* Adds supertype as supertype to class.
+   Checks whether clss is a subtype of supertype.  If not
+   adds also clss as subtype to supertype.  */
 void    add_class_supertype   (type *clss, type *supertype);
+/* Returns the number of supertypes */
 int     get_class_n_supertype (type *clss);
+/* Gets the supertype at position pos,  0 <= pos < n_supertype. */
 type   *get_class_supertype   (type *clss, int pos);
+/* Sets the supertype at postition pos, 0 <= pos < n_subtype.  Does not
+   set the corresponding subtype relation for supertype: this might
+   be a different position! */
 void    set_class_supertype   (type *clss, type *supertype, int pos);
+/* Finds supertype in the list of supertypes and overwrites it with NULL */
+void    remove_class_supertype(type *clss, type *supertype);
 
 /* typecheck */
 bool    is_class_type(type *clss);
@@ -210,6 +266,8 @@ void    add_struct_member   (type *strct, entity *member);
 int     get_struct_n_member (type *strct);
 entity *get_struct_member   (type *strct, int pos);
 void    set_struct_member   (type *strct, int pos, entity *member);
+/* Finds member in the list of memberss and overwrites it with NULL */
+void    remove_struct_member (type *strct, entity *member);
 
 /* typecheck */
 bool    is_struct_type(type *strct);
@@ -282,6 +340,7 @@ int     get_union_n_members      (type *uni);
 void    add_union_member (type *uni, entity *member);
 entity *get_union_member (type *uni, int pos);
 void    set_union_member (type *uni, int pos, entity *member);
+void    remove_union_member (type *uni, entity *member);
 
 /* typecheck */
 bool    is_union_type          (type *uni);
@@ -308,23 +367,34 @@ 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.
+ *                    @@@ Do we need several entities?  One might want
+ *                    to select a dimension and not a single element in
+ *                    case of multidim arrays.
  * 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);
-void  set_array_bounds       (type *array, int dimension, int lower_bound,
-                                                          int upper_bound);
-void  set_array_lower_bound  (type *array, int dimension, int lower_bound);
-void  set_array_upper_bound  (type *array, int dimension, int upper_bound);
-int   get_array_lower_bound  (type *array, int dimension);
-int   get_array_upper_bound  (type *array, int dimension);
+void  set_array_bounds       (type *array, int dimension, ir_node *lower_bound,
+                                                          ir_node *upper_bound);
+void  set_array_lower_bound  (type *array, int dimension, ir_node *lower_bound);
+void  set_array_upper_bound  (type *array, int dimension, ir_node *upper_bound);
+ir_node * get_array_lower_bound  (type *array, int dimension);
+ir_node * 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);
 /*****/