removed unused data/functions, reformated
[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   res->mem_disambig_opt    = aa_opt_inherited;
210
211   /*-- Type information for the procedure of the graph --*/
212   res->ent = ent;
213   set_entity_irg(ent, res);
214
215   /*--  a class type so that it can contain "inner" methods as in Pascal. --*/
216   res->frame_type = new_type_frame(mangle(get_entity_ident(ent), frame_type_suffix));
217
218   /*-- Nodes needed in every graph --*/
219   set_irg_end_block (res, new_immBlock());
220   end               = new_End();
221   set_irg_end       (res, end);
222   set_irg_end_reg   (res, end);
223   set_irg_end_except(res, end);
224
225   start_block = new_immBlock();
226   set_irg_start_block(res, start_block);
227   set_irg_bad        (res, new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL));
228   set_irg_no_mem     (res, new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
229   start = new_Start();
230   set_irg_start      (res, start);
231
232   /* Proj results of start node */
233   projX                   = new_Proj(start, mode_X, pn_Start_X_initial_exec);
234   set_irg_frame           (res, new_Proj(start, mode_P_data, pn_Start_P_frame_base));
235   set_irg_globals         (res, new_Proj(start, mode_P_data, pn_Start_P_globals));
236   set_irg_tls             (res, new_Proj(start, mode_P_data, pn_Start_P_tls));
237   set_irg_args            (res, new_Proj(start, mode_T,      pn_Start_T_args));
238   set_irg_value_param_base(res, new_Proj(start, mode_P_data, pn_Start_P_value_arg_base));
239   initial_mem             = new_Proj(start, mode_M, pn_Start_M);
240   set_irg_initial_mem(res, initial_mem);
241
242   add_immBlock_pred(start_block, projX);
243   set_store(initial_mem);
244
245 #ifdef DEBUG_libfirm
246   res->graph_nr    = get_irp_new_node_nr();
247 #endif
248   res->proj_args   = NULL;
249
250   /*
251    * The code generation needs it. leave it in now.
252    * Use of this edge is matter of discussion, unresolved. Also possible:
253    * add_immBlock_pred(res->start_block, res->start_block), but invalid typed.
254    */
255   mature_immBlock(res->current_block);
256
257   /*-- Make a block to start with --*/
258   first_block = new_immBlock();
259   add_immBlock_pred(first_block, projX);
260
261   res->method_execution_frequency = -1;
262   res->estimated_node_count       = 0;
263
264   return res;
265 }
266
267
268 ir_graph *
269 new_ir_graph(ir_entity *ent, int n_loc)
270 {
271   ir_graph *res = new_r_ir_graph(ent, n_loc);
272   add_irp_irg(res);          /* remember this graph global. */
273   return res;
274 }
275
276 /* Make a rudimentary IR graph for the constant code.
277    Must look like a correct irg, spare everything else. */
278 ir_graph *new_const_code_irg(void) {
279   ir_graph *res;
280   ir_node  *end, *start_block, *start, *projX;
281
282   res = alloc_graph();
283
284   /* initialize the idx->node map. */
285   res->idx_irn_map = NEW_ARR_F(ir_node *, INITIAL_IDX_IRN_MAP_SIZE);
286   memset(res->idx_irn_map, 0, INITIAL_IDX_IRN_MAP_SIZE * sizeof(res->idx_irn_map[0]));
287
288   /* inform statistics here, as blocks will be already build on this graph */
289   hook_new_graph(res, NULL);
290
291   current_ir_graph = res;
292   res->n_loc = 1;         /* Only the memory. */
293   res->visited = 0;       /* visited flag, for the ir walker */
294   res->block_visited = 0; /* visited flag, for the 'block'-walker */
295 #if USE_EXPLICIT_PHI_IN_STACK
296   res->Phi_in_stack = NULL;
297 #endif
298   res->kind = k_ir_graph;
299   res->obst      = xmalloc (sizeof(*res->obst));
300   obstack_init (res->obst);
301   res->extbb_obst = NULL;
302
303   res->last_node_idx = 0;
304
305   res->phase_state      = phase_building;
306   res->irg_pinned_state = op_pin_state_pinned;
307   res->extblk_state     = ir_extblk_info_none;
308   res->fp_model         = fp_model_precise;
309
310   res->value_table = new_identities (); /* value table for global value
311                        numbering for optimizing use in
312                        iropt.c */
313   res->ent = NULL;
314   res->frame_type  = NULL;
315
316   /* -- The end block -- */
317   set_irg_end_block (res, new_immBlock());
318   end = new_End();
319   set_irg_end       (res, end);
320   set_irg_end_reg   (res, end);
321   set_irg_end_except(res, end);
322   mature_immBlock(get_cur_block());  /* mature the end block */
323
324   /* -- The start block -- */
325   start_block        = new_immBlock();
326   set_irg_start_block(res, start_block);
327   set_irg_bad        (res, new_ir_node (NULL, res, start_block, op_Bad, mode_T, 0, NULL));
328   set_irg_no_mem     (res, new_ir_node (NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
329   start              = new_Start();
330   set_irg_start      (res, start);
331
332   /* Proj results of start node */
333   set_irg_initial_mem(res, new_Proj(start, mode_M, pn_Start_M));
334   projX = new_Proj(start, mode_X, pn_Start_X_initial_exec);
335   add_immBlock_pred(start_block, projX);
336   mature_immBlock  (start_block);  /* mature the start block */
337
338   add_immBlock_pred(new_immBlock(), projX);
339   mature_immBlock  (get_cur_block());   /* mature the 'body' block for expressions */
340
341   /* Set the visited flag high enough that the blocks will never be visited. */
342   set_irn_visited(get_cur_block(), -1);
343   set_Block_block_visited(get_cur_block(), -1);
344   set_Block_block_visited(start_block, -1);
345   set_irn_visited(start_block, -1);
346   set_irn_visited(get_irg_bad(res), -1);
347   set_irn_visited(get_irg_no_mem(res), -1);
348
349   res->phase_state = phase_high;
350
351   return res;
352 }
353
354 /* Defined in iropt.c */
355 void  del_identities (pset *value_table);
356
357 /* Frees the passed irgraph.
358    Deallocates all nodes in this graph and the ir_graph structure.
359    Sets the field irgraph in the corresponding entity to NULL.
360    Does not remove the irgraph from the list in irprog (requires
361    inefficient search, call remove_irp_irg by hand).
362    Does not free types, entities or modes that are used only by this
363    graph, nor the entity standing for this graph. */
364 void free_ir_graph (ir_graph *irg) {
365   assert(is_ir_graph(irg));
366
367   hook_free_graph(irg);
368   if (irg->outs_state != outs_none) free_irg_outs(irg);
369   if (irg->frame_type)  free_type(irg->frame_type);
370   if (irg->value_table) del_identities(irg->value_table);
371   if (irg->ent) {
372     ir_peculiarity pec = get_entity_peculiarity (irg->ent);
373     set_entity_peculiarity (irg->ent, peculiarity_description);
374     set_entity_irg(irg->ent, NULL);  /* not set in const code irg */
375     set_entity_peculiarity (irg->ent, pec);
376   }
377
378   free_End(get_irg_end(irg));
379   obstack_free(irg->obst,NULL);
380   free(irg->obst);
381 #if USE_EXPLICIT_PHI_IN_STACK
382   free_Phi_in_stack(irg->Phi_in_stack);
383 #endif
384   if (irg->loc_descriptions)
385     free(irg->loc_descriptions);
386   irg->kind = k_BAD;
387   free_graph(irg);
388 }
389
390 /* access routines for all ir_graph attributes:
391    templates:
392    {attr type} get_irg_{attribute name} (ir_graph *irg);
393    void set_irg_{attr name} (ir_graph *irg, {attr type} {attr}); */
394
395 int
396 (is_ir_graph)(const void *thing) {
397   return _is_ir_graph(thing);
398 }
399
400 /* Outputs a unique number for this node */
401 long get_irg_graph_nr(ir_graph *irg) {
402   assert(irg);
403 #ifdef DEBUG_libfirm
404   return irg->graph_nr;
405 #else
406   return (long)PTR_TO_INT(irg);
407 #endif
408 }
409
410 ir_node *
411 (get_irg_start_block)(const ir_graph *irg) {
412   return _get_irg_start_block(irg);
413 }
414
415 void
416 (set_irg_start_block)(ir_graph *irg, ir_node *node) {
417   _set_irg_start_block(irg, node);
418 }
419
420 ir_node *
421 (get_irg_start)(const ir_graph *irg) {
422   return _get_irg_start(irg);
423 }
424
425 void
426 (set_irg_start)(ir_graph *irg, ir_node *node) {
427   _set_irg_start(irg, node);
428 }
429
430 ir_node *
431 (get_irg_end_block)(const ir_graph *irg) {
432   return _get_irg_end_block(irg);
433 }
434
435 void
436 (set_irg_end_block)(ir_graph *irg, ir_node *node) {
437   _set_irg_end_block(irg, node);
438 }
439
440 ir_node *
441 (get_irg_end)(const ir_graph *irg) {
442   return _get_irg_end(irg);
443 }
444
445 void
446 (set_irg_end)(ir_graph *irg, ir_node *node) {
447   _set_irg_end(irg, node);
448 }
449
450 ir_node *
451 (get_irg_end_reg)(const ir_graph *irg) {
452   return _get_irg_end_reg(irg);
453 }
454
455 void     set_irg_end_reg (ir_graph *irg, ir_node *node) {
456   assert(get_irn_op(node) == op_EndReg || get_irn_op(node) == op_End);
457   irg->anchors[anchor_end_reg] = node;
458 }
459
460 ir_node *
461 (get_irg_end_except)(const ir_graph *irg) {
462   return _get_irg_end_except(irg);
463 }
464
465 void     set_irg_end_except (ir_graph *irg, ir_node *node) {
466   assert(get_irn_op(node) == op_EndExcept || get_irn_op(node) == op_End);
467   irg->anchors[anchor_end_except] = node;
468 }
469
470 ir_node *
471 (get_irg_frame)(const ir_graph *irg) {
472   return _get_irg_frame(irg);
473 }
474
475 void
476 (set_irg_frame)(ir_graph *irg, ir_node *node) {
477   _set_irg_frame(irg, node);
478 }
479
480 ir_node *
481 (get_irg_globals)(const ir_graph *irg) {
482   return _get_irg_globals(irg);
483 }
484
485 void
486 (set_irg_globals)(ir_graph *irg, ir_node *node) {
487   _set_irg_globals(irg, node);
488 }
489
490 ir_node *
491 (get_irg_tls)(const ir_graph *irg) {
492   return _get_irg_tls(irg);
493 }
494
495 void
496 (set_irg_tls)(ir_graph *irg, ir_node *node) {
497   _set_irg_tls(irg, node);
498 }
499
500 ir_node *
501 (get_irg_initial_mem)(const ir_graph *irg) {
502   return _get_irg_initial_mem(irg);
503 }
504
505 void
506 (set_irg_initial_mem)(ir_graph *irg, ir_node *node) {
507   _set_irg_initial_mem(irg, node);
508 }
509
510 ir_node *
511 (get_irg_args)(const ir_graph *irg) {
512   return _get_irg_args(irg);
513 }
514
515 void
516 (set_irg_args)(ir_graph *irg, ir_node *node) {
517   _set_irg_args(irg, node);
518 }
519
520 ir_node *
521 (get_irg_value_param_base)(const ir_graph *irg) {
522   return _get_irg_value_param_base(irg);
523 }
524
525 void
526 (set_irg_value_param_base)(ir_graph *irg, ir_node *node) {
527   _set_irg_value_param_base(irg, node);
528 }
529
530 ir_node **
531 (get_irg_proj_args) (const ir_graph *irg) {
532   return _get_irg_proj_args (irg);
533 }
534
535 void
536 (set_irg_proj_args) (ir_graph *irg, ir_node **nodes) {
537   _set_irg_proj_args (irg, nodes);
538 }
539
540 ir_node *
541 (get_irg_bad)(const ir_graph *irg) {
542   return _get_irg_bad(irg);
543 }
544
545 void
546 (set_irg_bad)(ir_graph *irg, ir_node *node) {
547   _set_irg_bad(irg, node);
548 }
549
550 ir_node *
551 (get_irg_no_mem)(const ir_graph *irg) {
552   return _get_irg_no_mem(irg);
553 }
554
555 void
556 (set_irg_no_mem)(ir_graph *irg, ir_node *node) {
557   _set_irg_no_mem(irg, node);
558 }
559
560 ir_node *
561 (get_irg_current_block)(const ir_graph *irg) {
562   return _get_irg_current_block(irg);
563 }
564
565 void
566 (set_irg_current_block)(ir_graph *irg, ir_node *node) {
567   _set_irg_current_block(irg, node);
568 }
569
570 ir_entity *
571 (get_irg_entity)(const ir_graph *irg) {
572   return _get_irg_entity(irg);
573 }
574
575 void
576 (set_irg_entity)(ir_graph *irg, ir_entity *ent) {
577   _set_irg_entity(irg, ent);
578 }
579
580 ir_type *
581 (get_irg_frame_type)(ir_graph *irg) {
582   return _get_irg_frame_type(irg);
583 }
584
585 void
586 (set_irg_frame_type)(ir_graph *irg, ir_type *ftp) {
587   _set_irg_frame_type(irg, ftp);
588 }
589
590 int
591 get_irg_n_locs (ir_graph *irg)
592 {
593   if (get_opt_precise_exc_context())
594     return irg->n_loc - 1 - 1;
595   else
596     return irg->n_loc - 1;
597 }
598
599 void
600 set_irg_n_loc (ir_graph *irg, int n_loc)
601 {
602   if (get_opt_precise_exc_context())
603     irg->n_loc = n_loc + 1 + 1;
604   else
605     irg->n_loc = n_loc + 1;
606 }
607
608
609
610 /* Returns the obstack associated with the graph. */
611 struct obstack *
612 (get_irg_obstack)(const ir_graph *irg) {
613   return _get_irg_obstack(irg);
614 }
615
616 /*
617  * Returns true if the node n is allocated on the storage of graph irg.
618  *
619  * Implementation is GLIBC specific as is uses the internal _obstack_chunk implementation.
620  */
621 int node_is_in_irgs_storage(ir_graph *irg, ir_node *n)
622 {
623   struct _obstack_chunk *p;
624
625   /*
626    * checks weather the ir_node pointer is on the obstack.
627    * A more sophisticated check would test the "whole" ir_node
628    */
629   for (p = irg->obst->chunk; p; p = p->prev) {
630     if (((char *)p->contents <= (char *)n) && ((char *)n < (char *)p->limit))
631       return 1;
632   }
633
634   return 0;
635 }
636
637 irg_phase_state
638 (get_irg_phase_state)(const ir_graph *irg) {
639   return _get_irg_phase_state(irg);
640 }
641
642 void
643 (set_irg_phase_state)(ir_graph *irg, irg_phase_state state) {
644   _set_irg_phase_state(irg, state);
645 }
646
647 op_pin_state
648 (get_irg_pinned)(const ir_graph *irg) {
649   return _get_irg_pinned(irg);
650 }
651
652 irg_outs_state
653 (get_irg_outs_state)(const ir_graph *irg) {
654   return _get_irg_outs_state(irg);
655 }
656
657 void
658 (set_irg_outs_inconsistent)(ir_graph *irg) {
659   _set_irg_outs_inconsistent(irg);
660 }
661
662 irg_extblk_state
663 (get_irg_extblk_state)(const ir_graph *irg) {
664   return _get_irg_extblk_state(irg);
665 }
666
667 void
668 (set_irg_extblk_inconsistent)(ir_graph *irg) {
669   _set_irg_extblk_inconsistent(irg);
670 }
671
672 irg_dom_state
673 (get_irg_dom_state)(const ir_graph *irg) {
674   return _get_irg_dom_state(irg);
675 }
676
677 irg_dom_state
678 (get_irg_postdom_state)(const ir_graph *irg) {
679   return _get_irg_postdom_state(irg);
680 }
681
682 void
683 (set_irg_doms_inconsistent)(ir_graph *irg) {
684   _set_irg_doms_inconsistent(irg);
685 }
686
687 irg_loopinfo_state
688 (get_irg_loopinfo_state)(const ir_graph *irg) {
689   return _get_irg_loopinfo_state(irg);
690 }
691
692 void
693 (set_irg_loopinfo_state)(ir_graph *irg, irg_loopinfo_state s) {
694   _set_irg_loopinfo_state(irg, s);
695 }
696
697 void
698 (set_irg_loopinfo_inconsistent)(ir_graph *irg) {
699   _set_irg_loopinfo_inconsistent(irg);
700 }
701
702 void set_irp_loopinfo_inconsistent(void) {
703   int i, n_irgs = get_irp_n_irgs();
704   for (i = 0; i < n_irgs; ++i) {
705     set_irg_loopinfo_inconsistent(get_irp_irg(i));
706   }
707 }
708
709
710
711 void
712 (set_irg_pinned)(ir_graph *irg, op_pin_state p) {
713   _set_irg_pinned(irg, p);
714 }
715
716 irg_callee_info_state
717 (get_irg_callee_info_state)(const ir_graph *irg) {
718   return _get_irg_callee_info_state(irg);
719 }
720
721 void
722 (set_irg_callee_info_state)(ir_graph *irg, irg_callee_info_state s) {
723   _set_irg_callee_info_state(irg, s);
724 }
725
726 irg_inline_property
727 (get_irg_inline_property)(const ir_graph *irg) {
728   return _get_irg_inline_property(irg);
729 }
730
731 void
732 (set_irg_inline_property)(ir_graph *irg, irg_inline_property s) {
733   _set_irg_inline_property(irg, s);
734 }
735
736 unsigned
737 (get_irg_additional_properties)(const ir_graph *irg) {
738   return _get_irg_additional_properties(irg);
739 }
740
741 void
742 (set_irg_additional_properties)(ir_graph *irg, unsigned property_mask) {
743   _set_irg_additional_properties(irg, property_mask);
744 }
745
746 void
747 (set_irg_additional_property)(ir_graph *irg, mtp_additional_property flag) {
748   _set_irg_additional_property(irg, flag);
749 }
750
751 void
752 (set_irg_link)(ir_graph *irg, void *thing) {
753   _set_irg_link(irg, thing);
754 }
755
756 void *
757 (get_irg_link)(const ir_graph *irg) {
758   return _get_irg_link(irg);
759 }
760
761 /** maximum visited flag content of all ir_graph visited fields. */
762 static unsigned long max_irg_visited = 0;
763
764 unsigned long
765 (get_irg_visited)(const ir_graph *irg) {
766   return _get_irg_visited(irg);
767 }
768
769 void
770 set_irg_visited (ir_graph *irg, unsigned long visited)
771 {
772   irg->visited = visited;
773   if (irg->visited > max_irg_visited) {
774     max_irg_visited = irg->visited;
775   }
776 }
777
778 void
779 inc_irg_visited (ir_graph *irg)
780 {
781   if (++irg->visited > max_irg_visited) {
782     max_irg_visited = irg->visited;
783   }
784 }
785
786 unsigned long
787 get_max_irg_visited(void)
788 {
789   /*
790   int i;
791   for(i = 0; i < get_irp_n_irgs(); i++)
792   assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
793    */
794   return max_irg_visited;
795 }
796
797 void set_max_irg_visited(int val) {
798   max_irg_visited = val;
799 }
800
801 unsigned long
802 inc_max_irg_visited(void)
803 {
804   /*
805   int i;
806   for(i = 0; i < get_irp_n_irgs(); i++)
807   assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
808   */
809   max_irg_visited++;
810   return max_irg_visited;
811 }
812
813 unsigned long
814 (get_irg_block_visited)(const ir_graph *irg) {
815   return _get_irg_block_visited(irg);
816 }
817
818 void
819 (set_irg_block_visited)(ir_graph *irg, unsigned long visited) {
820   _set_irg_block_visited(irg, visited);
821 }
822
823 void
824 (inc_irg_block_visited)(ir_graph *irg) {
825   _inc_irg_block_visited(irg);
826 }
827
828 /* Return the floating point model of this graph. */
829 unsigned (get_irg_fp_model)(const ir_graph *irg) {
830   return _get_irg_fp_model(irg);
831 }
832
833 /* Sets the floating point model for this graph. */
834 void set_irg_fp_model(ir_graph *irg, unsigned model) {
835   irg->fp_model = model;
836 }
837
838 /**
839  * walker Start->End: places Proj nodes into the same block
840  * as it's predecessors
841  *
842  * @param n    the node
843  * @param env  ignored
844  */
845 static void normalize_proj_walker(ir_node *n, void *env){
846   if (is_Proj(n)) {
847     ir_node *pred  = get_Proj_pred(n);
848     ir_node *block = get_nodes_block(pred);
849
850     set_nodes_block(n, block);
851   }
852 }
853
854 /* move Proj nodes into the same block as its predecessors */
855 void normalize_proj_nodes(ir_graph *irg) {
856   irg_walk_graph(irg, NULL, normalize_proj_walker, NULL);
857   set_irg_outs_inconsistent(irg);
858 }
859
860 /* set a description for local value n */
861 void set_irg_loc_description(ir_graph *irg, int n, void *description) {
862   assert(0 <= n && n < irg->n_loc);
863
864   if (! irg->loc_descriptions)
865     irg->loc_descriptions = xcalloc(sizeof(*irg->loc_descriptions), irg->n_loc);
866
867   irg->loc_descriptions[n] = description;
868 }
869
870 /* get the description for local value n */
871 void *get_irg_loc_description(ir_graph *irg, int n) {
872   assert(0 <= n && n < irg->n_loc);
873   return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL;
874 }
875
876 /* Sets the inside block walk flag */
877 void (set_inside_block_walk)(ir_graph *irg) {
878   _set_inside_block_walk(irg);
879 }
880
881 /* Clears the inside block walk flag */
882 void (clear_inside_block_walk)(ir_graph *irg) {
883   _clear_inside_block_walk(irg);
884 }
885
886 /* Returns the inside block walk flag */
887 unsigned (inside_block_walk)(const ir_graph *irg) {
888   return _inside_block_walk(irg);
889 }
890
891 /* Sets the inside irg walk flag */
892 void (set_inside_irg_walk)(ir_graph *irg) {
893   _clear_inside_irg_walk(irg);
894 }
895
896 /* Clears the inside irg walk flag */
897 void (clear_inside_irg_walk)(ir_graph *irg) {
898   _clear_inside_irg_walk(irg);
899 }
900
901 /* Returns the inside irg walk flag */
902 unsigned (inside_irg_walk)(const ir_graph *irg) {
903   return _inside_irg_walk(irg);
904 }
905
906 /* Returns a estimated node count of the irg. */
907 unsigned (get_irg_estimated_node_cnt)(const ir_graph *irg) {
908   return _get_irg_estimated_node_cnt(irg);
909 }
910
911 /* Returns the last irn index for this graph. */
912 unsigned get_irg_last_idx(const ir_graph *irg) {
913   return irg->last_node_idx;
914 }
915
916 /* register additional space in an IR graph */
917 size_t register_additional_graph_data(size_t size)
918 {
919   assert(!forbid_new_data && "Too late to register additional node data");
920
921   if (forbid_new_data)
922     return 0;
923
924   return additional_graph_data_size += size;
925 }