Correct typos, mostly s/there/their/.
[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  * @brief
25  *
26  * Abstract graph implementations for the CFG of a ir_graph.
27  */
28 #include <config.h>
29
30 #include "irgraph_t.h"
31 #include "iredges_t.h"
32 #include "absgraph.h"
33
34 static void *irg_cfg_succ_get_root(void *self)
35 {
36         ir_graph *irg = (ir_graph*) self;
37         edges_assure_kind(irg, EDGE_KIND_BLOCK);
38         return get_irg_start_block(irg);
39 }
40
41 static void *irg_cfg_succ_get_end(void *self)
42 {
43         ir_graph *irg = (ir_graph*) self;
44         return get_irg_end_block(irg);
45 }
46
47 static void irg_cfg_succ_grow_succs(void *self, void *node, struct obstack *obst)
48 {
49         ir_node *bl = (ir_node*) node;
50         const ir_edge_t *edge;
51
52         (void) self;
53         foreach_block_succ(bl, edge) {
54                 obstack_ptr_grow(obst, get_edge_src_irn(edge));
55         }
56 }
57
58 const absgraph_t absgraph_irg_cfg_succ = {
59         irg_cfg_succ_get_root,
60         irg_cfg_succ_grow_succs,
61         irg_cfg_succ_get_end
62 };
63
64 static void *irg_cfg_pred_get_root(void *self)
65 {
66         return get_irg_end_block((ir_graph*) self);
67 }
68
69 static void *irg_cfg_pred_get_end(void *self)
70 {
71         return get_irg_start_block((ir_graph*) self);
72 }
73
74 static void irg_cfg_pred_grow_succs(void *self, void *node, struct obstack *obst)
75 {
76         int i, n;
77
78         (void) self;
79         for (i = 0, n = get_irn_arity((ir_node*) node); i < n; ++i) {
80                 obstack_ptr_grow(obst, get_irn_n((ir_node*) node, i));
81         }
82 }
83
84 const absgraph_t absgraph_irg_cfg_pred = {
85         irg_cfg_pred_get_root,
86         irg_cfg_pred_grow_succs,
87         irg_cfg_pred_get_end
88 };