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