Extended semantics of Cond node. There are two flavors now.
[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 /* SymConst attributes */
26 /*   This union contains the symbolic information represented by the node */
27 typedef union type_or_id {
28   type *typ;
29   ident *ptrinfo;
30 } type_or_id;
31
32 typedef struct {
33   type_or_id tori;
34   symconst_kind num;
35 } symconst_attr;
36
37 /* Sel attributes */
38 typedef struct {
39   entity *ent;          /* entity to select */
40   linkage_type ltyp;    /* linkage type of the entity */
41 } sel_attr;
42
43 /* Alloc attributes */
44 typedef struct {
45   type *type;           /* Type of the allocated object.  */
46   where_alloc where;    /* stack, heap or other managed part of memory */
47 } alloc_attr;
48
49 /* Some irnodes just have one attribute, these are stored here,
50    some have more. Their name is 'irnodename_attr' */
51 typedef union {
52   block_attr     block; /* For Block: Fields needed to construct it */
53   struct tarval *con;   /* For Const: contains the value of the constant */
54   symconst_attr  i;     /* For SymConst. */
55   sel_attr       s;     /* For Sel. */
56   type          *call;  /* For Call: pointer to the type of the method to call */
57   long           proj;  /* For Proj: contains the result position to project */
58   alloc_attr     a;     /* For Alloc. */
59   type          *f;     /* For Free. */
60   cond_kind      c;     /* For Cond. */
61   int            phi0_pos;  /* For Phi. Used to remember the value defined by
62                                this Phi node.  Needed when the Phi is completed
63                                to call get_r_internal_value to find the
64                                predecessors. If this attribute is set, the Phi
65                                node takes the role of the obsolete Phi0 node,
66                                therefore the name. */
67 } attr;
68
69
70 /* common structure of an irnode */
71 /* if the node has some attributes, they are stored in attr */
72
73 struct ir_node {
74   firm_kind kind;          /* distinguishes this node from others */
75   ir_op *op;               /* Opcode of this node. */
76   ir_mode *mode;           /* Mode of this node. */
77   unsigned long visited;   /* visited counter for walks of the graph */
78   struct ir_node **in;     /* array with predecessors / operands */
79   struct ir_node *link;    /* for linking nodes somehow to a list, e.g.
80                               used while construction to link Phi0 nodes and
81                               during optimization to link to nodes that
82                               shall replace a node. */
83 #ifdef DEBUG_libfirm
84   int node_nr;             /* a unique node number for each node to make output
85                               readable. */
86 #endif
87   attr attr;               /* attribute of this node. Depends on opcode. */
88                            /* Must be last field of struct ir_node. */
89 };
90
91 /* Copies all attributes stored in the old node  to the new node.
92    Assumes both have the same opcode and sufficient size. */
93 void
94 copy_attrs (ir_node *old, ir_node *new);
95
96
97 /* Print IR-Nodes with attributes */
98 /* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
99 int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
100
101
102 /** access attributes directly **/
103 inline tarval       *get_irn_const_attr    (ir_node *node);
104 inline long          get_irn_proj_attr     (ir_node *node);
105 inline alloc_attr    get_irn_alloc_attr    (ir_node *node);
106 inline type         *get_irn_free_attr     (ir_node *node);
107 inline symconst_attr get_irn_symconst_attr (ir_node *node);
108 type         *get_irn_call_attr     (ir_node *node);
109 sel_attr      get_irn_sel_attr      (ir_node *node);
110 int           get_irn_phi_attr      (ir_node *node);
111 block_attr    get_irn_return_attr   (ir_node *node);
112
113 # endif /* _IRNODE_T_H_ */