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