-/* 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_ir_graph (entity *ent, int n_loc)
-{
- ir_graph *res;
- ir_node *first_block;
- ir_node *projX;
-
- res = (ir_graph *) malloc (sizeof (ir_graph));
- memset(res, 0, sizeof (ir_graph));
- res->kind=k_ir_graph;
-
- /* inform statistics here, as blocks will be already build on this graph */
- stat_new_graph(res, ent);
-
- current_ir_graph = res;
- add_irp_irg(res); /* remember this graph global. */
-
- /*-- 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! */
- }
-
- 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 = (struct obstack *) xmalloc (sizeof (struct obstack));
- obstack_init (res->obst);
- res->value_table = new_identities (); /* value table for global value
- numbering for optimizing use in
- iropt.c */
- res->outs = NULL;
-
- res->phase_state = phase_building;
- res->pinned = pinned;
- res->outs_state = no_outs;
- res->dom_state = no_dom;
- res->typeinfo_state = irg_typeinfo_none;
- res->loopinfo_state = loopinfo_none;
-
- /*-- Type information for the procedure of the graph --*/
- res->ent = ent;
- set_entity_irg(ent, res);
-
- /*-- contain "inner" methods as in Pascal. --*/
- res->frame_type = new_type_class(mangle(get_entity_ident(ent), frame_type_suffix));
- /* Remove type from type list. Must be treated differently than other types. */
- remove_irp_type_from_list(res->frame_type);
-
- /*-- 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->unknown = new_ir_node (NULL, res, res->start_block, op_Unknown, mode_T, 0, NULL); */
-
- /* Proj results of start node */
- projX = new_Proj (res->start, mode_X, pns_initial_exec);
- set_store (new_Proj (res->start, mode_M, pns_global_store));
- res->frame = new_Proj (res->start, mode_P_mach, pns_frame_base);
- res->globals = new_Proj (res->start, mode_P_mach, pns_globals);
- res->args = new_Proj (res->start, mode_T, pns_args);
+ 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! */
+
+ if (res->loc_descriptions) {
+ xfree(res->loc_descriptions);
+ res->loc_descriptions = NULL;
+ }
+}
+
+ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
+{
+ ir_graph *res;
+ ir_node *first_block;
+ ir_node *start, *start_block, *initial_mem, *projX;
+
+ res = alloc_graph();
+
+ /* inform statistics here, as blocks will be already build on this graph */
+ hook_new_graph(res, ent);
+
+ /*-- initialized for each graph. --*/
+ res->kind = k_ir_graph;
+ res->obst = XMALLOC(struct obstack);
+ obstack_init(res->obst);
+
+ res->phase_state = phase_building;
+ irg_set_nloc(res, n_loc);
+
+ /* 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 */
+
+ res->last_node_idx = 0;
+
+ new_identities(res);
+ res->outs = NULL;
+
+ res->inline_property = irg_inline_any;
+ res->additional_properties = mtp_property_inherited; /* inherited from type */
+
+ res->irg_pinned_state = op_pin_state_pinned;
+ 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->class_cast_state = ir_class_casts_transitive;
+ res->fp_model = fp_model_precise;
+ res->mem_disambig_opt = aa_opt_inherited;
+
+ /*-- 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();
+
+ /* the Anchor node must be created first */
+ res->anchor = new_r_Anchor(res);
+
+ /*-- Nodes needed in every graph --*/
+ set_irg_end_block(res, new_r_immBlock(res));
+ set_irg_end(res, new_r_End(res, 0, NULL));
+
+ start_block = new_r_Block_noopt(res, 0, NULL);
+ set_irg_start_block(res, start_block);
+ set_irg_no_mem (res, new_r_NoMem(res));
+ start = new_r_Start(res);
+ set_irg_start (res, start);
+
+ /* Proj results of start node */
+ projX = new_r_Proj(start, mode_X, pn_Start_X_initial_exec);
+ set_irg_initial_exec (res, projX);
+ set_irg_frame (res, new_r_Proj(start, mode_P_data, pn_Start_P_frame_base));
+ set_irg_args (res, new_r_Proj(start, mode_T, pn_Start_T_args));
+ initial_mem = new_r_Proj(start, mode_M, pn_Start_M);
+ set_irg_initial_mem(res, initial_mem);
+
+ res->index = get_irp_new_irg_idx();