2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief pseudo irg implementation
23 * @author Goetz Lindenmaier, Boris Boesler
30 #include "pseudo_irg.h"
32 #include "irgraph_t.h"
37 /* Returns the number of pseudo graphs in the program. */
38 int get_irp_n_pseudo_irgs(void) {
39 assert (irp && irp->pseudo_graphs);
40 return ARR_LEN(irp->pseudo_graphs);
43 /* Returns the pos'th pseudo graph in the program. */
44 ir_graph *get_irp_pseudo_irg(int pos) {
45 assert(0 <= pos && pos <= get_irp_n_pseudo_irgs());
46 return irp->pseudo_graphs[pos];
49 void add_irp_pseudo_irg(ir_graph *irg) {
50 assert (irp && irp->pseudo_graphs);
51 ARR_APP1(ir_graph *, irp->pseudo_graphs, irg);
55 /* Create a new ir graph to build a pseudo representation of a procedure.
57 * The pseudo representation can only be used for analyses. It may not be
58 * optimized. Pseudo graphs are kept in a separate graph list in irprog.
61 new_pseudo_ir_graph(ir_entity *ent, int n_loc) {
62 ir_graph *res = new_r_ir_graph(ent, n_loc);
63 add_irp_pseudo_irg(res); /* remember this graph global. */
67 /* Returns non-zero ir ir_graph is pseudo graph. */
68 int is_pseudo_ir_graph(ir_graph *irg) {
71 assert(irg && "nothing here");
72 assert(is_ir_graph(irg) && "no ir_graph given");
74 n_pseudo_irgs = get_irp_n_pseudo_irgs();
75 for (i = 0; i < n_pseudo_irgs; ++i) {
76 if (irg == get_irp_pseudo_irg(i))
82 static int visit_pseudo_irgs = 0;
84 void set_visit_pseudo_irgs(int x) {
85 visit_pseudo_irgs = x;
88 int get_visit_pseudo_irgs(void) {
89 return visit_pseudo_irgs;