ir_address_taken_computed_state added for a graph
[libfirm] / ir / ir / irgraph.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irgraph.c
4  * Purpose:     Entry point to the representation of procedure code.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier, Michael Beck
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2007 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16
17 #ifdef HAVE_STRING_H
18 # include <string.h>
19 #endif
20 #ifdef HAVE_STDDEF_H
21 # include <stddef.h>
22 #endif
23
24 #include "xmalloc.h"
25 #include "ircons.h"
26 #include "irgraph_t.h"
27 #include "irprog_t.h"
28 #include "irnode_t.h"
29 #include "iropt_t.h"
30 #include "irflag_t.h"
31 #include "array.h"
32 #include "irgmod.h"
33 #include "mangle.h"
34 #include "irouts.h"
35 #include "irhooks.h"
36 #include "irtools.h"
37 #include "irgwalk.h"
38 #include "iredges_t.h"
39 #include "type_t.h"
40 #include "irmemory.h"
41
42 #define INITIAL_IDX_IRN_MAP_SIZE 1024
43
44 /**
45  * Indicates, whether additional data can be registered to graphs.
46  * If set to 1, this is not possible anymore.
47  */
48 static int forbid_new_data = 0;
49
50 /**
51  * The amount of additional space for custom data to be allocated upon
52  * creating a new graph.
53  */
54 static size_t additional_graph_data_size = 0;
55
56 ir_graph *current_ir_graph;
57 ir_graph *get_current_ir_graph(void) {
58   return current_ir_graph;
59 }
60 void set_current_ir_graph(ir_graph *graph) {
61   current_ir_graph = graph;
62 }
63
64
65 int firm_interprocedural_view = 0;
66
67 int (get_interprocedural_view)(void) {
68   return _get_interprocedural_view();
69 }
70
71 void (set_interprocedural_view)(int state) {
72   firm_interprocedural_view = state;
73
74   /* set function vectors for faster access */
75   if (state) {
76     _get_irn_arity = _get_irn_inter_arity;
77     _get_irn_n     = _get_irn_inter_n;
78   }
79   else {
80     _get_irn_arity = _get_irn_intra_arity;
81     _get_irn_n     = _get_irn_intra_n;
82   }
83 }
84
85 /** contains the suffix for frame type names */
86 static ident *frame_type_suffix = NULL;
87
88 /* initialize the IR graph module */
89 void firm_init_irgraph(void) {
90   frame_type_suffix = new_id_from_str(FRAME_TP_SUFFIX);
91   forbid_new_data   = 1;
92 }
93
94 /**
95  * Allocate a new IR graph.
96  * This function respects the registered graph data. The only reason for
97  * this function is, that there are two locations, where graphs are
98  * allocated (new_r_ir_graph, new_const_code_irg).
99  * @return Memory for a new graph.
100  */
101 static ir_graph *alloc_graph(void) {
102   size_t size = sizeof(ir_graph) + additional_graph_data_size;
103   char *ptr = xmalloc(size);
104   memset(ptr, 0, size);
105
106   return (ir_graph *) (ptr + additional_graph_data_size);
107 }
108
109 /**
110  * Frees an allocated IR graph
111  */
112 static void free_graph(ir_graph *irg) {
113   char *ptr = (char *)irg;
114   free(ptr - additional_graph_data_size);
115 }
116
117 #if USE_EXPLICIT_PHI_IN_STACK
118 /* really defined in ircons.c */
119 typedef struct Phi_in_stack Phi_in_stack;
120 Phi_in_stack *new_Phi_in_stack();
121 void free_Phi_in_stack(Phi_in_stack *s);
122 #endif
123
124 /* Allocates a list of nodes:
125     - The start block containing a start node and Proj nodes for it's four
126       results (X, M, P, Tuple).
127     - The end block containing an end node. This block is not matured after
128       new_ir_graph as predecessors need to be added to it.
129     - The current block, which is empty and also not matured.
130    Further it allocates several datastructures needed for graph construction
131    and optimization.
132 */
133 ir_graph *
134 new_r_ir_graph (ir_entity *ent, int n_loc)
135 {
136   ir_graph *res;
137   ir_node  *first_block;
138   ir_node  *end, *start, *start_block, *initial_mem, *projX;
139
140   res = alloc_graph();
141   res->kind = k_ir_graph;
142
143   //edges_init_graph_kind(res, EDGE_KIND_NORMAL);
144   //edges_init_graph_kind(res, EDGE_KIND_BLOCK);
145
146   /* initialize the idx->node map. */
147   res->idx_irn_map = NEW_ARR_F(ir_node *, INITIAL_IDX_IRN_MAP_SIZE);
148   memset(res->idx_irn_map, 0, INITIAL_IDX_IRN_MAP_SIZE * sizeof(res->idx_irn_map[0]));
149
150   /* inform statistics here, as blocks will be already build on this graph */
151   hook_new_graph(res, ent);
152
153   current_ir_graph = res;
154
155   /*-- initialized for each graph. --*/
156   if (get_opt_precise_exc_context()) {
157     res->n_loc = n_loc + 1 + 1; /* number of local variables that are never
158                    dereferenced in this graph plus one for
159                    the store plus one for links to fragile
160                    operations.  n_loc is not the number of
161                    parameters to the procedure!  */
162   }
163   else {
164     res->n_loc = n_loc + 1;  /* number of local variables that are never
165                 dereferenced in this graph plus one for
166                 the store. This is not the number of parameters
167                 to the procedure!  */
168   }
169
170   /* descriptions will be allocated on demand */
171   res->loc_descriptions = NULL;
172
173   res->visited       = 0; /* visited flag, for the ir walker */
174   res->block_visited = 0; /* visited flag, for the 'block'-walker */
175
176 #if USE_EXPLICIT_PHI_IN_STACK
177   res->Phi_in_stack = new_Phi_in_stack();  /* A stack needed for automatic Phi
178                                 generation */
179 #endif
180   res->kind = k_ir_graph;
181   res->obst = xmalloc (sizeof(*res->obst));
182   obstack_init(res->obst);
183   res->extbb_obst = NULL;
184
185   res->last_node_idx = 0;
186
187   res->value_table = new_identities (); /* value table for global value
188                        numbering for optimizing use in
189                        iropt.c */
190   res->outs = NULL;
191
192   res->inline_property       = irg_inline_any;
193   res->additional_properties = mtp_property_inherited;  /* inherited from type */
194
195   res->phase_state         = phase_building;
196   res->irg_pinned_state    = op_pin_state_pinned;
197   res->outs_state          = outs_none;
198   res->dom_state           = dom_none;
199   res->pdom_state          = dom_none;
200   res->typeinfo_state      = ir_typeinfo_none;
201   set_irp_typeinfo_inconsistent();           /* there is a new graph with typeinfo_none. */
202   res->callee_info_state   = irg_callee_info_none;
203   res->loopinfo_state      = loopinfo_none;
204   res->class_cast_state    = ir_class_casts_transitive;
205   res->extblk_state        = ir_extblk_info_none;
206   res->execfreq_state      = exec_freq_none;
207   res->fp_model            = fp_model_precise;
208   res->adr_taken_state     = ir_address_taken_not_computed;
209
210   /*-- Type information for the procedure of the graph --*/
211   res->ent = ent;
212   set_entity_irg(ent, res);
213
214   /*--  a class type so that it can contain "inner" methods as in Pascal. --*/
215   res->frame_type = new_type_frame(mangle(get_entity_ident(ent), frame_type_suffix));
216
217   /*-- Nodes needed in every graph --*/
218   set_irg_end_block (res, new_immBlock());
219   end               = new_End();
220   set_irg_end       (res, end);
221   set_irg_end_reg   (res, end);
222   set_irg_end_except(res, end);
223
224   start_block = new_immBlock();
225   set_irg_start_block(res, start_block);
226   set_irg_bad        (res, new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL));
227   set_irg_no_mem     (res, new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
228   start = new_Start();
229   set_irg_start      (res, start);
230
231   /* Proj results of start node */
232   projX                   = new_Proj(start, mode_X, pn_Start_X_initial_exec);
233   set_irg_frame           (res, new_Proj(start, mode_P_data, pn_Start_P_frame_base));
234   set_irg_globals         (res, new_Proj(start, mode_P_data, pn_Start_P_globals));
235   set_irg_tls             (res, new_Proj(start, mode_P_data, pn_Start_P_tls));
236   set_irg_args            (res, new_Proj(start, mode_T,      pn_Start_T_args));
237   set_irg_value_param_base(res, new_Proj(start, mode_P_data, pn_Start_P_value_arg_base));
238   initial_mem             = new_Proj(start, mode_M, pn_Start_M);
239   set_irg_initial_mem(res, initial_mem);
240
241   add_immBlock_pred(start_block, projX);
242   set_store(initial_mem);
243
244 #ifdef DEBUG_libfirm
245   res->graph_nr    = get_irp_new_node_nr();
246 #endif
247   res->proj_args   = NULL;
248
249   /*
250    * The code generation needs it. leave it in now.
251    * Use of this edge is matter of discussion, unresolved. Also possible:
252    * add_immBlock_pred(res->start_block, res->start_block), but invalid typed.
253    */
254   mature_immBlock(res->current_block);
255
256   /*-- Make a block to start with --*/
257   first_block = new_immBlock();
258   add_immBlock_pred(first_block, projX);
259
260   res->method_execution_frequency = -1;
261   res->estimated_node_count       = 0;
262
263   return res;
264 }
265
266
267 ir_graph *
268 new_ir_graph(ir_entity *ent, int n_loc)
269 {
270   ir_graph *res = new_r_ir_graph(ent, n_loc);
271   add_irp_irg(res);          /* remember this graph global. */
272   return res;
273 }
274
275 /* Make a rudimentary IR graph for the constant code.
276    Must look like a correct irg, spare everything else. */
277 ir_graph *new_const_code_irg(void) {
278   ir_graph *res;
279   ir_node  *end, *start_block, *start, *projX;
280
281   res = alloc_graph();
282
283   /* initialize the idx->node map. */
284   res->idx_irn_map = NEW_ARR_F(ir_node *, INITIAL_IDX_IRN_MAP_SIZE);
285   memset(res->idx_irn_map, 0, INITIAL_IDX_IRN_MAP_SIZE * sizeof(res->idx_irn_map[0]));
286
287   /* inform statistics here, as blocks will be already build on this graph */
288   hook_new_graph(res, NULL);
289
290   current_ir_graph = res;
291   res->n_loc = 1;         /* Only the memory. */
292   res->visited = 0;       /* visited flag, for the ir walker */
293   res->block_visited = 0; /* visited flag, for the 'block'-walker */
294 #if USE_EXPLICIT_PHI_IN_STACK
295   res->Phi_in_stack = NULL;
296 #endif
297   res->kind = k_ir_graph;
298   res->obst      = xmalloc (sizeof(*res->obst));
299   obstack_init (res->obst);
300   res->extbb_obst = NULL;
301
302   res->last_node_idx = 0;
303
304   res->phase_state      = phase_building;
305   res->irg_pinned_state = op_pin_state_pinned;
306   res->extblk_state     = ir_extblk_info_none;
307   res->fp_model         = fp_model_precise;
308
309   res->value_table = new_identities (); /* value table for global value
310                        numbering for optimizing use in
311                        iropt.c */
312   res->ent = NULL;
313   res->frame_type  = NULL;
314
315   /* -- The end block -- */
316   set_irg_end_block (res, new_immBlock());
317   end = new_End();
318   set_irg_end       (res, end);
319   set_irg_end_reg   (res, end);
320   set_irg_end_except(res, end);
321   mature_immBlock(get_cur_block());  /* mature the end block */
322
323   /* -- The start block -- */
324   start_block        = new_immBlock();
325   set_irg_start_block(res, start_block);
326   set_irg_bad        (res, new_ir_node (NULL, res, start_block, op_Bad, mode_T, 0, NULL));
327   set_irg_no_mem     (res, new_ir_node (NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
328   start              = new_Start();
329   set_irg_start      (res, start);
330
331   /* Proj results of start node */
332   set_irg_initial_mem(res, new_Proj(start, mode_M, pn_Start_M));
333   projX = new_Proj(start, mode_X, pn_Start_X_initial_exec);
334   add_immBlock_pred(start_block, projX);
335   mature_immBlock  (start_block);  /* mature the start block */
336
337   add_immBlock_pred(new_immBlock(), projX);
338   mature_immBlock  (get_cur_block());   /* mature the 'body' block for expressions */
339
340   /* Set the visited flag high enough that the blocks will never be visited. */
341   set_irn_visited(get_cur_block(), -1);
342   set_Block_block_visited(get_cur_block(), -1);
343   set_Block_block_visited(start_block, -1);
344   set_irn_visited(start_block, -1);
345   set_irn_visited(get_irg_bad(res), -1);
346   set_irn_visited(get_irg_no_mem(res), -1);
347
348   res->phase_state = phase_high;
349
350   return res;
351 }
352
353 /* Defined in iropt.c */
354 void  del_identities (pset *value_table);
355
356 /* Frees the passed irgraph.
357    Deallocates all nodes in this graph and the ir_graph structure.
358    Sets the field irgraph in the corresponding entity to NULL.
359    Does not remove the irgraph from the list in irprog (requires
360    inefficient search, call remove_irp_irg by hand).
361    Does not free types, entities or modes that are used only by this
362    graph, nor the entity standing for this graph. */
363 void free_ir_graph (ir_graph *irg) {
364   assert(is_ir_graph(irg));
365
366   hook_free_graph(irg);
367   if (irg->outs_state != outs_none) free_irg_outs(irg);
368   if (irg->frame_type)  free_type(irg->frame_type);
369   if (irg->value_table) del_identities(irg->value_table);
370   if (irg->ent) {
371     ir_peculiarity pec = get_entity_peculiarity (irg->ent);
372     set_entity_peculiarity (irg->ent, peculiarity_description);
373     set_entity_irg(irg->ent, NULL);  /* not set in const code irg */
374     set_entity_peculiarity (irg->ent, pec);
375   }
376
377   free_End(get_irg_end(irg));
378   obstack_free(irg->obst,NULL);
379   free(irg->obst);
380 #if USE_EXPLICIT_PHI_IN_STACK
381   free_Phi_in_stack(irg->Phi_in_stack);
382 #endif
383   if (irg->loc_descriptions)
384     free(irg->loc_descriptions);
385   irg->kind = k_BAD;
386   free_graph(irg);
387 }
388
389 /* access routines for all ir_graph attributes:
390    templates:
391    {attr type} get_irg_{attribute name} (ir_graph *irg);
392    void set_irg_{attr name} (ir_graph *irg, {attr type} {attr}); */
393
394 int
395 (is_ir_graph)(const void *thing) {
396   return _is_ir_graph(thing);
397 }
398
399 /* Outputs a unique number for this node */
400 long get_irg_graph_nr(ir_graph *irg) {
401   assert(irg);
402 #ifdef DEBUG_libfirm
403   return irg->graph_nr;
404 #else
405   return (long)PTR_TO_INT(irg);
406 #endif
407 }
408
409 ir_node *
410 (get_irg_start_block)(const ir_graph *irg) {
411   return _get_irg_start_block(irg);
412 }
413
414 void
415 (set_irg_start_block)(ir_graph *irg, ir_node *node) {
416   _set_irg_start_block(irg, node);
417 }
418
419 ir_node *
420 (get_irg_start)(const ir_graph *irg) {
421   return _get_irg_start(irg);
422 }
423
424 void
425 (set_irg_start)(ir_graph *irg, ir_node *node) {
426   _set_irg_start(irg, node);
427 }
428
429 ir_node *
430 (get_irg_end_block)(const ir_graph *irg) {
431   return _get_irg_end_block(irg);
432 }
433
434 void
435 (set_irg_end_block)(ir_graph *irg, ir_node *node) {
436   _set_irg_end_block(irg, node);
437 }
438
439 ir_node *
440 (get_irg_end)(const ir_graph *irg) {
441   return _get_irg_end(irg);
442 }
443
444 void
445 (set_irg_end)(ir_graph *irg, ir_node *node) {
446   _set_irg_end(irg, node);
447 }
448
449 ir_node *
450 (get_irg_end_reg)(const ir_graph *irg) {
451   return _get_irg_end_reg(irg);
452 }
453
454 void     set_irg_end_reg (ir_graph *irg, ir_node *node) {
455   assert(get_irn_op(node) == op_EndReg || get_irn_op(node) == op_End);
456   irg->anchors[anchor_end_reg] = node;
457 }
458
459 ir_node *
460 (get_irg_end_except)(const ir_graph *irg) {
461   return _get_irg_end_except(irg);
462 }
463
464 void     set_irg_end_except (ir_graph *irg, ir_node *node) {
465   assert(get_irn_op(node) == op_EndExcept || get_irn_op(node) == op_End);
466   irg->anchors[anchor_end_except] = node;
467 }
468
469 ir_node *
470 (get_irg_frame)(const ir_graph *irg) {
471   return _get_irg_frame(irg);
472 }
473
474 void
475 (set_irg_frame)(ir_graph *irg, ir_node *node) {
476   _set_irg_frame(irg, node);
477 }
478
479 ir_node *
480 (get_irg_globals)(const ir_graph *irg) {
481   return _get_irg_globals(irg);
482 }
483
484 void
485 (set_irg_globals)(ir_graph *irg, ir_node *node) {
486   _set_irg_globals(irg, node);
487 }
488
489 ir_node *
490 (get_irg_tls)(const ir_graph *irg) {
491   return _get_irg_tls(irg);
492 }
493
494 void
495 (set_irg_tls)(ir_graph *irg, ir_node *node) {
496   _set_irg_tls(irg, node);
497 }
498
499 ir_node *
500 (get_irg_initial_mem)(const ir_graph *irg) {
501   return _get_irg_initial_mem(irg);
502 }
503
504 void
505 (set_irg_initial_mem)(ir_graph *irg, ir_node *node) {
506   _set_irg_initial_mem(irg, node);
507 }
508
509 ir_node *
510 (get_irg_args)(const ir_graph *irg) {
511   return _get_irg_args(irg);
512 }
513
514 void
515 (set_irg_args)(ir_graph *irg, ir_node *node) {
516   _set_irg_args(irg, node);
517 }
518
519 ir_node *
520 (get_irg_value_param_base)(const ir_graph *irg) {
521   return _get_irg_value_param_base(irg);
522 }
523
524 void
525 (set_irg_value_param_base)(ir_graph *irg, ir_node *node) {
526   _set_irg_value_param_base(irg, node);
527 }
528
529 ir_node **
530 (get_irg_proj_args) (const ir_graph *irg) {
531   return _get_irg_proj_args (irg);
532 }
533
534 void
535 (set_irg_proj_args) (ir_graph *irg, ir_node **nodes) {
536   _set_irg_proj_args (irg, nodes);
537 }
538
539 ir_node *
540 (get_irg_bad)(const ir_graph *irg) {
541   return _get_irg_bad(irg);
542 }
543
544 void
545 (set_irg_bad)(ir_graph *irg, ir_node *node) {
546   _set_irg_bad(irg, node);
547 }
548
549 ir_node *
550 (get_irg_no_mem)(const ir_graph *irg) {
551   return _get_irg_no_mem(irg);
552 }
553
554 void
555 (set_irg_no_mem)(ir_graph *irg, ir_node *node) {
556   _set_irg_no_mem(irg, node);
557 }
558
559 ir_node *
560 (get_irg_current_block)(const ir_graph *irg) {
561   return _get_irg_current_block(irg);
562 }
563
564 void
565 (set_irg_current_block)(ir_graph *irg, ir_node *node) {
566   _set_irg_current_block(irg, node);
567 }
568
569 ir_entity *
570 (get_irg_entity)(const ir_graph *irg) {
571   return _get_irg_entity(irg);
572 }
573
574 void
575 (set_irg_entity)(ir_graph *irg, ir_entity *ent) {
576   _set_irg_entity(irg, ent);
577 }
578
579 ir_type *
580 (get_irg_frame_type)(ir_graph *irg) {
581   return _get_irg_frame_type(irg);
582 }
583
584 void
585 (set_irg_frame_type)(ir_graph *irg, ir_type *ftp) {
586   _set_irg_frame_type(irg, ftp);
587 }
588
589 int
590 get_irg_n_locs (ir_graph *irg)
591 {
592   if (get_opt_precise_exc_context())
593     return irg->n_loc - 1 - 1;
594   else
595     return irg->n_loc - 1;
596 }
597
598 void
599 set_irg_n_loc (ir_graph *irg, int n_loc)
600 {
601   if (get_opt_precise_exc_context())
602     irg->n_loc = n_loc + 1 + 1;
603   else
604     irg->n_loc = n_loc + 1;
605 }
606
607
608
609 /* Returns the obstack associated with the graph. */
610 struct obstack *
611 (get_irg_obstack)(const ir_graph *irg) {
612   return _get_irg_obstack(irg);
613 }
614
615 /*
616  * Returns true if the node n is allocated on the storage of graph irg.
617  *
618  * Implementation is GLIBC specific as is uses the internal _obstack_chunk implementation.
619  */
620 int node_is_in_irgs_storage(ir_graph *irg, ir_node *n)
621 {
622   struct _obstack_chunk *p;
623
624   /*
625    * checks weather the ir_node pointer is on the obstack.
626    * A more sophisticated check would test the "whole" ir_node
627    */
628   for (p = irg->obst->chunk; p; p = p->prev) {
629     if (((char *)p->contents <= (char *)n) && ((char *)n < (char *)p->limit))
630       return 1;
631   }
632
633   return 0;
634 }
635
636 irg_phase_state
637 (get_irg_phase_state)(const ir_graph *irg) {
638   return _get_irg_phase_state(irg);
639 }
640
641 void
642 (set_irg_phase_state)(ir_graph *irg, irg_phase_state state) {
643   _set_irg_phase_state(irg, state);
644 }
645
646 op_pin_state
647 (get_irg_pinned)(const ir_graph *irg) {
648   return _get_irg_pinned(irg);
649 }
650
651 irg_outs_state
652 (get_irg_outs_state)(const ir_graph *irg) {
653   return _get_irg_outs_state(irg);
654 }
655
656 void
657 (set_irg_outs_inconsistent)(ir_graph *irg) {
658   _set_irg_outs_inconsistent(irg);
659 }
660
661 irg_extblk_state
662 (get_irg_extblk_state)(const ir_graph *irg) {
663   return _get_irg_extblk_state(irg);
664 }
665
666 void
667 (set_irg_extblk_inconsistent)(ir_graph *irg) {
668   _set_irg_extblk_inconsistent(irg);
669 }
670
671 irg_dom_state
672 (get_irg_dom_state)(const ir_graph *irg) {
673   return _get_irg_dom_state(irg);
674 }
675
676 irg_dom_state
677 (get_irg_postdom_state)(const ir_graph *irg) {
678   return _get_irg_postdom_state(irg);
679 }
680
681 void
682 (set_irg_doms_inconsistent)(ir_graph *irg) {
683   _set_irg_doms_inconsistent(irg);
684 }
685
686 irg_loopinfo_state
687 (get_irg_loopinfo_state)(const ir_graph *irg) {
688   return _get_irg_loopinfo_state(irg);
689 }
690
691 void
692 (set_irg_loopinfo_state)(ir_graph *irg, irg_loopinfo_state s) {
693   _set_irg_loopinfo_state(irg, s);
694 }
695
696 void
697 (set_irg_loopinfo_inconsistent)(ir_graph *irg) {
698   _set_irg_loopinfo_inconsistent(irg);
699 }
700
701 void set_irp_loopinfo_inconsistent(void) {
702   int i, n_irgs = get_irp_n_irgs();
703   for (i = 0; i < n_irgs; ++i) {
704     set_irg_loopinfo_inconsistent(get_irp_irg(i));
705   }
706 }
707
708
709
710 void
711 (set_irg_pinned)(ir_graph *irg, op_pin_state p) {
712   _set_irg_pinned(irg, p);
713 }
714
715 irg_callee_info_state
716 (get_irg_callee_info_state)(const ir_graph *irg) {
717   return _get_irg_callee_info_state(irg);
718 }
719
720 void
721 (set_irg_callee_info_state)(ir_graph *irg, irg_callee_info_state s) {
722   _set_irg_callee_info_state(irg, s);
723 }
724
725 irg_inline_property
726 (get_irg_inline_property)(const ir_graph *irg) {
727   return _get_irg_inline_property(irg);
728 }
729
730 void
731 (set_irg_inline_property)(ir_graph *irg, irg_inline_property s) {
732   _set_irg_inline_property(irg, s);
733 }
734
735 unsigned
736 (get_irg_additional_properties)(const ir_graph *irg) {
737   return _get_irg_additional_properties(irg);
738 }
739
740 void
741 (set_irg_additional_properties)(ir_graph *irg, unsigned property_mask) {
742   _set_irg_additional_properties(irg, property_mask);
743 }
744
745 void
746 (set_irg_additional_property)(ir_graph *irg, mtp_additional_property flag) {
747   _set_irg_additional_property(irg, flag);
748 }
749
750 void
751 (set_irg_link)(ir_graph *irg, void *thing) {
752   _set_irg_link(irg, thing);
753 }
754
755 void *
756 (get_irg_link)(const ir_graph *irg) {
757   return _get_irg_link(irg);
758 }
759
760 /** maximum visited flag content of all ir_graph visited fields. */
761 static unsigned long max_irg_visited = 0;
762
763 unsigned long
764 (get_irg_visited)(const ir_graph *irg) {
765   return _get_irg_visited(irg);
766 }
767
768 void
769 set_irg_visited (ir_graph *irg, unsigned long visited)
770 {
771   irg->visited = visited;
772   if (irg->visited > max_irg_visited) {
773     max_irg_visited = irg->visited;
774   }
775 }
776
777 void
778 inc_irg_visited (ir_graph *irg)
779 {
780   if (++irg->visited > max_irg_visited) {
781     max_irg_visited = irg->visited;
782   }
783 }
784
785 unsigned long
786 get_max_irg_visited(void)
787 {
788   /*
789   int i;
790   for(i = 0; i < get_irp_n_irgs(); i++)
791   assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
792    */
793   return max_irg_visited;
794 }
795
796 void set_max_irg_visited(int val) {
797   max_irg_visited = val;
798 }
799
800 unsigned long
801 inc_max_irg_visited(void)
802 {
803   /*
804   int i;
805   for(i = 0; i < get_irp_n_irgs(); i++)
806   assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
807   */
808   max_irg_visited++;
809   return max_irg_visited;
810 }
811
812 unsigned long
813 (get_irg_block_visited)(const ir_graph *irg) {
814   return _get_irg_block_visited(irg);
815 }
816
817 void
818 (set_irg_block_visited)(ir_graph *irg, unsigned long visited) {
819   _set_irg_block_visited(irg, visited);
820 }
821
822 void
823 (inc_irg_block_visited)(ir_graph *irg) {
824   _inc_irg_block_visited(irg);
825 }
826
827 /* Return the floating point model of this graph. */
828 unsigned (get_irg_fp_model)(const ir_graph *irg) {
829   return _get_irg_fp_model(irg);
830 }
831
832 /* Sets the floating point model for this graph. */
833 void set_irg_fp_model(ir_graph *irg, unsigned model) {
834   irg->fp_model = model;
835 }
836
837 /**
838  * walker Start->End: places Proj nodes into the same block
839  * as it's predecessors
840  *
841  * @param n    the node
842  * @param env  ignored
843  */
844 static void normalize_proj_walker(ir_node *n, void *env){
845   if (is_Proj(n)) {
846     ir_node *pred  = get_Proj_pred(n);
847     ir_node *block = get_nodes_block(pred);
848
849     set_nodes_block(n, block);
850   }
851 }
852
853 /* move Proj nodes into the same block as its predecessors */
854 void normalize_proj_nodes(ir_graph *irg) {
855   irg_walk_graph(irg, NULL, normalize_proj_walker, NULL);
856   set_irg_outs_inconsistent(irg);
857 }
858
859 /* set a description for local value n */
860 void set_irg_loc_description(ir_graph *irg, int n, void *description) {
861   assert(0 <= n && n < irg->n_loc);
862
863   if (! irg->loc_descriptions)
864     irg->loc_descriptions = xcalloc(sizeof(*irg->loc_descriptions), irg->n_loc);
865
866   irg->loc_descriptions[n] = description;
867 }
868
869 /* get the description for local value n */
870 void *get_irg_loc_description(ir_graph *irg, int n) {
871   assert(0 <= n && n < irg->n_loc);
872   return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL;
873 }
874
875 /* Returns a estimated node count of the irg. */
876 unsigned (get_irg_estimated_node_cnt)(const ir_graph *irg) {
877   return _get_irg_estimated_node_cnt(irg);
878 }
879
880 /* Returns the last irn index for this graph. */
881 unsigned get_irg_last_idx(const ir_graph *irg) {
882   return irg->last_node_idx;
883 }
884
885 /* register additional space in an IR graph */
886 size_t register_additional_graph_data(size_t size)
887 {
888   assert(!forbid_new_data && "Too late to register additional node data");
889
890   if (forbid_new_data)
891     return 0;
892
893   return additional_graph_data_size += size;
894 }