664e6a0f3d7b7aa528cd17a99e729c7f73e7bae6
[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., the
28                                       type of the procedure and the class it
29                                       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 construction */
44 #endif
45   struct ir_node *current_block;   /* block for newly gen_*()-erated ir_nodes */
46   int params;                      /* number of local variable in this procedure */
47   // should be n_loc or so, params is ambiguous.
48   pset *value_table;               /* value table for global value numbering / cse
49                                       for optimizing use in iropt.c */
50 } ir_graph;
51
52
53 /* Global variable holding the current_ir_graph.  This global variable
54    is used by the ir construction interface in ircons and by the
55    optimizations. */
56 extern ir_graph *current_ir_graph;
57
58 /* create a new ir graph */
59 ir_graph *new_ir_graph (entity *ent, int params);
60
61 extern unsigned long ir_visited;
62 extern unsigned long block_visited;
63
64 /* access routines for all ir_graph attributes */
65
66 ir_node *get_start_block_of_irgraph (ir_graph *irg);
67 void     set_start_block_of_irgraph (ir_graph *irg, ir_node *node);
68
69 ir_node *get_start_of_irgraph (ir_graph *irg);
70 void     set_start_of_irgraph(ir_graph *irg, ir_node *node);
71
72 ir_node *get_end_block_of_irgraph (ir_graph *irg);
73 void     set_end_block_of_irgraph (ir_graph *irg, ir_node *node);
74
75 ir_node *get_end_of_irgraph (ir_graph *irg);
76 void     set_end_of_irgraph (ir_graph *irg, ir_node *node);
77
78 ir_node *get_cstore_of_irgraph (ir_graph *irg);
79 void     set_cstore_of_irgraph (ir_graph *irg, ir_node *node);
80
81 ir_node *get_frame_of_irgraph (ir_graph *irg);
82 void     set_frame_of_irgraph (ir_graph *irg, ir_node *node);
83
84 /*
85 ir_node *get_irg_globals (ir_graph *irg);
86 void     set_irg_globals (ir_graph *irg, ir_node *node);
87  */
88
89 ir_node *get_args_of_irgraph (ir_graph *irg);
90 void     set_args_of_irgraph (ir_graph *irg, ir_node *node);
91
92 ir_node *get_bad_of_irgraph (ir_graph *irg);
93 void     set_bad_of_irgraph (ir_graph *irg, ir_node *node);
94
95 /* not implemented yet
96 struct obstack *get_obst_of_irgraph (ir_graph *irg);
97 void set_obst_of_irgraph (ir_graph *irg, struct obstack *obst);
98 */
99
100 ir_node *get_current_block_of_irgraph (ir_graph *irg);
101 void     set_current_block_of_irgraph (ir_graph *irg, ir_node *node);
102
103 entity  *get_ent_of_irgraph (ir_graph *irg);
104 void     set_ent_of_irgraph (ir_graph *irg, entity *ent);
105
106 int      get_params_of_irgraph (ir_graph *irg);
107 void     set_params_of_irgraph (ir_graph *irg, int params);
108
109 # endif /* _IRGRAPH_H_ */