update copyright message
[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 "iropt.h"
30 #include "irnode_t.h"
31 #include "pset.h"
32 #include "tv.h"
33
34 ir_node *equivalent_node(ir_node *n);
35
36 /**
37  * Calculate a hash value of a node.
38  * The hash value is calculated from the nodes predecessors.
39  * Special handling for Const and SymConst nodes (these don't have predecessors).
40  *
41  * @param node  The IR-node
42  */
43 unsigned ir_node_hash(ir_node *node);
44
45 /**
46  * Creates a new value table used for storing CSE identities.
47  * The value table is used to identify common expressions.
48  *
49  */
50 pset *new_identities(void);
51
52 /**
53  * Deletes a identities value table.
54  *
55  * @param value_table  the identity set
56  */
57 void  del_identities(pset *value_table);
58
59 /**
60  * Add a node to the identities value table.
61  */
62 void  add_identities(pset *value_table, ir_node *node);
63
64 /**
65  * Compare function for two nodes in the hash table. Gets two
66  * nodes as parameters.  Returns 0 if the nodes are a cse.
67  */
68 int identities_cmp(const void *elt, const void *key);
69
70 /**
71  * Return the canonical node computing the same value as n.
72  * Looks up the node in a hash table, enters it in the table
73  * if it isn't there yet.
74  */
75 ir_node *identify_remember(pset *value_table, ir_node *n);
76
77 /** Visit each node in the value table of a graph. */
78 void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
79
80 ir_node *optimize_node(ir_node *n);
81
82 ir_node *optimize_in_place_2(ir_node *n);
83
84 /**
85  * Returns the tarval of a Const node or tarval_bad for all other nodes.
86  */
87 static INLINE tarval *
88 value_of(ir_node *n) {
89   if ((n != NULL) && (get_irn_op(n) == op_Const))
90     return get_Const_tarval(n); /* might return tarval_bad */
91   else
92     return tarval_bad;
93 }
94
95 /**
96  * Sets the default operations for an ir_op_ops.
97  *
98  * @param code   the opcode for the default operation
99  * @param ops    the operations initialized
100  *
101  * @return
102  *    The operations.
103  */
104 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);
105
106 #endif