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