fixed some depencies between irdump.c and irdumptxt.c
[libfirm] / ir / external / pseudo_irg.c
1
2
3 #include "pseudo_irg.h"
4
5 #include "irgraph_t.h"
6 #include "irprog_t.h"
7 #include "array.h"
8
9
10 /** Returns the number of pseudo graphs in the program. */
11 int get_irp_n_pseudo_irgs(void) {
12   assert (irp && irp->pseudo_graphs);
13   return ARR_LEN(irp->pseudo_graphs);
14 }
15
16 /** Returns the number of pseudo graphs in the program. */
17 ir_graph *get_irp_pseudo_irg(int pos) {
18   assert(0 <= pos && pos <= get_irp_n_pseudo_irgs());
19   return irp->pseudo_graphs[pos];
20 }
21
22 void add_irp_pseudo_irg(ir_graph *irg) {
23   assert (irp && irp->pseudo_graphs);
24   ARR_APP1(ir_graph *, irp->pseudo_graphs, irg);
25 }
26
27
28 /* Create a new ir graph to build a pseudo representation of a procedure.
29  *
30  *  The pseudo representation can only be used for analyses.  It may not be
31  *  optimized.  Pseudo graphs are kept in a separate graph list in irprog.
32  */
33 ir_graph *
34 new_pseudo_ir_graph(entity *ent, int n_loc) {
35   ir_graph *res = new_r_ir_graph (ent, n_loc);
36   add_irp_pseudo_irg(res);          /* remember this graph global. */
37   return res;
38 }
39
40 /** Returns true ir ir_graph is pseudo graph. */
41 int is_pseudo_ir_graph(ir_graph *irg)
42 {
43   assert(irg && "nothing here");
44   assert(is_ir_graph(irg) && "no ir_graph given");
45
46   int i, n_pseudo_irgs = get_irp_n_pseudo_irgs();
47   for (i = 0; i < n_pseudo_irgs; ++i) {
48     if (irg == get_irp_pseudo_irg(i)) return true;
49   }
50   return false;
51 }
52
53 static int visit_pseudo_irgs = 0;
54
55 void set_visit_pseudo_irgs(int x) {
56   visit_pseudo_irgs = x;
57 }
58
59 int get_visit_pseudo_irgs(void) {
60   return visit_pseudo_irgs;
61 }