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