Typo in comment.
[libfirm] / ir / ana / absgraph.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file    absgraph.c
22  * @author  Sebastian Hack
23  * @date    20.04.2007
24  * @version $Id$
25  * @summary
26  *
27  * Abstract graph implementations for the CFG of a ir_graph.
28  */
29 #ifdef HAVE_CONFIG_H
30 #include <config.h>
31 #endif
32
33 #include "irgraph_t.h"
34 #include "iredges_t.h"
35 #include "absgraph.h"
36
37 static void *irg_cfg_succ_get_root(void *self)
38 {
39         ir_graph *irg = self;
40         edges_activate_kind(irg, EDGE_KIND_BLOCK);
41         return get_irg_start_block(irg);
42 }
43
44 static void *irg_cfg_succ_get_end(void *self)
45 {
46         ir_graph *irg = self;
47         return get_irg_end_block(irg);
48 }
49
50 static void irg_cfg_succ_grow_succs(void *self, void *node, struct obstack *obst)
51 {
52         ir_node *bl = node;
53         const ir_edge_t *edge;
54
55         (void) self;
56         foreach_block_succ(bl, edge) {
57                 obstack_ptr_grow(obst, get_edge_src_irn(edge));
58         }
59 }
60
61 const absgraph_t absgraph_irg_cfg_succ = {
62         irg_cfg_succ_get_root,
63         irg_cfg_succ_grow_succs,
64         irg_cfg_succ_get_end
65 };
66
67 static void *irg_cfg_pred_get_root(void *self)
68 {
69         return get_irg_end_block((ir_graph*) self);
70 }
71
72 static void *irg_cfg_pred_get_end(void *self)
73 {
74         return get_irg_start_block((ir_graph*) self);
75 }
76
77 static void irg_cfg_pred_grow_succs(void *self, void *node, struct obstack *obst)
78 {
79         int i, n;
80
81         (void) self;
82         for (i = 0, n = get_irn_arity(node); i < n; ++i) {
83                 obstack_ptr_grow(obst, get_irn_n(node, i));
84         }
85 }
86
87 const absgraph_t absgraph_irg_cfg_pred = {
88         irg_cfg_pred_get_root,
89         irg_cfg_pred_grow_succs,
90         irg_cfg_pred_get_end
91 };