Added support for lowering to entites, types.
[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 typedef union {
80   cls_attr ca;
81   stc_attr sa;
82   mtd_attr ma;
83   uni_attr ua;
84   arr_attr aa;
85   enm_attr ea;
86   ptr_attr pa;
87 } tp_attr;
88
89 struct type {
90   firm_kind kind;
91   tp_op *type_op;
92   ir_mode *mode;
93   ident *name;
94   type_state state;        /* Represents the types state: layout undefined or
95                               fixed. */
96   int size;                /* Size of an entity of this type.  This is determined
97                               when fixing the layout of this class.  Size must be
98                               given in bytes. */
99   unsigned long visit;     /* visited counter for walks of the type information */
100   tp_attr attr;            /* type kind specific fields. This must be the last
101                               entry in this struct!  Varying size! */
102 };
103
104 /****f* type_t.h/new_type
105  *
106  * NAME
107  *   new_type - creates a new type representation
108  * SYNOPSIS
109  *  type *new_type(tp_op *type_op, ir_mode *mode, ident* name);
110  * INPUTS
111  *   type_op - the kind of this type
112  *   mode    - the mode to be used for this type, may be NULL
113  *   name    - an ident for the name of this type.
114  * RESULT
115  *   a new type of the given type.  The remaining private attributes are not
116  *   initalized.  The type is in state layout_undefined.
117  ***
118  */
119 inline type *
120 new_type(tp_op *type_op,
121          ir_mode *mode,
122          ident* name);
123
124 # endif /* _TYPE_T_H_ */