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