1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
8 * Declarations of an ir node.
10 * @author Martin Trapp, Christian Schaefer
25 # include "firm_common_t.h"
26 # include "irdom_t.h" /* For size of struct dom_info. */
31 /** ir node attributes **/
33 /** Block attributes */
35 unsigned long block_visited; /**< for the walker that walks over all blocks. */
36 /* Attributes private to construction: */
37 bool matured; /**< if set, all in-nodes of the block are fixed */
38 struct ir_node **graph_arr; /**< array to store all parameters */
39 struct dom_info dom; /**< Datastructure that holds information about dominators.
41 Eventually overlay with graph_arr as only valid
42 in different phases. Eventually inline the whole
44 exc_t exc; /**< role of this block for exception handling */
45 ir_node *handler_entry; /**< handler entry block iff this block is part of a region */
46 ir_node ** in_cg; /**< array with predecessors in
47 * interprocedural_view, if they differ
48 * from intraprocedural predecessors */
49 int *backedge; /**< Field n set to true if pred n is backedge.
50 @todo Ev. replace by bitfield! */
51 int *cg_backedge; /**< Field n set to true if pred n is interprocedural backedge.
52 @todo Ev. replace by bitfield! */
55 /** Cond attributes */
57 cond_kind kind; /**< flavor of Cond */
58 long default_proj; /**< for optimization: biggest Proj number, i.e. the one
62 /** SymConst attributes
63 This union contains the symbolic information represented by the node */
64 typedef union type_or_id {
76 entity *ent; /**< entity to select */
80 type *cld_tp; /**< type of called procedure */
81 #if PRECISE_EXC_CONTEXT
82 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
84 entity ** callee_arr; /**< result of callee analysis */
87 /** Alloc attributes */
89 type *type; /**< Type of the allocated object. */
90 where_alloc where; /**< stack, heap or other managed part of memory */
91 #if PRECISE_EXC_CONTEXT
92 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions */
96 /** InstOf attributes */
103 /** Filter attributes */
105 long proj; /**< contains the result position to project (Proj) */
106 ir_node ** in_cg; /**< array with interprocedural predecessors (Phi) */
107 int *backedge; /**< Field n set to true if pred n is backedge.
108 @todo Ev. replace by bitfield! */
111 /** EndReg/EndExcept attributes */
113 ir_graph * irg; /**< ir_graph this node belongs to (for
114 * navigating in interprocedural graphs) */
117 /** CallBegin attributes */
119 ir_graph * irg; /**< ir_graph this node belongs to (for
120 * navigating in interprocedural graphs) */
121 ir_node * call; /**< associated Call-operation */
124 /** Some irnodes just have one attribute, these are stored here,
125 some have more. Their name is 'irnodename_attr' */
127 block_attr block; /**< For Block: Fields needed to construct it */
128 cond_attr c; /**< For Cond. */
129 struct tarval *con; /**< For Const: contains the value of the constant */
130 symconst_attr i; /**< For SymConst. */
131 sel_attr s; /**< For Sel. */
132 call_attr call; /**< For Call: pointer to the type of the method to call */
133 callbegin_attr callbegin; /**< For CallBegin */
134 alloc_attr a; /**< For Alloc. */
135 io_attr io; /**< For InstOf */
136 type *f; /**< For Free. */
137 int phi0_pos; /**< For Phi. Used to remember the value defined by
138 this Phi node. Needed when the Phi is completed
139 to call get_r_internal_value to find the
140 predecessors. If this attribute is set, the Phi
141 node takes the role of the obsolete Phi0 node,
142 therefore the name. */
143 int *phi_backedge; /**< For Phi after construction.
144 Field n set to true if pred n is backedge.
145 @todo Ev. replace by bitfield! */
146 long proj; /**< For Proj: contains the result position to project */
147 filter_attr filter; /**< For Filter */
148 end_attr end; /**< For EndReg, EndExcept */
149 #if PRECISE_EXC_CONTEXT
150 struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions
151 for nodes Store, Load, Div, Mod, Quot, DivMod. */
156 /** common structure of an irnode
157 if the node has some attributes, they are stored in attr */
159 /* ------- Basics of the representation ------- */
160 firm_kind kind; /**< distinguishes this node from others */
161 ir_op *op; /**< Opcode of this node. */
162 ir_mode *mode; /**< Mode of this node. */
163 unsigned long visited; /**< visited counter for walks of the graph */
164 struct ir_node **in; /**< array with predecessors / operands */
165 void *link; /**< to attach additional information to the node, e.g.
166 used while construction to link Phi0 nodes and
167 during optimization to link to nodes that
168 shall replace a node. */
169 /* ------- Fields for optimizations / analysis information ------- */
170 struct ir_node **out; /**< array of out edges */
171 struct dbg_info* dbi; /**< A pointer to information for debug support. */
172 /* ------- For debugging ------- */
174 int node_nr; /**< a unique node number for each node to make output
177 attr attr; /**< attribute of this node. Depends on opcode.
178 Must be last field of struct ir_node. */
181 /** Copies all attributes stored in the old node to the new node.
182 Assumes both have the same opcode and sufficient size. */
184 copy_attrs (ir_node *old, ir_node *new);
187 /** Print IR-Nodes with attributes
188 @todo brauchen wir dienoch? dann fliegt ev. das xprint raus? */
189 int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
191 /** Returns the array with the ins. The content of the array may not be
193 ir_node **get_irn_in (ir_node *node);
196 /** access attributes directly */
197 INLINE tarval *get_irn_const_attr (ir_node *node);
198 INLINE long get_irn_proj_attr (ir_node *node);
199 INLINE alloc_attr get_irn_alloc_attr (ir_node *node);
200 INLINE type *get_irn_free_attr (ir_node *node);
201 INLINE symconst_attr get_irn_symconst_attr (ir_node *node);
202 type *get_irn_call_attr (ir_node *node);
203 sel_attr get_irn_sel_attr (ir_node *node);
204 int get_irn_phi_attr (ir_node *node);
205 block_attr get_irn_block_attr (ir_node *node);
208 # endif /* _IRNODE_T_H_ */