1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Martin Trapp, Christian Schaefer
15 ir_graph *current_ir_graph;
17 unsigned long ir_visited = 0;
18 unsigned long block_visited = 0;
21 /* Allocates a list of nodes:
22 - The start block containing a start node and Proj nodes for it's four
23 results (X, M, P, Tuple).
24 - The end block containing an end node. This block is not matured after
25 new_ir_graph as predecessors need to be added to it.
26 - The current block, which is empty and also not matured.
27 Further it allocates several datastructures needed for graph construction
31 new_ir_graph (entity *ent, int params)
37 res = (ir_graph *) malloc (sizeof (ir_graph));
38 current_ir_graph = res;
40 /** Internal information for graph construction either held in the graph or
41 *** initialized for each graph. **/
42 res->params = params + 1; /* number of local variables that are never
43 dereferenced in this graph plus one for
44 the store. This is not the number of parameters
46 #if USE_EXPICIT_PHI_IN_STACK
47 res->Phi_in_stack = new_Phi_in_stack(); /* A stack needed for automatic Phi
50 //???!! turn the Phi_in_stack into a field of ir_graph??
51 res->obst = (struct obstack *) xmalloc (sizeof (struct obstack));
52 obstack_init (res->obst);
53 res->value_table = new_identities (); /* Symbol table for local variables
56 /** Type inforamtion for the procedure of the graph **/
59 /** Nodes needed in every graph **/
60 res->end_block = new_Block ();
61 res->end = new_End ();
63 res->start_block = new_Block ();
64 res->start = new_Start ();
65 res->bad = new_ir_node (res, res->start_block, op_Bad, mode_T, 0, NULL);
67 /* Proj results of start node */
68 projX = new_Proj (res->start, mode_X, pns_initial_exec);
69 set_store (new_Proj (res->start, mode_M, pns_global_store));
70 res->frame = new_Proj (res->start, mode_p, pns_frame_base);
71 res->globals = new_Proj (res->start, mode_p, pns_globals);
72 res->args = new_Proj (res->start, mode_T, pns_args);
74 add_in_edge(res->start_block, projX);
75 // The code generation needs it. leave it in now.
76 // Use of this edge is matter of discussion, unresolved. Also possible:
77 // add_in_edge(res->start_block, res->start_block), but invalid typed.
79 mature_block (res->current_block);
81 /** Make a block to start with **/
82 first_block = new_Block ();
83 add_in_edge (first_block, projX);
88 /* access routines for all ir_graph attributes */
91 get_start_block_of_irgraph (ir_graph *irg)
93 return irg->start_block;
97 set_start_block_of_irgraph (ir_graph *irg, ir_node *node)
99 irg->start_block = node;
103 get_start_of_irgraph (ir_graph *irg)
109 set_start_of_irgraph(ir_graph *irg, ir_node *node)
115 get_end_block_of_irgraph (ir_graph *irg)
117 return irg->end_block;
121 set_end_block_of_irgraph (ir_graph *irg, ir_node *node)
123 irg->end_block = node;
127 get_end_of_irgraph (ir_graph *irg)
133 set_end_of_irgraph (ir_graph *irg, ir_node *node)
139 get_cstore_of_irgraph (ir_graph *irg)
145 set_cstore_of_irgraph (ir_graph *irg, ir_node *node)
151 get_frame_of_irgraph (ir_graph *irg)
157 set_frame_of_irgraph(ir_graph *irg, ir_node *node)
163 get_args_of_irgraph (ir_graph *irg)
169 set_args_of_irgraph(ir_graph *irg, ir_node *node)
175 get_bad_of_irgraph (ir_graph *irg)
181 set_bad_of_irgraph(ir_graph *irg, ir_node *node)
187 get_current_block_of_irgraph (ir_graph *irg)
189 return irg->current_block;
193 set_current_block_of_irgraph(ir_graph *irg, ir_node *node)
195 irg->current_block = node;
199 get_ent_of_irgraph(ir_graph *irg)
205 set_ent_of_irgraph(ir_graph *irg, entity *ent)
211 get_params_of_irgraph(ir_graph *irg)
217 set_params_of_irgraph(ir_graph *irg, int params)
219 irg->params = params;