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