2 * Copyright (C) 1995-2008 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 * @brief iropt --- optimizations intertwined with IR construction -- private header.
23 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
26 #ifndef FIRM_IR_IROPT_T_H
27 #define FIRM_IR_IROPT_T_H
34 ir_node *equivalent_node(ir_node *n);
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).
41 * @param node The IR-node
43 unsigned ir_node_hash(const ir_node *node);
46 * Creates a new value table used for storing CSE identities.
47 * The value table is used to identify common expressions.
50 pset *new_identities(void);
53 * Deletes a identities value table.
55 * @param value_table the identity set
57 void del_identities(pset *value_table);
60 * Add a node to the identities value table.
62 void add_identities(pset *value_table, ir_node *node);
65 * Compare function for two nodes in the hash table. Gets two
66 * nodes as parameters. Returns 0 if the nodes are a cse.
68 int identities_cmp(const void *elt, const void *key);
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.
75 ir_node *identify_remember(pset *value_table, ir_node *n);
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);
80 ir_node *optimize_node(ir_node *n);
82 ir_node *optimize_in_place_2(ir_node *n);
85 * The value_of operation.
86 * This operation returns for every IR node an associated tarval if existing,
87 * returning tarval_bad otherwise.
88 * No calculations are done here, just a lookup.
90 typedef tarval *(*value_of_func)(const ir_node *self);
92 extern value_of_func value_of_ptr;
95 * Set a new value_of function.
97 * @param func the function, NULL restores the default behavior
99 void set_value_of_func(value_of_func func);
102 * Returns the associated tarval of a node.
104 static INLINE tarval *
105 value_of(const ir_node *n) {
106 return value_of_ptr(n);
110 * Sets the default operations for an ir_op_ops.
112 * @param code the opcode for the default operation
113 * @param ops the operations initialized
118 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);