remove $Id$, it doesn't work with git anyway
[libfirm] / ir / be / beutil.h
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
22  * @brief       Contains some useful function for the backend.
23  * @author      Sebastian Hack
24  */
25 #ifndef FIRM_BE_BEUTIL_H
26 #define FIRM_BE_BEUTIL_H
27
28 #include <stdio.h>
29
30 #include "firm_types.h"
31 #include "pset.h"
32
33 #include "bearch.h"
34
35 /* iterate over a list of ir_nodes linked by link field */
36 #define foreach_linked_irns(head, iter) for ((iter) = (head); (iter); (iter) = get_irn_link((iter)))
37
38 /**
39  * Convenient block getter.
40  * Works also, if the given node is a block.
41  * @param  irn The node.
42  * @return The block of the node, or the node itself, if the node is a
43  *         block.
44  */
45 static inline ir_node *get_block(ir_node *irn)
46 {
47         return is_Block(irn) ? irn : get_nodes_block(irn);
48 }
49
50 static inline const ir_node *get_block_const(const ir_node *irn)
51 {
52         return is_Block(irn) ? irn : get_nodes_block(irn);
53 }
54
55 /**
56  * Clears the link fields of all nodes of the given graph.
57  * @param irg The graph.
58  */
59 void be_clear_links(ir_graph *irg);
60
61 /**
62  * Gets the Proj with number pn from irn.
63  */
64 ir_node *be_get_Proj_for_pn(const ir_node *irn, long pn);
65
66 /**
67  * Returns an array (an ARR_F) of the programs blocks in reverse postorder
68  * (note: caller has to free the memory with DEL_ARR_F after use;
69  *  of course you can use ARR_LEN on the array too.)
70  */
71 ir_node **be_get_cfgpostorder(ir_graph *irg);
72
73 /**
74  * convenience function to return the first successor block
75  * (it is often known that there is exactly 1 successor anyway)
76  */
77 ir_node *get_first_block_succ(const ir_node *block);
78
79 #endif