2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Contains some useful function for the backend.
9 * @author Sebastian Hack
11 #ifndef FIRM_BE_BEUTIL_H
12 #define FIRM_BE_BEUTIL_H
14 #include "firm_types.h"
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
23 static inline ir_node *get_block(ir_node *irn)
25 return is_Block(irn) ? irn : get_nodes_block(irn);
28 static inline const ir_node *get_block_const(const ir_node *irn)
30 return is_Block(irn) ? irn : get_nodes_block(irn);
34 * Clears the link fields of all nodes of the given graph.
35 * @param irg The graph.
37 void be_clear_links(ir_graph *irg);
40 * Gets the Proj with number pn from irn.
42 ir_node *be_get_Proj_for_pn(const ir_node *irn, long pn);
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.)
49 ir_node **be_get_cfgpostorder(ir_graph *irg);
52 * convenience function to return the first successor block
53 * (it is often known that there is exactly 1 successor anyway)
55 ir_node *get_first_block_succ(const ir_node *block);