Normalisierung der Zugriffsfunktionen,
[libfirm] / ir / ir / irnode_t.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** declarations of an ir node
7 */
8
9 /* $Id$ */
10
11 # ifndef _IRNODE_T_H_
12 # define _IRNODE_T_H_
13
14 # include "irnode.h"
15 # include "xprintf.h"
16 # include "irop_t.h"
17 # include "common_t.h"
18 # include "irdom_t.h" /* For size of struct dom_info. */
19 # include "dbginfo.h"
20
21 # include "exc.h"
22
23 /** ir node attributes **/
24
25 /* Block attributes */
26 typedef struct {
27   unsigned long block_visited;  /* for the walker that walks over all blocks. */
28   /* Attributes private to construction: */
29   bool matured;               /* if set, all in-nodes of the block are fixed */
30   struct ir_node **graph_arr; /* array to store all parameters */
31   struct dom_info dom;        /* Datastructure that holds information about dominators.
32                                  @@@ Eventually overlay with graph_arr as only valid
33                                  in different phases.  Eventually inline the whole
34                                  datastructure. */
35   exc_t exc;                  /* role of this block for exception handling */
36   ir_node *handler_entry;     /* handler entry block iff this block is part of a region */
37   ir_node ** in_cg;           /* array with predecessors in
38                                * interprocedural_view, if they differ
39                                * from intraprocedural predecessors */
40 } block_attr;
41
42 /* Cond attributes */
43 typedef struct {
44   cond_kind kind;    /* flavor of Cond */
45   long default_proj; /* for optimization: biggest Proj number, i.e. the one
46                         used for default. */
47 } cond_attr;
48
49 /* SymConst attributes */
50 /*   This union contains the symbolic information represented by the node */
51 typedef union type_or_id {
52   type *typ;
53   ident *ptrinfo;
54 } type_or_id;
55
56 typedef struct {
57   type_or_id tori;
58   symconst_kind num;
59 } symconst_attr;
60
61 /* Sel attributes */
62 typedef struct {
63   entity *ent;          /* entity to select */
64 } sel_attr;
65
66 typedef struct {
67   type *cld_tp;         /* type of called procedure */
68 #if PRECISE_EXC_CONTEXT
69   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions */
70 #endif
71   entity ** callee_arr; /* result of callee analysis */
72 } call_attr;
73
74 /* Alloc attributes */
75 typedef struct {
76   type *type;           /* Type of the allocated object.  */
77   where_alloc where;    /* stack, heap or other managed part of memory */
78 #if PRECISE_EXC_CONTEXT
79   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions */
80 #endif
81 } alloc_attr;
82
83 /* InstOf attributes */
84 typedef struct
85 {
86   type *ent;
87   int dfn;
88 } io_attr;
89
90 /* Filter attributes */
91 typedef struct {
92   long proj;                 /* contains the result position to project (Proj) */
93   ir_node ** in_cg;          /* array with interprocedural predecessors (Phi) */
94 } filter_attr;
95
96 /* EndReg/EndExcept attributes */
97 typedef struct {
98   ir_graph * irg;            /* ir_graph this node belongs to (for
99                               * navigating in interprocedural graphs) */
100 } end_attr;
101
102 /* CallBegin attributes */
103 typedef struct {
104   ir_graph * irg;            /* ir_graph this node belongs to (for
105                               * navigating in interprocedural graphs) */
106   ir_node * call;            /* associated Call-operation */
107 } callbegin_attr;
108
109 /* Some irnodes just have one attribute, these are stored here,
110    some have more. Their name is 'irnodename_attr' */
111 typedef union {
112   block_attr     block; /* For Block: Fields needed to construct it */
113   cond_attr      c;     /* For Cond. */
114   struct tarval *con;   /* For Const: contains the value of the constant */
115   symconst_attr  i;     /* For SymConst. */
116   sel_attr       s;     /* For Sel. */
117   call_attr      call;  /* For Call: pointer to the type of the method to call */
118   callbegin_attr callbegin; /* For CallBegin */
119   alloc_attr     a;     /* For Alloc. */
120   io_attr                io;    /* For InstOf */
121   type          *f;     /* For Free. */
122   int            phi0_pos;  /* For Phi. Used to remember the value defined by
123                                this Phi node.  Needed when the Phi is completed
124                                to call get_r_internal_value to find the
125                                predecessors. If this attribute is set, the Phi
126                                node takes the role of the obsolete Phi0 node,
127                                therefore the name. */
128   long           proj;   /* For Proj: contains the result position to project */
129   filter_attr    filter;    /* For Filter */
130   end_attr       end;       /* For EndReg, EndExcept */
131 #if PRECISE_EXC_CONTEXT
132   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions
133                                for nodes Store, Load, Div, Mod, Quot, DivMod. */
134 #endif
135 } attr;
136
137
138 /* common structure of an irnode */
139 /* if the node has some attributes, they are stored in attr */
140
141 struct ir_node {
142   /** Basics of the representation **/
143   firm_kind kind;          /* distinguishes this node from others */
144   ir_op *op;               /* Opcode of this node. */
145   ir_mode *mode;           /* Mode of this node. */
146   unsigned long visited;   /* visited counter for walks of the graph */
147   struct ir_node **in;     /* array with predecessors / operands */
148   void *link;              /* to attach additional information to the node, e.g.
149                               used while construction to link Phi0 nodes and
150                               during optimization to link to nodes that
151                               shall replace a node. */
152   /**  Fields for optimizations / analysis information **/
153   struct ir_node **out;    /* array of out edges */
154   struct dbg_info* dbi;           /* A pointer to information for debug support. */
155   /** For debugging **/
156 #ifdef DEBUG_libfirm
157   int node_nr;             /* a unique node number for each node to make output
158                               readable. */
159 #endif
160   attr attr;               /* attribute of this node. Depends on opcode. */
161                            /* Must be last field of struct ir_node. */
162 };
163
164 /* Copies all attributes stored in the old node  to the new node.
165    Assumes both have the same opcode and sufficient size. */
166 void
167 copy_attrs (ir_node *old, ir_node *new);
168
169
170 /* Print IR-Nodes with attributes */
171 /* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
172 int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
173
174 /* Returns the array with the ins.  The content of the array may not be
175    changed.  */
176 ir_node     **get_irn_in            (ir_node *node);
177
178 /** access attributes directly **/
179 INLINE tarval       *get_irn_const_attr    (ir_node *node);
180 INLINE long          get_irn_proj_attr     (ir_node *node);
181 INLINE alloc_attr    get_irn_alloc_attr    (ir_node *node);
182 INLINE type         *get_irn_free_attr     (ir_node *node);
183 INLINE symconst_attr get_irn_symconst_attr (ir_node *node);
184 type         *get_irn_call_attr     (ir_node *node);
185 sel_attr      get_irn_sel_attr      (ir_node *node);
186 int           get_irn_phi_attr      (ir_node *node);
187 block_attr    get_irn_block_attr   (ir_node *node);
188
189 # endif /* _IRNODE_T_H_ */