*** empty log message ***
[libfirm] / ir / ir / irgraph.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** irgraph.h: ir graph construction
7 */
8
9 # ifndef _IRGRAPH_H_
10 # define _IRGRAPH_H_
11
12 # include "obst.h"
13 # include "tv.h"
14 # include "pset.h"
15 /* @@@ we need at most a subset */
16 # include "entity.h"
17
18
19 #ifndef _IR_NODE_TYPEDEF_
20 #define _IR_NODE_TYPEDEF_
21 /* to resolve recursion between irnode.h and irgraph.h */
22 typedef struct ir_node ir_node;
23 #endif
24
25 /* ir_graph holds all information for a procedure */
26 typedef struct {
27   struct entity  *ent;               /* The entity of this procedure, i.e.,
28                                         the type of the procedure and the
29                                         class it belongs to. */
30   struct ir_node *start_block;       /* block the start node will belong to */
31   struct ir_node *start;             /* start node of this ir_graph */
32   struct ir_node *end_block;         /* block the end node will belong to */
33   struct ir_node *end;               /* end node of this ir_graph */
34   struct ir_node *cstore;            /* constant store */
35   struct ir_node *frame;             /* method's frame */
36   struct ir_node *globals;           /* pointer to the data segment containing all globals as
37                                       well as global procedures. */
38   struct ir_node *args;              /* methods arguments */
39   struct ir_node *bad;               /* bad node of this ir_graph, the one and
40                                         only in this graph */
41   struct obstack *obst;              /* obstack where all of the ir_nodes live */
42 #if USE_EXPICIT_PHI_IN_STACK
43   struct Phi_in_stack *Phi_in_stack; /* needed for automatic Phi
44                                         construction */
45 #endif
46   struct ir_node *current_block;     /* block for newly gen_*()-erated
47                                         ir_nodes */
48   int params;                        /* number of local variable in this
49                                         procedure; should be n_loc or so,
50                                         params is ambiguous. */
51   pset *value_table;                 /* value table for global value
52                                         numbering for optimizing use in
53                                         iropt.c */
54   unsigned long visited;             /* this flag is an identifier for
55                                         ir walk. it will be incremented,
56                                         every time, someone walk through
57                                         the graph */
58   unsigned long block_visited;       /* same as visited, for a
59                                         complete block */
60 } ir_graph;
61
62
63 /* Global variable holding the current_ir_graph.  This global variable
64    is used by the ir construction interface in ircons and by the
65    optimizations. */
66 extern ir_graph *current_ir_graph;
67
68 /* create a new ir graph */
69 ir_graph *new_ir_graph (entity *ent, int params);
70
71
72 /* access routines for all ir_graph attributes */
73 ir_node *get_irg_start_block (ir_graph *irg);
74 void set_irg_start_block (ir_graph *irg, ir_node *node);
75
76 ir_node *get_irg_start (ir_graph *irg);
77 void set_irg_start (ir_graph *irg, ir_node *node);
78
79 ir_node *get_start_of_irgraph (ir_graph *irg);
80 void     set_start_of_irgraph(ir_graph *irg, ir_node *node);
81
82 ir_node *get_irg_end_block (ir_graph *irg);
83 void set_irg_end_block (ir_graph *irg, ir_node *node);
84
85 ir_node *get_irg_end (ir_graph *irg);
86 void set_irg_end (ir_graph *irg, ir_node *node);
87
88 ir_node *get_irg_cstore (ir_graph *irg);
89 void set_irg_cstore (ir_graph *irg, ir_node *node);
90
91 ir_node *get_irg_frame (ir_graph *irg);
92 void set_irg_frame (ir_graph *irg, ir_node *node);
93
94 ir_node *get_irg_globals (ir_graph *irg);
95 void     set_irg_globals (ir_graph *irg, ir_node *node);
96
97 ir_node *get_irg_args (ir_graph *irg);
98 void set_irg_args (ir_graph *irg, ir_node *node);
99
100 /* Use new_Bad() instead!! */
101 ir_node *get_irg_bad (ir_graph *irg);
102 void set_irg_bad (ir_graph *irg, ir_node *node);
103
104 /* not implemented yet
105 struct obstack *get_obst_of_irgraph (ir_graph *irg);
106 void set_obst_of_irgraph (ir_graph *irg, struct obstack *obst);
107 */
108
109 ir_node *get_irg_current_block (ir_graph *irg);
110 void set_irg_current_block (ir_graph *irg, ir_node *node);
111
112 entity *get_irg_ent (ir_graph *irg);
113 void set_irg_ent (ir_graph *irg, entity *ent);
114
115 int get_irg_params (ir_graph *irg);
116 void set_irg_params (ir_graph *irg, int params);
117
118 unsigned long get_irg_visited (ir_graph *irg);
119 void set_irg_visited(ir_graph *irg, unsigned long i);
120
121 /* increments visited by one */
122 void inc_irg_visited(ir_graph *irg);
123
124 unsigned long get_irg_block_visited (ir_graph *irg);
125 void set_irg_block_visited(ir_graph *irg, unsigned long i);
126
127 /* increments block_visited by one */
128 void inc_irg_block_visited(ir_graph *irg);
129
130 int      get_params_of_irgraph (ir_graph *irg);
131 void     set_params_of_irgraph (ir_graph *irg, int params);
132
133 # endif /* _IRGRAPH_H_ */