1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Martin Trapp, Christian Schaefer
6 ** irgraph.h: ir graph construction
15 /* to resolve recursion between irnode.h and irgraph.h */
16 #ifndef _IR_NODE_TYPEDEF_
17 #define _IR_NODE_TYPEDEF_
18 typedef struct ir_node ir_node;
21 /* to resolve recursion between entity.h and irgraph.h */
22 #ifndef _IR_GRAPH_TYPEDEF_
23 #define _IR_GRAPH_TYPEDEF_
24 typedef struct ir_graph ir_graph;
27 /***** irgraph/irgraph
29 * NAME Datastructure that holds central information about a procedure
32 ** ir_graph *new_ir_graph (entity *ent, int params);
33 * -------------------------------------------------
35 * This constructor generates the basic infrastructure needed to
36 * represent a procedure in FIRM.
38 * The parameters of new_ir_graph are:
40 * *ent A pointer to an entity representing the procedure.
42 * params An integer giving the number of local variables in the
45 * It allocates an ir_graph and sets current_ir_graph to point to this
46 * graph. Further it allocates the following nodes needed for every
49 * * The start block containing a start node and Proj nodes for it's
50 * five results (X, M, P, P, T).
51 * * The end block containing an end node. This block is not matured
52 * after executing new_ir_graph as predecessors need to be added to it.
53 * (Maturing a block means fixing it's number of predecessors.)
54 * * The current block, which is empty and also not matured.
56 * Further it enters the global store into the datastructure of the start
57 * block that contanis all valid values in this block (set_store()). This
58 * datastructure is used to build the Phi nodes and removed after
59 * completion of the graph. There is no path from end to start in the
60 * graph after calling ir_graph.
64 /* Global variable holding the current_ir_graph. This global variable
65 is used by the ir construction interface in ircons and by the
67 extern ir_graph *current_ir_graph;
69 /* Create a new ir graph to built ir for a procedure.
70 ent is the entity representing this procedure, i.e., the type of the
71 entity must be of a method type. The constructor automatically sets the
72 field irg of the entity as well as current_ir_graph to the new ir graph.
73 n_loc is the number of local variables in this procedure including
74 the procedure parameters. */
75 ir_graph *new_ir_graph (entity *ent, int n_loc);
77 /* Frees the passed irgraph.
78 Deallocates all nodes in this graph and the ir_graph structure.
79 Sets the field irgraph in the corresponding entity to NULL.
80 Does not remove the irgraph from the list in irprog (requires
81 inefficient search, call remove_irp_irg by hand).
82 Does not free types, entities or modes that are used only by this
83 graph, nor the entity standing for this graph. */
84 void free_ir_graph (ir_graph *irg);
86 /* access routines for all ir_graph attributes */
87 ir_node *get_irg_start_block (ir_graph *irg);
88 void set_irg_start_block (ir_graph *irg, ir_node *node);
90 ir_node *get_irg_start (ir_graph *irg);
91 void set_irg_start (ir_graph *irg, ir_node *node);
93 ir_node *get_irg_end_block (ir_graph *irg);
94 void set_irg_end_block (ir_graph *irg, ir_node *node);
96 ir_node *get_irg_end (ir_graph *irg);
97 void set_irg_end (ir_graph *irg, ir_node *node);
99 ir_node *get_irg_cstore (ir_graph *irg);
100 void set_irg_cstore (ir_graph *irg, ir_node *node);
102 ir_node *get_irg_frame (ir_graph *irg);
103 void set_irg_frame (ir_graph *irg, ir_node *node);
105 ir_node *get_irg_globals (ir_graph *irg);
106 void set_irg_globals (ir_graph *irg, ir_node *node);
108 ir_node *get_irg_args (ir_graph *irg);
109 void set_irg_args (ir_graph *irg, ir_node *node);
111 /* Use new_Bad() instead!! */
112 ir_node *get_irg_bad (ir_graph *irg);
113 void set_irg_bad (ir_graph *irg, ir_node *node);
115 ir_node *get_irg_current_block (ir_graph *irg);
116 void set_irg_current_block (ir_graph *irg, ir_node *node);
118 entity *get_irg_ent (ir_graph *irg);
119 void set_irg_ent (ir_graph *irg, entity *ent);
121 type *get_irg_frame_type (ir_graph *irg);
122 void set_irg_frame_type (ir_graph *irg, type *ftp);
124 /* Use not encouraged, internal of Phi construction algorithm. */
125 int get_irg_n_loc (ir_graph *irg);
126 void set_irg_n_loc (ir_graph *irg, int n_loc);
128 /* increments visited by one */
129 void inc_irg_visited(ir_graph *irg);
130 unsigned long get_irg_visited (ir_graph *irg);
131 void set_irg_visited(ir_graph *irg, unsigned long i);
133 /* increments block_visited by one */
134 void inc_irg_block_visited(ir_graph *irg);
135 unsigned long get_irg_block_visited (ir_graph *irg);
136 void set_irg_block_visited(ir_graph *irg, unsigned long i);
139 # endif /* _IRGRAPH_H_ */