b8e4d8d643c5345893ab9d18af04f8d691bd1253
[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   int  *lower_bound;   /* Lower bounds of dimensions.  Usually all 0. */
56   int  *upper_bound;   /* Upper bounds or dimensions. */
57   type *element_type;  /* The type of the array elements. */
58 } arr_attr;
59
60 typedef struct {
61   int      n_enums;    /* Number of enumerators. */
62   tarval **enumer;     /* Contains all constants that represent a member
63                           of the enum -- enumerators. */
64   ident  **enum_nameid;/* Contains the names of the enum fields as specified by
65                           the source program */
66 } enm_attr;
67
68 typedef struct {
69   type *points_to;     /* The type of the enitity the pointer points to. */
70 } ptr_attr;
71
72 /*
73 typedef struct {        * No private attr yet. *
74 } pri_attr;
75 */
76
77 typedef union {
78   cls_attr ca;
79   stc_attr sa;
80   mtd_attr ma;
81   uni_attr ua;
82   arr_attr aa;
83   enm_attr ea;
84   ptr_attr pa;
85 } tp_attr;
86
87 struct type {
88   firm_kind kind;
89   tp_op *type_op;
90   ir_mode *mode;
91   ident *name;
92   int size;                /* Size of an entity of this type.  This is determined
93                               when fixing the layout of this class.  Size must be
94                               given in bytes. */
95   unsigned long visit;     /* visited counter for walks of the type information */
96   tp_attr attr;            /* type kind specific fields. This must be the last
97                               entry in this struct!  Varying size! */
98 };
99
100 /****f* type_t.h/new_type
101  *
102  * NAME
103  *   new_type - creates a new type representation
104  * SYNOPSIS
105  *  type *new_type(tp_op *type_op, ir_mode *mode, ident* name);
106  * INPUTS
107  *   type_op - the kind of this type
108  *   mode    - the mode to be used for this type, may be NULL
109  *   name    - an ident for the name of this type.
110  * RESULT
111  *   a new type of the given type.  The remaining private attributes are not
112  *   initalized.
113  ***
114  */
115 inline type *
116 new_type(tp_op *type_op,
117          ir_mode *mode,
118          ident* name);
119
120 # endif /* _TYPE_T_H_ */