2 * Copyright (C) 1995-2007 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 * File name: ir/ir/iropt_t.h
23 * Purpose: iropt --- optimizations intertwined with IR construction -- private header.
24 * Author: Martin Trapp, Christian Schaefer
25 * Modified by: Goetz Lindenmaier, Michael Beck
28 * Copyright: (c) 1998-2003 Universität Karlsruhe
34 * Declarations for optimizations intertwined with IR construction.
36 * @author Martin Trapp, Christian Schaefer
47 ir_node *equivalent_node(ir_node *n);
50 * Calculate a hash value of a node.
51 * The hash value is calculated from the nodes predecessors.
52 * Special handling for Const and SymConst nodes (these don't have predecessors).
54 * @param node The IR-node
56 unsigned ir_node_hash(ir_node *node);
59 * Creates a new value table used for storing CSE identities.
60 * The value table is used to identify common expressions.
63 pset *new_identities(void);
66 * Deletes a identities value table.
68 * @param value_table the identity set
70 void del_identities(pset *value_table);
73 * Add a node to the identities value table.
75 void add_identities(pset *value_table, ir_node *node);
78 * Compare function for two nodes in the hash table. Gets two
79 * nodes as parameters. Returns 0 if the nodes are a cse.
81 int identities_cmp(const void *elt, const void *key);
84 * Return the canonical node computing the same value as n.
85 * Looks up the node in a hash table, enters it in the table
86 * if it isn't there yet.
88 ir_node *identify_remember(pset *value_table, ir_node *n);
90 /** Visit each node in the value table of a graph. */
91 void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
93 ir_node *optimize_node(ir_node *n);
95 ir_node *optimize_in_place_2(ir_node *n);
98 * Returns the tarval of a Const node or tarval_bad for all other nodes.
100 static INLINE tarval *
101 value_of(ir_node *n) {
102 if ((n != NULL) && (get_irn_op(n) == op_Const))
103 return get_Const_tarval(n); /* might return tarval_bad */
109 * Sets the default operations for an ir_op_ops.
111 * @param code the opcode for the default operation
112 * @param ops the operations initialized
117 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);
119 #endif /* _IROPT_T_H_ */