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