becopyheur2: Cache the admissible registers eagerly.
[libfirm] / ir / common / irtools.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief     Some often needed tool-functions
9  * @author    Michael Beck
10  */
11 #ifndef FIRM_COMMON_IRTOOLS_H
12 #define FIRM_COMMON_IRTOOLS_H
13
14 #include "firm_types.h"
15 #include "lc_opts.h"
16 #include "pset.h"
17
18 /**
19  * Return root commandlineoptions for libfirm library
20  */
21 lc_opt_entry_t *firm_opt_get_root(void);
22
23 /**
24  * Dump a pset containing Firm objects.
25  */
26 void firm_pset_dump(pset *set);
27
28 /**
29  * The famous clear_link() walker-function.
30  * Sets all links fields of visited nodes to NULL.
31  * Do not implement it by yourself, use this one.
32  */
33 void firm_clear_link(ir_node *n, void *env);
34
35 /**
36  * The famous clear_link_and_block_lists() walker-function.
37  * Sets all links fields of visited nodes to NULL.
38  * Additionally, clear all Phi-lists of visited blocks.
39  * Do not implement it by yourself, use this one.
40  */
41 void firm_clear_node_and_phi_links(ir_node *n, void *env);
42
43 /**
44  * Walker function, sets all phi list heads fields of visited Blocks
45  * to NULL.
46  * Use in conjunction with firm_collect_block_phis().
47  */
48 void firm_clear_block_phis(ir_node *node, void *env);
49
50 /**
51  * Walker function, links all visited Phi nodes into its block links.
52  * Use in conjunction with firm_clear_block_phis().
53  */
54 void firm_collect_block_phis(ir_node *node, void *env);
55
56 /**
57  * Creates an exact copy of a node with same inputs and attributes in the
58  * same block. The copied node will not be optimized (so no CSE is performed).
59  *
60  * @param node   the node to copy
61  */
62 ir_node *exact_copy(const ir_node *node);
63
64 /**
65  * Create an exact copy of a node with same inputs and attributes in the same
66  * block but puts the node on a graph which might be different than the graph
67  * of the original node.
68  * Note: You have to fixup the inputs/block later
69  */
70 ir_node *irn_copy_into_irg(const ir_node *node, ir_graph *irg);
71
72 /**
73  * This is a helper function used by some routines copying irg graphs
74  * This assumes that we have "old" nodes which have been copied to "new"
75  * nodes; The inputs of the new nodes still point to old nodes.
76  *
77  * Given an old(!) node this function rewires the matching new_node
78  * so that all its inputs point to new nodes afterwards.
79  */
80 void irn_rewire_inputs(ir_node *node);
81
82 /**
83  * @deprecated
84  * Copies a node to a new irg. The Ins of the new node point to
85  * the predecessors on the old irg.  n->link points to the new node.
86  *
87  * @param n    The node to be copied
88  * @param irg  the new irg
89  *
90  * Does NOT copy standard nodes like Start, End etc that are fixed
91  * in an irg. Instead, the corresponding nodes of the new irg are returned.
92  * Note further, that the new nodes have no block.
93  */
94 void copy_irn_to_irg(ir_node *n, ir_graph *irg);
95
96 #endif