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