removed a bug
[libfirm] / ir / ir / irnode_t.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** declarations of an ir node
7 */
8
9 # ifndef _IRNODE_T_H_
10 # define _IRNODE_T_H_
11
12 # include "irnode.h"
13 # include "xprintf.h"
14 # include "irop_t.h"
15
16 /** ir node attributes **/
17 /* Block attributes */
18 typedef struct {
19   unsigned long block_visited;  /* for the walker that walks over all blocks. */
20   /* Attributes private to construction: */
21   bool matured;               /* if set, all in-nodes of the block are fixed */
22   struct ir_node **graph_arr; /* array to store all parameters */
23 } block_attr;
24
25 /* Cond attributes */
26 typedef struct {
27   cond_kind kind;    /* flavor of Cond */
28   long default_proj; /* for optimization: biggest Proj number, i.e. the one
29                         used for default. */
30 } cond_attr;
31
32 /* SymConst attributes */
33 /*   This union contains the symbolic information represented by the node */
34 typedef union type_or_id {
35   type *typ;
36   ident *ptrinfo;
37 } type_or_id;
38
39 typedef struct {
40   type_or_id tori;
41   symconst_kind num;
42 } symconst_attr;
43
44 /* Sel attributes */
45 typedef struct {
46   entity *ent;          /* entity to select */
47   linkage_type ltyp;    /* linkage type of the entity */
48 } sel_attr;
49
50 typedef struct {
51   type *cld_tp;         /* type of called procedure */
52 #if PRECISE_EXC_CONTEXT
53   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions */
54 #endif
55 } call_attr;
56
57 /* Alloc attributes */
58 typedef struct {
59   type *type;           /* Type of the allocated object.  */
60   where_alloc where;    /* stack, heap or other managed part of memory */
61 #if PRECISE_EXC_CONTEXT
62   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions */
63 #endif
64 } alloc_attr;
65
66 /* Some irnodes just have one attribute, these are stored here,
67    some have more. Their name is 'irnodename_attr' */
68 typedef union {
69   block_attr     block; /* For Block: Fields needed to construct it */
70   cond_attr      c;     /* For Cond. */
71   struct tarval *con;   /* For Const: contains the value of the constant */
72   symconst_attr  i;     /* For SymConst. */
73   sel_attr       s;     /* For Sel. */
74   call_attr      call;  /* For Call: pointer to the type of the method to call */
75   long           proj;  /* For Proj: contains the result position to project */
76   alloc_attr     a;     /* For Alloc. */
77   type          *f;     /* For Free. */
78   int            phi0_pos;  /* For Phi. Used to remember the value defined by
79                                this Phi node.  Needed when the Phi is completed
80                                to call get_r_internal_value to find the
81                                predecessors. If this attribute is set, the Phi
82                                node takes the role of the obsolete Phi0 node,
83                                therefore the name. */
84 #if PRECISE_EXC_CONTEXT
85   struct ir_node **frag_arr; /* For Phi node construction in case of exceptions
86                                for nodes Store, Load, Div, Mod, Quot, DivMod. */
87 #endif
88
89 } attr;
90
91
92 /* common structure of an irnode */
93 /* if the node has some attributes, they are stored in attr */
94
95 struct ir_node {
96   firm_kind kind;          /* distinguishes this node from others */
97   ir_op *op;               /* Opcode of this node. */
98   ir_mode *mode;           /* Mode of this node. */
99   unsigned long visited;   /* visited counter for walks of the graph */
100   struct ir_node **in;     /* array with predecessors / operands */
101   struct ir_node *link;    /* for linking nodes somehow to a list, e.g.
102                               used while construction to link Phi0 nodes and
103                               during optimization to link to nodes that
104                               shall replace a node. */
105 #ifdef DEBUG_libfirm
106   int node_nr;             /* a unique node number for each node to make output
107                               readable. */
108 #endif
109   attr attr;               /* attribute of this node. Depends on opcode. */
110                            /* Must be last field of struct ir_node. */
111 };
112
113 /* Copies all attributes stored in the old node  to the new node.
114    Assumes both have the same opcode and sufficient size. */
115 void
116 copy_attrs (ir_node *old, ir_node *new);
117
118
119 /* Print IR-Nodes with attributes */
120 /* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
121 int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
122
123
124 /** access attributes directly **/
125 inline tarval       *get_irn_const_attr    (ir_node *node);
126 inline long          get_irn_proj_attr     (ir_node *node);
127 inline alloc_attr    get_irn_alloc_attr    (ir_node *node);
128 inline type         *get_irn_free_attr     (ir_node *node);
129 inline symconst_attr get_irn_symconst_attr (ir_node *node);
130 type         *get_irn_call_attr     (ir_node *node);
131 sel_attr      get_irn_sel_attr      (ir_node *node);
132 int           get_irn_phi_attr      (ir_node *node);
133 block_attr    get_irn_return_attr   (ir_node *node);
134
135 # endif /* _IRNODE_T_H_ */