Removed ANNOUNCE macro
[libfirm] / ir / ir / iropt_t.h
1 /*
2  * Project:     libFIRM
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
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file iropt_t.h
15  *
16  * Declarations for optimizations intertwined with IR construction.
17  *
18  * @author Martin Trapp, Christian Schaefer
19  */
20
21 #ifndef _IROPT_T_H_
22 #define _IROPT_T_H_
23
24 #include "iropt.h"
25 #include "irnode_t.h"
26 #include "pset.h"
27 #include "tv.h"
28
29 ir_node *equivalent_node(ir_node *n);
30
31 /**
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).
35  *
36  * @param node  The IR-node
37  */
38 unsigned ir_node_hash(ir_node *node);
39
40 /**
41  * Creates a new value table used for storing CSE identities.
42  * The value table is used to identify common expressions.
43  *
44  */
45 pset *new_identities(void);
46
47 /**
48  * Deletes a identities value table.
49  *
50  * @param value_table  the identity set
51  */
52 void  del_identities(pset *value_table);
53
54 /**
55  * Add a node to the identities value table.
56  */
57 void  add_identities(pset *value_table, ir_node *node);
58
59 /**
60  * Compare function for two nodes in the hash table. Gets two
61  * nodes as parameters.  Returns 0 if the nodes are a cse.
62  */
63 int identities_cmp(const void *elt, const void *key);
64
65 /**
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.
69  */
70 ir_node *identify_remember(pset *value_table, ir_node *n);
71
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);
74
75 ir_node *optimize_node(ir_node *n);
76
77 ir_node *optimize_in_place_2(ir_node *n);
78
79 /**
80  * Returns the tarval of a Const node or tarval_bad for all other nodes.
81  */
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 */
86   else
87     return tarval_bad;
88 }
89
90 /**
91  * Sets the default operations for an ir_op_ops.
92  *
93  * @param code   the opcode for the default operation
94  * @param ops    the operations initialized
95  *
96  * @return
97  *    The operations.
98  */
99 ir_op_ops *firm_set_default_operations(ir_opcode code, ir_op_ops *ops);
100
101 #endif /* _IROPT_T_H_ */