remove unnecessary comments before functions
[libfirm] / ir / ir / rm_tuples.c
1 /*
2  * Copyright (C) 2011 Karlsruhe Institute of Technology.  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  * @brief    Remove all Tuple nodes from ir graph
22  * @author   Andreas Zwinkau
23  */
24 #include "config.h"
25
26 #include "irnode_t.h"
27 #include "irgopt.h"
28 #include "irgmod.h"
29 #include "irgwalk.h"
30 #include "irtools.h"
31 #include "irgopt.h"
32
33 /** Transforms:
34  *    a
35  *    |
36  *   Tuple
37  *    |        =>
38  *   Proj x          a
39  */
40 static void exchange_tuple_projs(ir_node *node, void *env)
41 {
42         bool *changed = (bool*)env;
43         ir_node *pred;
44         int proj;
45
46         if (!is_Proj(node)) return;
47
48         pred = get_Proj_pred(node);
49         proj = get_Proj_proj(node);
50
51         if (!is_Tuple(pred)) return;
52
53         pred = get_Tuple_pred(pred, proj);
54         exchange(node, pred);
55         *changed = true;
56 }
57
58 int remove_tuples(ir_graph *irg)
59 {
60         bool changed = 0;
61         irg_walk_graph(irg, exchange_tuple_projs, NULL, &changed);
62         return changed;
63 }