2 * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Some often needed tool-functions
23 * @author Michael Beck
25 #ifndef FIRM_COMMON_IRTOOLS_H
26 #define FIRM_COMMON_IRTOOLS_H
28 #include "firm_types.h"
33 * Return root commandlineoptions for libfirm library
35 lc_opt_entry_t *firm_opt_get_root(void);
38 * Dump a pset containing Firm objects.
40 void firm_pset_dump(pset *set);
43 * The famous clear_link() walker-function.
44 * Sets all links fields of visited nodes to NULL.
45 * Do not implement it by yourself, use this one.
47 void firm_clear_link(ir_node *n, void *env);
50 * The famous clear_link_and_block_lists() walker-function.
51 * Sets all links fields of visited nodes to NULL.
52 * Additionally, clear all Phi-lists of visited blocks.
53 * Do not implement it by yourself, use this one.
55 void firm_clear_node_and_phi_links(ir_node *n, void *env);
58 * Walker function, sets all phi list heads fields of visited Blocks
60 * Use in conjunction with firm_collect_block_phis().
62 void firm_clear_block_phis(ir_node *node, void *env);
65 * Walker function, links all visited Phi nodes into its block links.
66 * Use in conjunction with firm_clear_block_phis().
68 void firm_collect_block_phis(ir_node *node, void *env);
71 * Creates an exact copy of a node with same inputs and attributes in the
72 * same block. The copied node will not be optimized (so no CSE is performed).
74 * @param node the node to copy
76 ir_node *exact_copy(const ir_node *node);
79 * Create an exact copy of a node with same inputs and attributes in the same
80 * block but puts the node on a graph which might be different than the graph
81 * of the original node.
82 * Note: You have to fixup the inputs/block later
84 ir_node *irn_copy_into_irg(const ir_node *node, ir_graph *irg);
87 * This is a helper function used by some routines copying irg graphs
88 * This assumes that we have "old" nodes which have been copied to "new"
89 * nodes; The inputs of the new nodes still point to old nodes.
91 * Given an old(!) node this function rewires the matching new_node
92 * so that all its inputs point to new nodes afterwards.
94 void irn_rewire_inputs(ir_node *node);
98 * Copies a node to a new irg. The Ins of the new node point to
99 * the predecessors on the old irg. n->link points to the new node.
101 * @param n The node to be copied
102 * @param irg the new irg
104 * Does NOT copy standard nodes like Start, End etc that are fixed
105 * in an irg. Instead, the corresponding nodes of the new irg are returned.
106 * Note further, that the new nodes have no block.
108 void copy_irn_to_irg(ir_node *n, ir_graph *irg);