1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Martin Trapp, Christian Schaefer
6 ** irgraph.h: ir graph construction
13 /* to resolve recursion between irnode.h and irgraph.h */
14 #ifndef _IR_NODE_TYPEDEF_
15 #define _IR_NODE_TYPEDEF_
16 typedef struct ir_node ir_node;
19 /* to resolve recursion between entity.h and irgraph.h */
20 #ifndef _IR_GRAPH_TYPEDEF_
21 #define _IR_GRAPH_TYPEDEF_
22 typedef struct ir_graph ir_graph;
25 /***** irgraph/irgraph
27 * NAME Datastructure that holds central information about a procedure
30 ** ir_graph *new_ir_graph (entity *ent, int params);
31 * -------------------------------------------------
33 * This constructor generates the basic infrastructure needed to
34 * represent a procedure in FIRM.
36 * The parameters of new_ir_graph are:
38 * *ent A pointer to an entity representing the procedure.
40 * params An integer giving the number of local variables in the
43 * It allocates an ir_graph and sets current_ir_graph to point to this
44 * graph. Further it allocates the following nodes needed for every
47 * * The start block containing a start node and Proj nodes for it's
48 * five results (X, M, P, P, T).
49 * * The end block containing an end node. This block is not matured
50 * after executing new_ir_graph as predecessors need to be added to it.
51 * (Maturing a block means fixing it's number of predecessors.)
52 * * The current block, which is empty and also not matured.
54 * Further it enters the global store into the datastructure of the start
55 * block that contanis all valid values in this block (set_store()). This
56 * datastructure is used to build the Phi nodes and removed after
57 * completion of the graph. There is no path from end to start in the
58 * graph after calling ir_graph.
62 /* Global variable holding the current_ir_graph. This global variable
63 is used by the ir construction interface in ircons and by the
65 extern ir_graph *current_ir_graph;
67 /* Create a new ir graph to built ir for a procedure.
68 ent is the entity representing this procedure, i.e., the type of the
69 entity must be of a method type. The constructor automatically sets the
70 field irg of the entity as well as current_ir_graph to the new ir graph.
71 n_loc is the number of local variables in this procedure including
72 the procedure parameters. */
73 ir_graph *new_ir_graph (entity *ent, int n_loc);
75 /* access routines for all ir_graph attributes */
76 ir_node *get_irg_start_block (ir_graph *irg);
77 void set_irg_start_block (ir_graph *irg, ir_node *node);
79 ir_node *get_irg_start (ir_graph *irg);
80 void set_irg_start (ir_graph *irg, ir_node *node);
82 ir_node *get_irg_end_block (ir_graph *irg);
83 void set_irg_end_block (ir_graph *irg, ir_node *node);
85 ir_node *get_irg_end (ir_graph *irg);
86 void set_irg_end (ir_graph *irg, ir_node *node);
88 ir_node *get_irg_cstore (ir_graph *irg);
89 void set_irg_cstore (ir_graph *irg, ir_node *node);
91 ir_node *get_irg_frame (ir_graph *irg);
92 void set_irg_frame (ir_graph *irg, ir_node *node);
94 ir_node *get_irg_globals (ir_graph *irg);
95 void set_irg_globals (ir_graph *irg, ir_node *node);
97 ir_node *get_irg_args (ir_graph *irg);
98 void set_irg_args (ir_graph *irg, ir_node *node);
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);
104 ir_node *get_irg_current_block (ir_graph *irg);
105 void set_irg_current_block (ir_graph *irg, ir_node *node);
107 entity *get_irg_ent (ir_graph *irg);
108 void set_irg_ent (ir_graph *irg, entity *ent);
110 /* Use not encouraged, internal of Phi construction algorithm. */
111 int get_irg_n_loc (ir_graph *irg);
112 void set_irg_n_loc (ir_graph *irg, int n_loc);
114 /* increments visited by one */
115 void inc_irg_visited(ir_graph *irg);
116 unsigned long get_irg_visited (ir_graph *irg);
117 void set_irg_visited(ir_graph *irg, unsigned long i);
119 /* increments block_visited by one */
120 void inc_irg_block_visited(ir_graph *irg);
121 unsigned long get_irg_block_visited (ir_graph *irg);
122 void set_irg_block_visited(ir_graph *irg, unsigned long i);
125 # endif /* _IRGRAPH_H_ */