1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
8 * Declarations of an ir node.
10 * @author Martin Trapp, Christian Schaefer
24 # include "firm_common_t.h"
25 # include "irdom_t.h" /* For size of struct dom_info. */
30 /** ir node attributes **/
32 /** Block attributes */
34 unsigned long block_visited; /**< for the walker that walks over all blocks. */
35 /* Attributes private to construction: */
36 bool matured; /**< if set, all in-nodes of the block are fixed */
37 struct ir_node **graph_arr; /**< array to store all parameters */
38 struct dom_info dom; /**< Datastructure that holds information about dominators.
40 Eventually overlay with graph_arr as only valid
41 in different phases. Eventually inline the whole
43 exc_t exc; /**< role of this block for exception handling */
44 ir_node *handler_entry; /**< handler entry block iff this block is part of a region */
45 ir_node ** in_cg; /**< array with predecessors in
46 * interprocedural_view, if they differ
47 * from intraprocedural predecessors */
48 int *backedge; /**< Field n set to true if pred n is backedge.
49 @todo Ev. replace by bitfield! */
50 int *cg_backedge; /**< Field n set to true if pred n is interprocedural backedge.
51 @todo Ev. replace by bitfield! */
54 /** Start attributes */
59 /** Cond attributes */
61 cond_kind kind; /**< flavor of Cond */
62 long default_proj; /**< for optimization: biggest Proj number, i.e. the one
66 /** SymConst attributes
67 This union contains the symbolic information represented by the node */
68 typedef union type_or_id {
80 entity *ent; /**< entity to select */
84 type *cld_tp; /**< type of called procedure */
85 #if PRECISE_EXC_CONTEXT
86 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
88 entity ** callee_arr; /**< result of callee analysis */
91 /** Alloc attributes */
93 type *type; /**< Type of the allocated object. */
94 where_alloc where; /**< stack, heap or other managed part of memory */
95 #if PRECISE_EXC_CONTEXT
96 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
100 /** InstOf attributes */
107 /** Filter attributes */
109 long proj; /**< contains the result position to project (Proj) */
110 ir_node ** in_cg; /**< array with interprocedural predecessors (Phi) */
111 int *backedge; /**< Field n set to true if pred n is backedge.
112 @todo Ev. replace by bitfield! */
115 /** EndReg/EndExcept attributes */
117 ir_graph * irg; /**< ir_graph this node belongs to (for
118 * navigating in interprocedural graphs) */
121 /** CallBegin attributes */
123 ir_graph * irg; /**< ir_graph this node belongs to (for
124 * navigating in interprocedural graphs) */
125 ir_node * call; /**< associated Call-operation */
128 /** Cast attributes */
133 /** Some irnodes just have one attribute, these are stored here,
134 some have more. Their name is 'irnodename_attr' */
136 start_attr start; /**< For Start */
137 block_attr block; /**< For Block: Fields needed to construct it */
138 cond_attr c; /**< For Cond. */
139 struct tarval *con; /**< For Const: contains the value of the constant */
140 symconst_attr i; /**< For SymConst. */
141 sel_attr s; /**< For Sel. */
142 call_attr call; /**< For Call: pointer to the type of the method to call */
143 callbegin_attr callbegin; /**< For CallBegin */
144 alloc_attr a; /**< For Alloc. */
145 io_attr io; /**< For InstOf */
146 type *f; /**< For Free. */
147 cast_attr cast; /**< For Cast. */
148 int phi0_pos; /**< For Phi. Used to remember the value defined by
149 this Phi node. Needed when the Phi is completed
150 to call get_r_internal_value to find the
151 predecessors. If this attribute is set, the Phi
152 node takes the role of the obsolete Phi0 node,
153 therefore the name. */
154 int *phi_backedge; /**< For Phi after construction.
155 Field n set to true if pred n is backedge.
156 @todo Ev. replace by bitfield! */
157 long proj; /**< For Proj: contains the result position to project */
158 filter_attr filter; /**< For Filter */
159 end_attr end; /**< For EndReg, EndExcept */
160 #if PRECISE_EXC_CONTEXT
161 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions
162 for nodes Store, Load, Div, Mod, Quot, DivMod. */
167 /** common structure of an irnode
168 if the node has some attributes, they are stored in attr */
170 /* ------- Basics of the representation ------- */
171 firm_kind kind; /**< distinguishes this node from others */
172 ir_op *op; /**< Opcode of this node. */
173 ir_mode *mode; /**< Mode of this node. */
174 unsigned long visited; /**< visited counter for walks of the graph */
175 struct ir_node **in; /**< array with predecessors / operands */
176 void *link; /**< to attach additional information to the node, e.g.
177 used while construction to link Phi0 nodes and
178 during optimization to link to nodes that
179 shall replace a node. */
180 /* ------- Fields for optimizations / analysis information ------- */
181 struct ir_node **out; /**< array of out edges */
182 struct dbg_info* dbi; /**< A pointer to information for debug support. */
183 /* ------- For debugging ------- */
185 int node_nr; /**< a unique node number for each node to make output
188 attr attr; /**< attribute of this node. Depends on opcode.
189 Must be last field of struct ir_node. */
192 /** Copies all attributes stored in the old node to the new node.
193 Assumes both have the same opcode and sufficient size. */
195 copy_attrs (ir_node *old, ir_node *new);
198 /** Returns the array with the ins. The content of the array may not be
200 ir_node **get_irn_in (const ir_node *node);
203 /** access attributes directly */
204 INLINE tarval *get_irn_const_attr (ir_node *node);
205 INLINE long get_irn_proj_attr (ir_node *node);
206 INLINE alloc_attr get_irn_alloc_attr (ir_node *node);
207 INLINE type *get_irn_free_attr (ir_node *node);
208 INLINE symconst_attr get_irn_symconst_attr (ir_node *node);
209 type *get_irn_call_attr (ir_node *node);
210 sel_attr get_irn_sel_attr (ir_node *node);
211 int get_irn_phi_attr (ir_node *node);
212 block_attr get_irn_block_attr (ir_node *node);
215 # endif /* _IRNODE_T_H_ */