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