treat pseudo irgs special
[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   return ARR_LEN(irp->pseudo_graphs);
13 }
14
15 /** Returns the number of pseudo graphs in the program. */
16 ir_graph *get_irp_pseudo_irg(int pos) {
17   return irp->pseudo_graphs[pos];
18 }
19
20 void add_irp_pseudo_irg(ir_graph *irg) {
21   ARR_APP1(ir_graph *, irp->pseudo_graphs, irg);
22 }
23
24
25 /* Create a new ir graph to build a pseudo representation of a procedure.
26  *
27  *  The pseudo representation can only be used for analyses.  It may not be
28  *  optimized.  Pseudo graphs are kept in a separate graph list in irprog.
29  */
30 ir_graph *
31 new_pseudo_ir_graph(entity *ent, int n_loc) {
32   ir_graph *res = new_r_ir_graph (ent, n_loc);
33   add_irp_irg(res);          /* remember this graph global. */
34   return res;
35 }
36
37 /** Returns true ir ir_graph is pseudo graph. */
38 int is_pseudo_ir_graph(ir_graph *irg)
39 {
40   assert(irg && "nothing here");
41   assert(is_ir_graph(irg) && "no ir_graph given");
42
43   int i, n_pseudo_irgs = get_irp_n_pseudo_irgs();
44   for (i = 0; i < n_pseudo_irgs; ++i) {
45     if (irg == get_irp_pseudo_irg(i)) return true;
46   }
47   return false;
48 }
49
50 static int visit_pseudo_irgs = 0;
51
52 void set_visit_pseudo_irgs(int x) {
53   visit_pseudo_irgs = x;
54 }
55
56 int get_visit_pseudo_irgs(void) {
57   return visit_pseudo_irgs;
58 }