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