3 * File name: ir/ir/iropt_t.h
4 * Purpose: iropt --- optimizations intertwined with IR construction -- private header.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier, Michael Beck
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 * Declarations for optimizations intertwined with IR construction.
18 * @author Martin Trapp, Christian Schaefer
29 ir_node *equivalent_node(ir_node *n);
32 * Calculate a hash value of a node.
33 * The hash value is calculated from the nodes predecessors.
34 * Special handling for Const and SymConst nodes (these don't have predecessors).
36 * @param node The IR-node
38 unsigned ir_node_hash(ir_node *node);
41 * Creates a new value table used for storing CSE identities.
42 * The value table is used to identify common expressions.
45 pset *new_identities(void);
48 * Deletes a identities value table.
50 * @param value_table the identity set
52 void del_identities(pset *value_table);
55 * Add a node to the identities value table.
57 void add_identities(pset *value_table, ir_node *node);
60 * Compare function for two nodes in the hash table. Gets two
61 * nodes as parameters. Returns 0 if the nodes are a cse.
63 int identities_cmp(const void *elt, const void *key);
66 * Return the canonical node computing the same value as n.
67 * Looks up the node in a hash table, enters it in the table
68 * if it isn't there yet.
70 ir_node *identify_remember(pset *value_table, ir_node *n);
72 /** Visit each node in the value table of a graph. */
73 void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
75 ir_node *optimize_node(ir_node *n);
77 ir_node *optimize_in_place_2(ir_node *n);
80 * Returns the tarval of a Const node or tarval_bad for all other nodes.
82 static INLINE tarval *
83 value_of(ir_node *n) {
84 if ((n != NULL) && (get_irn_op(n) == op_Const))
85 return get_Const_tarval(n); /* might return tarval_bad */
91 * Sets the default operations for an ir_op_ops.
93 * @param code the opcode for the default operation
94 * @param ops the operations initialized
99 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);
101 #endif /* _IROPT_T_H_ */