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
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 * Declarations of an ir node.
19 * @author Martin Trapp, Christian Schaefer
32 # include "firm_common_t.h"
33 # include "irdom_t.h" /* For size of struct dom_info. */
39 /** ir node attributes **/
41 /** Block attributes */
43 /* General attributes */
45 unsigned long block_visited; /**< for the walker that walks over all blocks. */
46 /* Attributes private to construction: */
47 bool matured; /**< if set, all in-nodes of the block are fixed */
48 struct ir_node **graph_arr; /**< array to store all parameters */
49 /* Attributes holding analyses information */
50 struct dom_info dom; /**< Datastructure that holds information about dominators.
52 Eventually overlay with graph_arr as only valid
53 in different phases. Eventually inline the whole
55 // exc_t exc; /**< role of this block for exception handling */
56 // ir_node *handler_entry; /**< handler entry block iff this block is part of a region */
57 ir_node ** in_cg; /**< array with predecessors in
58 * interprocedural_view, if they differ
59 * from intraprocedural predecessors */
60 int *backedge; /**< Field n set to true if pred n is backedge.
61 @@@ @todo Ev. replace by bitfield! */
62 int *cg_backedge; /**< Field n set to true if pred n is interprocedural backedge.
63 @@@ @todo Ev. replace by bitfield! */
66 /** Start attributes */
69 // ir_graph *irg; @@@ now in block
72 /** Cond attributes */
74 cond_kind kind; /**< flavor of Cond */
75 long default_proj; /**< for optimization: biggest Proj number, i.e. the one
79 /** Const attributes */
81 tarval *tv; /**< the target value */
82 type *tp; /**< the source type, for analyses. default: type_unknown. */
85 /** SymConst attributes
86 This union contains the symbolic information represented by the node */
87 typedef union type_or_id {
99 entity *ent; /**< entity to select */
103 type *cld_tp; /**< type of called procedure */
104 #if PRECISE_EXC_CONTEXT
105 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
107 entity ** callee_arr; /**< result of callee analysis */
110 /** Alloc attributes */
112 type *type; /**< Type of the allocated object. */
113 where_alloc where; /**< stack, heap or other managed part of memory */
114 #if PRECISE_EXC_CONTEXT
115 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
119 /** InstOf attributes */
126 /** Filter attributes */
128 long proj; /**< contains the result position to project (Proj) */
129 ir_node ** in_cg; /**< array with interprocedural predecessors (Phi) */
130 int *backedge; /**< Field n set to true if pred n is backedge.
131 @todo Ev. replace by bitfield! */
134 /** EndReg/EndExcept attributes */
137 // ir_graph * irg; /**< ir_graph this node belongs to (for
138 // * navigating in interprocedural graphs)
139 // @@@ now in block */
142 /** CallBegin attributes */
144 // ir_graph * irg; / **< ir_graph this node belongs to (for
145 // * navigating in interprocedural graphs) */
147 ir_node * call; /**< associated Call-operation */
150 /** Cast attributes */
155 typedef pn_Cmp confirm_attr; /** Attribute to hold compare operation */
157 /** Some irnodes just have one attribute, these are stored here,
158 some have more. Their name is 'irnodename_attr' */
160 start_attr start; /**< For Start */
161 block_attr block; /**< For Block: Fields needed to construct it */
162 cond_attr c; /**< For Cond. */
163 const_attr con; /**< For Const: contains the value of the constant and a type */
164 symconst_attr i; /**< For SymConst. */
165 sel_attr s; /**< For Sel. */
166 call_attr call; /**< For Call: pointer to the type of the method to call */
167 callbegin_attr callbegin; /**< For CallBegin */
168 alloc_attr a; /**< For Alloc. */
169 io_attr io; /**< For InstOf */
170 type *f; /**< For Free. */
171 cast_attr cast; /**< For Cast. */
172 int phi0_pos; /**< For Phi. Used to remember the value defined by
173 this Phi node. Needed when the Phi is completed
174 to call get_r_internal_value to find the
175 predecessors. If this attribute is set, the Phi
176 node takes the role of the obsolete Phi0 node,
177 therefore the name. */
178 int *phi_backedge; /**< For Phi after construction.
179 Field n set to true if pred n is backedge.
180 @todo Ev. replace by bitfield! */
181 long proj; /**< For Proj: contains the result position to project */
182 confirm_attr confirm_cmp; /**< For Confirm: compare operation */
183 filter_attr filter; /**< For Filter */
184 end_attr end; /**< For EndReg, EndExcept */
185 #if PRECISE_EXC_CONTEXT
186 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions
187 for nodes Store, Load, Div, Mod, Quot, DivMod. */
192 /** common structure of an irnode
193 if the node has some attributes, they are stored in attr */
195 /* ------- Basics of the representation ------- */
196 firm_kind kind; /**< distinguishes this node from others */
197 ir_op *op; /**< Opcode of this node. */
198 ir_mode *mode; /**< Mode of this node. */
199 unsigned long visited; /**< visited counter for walks of the graph */
200 struct ir_node **in; /**< array with predecessors / operands */
201 void *link; /**< to attach additional information to the node, e.g.
202 used while construction to link Phi0 nodes and
203 during optimization to link to nodes that
204 shall replace a node. */
205 /* ------- Fields for optimizations / analysis information ------- */
206 struct ir_node **out; /**< array of out edges */
207 struct dbg_info* dbi; /**< A pointer to information for debug support. */
208 /* ------- For debugging ------- */
210 int node_nr; /**< a unique node number for each node to make output
213 /* ------- For analyses -------- */
214 ir_loop *loop; /**< the loop the node is in. Access routines in irloop.h */
215 /* ------- Opcode depending fields -------- */
216 attr attr; /**< attribute of this node. Depends on opcode.
217 Must be last field of struct ir_node. */
220 /** Copies all attributes stored in the old node to the new node.
221 Assumes both have the same opcode and sufficient size. */
223 copy_attrs(const ir_node *old_node, ir_node *new_node);
226 /** Returns the array with the ins. The content of the array may not be
228 ir_node **get_irn_in (const ir_node *node);
231 /** access attributes directly */
232 INLINE const_attr get_irn_const_attr (ir_node *node);
233 INLINE long get_irn_proj_attr (ir_node *node);
234 INLINE alloc_attr get_irn_alloc_attr (ir_node *node);
235 INLINE type *get_irn_free_attr (ir_node *node);
236 INLINE symconst_attr get_irn_symconst_attr (ir_node *node);
237 type *get_irn_call_attr (ir_node *node);
238 type *get_irn_funccall_attr (ir_node *node);
239 sel_attr get_irn_sel_attr (ir_node *node);
240 int get_irn_phi_attr (ir_node *node);
241 block_attr get_irn_block_attr (ir_node *node);
244 # endif /* _IRNODE_T_H_ */