- currently we support IEEE 754 only, so change the condition
[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  * @version  $Id$
25  */
26 #ifndef FIRM_IR_IROPT_T_H
27 #define FIRM_IR_IROPT_T_H
28
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  */
56 pset *new_identities(void);
57
58 /**
59  * Deletes a identities value table.
60  *
61  * @param value_table  the identity set
62  */
63 void del_identities(pset *value_table);
64
65 /**
66  * Add a node to the identities value table.
67  */
68 void add_identities(pset *value_table, ir_node *node);
69
70 /**
71  * Compare function for two nodes in the hash table. Gets two
72  * nodes as parameters.  Returns 0 if the nodes are a cse.
73  */
74 int identities_cmp(const void *elt, const void *key);
75
76 /**
77  * Return the canonical node computing the same value as n.
78  * Looks up the node in a hash table, enters it in the table
79  * if it isn't there yet.
80  */
81 ir_node *identify_remember(pset *value_table, ir_node *n);
82
83 /** Visit each node in the value table of a graph. */
84 void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
85
86 ir_node *optimize_node(ir_node *n);
87
88 ir_node *optimize_in_place_2(ir_node *n);
89
90 /**
91  * The value_of operation.
92  * This operation returns for every IR node an associated tarval if existing,
93  * returning tarval_bad otherwise.
94  * No calculations are done here, just a lookup.
95  */
96 typedef tarval *(*value_of_func)(const ir_node *self);
97
98 extern value_of_func value_of_ptr;
99
100 /**
101  * Set a new value_of function.
102  *
103  * @param func  the function, NULL restores the default behavior
104  */
105 void set_value_of_func(value_of_func func);
106
107 /**
108  * Returns the associated tarval of a node.
109  */
110 static INLINE tarval *
111 value_of(const ir_node *n) {
112         return value_of_ptr(n);
113 }
114
115 /**
116  * Sets the default operations for an ir_op_ops.
117  *
118  * @param code   the opcode for the default operation
119  * @param ops    the operations initialized
120  *
121  * @return
122  *    The operations.
123  */
124 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);
125
126 #endif