remove obsolete comment
[libfirm] / ir / ir / iropt_t.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    iropt --- optimizations intertwined with IR construction -- private header.
23  * @author   Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
24  */
25 #ifndef FIRM_IR_IROPT_T_H
26 #define FIRM_IR_IROPT_T_H
27
28 #include <stdbool.h>
29 #include "irop_t.h"
30 #include "iropt.h"
31 #include "irnode_t.h"
32 #include "pset.h"
33 #include "tv.h"
34
35 /**
36  * Calculate a hash value of a node.
37  *
38  * @param node  The IR-node
39  */
40 unsigned ir_node_hash(const ir_node *node);
41
42 /**
43  * equivalent_node() returns a node equivalent to input n. It skips all nodes that
44  * perform no actual computation, as, e.g., the Id nodes.  It does not create
45  * new nodes.  It is therefore safe to free n if the node returned is not n.
46  * If a node returns a Tuple we can not just skip it.  If the size of the
47  * in array fits, we transform n into a tuple (e.g., Div).
48  */
49 ir_node *equivalent_node(ir_node *n);
50
51 /**
52  * Creates a new value table used for storing CSE identities.
53  * The value table is used to identify common expressions.
54  */
55 void new_identities(ir_graph *irg);
56
57 /**
58  * Deletes a identities value table.
59  *
60  * @param value_table  the identity set
61  */
62 void del_identities(ir_graph *irg);
63
64 /**
65  * Add a node to the identities value table.
66  */
67 void add_identities(ir_node *node);
68
69 /**
70  * Compare function for two nodes in the hash table. Gets two
71  * nodes as parameters.  Returns 0 if the nodes are a cse.
72  */
73 int identities_cmp(const void *elt, const void *key);
74
75 /**
76  * Return the canonical node computing the same value as n.
77  * Looks up the node in a hash table, enters it in the table
78  * if it isn't there yet.
79  */
80 ir_node *identify_remember(ir_node *n);
81
82 /** Visit each node in the value table of a graph. */
83 void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
84
85 /**
86  * Normalize a node by putting constants (and operands with larger
87  * node index) on the right (operator side).
88  *
89  * @param n   The node to normalize
90  */
91 void ir_normalize_node(ir_node *n);
92
93 ir_node *optimize_node(ir_node *n);
94
95 ir_node *optimize_in_place_2(ir_node *n);
96
97 /**
98  * The value_of operation.
99  * This operation returns for every IR node an associated tarval if existing,
100  * returning tarval_bad otherwise.
101  * No calculations are done here, just a lookup.
102  */
103 typedef ir_tarval *(*value_of_func)(const ir_node *self);
104
105 extern value_of_func value_of_ptr;
106
107 /**
108  * Set a new value_of function.
109  *
110  * @param func  the function, NULL restores the default behavior
111  */
112 void set_value_of_func(value_of_func func);
113
114 /**
115  * Returns the associated tarval of a node.
116  */
117 static inline ir_tarval *value_of(const ir_node *n)
118 {
119         return value_of_ptr(n);
120 }
121
122 /**
123  * returns true if a value becomes zero when converted to mode @p mode
124  */
125 bool ir_zero_when_converted(const ir_node *node, ir_mode *dest_mode);
126
127 int ir_mux_is_abs(const ir_node *sel, const ir_node *mux_false,
128                   const ir_node *mux_true);
129
130 ir_node *ir_get_abs_op(const ir_node *sel, ir_node *mux_false,
131                        ir_node *mux_true);
132
133 /**
134  * return true if the Mux node will be optimized away. This can be used for
135  * the if-conversion callback. Allowing these Muxes should be always safe, even
136  * if the backend cannot handle them.
137  */
138 bool ir_is_optimizable_mux(const ir_node *sel, const ir_node *mux_false,
139                            const ir_node *mux_true);
140
141 /**
142  * Returns true if Conv_m0(Conv_m1( x_m2)) is equivalent to Conv_m0(x_m2)
143  */
144 bool may_leave_out_middle_conv(ir_mode *m0, ir_mode *m1, ir_mode *m2);
145
146 void ir_register_opt_node_ops(void);
147
148 #endif