remove license stuff from files
[libfirm] / ir / be / beutil.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Contains some useful function for the backend.
9  * @author      Sebastian Hack
10  */
11 #ifndef FIRM_BE_BEUTIL_H
12 #define FIRM_BE_BEUTIL_H
13
14 #include "firm_types.h"
15
16 /**
17  * Convenient block getter.
18  * Works also, if the given node is a block.
19  * @param  irn The node.
20  * @return The block of the node, or the node itself, if the node is a
21  *         block.
22  */
23 static inline ir_node *get_block(ir_node *irn)
24 {
25         return is_Block(irn) ? irn : get_nodes_block(irn);
26 }
27
28 static inline const ir_node *get_block_const(const ir_node *irn)
29 {
30         return is_Block(irn) ? irn : get_nodes_block(irn);
31 }
32
33 /**
34  * Clears the link fields of all nodes of the given graph.
35  * @param irg The graph.
36  */
37 void be_clear_links(ir_graph *irg);
38
39 /**
40  * Gets the Proj with number pn from irn.
41  */
42 ir_node *be_get_Proj_for_pn(const ir_node *irn, long pn);
43
44 /**
45  * Returns an array (an ARR_F) of the programs blocks in reverse postorder
46  * (note: caller has to free the memory with DEL_ARR_F after use;
47  *  of course you can use ARR_LEN on the array too.)
48  */
49 ir_node **be_get_cfgpostorder(ir_graph *irg);
50
51 /**
52  * convenience function to return the first successor block
53  * (it is often known that there is exactly 1 successor anyway)
54  */
55 ir_node *get_first_block_succ(const ir_node *block);
56
57 #endif