reset node index on dead node elimination
[libfirm] / ir / ir / pseudo_irg.c
1 /* -*- c -*- */
2
3 /*
4  * Project:     libFIRM
5  * File name:   ir/external/pseudo_irg.c
6  * Purpose:     implementation
7  * Author:      G"otz Lindenmaier
8  * Modified by: Boris Boesler
9  * Created:     xx.10.2004
10  * CVS-ID:      $Id$
11  * Copyright:   (c) 1999-2004 Universität Karlsruhe
12  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  */
14
15 #ifdef HAVE_CONFIG_H
16 # include "config.h"
17 #endif
18
19
20 #include "pseudo_irg.h"
21
22 #include "irgraph_t.h"
23 #include "irprog_t.h"
24 #include "array.h"
25
26
27 /* Returns the number of pseudo graphs in the program. */
28 int get_irp_n_pseudo_irgs(void) {
29   assert (irp && irp->pseudo_graphs);
30   return ARR_LEN(irp->pseudo_graphs);
31 }
32
33 /* Returns the pos'th  pseudo graph in the program. */
34 ir_graph *get_irp_pseudo_irg(int pos) {
35   assert(0 <= pos && pos <= get_irp_n_pseudo_irgs());
36   return irp->pseudo_graphs[pos];
37 }
38
39 void add_irp_pseudo_irg(ir_graph *irg) {
40   assert (irp && irp->pseudo_graphs);
41   ARR_APP1(ir_graph *, irp->pseudo_graphs, irg);
42 }
43
44
45 /* Create a new ir graph to build a pseudo representation of a procedure.
46  *
47  *  The pseudo representation can only be used for analyses.  It may not be
48  *  optimized.  Pseudo graphs are kept in a separate graph list in irprog.
49  */
50 ir_graph *
51 new_pseudo_ir_graph(entity *ent, int n_loc) {
52   ir_graph *res = new_r_ir_graph (ent, n_loc);
53   add_irp_pseudo_irg(res);          /* remember this graph global. */
54   return res;
55 }
56
57 /* Returns non-zero ir ir_graph is pseudo graph. */
58 int is_pseudo_ir_graph(ir_graph *irg)
59 {
60   int i, n_pseudo_irgs;
61
62   assert(irg && "nothing here");
63   assert(is_ir_graph(irg) && "no ir_graph given");
64
65   n_pseudo_irgs = get_irp_n_pseudo_irgs();
66   for (i = 0; i < n_pseudo_irgs; ++i) {
67     if (irg == get_irp_pseudo_irg(i)) return 1;
68   }
69   return 0;
70 }
71
72 static int visit_pseudo_irgs = 0;
73
74 void set_visit_pseudo_irgs(int x) {
75   visit_pseudo_irgs = x;
76 }
77
78 int get_visit_pseudo_irgs(void) {
79   return visit_pseudo_irgs;
80 }