-/* Allocates a list of nodes:
- - The start block containing a start node and Proj nodes for it's four
- results (X, M, P, Tuple).
- - The end block containing an end node. This block is not matured after
- new_ir_graph as predecessors need to be added to it.
- - The current block, which is empty and also not matured.
- Further it allocates several datastructures needed for graph construction
- and optimization.
-*/
-ir_graph *
-new_r_ir_graph (entity *ent, int n_loc)
-{
- ir_graph *res;
- ir_node *first_block;
- ir_node *projX;
-
- res = alloc_graph();
- res->kind = k_ir_graph;
-
- edges_init_graph(res);
-
- /* inform statistics here, as blocks will be already build on this graph */
- hook_new_graph(res, ent);
-
- current_ir_graph = res;
-
- /*-- initialized for each graph. --*/
- if (get_opt_precise_exc_context()) {
- res->n_loc = n_loc + 1 + 1; /* number of local variables that are never
- dereferenced in this graph plus one for
- the store plus one for links to fragile
- operations. n_loc is not the number of
- parameters to the procedure! */
- }
- else {
- res->n_loc = n_loc + 1; /* number of local variables that are never
- dereferenced in this graph plus one for
- the store. This is not the number of parameters
- to the procedure! */
- }
-
- /* descriptions will be allocated on demand */
- res->loc_descriptions = NULL;
-
- res->visited = 0; /* visited flag, for the ir walker */
- res->block_visited = 0; /* visited flag, for the 'block'-walker */
-
-#if USE_EXPLICIT_PHI_IN_STACK
- res->Phi_in_stack = new_Phi_in_stack(); /* A stack needed for automatic Phi
- generation */
-#endif
- res->kind = k_ir_graph;
- res->obst = xmalloc (sizeof(*res->obst));
- obstack_init(res->obst);
- res->extbb_obst = NULL;
-
- res->value_table = new_identities (); /* value table for global value
- numbering for optimizing use in
- iropt.c */
- res->outs = NULL;
-
- res->inline_property = irg_inline_any;
- res->additional_properties = mtp_property_inherited; /* inherited from type */
-
- res->phase_state = phase_building;
- res->irg_pinned_state = op_pin_state_pinned;
- res->outs_state = outs_none;
- res->dom_state = dom_none;
- res->pdom_state = dom_none;
- res->typeinfo_state = ir_typeinfo_none;
- set_irp_typeinfo_inconsistent(); /* there is a new graph with typeinfo_none. */
- res->callee_info_state = irg_callee_info_none;
- res->loopinfo_state = loopinfo_none;
- res->execfreq_state = exec_freq_none;
- res->class_cast_state = ir_class_casts_transitive;
- res->extblk_state = ir_extblk_info_none;
-
- /*-- Type information for the procedure of the graph --*/
- res->ent = ent;
- set_entity_irg(ent, res);
-
- /*-- a class type so that it can contain "inner" methods as in Pascal. --*/
- res->frame_type = new_type_frame(mangle(get_entity_ident(ent), frame_type_suffix));
-
- /*-- Nodes needed in every graph --*/
- res->end_block = new_immBlock();
- res->end = new_End();
- res->end_reg = res->end;
- res->end_except = res->end;
-
- res->start_block = new_immBlock();
- res->start = new_Start();
- res->bad = new_ir_node(NULL, res, res->start_block, op_Bad, mode_T, 0, NULL);
- res->no_mem = new_ir_node(NULL, res, res->start_block, op_NoMem, mode_M, 0, NULL);
-
- /* Proj results of start node */
- projX = new_Proj (res->start, mode_X, pn_Start_X_initial_exec);
- res->frame = new_Proj (res->start, mode_P_data, pn_Start_P_frame_base);
- res->globals = new_Proj (res->start, mode_P_data, pn_Start_P_globals);
- res->initial_mem = new_Proj (res->start, mode_M, pn_Start_M);
- res->args = new_Proj (res->start, mode_T, pn_Start_T_args);
-#ifdef DEBUG_libfirm
- res->graph_nr = get_irp_new_node_nr();
-#endif
- res->proj_args = NULL;