1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
8 * Declarations of an ir node.
10 * @author Martin Trapp, Christian Schaefer
21 # include "firm_common_t.h"
22 # include "irdom_t.h" /* For size of struct dom_info. */
27 /** ir node attributes **/
29 /** Block attributes */
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.
37 Eventually overlay with graph_arr as only valid
38 in different phases. Eventually inline the whole
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! */
51 /** Cond attributes */
53 cond_kind kind; /**< flavor of Cond */
54 long default_proj; /**< for optimization: biggest Proj number, i.e. the one
58 /** SymConst attributes
59 This union contains the symbolic information represented by the node */
60 typedef union type_or_id {
72 entity *ent; /**< entity to select */
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 */
80 entity ** callee_arr; /**< result of callee analysis */
83 /** Alloc attributes */
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 */
92 /** InstOf attributes */
99 /** Filter attributes */
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! */
107 /** EndReg/EndExcept attributes */
109 ir_graph * irg; /**< ir_graph this node belongs to (for
110 * navigating in interprocedural graphs) */
113 /** CallBegin attributes */
115 ir_graph * irg; /**< ir_graph this node belongs to (for
116 * navigating in interprocedural graphs) */
117 ir_node * call; /**< associated Call-operation */
120 /** Some irnodes just have one attribute, these are stored here,
121 some have more. Their name is 'irnodename_attr' */
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. */
152 /** common structure of an irnode
153 if the node has some attributes, they are stored in attr */
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 ------- */
170 int node_nr; /**< a unique node number for each node to make output
173 attr attr; /**< attribute of this node. Depends on opcode.
174 Must be last field of struct ir_node. */
177 /** Copies all attributes stored in the old node to the new node.
178 Assumes both have the same opcode and sufficient size. */
180 copy_attrs (ir_node *old, ir_node *new);
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);
187 /** Returns the array with the ins. The content of the array may not be
189 ir_node **get_irn_in (ir_node *node);
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);
204 # endif /* _IRNODE_T_H_ */