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