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