*** 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 "lib/obstack.h" */
13
14
15 /*# include "irnode.h" */
16 # include "obst.h"
17 # include "tv.h"
18 # include "pset.h"
19
20 /* @@@ we need at most a subset */
21 # include "entity.h"
22
23
24 #ifndef _IR_NODE_TYPEDEF_
25 #define _IR_NODE_TYPEDEF_
26
27 /* to resolve recursion between irnode.h and irgraph.h */
28 typedef struct ir_node ir_node;
29
30 #endif
31
32 /* ir_graph holds all information for a procedure */
33 typedef struct {
34   struct entity  *ent;             /* The entity of this procedure, i.e., the
35                                       type of the procedure and the class it
36                                       belongs to. */
37   struct ir_node *start_block;     /* block the start node will belong to */
38   struct ir_node *start;           /* start node of this ir_graph */
39   struct ir_node *end_block;       /* block the end node will belong to */
40   struct ir_node *end;             /* end node of this ir_graph */
41   struct ir_node *cstore;          /* constant store */
42   struct ir_node *frame;           /* method's frame */
43 #if UEBPRAKT
44   struct ir_node *dataseg;         /* pointer to the data segment */
45 #endif
46   struct ir_node *args;            /* methods arguments */
47   struct ir_node *bad;             /* bad node of this ir_graph, the one and
48                                       only in this graph */
49   struct obstack *obst;            /* obstack where all of the ir_nodes live */
50 #if USE_EXPICIT_PHI_IN_STACK
51   struct Phi_in_stack *Phi_in_stack; /* needed for automatic Phi construction */
52 #endif
53   struct ir_node *current_block;   /* block for newly gen_*()-erated ir_nodes */
54   int params;                      /* number of local variable in this procedure */
55   // should be n_loc or so, params is ambiguous.
56   pset *value_table;               /* value table for global value numbering
57                                       for optimizing use in iropt.c */
58 } ir_graph;
59
60 extern ir_graph *current_ir_graph;
61
62 /* create a new ir graph */
63 ir_graph *new_ir_graph (entity *ent, int params);
64
65 extern unsigned long ir_visited;
66 extern unsigned long block_visited;
67
68 /* access routines for all ir_graph attributes */
69
70 ir_node *get_start_block_of_irgraph (ir_graph *irg);
71 void set_start_block_of_irgraph (ir_graph *irg, ir_node *node);
72
73 ir_node *get_start_of_irgraph (ir_graph *irg);
74 void set_start_of_irgraph(ir_graph *irg, ir_node *node);
75
76 ir_node *get_end_block_of_irgraph (ir_graph *irg);
77 void set_end_block_of_irgraph (ir_graph *irg, ir_node *node);
78
79 ir_node *get_end_of_irgraph (ir_graph *irg);
80 void set_end_of_irgraph (ir_graph *irg, ir_node *node);
81
82 ir_node *get_cstore_of_irgraph (ir_graph *irg);
83 void set_cstore_of_irgraph (ir_graph *irg, ir_node *node);
84
85 ir_node *get_frame_of_irgraph (ir_graph *irg);
86 void set_frame_of_irgraph (ir_graph *irg, ir_node *node);
87
88 ir_node *get_args_of_irgraph (ir_graph *irg);
89 void set_args_of_irgraph (ir_graph *irg, ir_node *node);
90
91 ir_node *get_bad_of_irgraph (ir_graph *irg);
92 void set_bad_of_irgraph (ir_graph *irg, ir_node *node);
93
94 /* not implemented yet
95 struct obstack *get_obst_of_irgraph (ir_graph *irg);
96 void set_obst_of_irgraph (ir_graph *irg, struct obstack *obst);
97 */
98
99 ir_node *get_current_block_of_irgraph (ir_graph *irg);
100 void set_current_block_of_irgraph (ir_graph *irg, ir_node *node);
101
102 entity *get_ent_of_irgraph (ir_graph *irg);
103 void set_ent_of_irgraph (ir_graph *irg, entity *ent);
104
105 int get_params_of_irgraph (ir_graph *irg);
106 void set_params_of_irgraph (ir_graph *irg, int params);
107
108 # endif /* _IRGRAPH_H_ */