# include "ircons.h"
# include "firm_common_t.h"
# include "irvrfy.h"
-# include "irop.h"
+# include "irop_t.h"
# include "iropt_t.h"
# include "irgmod.h"
# include "array.h"
new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con, type *tp)
{
ir_node *res;
- res = new_ir_node (db, irg, block, op_Const, mode, 0, NULL);
+ res = new_ir_node (db, irg, irg->start_block, op_Const, mode, 0, NULL);
res->attr.con.tv = con;
set_Const_type(res, tp); /* Call method because of complex assertion. */
res = optimize_node (res);
assert(get_Const_type(res) == tp);
irn_vrfy_irg (res, irg);
-#if 0
- res = local_optimize_newby (res);
-# endif
-
return res;
}
new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con)
{
type *tp = unknown_type;
+ /* removing this somehow causes errors in jack. */
if (tarval_is_entity(con))
tp = find_pointer_type_to_type(get_entity_type(get_tarval_entity(con)));
+
return new_rd_Const_type (db, irg, block, mode, con, tp);
}
return 0;
}
-/**
+/*
* Calculate a hash value of a node.
*/
-static unsigned
+unsigned
ir_node_hash (ir_node *node)
{
unsigned h;
int i, irn_arity;
- /* hash table value = 9*(9*(9*(9*(9*arity+in[0])+in[1])+ ...)+mode)+code */
- h = irn_arity = get_irn_arity(node);
+ if (node->op == op_Const) {
+ /* special value for const, as they only differ in their tarval. */
+ /* @@@ What about SymConst? */
+ h = ((unsigned) node->attr.con.tv)>>3 ;
+ h = 9*h + (unsigned)get_irn_mode(node);
+ } else {
- /* consider all in nodes... except the block. */
- for (i = 0; i < irn_arity; i++) {
- h = 9*h + (unsigned long)get_irn_n(node, i);
- }
+ /* hash table value = 9*(9*(9*(9*(9*arity+in[0])+in[1])+ ...)+mode)+code */
+ h = irn_arity = get_irn_arity(node);
- /* ...mode,... */
- h = 9*h + (unsigned long) get_irn_mode (node);
- /* ...and code */
- h = 9*h + (unsigned long) get_irn_op (node);
+ /* consider all in nodes... except the block. */
+ for (i = 0; i < irn_arity; i++) {
+ h = 9*h + (unsigned)get_irn_n(node, i);
+ }
+
+ /* ...mode,... */
+ h = 9*h + (unsigned) get_irn_mode (node);
+ /* ...and code */
+ h = 9*h + (unsigned) get_irn_op (node);
+ }
return h;
}
/**
* Return the canonical node computing the same value as n.
* Looks up the node in a hash table.
+ *
+ * For Const nodes this is performed in the constructor, too. Const
+ * nodes are extremely time critical because of their frequent use in
+ * constant string arrays.
*/
static INLINE ir_node *
identify (pset *value_table, ir_node *n)
/**
* During construction we set the pinned flag in the graph right when the
- * optimizatin is performed. The flag turning on procedure global cse could
+ * optimization is performed. The flag turning on procedure global cse could
* be changed between two allocations. This way we are safe.
*/
static INLINE ir_node *