Added FuncCall Node, a call to a procedure that did NOT change the memory
[libfirm] / ir / ir / irnode_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irnode_t.h
4  * Purpose:     Representation of an intermediate operation -- private header.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 /**
15  * @file irnode_t.h
16  *
17  * Declarations of an ir node.
18  *
19  * @author Martin Trapp, Christian Schaefer
20  */
21
22
23 # ifndef _IRNODE_T_H_
24 # define _IRNODE_T_H_
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 # include "irnode.h"
31 # include "irop_t.h"
32 # include "firm_common_t.h"
33 # include "irdom_t.h" /* For size of struct dom_info. */
34 # include "dbginfo.h"
35
36 # include "exc.h"
37
38 /** ir node attributes **/
39
40 /** Block attributes */
41 typedef struct {
42   /* General attributes */
43   ir_graph *irg;
44   unsigned long block_visited;  /**< for the walker that walks over all blocks. */
45   /* Attributes private to construction: */
46   bool matured;               /**< if set, all in-nodes of the block are fixed */
47   struct ir_node **graph_arr; /**< array to store all parameters */
48   /* Attributes holding analyses information */
49   struct dom_info dom;        /**< Datastructure that holds information about dominators.
50                                  @@@ @todo
51                                  Eventually overlay with graph_arr as only valid
52                                  in different phases.  Eventually inline the whole
53                                  datastructure. */
54   //  exc_t exc;                      /**< role of this block for exception handling */
55   //  ir_node *handler_entry;     /**< handler entry block iff this block is part of a region */
56   ir_node ** in_cg;           /**< array with predecessors in
57                                * interprocedural_view, if they differ
58                                * from intraprocedural predecessors */
59   int *backedge;              /**< Field n set to true if pred n is backedge.
60                                  @@@ @todo Ev. replace by bitfield! */
61   int *cg_backedge;           /**< Field n set to true if pred n is interprocedural backedge.
62                                  @@@ @todo Ev. replace by bitfield! */
63 } block_attr;
64
65 /** Start attributes */
66 typedef struct {
67   char dummy;
68   //  ir_graph *irg;   @@@ now in block
69 } start_attr;
70
71 /** Cond attributes */
72 typedef struct {
73   cond_kind kind;    /**< flavor of Cond */
74   long default_proj; /**< for optimization: biggest Proj number, i.e. the one
75                           used for default. */
76 } cond_attr;
77
78 /** Const attributes */
79 typedef struct {
80   tarval *tv;        /**< the target value */
81   type   *tp;        /**< the source type, for analyses. default: type_unknown. */
82 } const_attr;
83
84 /** SymConst attributes
85     This union contains the symbolic information represented by the node */
86 typedef union type_or_id {
87   type  *typ;
88   ident *ptrinfo;
89 } type_or_id;
90
91 typedef struct {
92   type_or_id tori;
93   symconst_kind num;
94 } symconst_attr;
95
96 /** Sel attributes */
97 typedef struct {
98   entity *ent;          /**< entity to select */
99 } sel_attr;
100
101 typedef struct {
102   type *cld_tp;         /**< type of called procedure */
103 #if PRECISE_EXC_CONTEXT
104   struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
105 #endif
106   entity ** callee_arr; /**< result of callee analysis */
107 } call_attr;
108
109 /** Alloc attributes */
110 typedef struct {
111   type *type;           /**< Type of the allocated object.  */
112   where_alloc where;    /**< stack, heap or other managed part of memory */
113 #if PRECISE_EXC_CONTEXT
114   struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
115 #endif
116 } alloc_attr;
117
118 /** InstOf attributes */
119 typedef struct
120 {
121   type *ent;
122   int dfn;
123 } io_attr;
124
125 /** Filter attributes */
126 typedef struct {
127   long proj;                 /**< contains the result position to project (Proj) */
128   ir_node ** in_cg;          /**< array with interprocedural predecessors (Phi) */
129   int *backedge;              /**< Field n set to true if pred n is backedge.
130                                  @todo Ev. replace by bitfield! */
131 } filter_attr;
132
133 /** EndReg/EndExcept attributes */
134 typedef struct {
135   char dummy;
136   //  ir_graph * irg;            /**< ir_graph this node belongs to (for
137   //                              * navigating in interprocedural graphs)
138   //                              @@@ now in block */
139 } end_attr;
140
141 /** CallBegin attributes */
142 typedef struct {
143   //  ir_graph * irg;            / **< ir_graph this node belongs to (for
144   //                          * navigating in interprocedural graphs) */
145   //                           @@@ now in block
146   ir_node * call;            /**< associated Call-operation */
147 } callbegin_attr;
148
149 /** Cast attributes */
150 typedef struct {
151   type *totype;
152 } cast_attr;
153
154 typedef pn_Cmp confirm_attr; /** Attribute to hold compare operation */
155
156 /** Some irnodes just have one attribute, these are stored here,
157    some have more. Their name is 'irnodename_attr' */
158 typedef union {
159   start_attr     start; /**< For Start */
160   block_attr     block; /**< For Block: Fields needed to construct it */
161   cond_attr      c;     /**< For Cond. */
162   const_attr     con;   /**< For Const: contains the value of the constant and a type */
163   symconst_attr  i;     /**< For SymConst. */
164   sel_attr       s;     /**< For Sel. */
165   call_attr      call;  /**< For Call: pointer to the type of the method to call */
166   callbegin_attr callbegin; /**< For CallBegin */
167   alloc_attr     a;     /**< For Alloc. */
168   io_attr        io;    /**< For InstOf */
169   type          *f;     /**< For Free. */
170   cast_attr      cast;  /**< For Cast. */
171   int            phi0_pos;  /**< For Phi. Used to remember the value defined by
172                                this Phi node.  Needed when the Phi is completed
173                                to call get_r_internal_value to find the
174                                predecessors. If this attribute is set, the Phi
175                                node takes the role of the obsolete Phi0 node,
176                                therefore the name. */
177   int *phi_backedge;    /**< For Phi after construction.
178                            Field n set to true if pred n is backedge.
179                            @todo Ev. replace by bitfield! */
180   long           proj;  /**< For Proj: contains the result position to project */
181   confirm_attr   confirm_cmp;   /**< For Confirm: compare operation */
182   filter_attr    filter;    /**< For Filter */
183   end_attr       end;       /**< For EndReg, EndExcept */
184 #if PRECISE_EXC_CONTEXT
185   struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions
186                                for nodes Store, Load, Div, Mod, Quot, DivMod. */
187 #endif
188 } attr;
189
190
191 /** common structure of an irnode
192     if the node has some attributes, they are stored in attr */
193 struct ir_node {
194   /* ------- Basics of the representation  ------- */
195   firm_kind kind;          /**< distinguishes this node from others */
196   ir_op *op;               /**< Opcode of this node. */
197   ir_mode *mode;           /**< Mode of this node. */
198   unsigned long visited;   /**< visited counter for walks of the graph */
199   struct ir_node **in;     /**< array with predecessors / operands */
200   void *link;              /**< to attach additional information to the node, e.g.
201                               used while construction to link Phi0 nodes and
202                               during optimization to link to nodes that
203                               shall replace a node. */
204   /* ------- Fields for optimizations / analysis information ------- */
205   struct ir_node **out;    /**< array of out edges */
206   struct dbg_info* dbi;    /**< A pointer to information for debug support. */
207   /* ------- For debugging ------- */
208 #ifdef DEBUG_libfirm
209   int node_nr;             /**< a unique node number for each node to make output
210                               readable. */
211 #endif
212   attr attr;               /**< attribute of this node. Depends on opcode.
213                               Must be last field of struct ir_node. */
214 };
215
216 /** Copies all attributes stored in the old node  to the new node.
217     Assumes both have the same opcode and sufficient size. */
218 void
219 copy_attrs (ir_node *old, ir_node *new);
220
221
222 /** Returns the array with the ins.  The content of the array may not be
223    changed.  */
224 ir_node     **get_irn_in            (const ir_node *node);
225
226 /*@{*/
227 /** access attributes directly */
228 INLINE const_attr    get_irn_const_attr    (ir_node *node);
229 INLINE long          get_irn_proj_attr     (ir_node *node);
230 INLINE alloc_attr    get_irn_alloc_attr    (ir_node *node);
231 INLINE type         *get_irn_free_attr     (ir_node *node);
232 INLINE symconst_attr get_irn_symconst_attr (ir_node *node);
233 type         *get_irn_call_attr     (ir_node *node);
234 sel_attr      get_irn_sel_attr      (ir_node *node);
235 int           get_irn_phi_attr      (ir_node *node);
236 block_attr    get_irn_block_attr   (ir_node *node);
237 /*@}*/
238
239 # endif /* _IRNODE_T_H_ */