c9e435e6b7ca6af9ef5ae0cf097662f5cc4af4a6
[libfirm] / ir / tr / type_t.h
1
2 /* $Id$ */
3
4 # ifndef _TYPE_T_H_
5 # define _TYPE_T_H_
6
7 # include "type.h"
8
9 /**
10  *
11  *   file type_t.h
12  *   (C) 2001 by Universitaet Karlsruhe
13  *   Goetz Lindenmaier
14  *   This file contains the datatypes hidden in type.h.
15  * @see  type.h tpop_t.h tpop.h
16  */
17
18 typedef struct {
19   entity **members;    /* fields and methods of this class */
20   type   **subtypes;   /* direct subtypes */
21   type   **supertypes; /* direct supertypes */
22   peculiarity peculiarity;
23   int dfn;             /* number used for 'instanceof' operator */
24 } cls_attr;
25
26 typedef struct {
27   entity **members;    /* fields of this struct. No method entities
28                           allowed. */
29 } stc_attr;
30
31 typedef struct {
32   int n_params;        /* number of parameters */
33   type **param_type;   /* code generation needs this information.
34                           @@@ Should it be generated by the frontend,
35                           or does this impose unnecessary work for
36                           optimizations that change the parameters of
37                           methods? */
38   int n_res;           /* number of results */
39   type **res_type;     /* array with result types */
40 } mtd_attr;
41
42 typedef struct {
43   int     n_types;
44   /* type  **unioned_type; * a list of unioned types. */
45   /* ident **delim_names;  * names of the union delimiters. */
46   entity **members;    /* fields of this union. No method entities
47                           allowed.  */
48
49 } uni_attr;
50
51 typedef struct {
52   int   n_dimensions;  /* Number of array dimensions.  */
53   ir_node **lower_bound;   /* Lower bounds of dimensions.  Usually all 0. */
54   ir_node **upper_bound;   /* Upper bounds or dimensions. */
55   int *order;              /* Ordering of dimensions. */
56   type *element_type;  /* The type of the array elements. */
57   entity *element_ent; /* Entity for the array elements, to be used for
58                           element selection with Sel. */
59 } arr_attr;
60
61 typedef struct {
62   int      n_enums;    /* Number of enumerators. */
63   tarval **enumer;     /* Contains all constants that represent a member
64                           of the enum -- enumerators. */
65   ident  **enum_nameid;/* Contains the names of the enum fields as specified by
66                           the source program */
67 } enm_attr;
68
69 typedef struct {
70   type *points_to;     /* The type of the enitity the pointer points to. */
71 } ptr_attr;
72
73 /*
74 typedef struct {   * No private attr yet! *
75 } pri_attr; */
76
77
78 /*
79 typedef struct {        * No private attr, must be smaller than others! *
80 } id_attr;
81 */
82
83
84 typedef union {
85   cls_attr ca;
86   stc_attr sa;
87   mtd_attr ma;
88   uni_attr ua;
89   arr_attr aa;
90   enm_attr ea;
91   ptr_attr pa;
92 } tp_attr;
93
94 struct type {
95   firm_kind kind;
96   tp_op *type_op;
97   ident *name;
98   type_state state;        /* Represents the types state: layout undefined or
99                               fixed. */
100   int size;                /* Size of an entity of this type.  This is determined
101                               when fixing the layout of this class.  Size must be
102                               given in bytes. */
103   ir_mode *mode;           /* The mode for atomic types */
104   unsigned long visit;     /* visited counter for walks of the type information */
105   void *link;              /* holds temporary data - like in irnode_t.h */
106   struct dbg_info* dbi;    /* A pointer to information for debug support. */
107   tp_attr attr;            /* type kind specific fields. This must be the last
108                               entry in this struct!  Varying size! */
109 };
110
111 /**
112  *
113  *   creates a new type representation
114  *   @param type_op - the kind of this type.  May not be type_id.
115  *   @param mode    - the mode to be used for this type, may be NULL
116  *   @param name    - an ident for the name of this type.
117  *   @return a new type of the given type.  The remaining private attributes are not
118  *   @return initalized.  The type is in state layout_undefined.
119  *
120  */
121 INLINE type *
122 new_type(tp_op *type_op,
123          ir_mode *mode,
124          ident* name);
125 void free_type_attrs       (type *tp);
126
127 INLINE void free_class_attrs      (type *clss);
128 INLINE void free_struct_attrs     (type *strct);
129 INLINE void free_method_attrs     (type *method);
130 INLINE void free_union_attrs      (type *uni);
131 INLINE void free_array_attrs      (type *array);
132 INLINE void free_enumeration_attrs(type *enumeration);
133 INLINE void free_pointer_attrs    (type *pointer);
134 INLINE void free_primitive_attrs  (type *primitive);
135
136
137 # endif /* _TYPE_T_H_ */