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