group High-Level exception support ops together
[libfirm] / ir / ir / iropt.c
index 3013491..d105777 100644 (file)
 #include <string.h>
 #endif
 
-# include "irnode_t.h"
-# include "irgraph_t.h"
-# include "iredges_t.h"
-# include "irmode_t.h"
-# include "iropt_t.h"
-# include "ircons_t.h"
-# include "irgmod.h"
-# include "irvrfy.h"
-# include "tv_t.h"
-# include "dbginfo_t.h"
-# include "iropt_dbg.h"
-# include "irflag_t.h"
-# include "irhooks.h"
-# include "irarch.h"
-# include "hashptr.h"
-# include "archop.h"
-# include "opt_polymorphy.h"
-# include "opt_confirms.h"
+#include "irnode_t.h"
+#include "irgraph_t.h"
+#include "iredges_t.h"
+#include "irmode_t.h"
+#include "iropt_t.h"
+#include "ircons_t.h"
+#include "irgmod.h"
+#include "irvrfy.h"
+#include "tv_t.h"
+#include "dbginfo_t.h"
+#include "iropt_dbg.h"
+#include "irflag_t.h"
+#include "irhooks.h"
+#include "irarch.h"
+#include "hashptr.h"
+#include "archop.h"
+#include "opt_polymorphy.h"
+#include "opt_confirms.h"
 
 /* Make types visible to allow most efficient access */
 # include "entity_t.h"
@@ -591,22 +591,28 @@ static tarval *computed_value_Confirm(ir_node *n)
  */
 tarval *computed_value(ir_node *n)
 {
-  if (n->op->computed_value)
-    return n->op->computed_value(n);
+  if (n->op->ops.computed_value)
+    return n->op->ops.computed_value(n);
   return tarval_bad;
 }
 
 /**
- * set the default computed_value evaluator
+ * set the default computed_value evaluator in an ir_op_ops.
+ *
+ * @param code   the opcode for the default operation
+ * @param ops    the operations initialized
+ *
+ * @return
+ *    The operations.
  */
-static ir_op *firm_set_default_computed_value(ir_op *op)
+static ir_op_ops *firm_set_default_computed_value(opcode code, ir_op_ops *ops)
 {
 #define CASE(a)                               \
   case iro_##a:                               \
-    op->computed_value  = computed_value_##a; \
+    ops->computed_value  = computed_value_##a; \
     break
 
-  switch (op->code) {
+  switch (code) {
   CASE(Const);
   CASE(SymConst);
   CASE(Add);
@@ -630,10 +636,10 @@ static ir_op *firm_set_default_computed_value(ir_op *op)
   CASE(Mux);
   CASE(Confirm);
   default:
-    op->computed_value  = NULL;
+    /* leave NULL */;
   }
 
-  return op;
+  return ops;
 #undef CASE
 }
 
@@ -945,9 +951,10 @@ static ir_node *equivalent_node_Sub(ir_node *n)
 /**
  * Optimize an "idempotent unary op", ie op(op(n)) = n.
  *
- * @fixme -(-a) == a, but might overflow two times.
- * We handle it anyway here but the better way would be a
- * flag. This would be needed for Pascal for instance.
+ * @todo
+ *   -(-a) == a, but might overflow two times.
+ *   We handle it anyway here but the better way would be a
+ *   flag. This would be needed for Pascal for instance.
  */
 static ir_node *equivalent_node_idempotent_unop(ir_node *n)
 {
@@ -1002,7 +1009,7 @@ static ir_node *equivalent_node_Div(ir_node *n)
   if (classify_tarval(value_of(b)) == TV_CLASSIFY_ONE) { /* div(x, 1) == x */
     /* Turn Div into a tuple (mem, bad, a) */
     ir_node *mem = get_Div_mem(n);
-    turn_into_tuple(n, 3);
+    turn_into_tuple(n, pn_Div_max);
     set_Tuple_pred(n, pn_Div_M,        mem);
     set_Tuple_pred(n, pn_Div_X_except, new_Bad());        /* no exception */
     set_Tuple_pred(n, pn_Div_res,      a);
@@ -1024,7 +1031,7 @@ static ir_node *equivalent_node_DivMod(ir_node *n)
     ir_node *mem = get_Div_mem(n);
     ir_mode *mode = get_irn_mode(b);
 
-    turn_into_tuple(n, 4);
+    turn_into_tuple(n, pn_DivMod_max);
     set_Tuple_pred(n, pn_DivMod_M,        mem);
     set_Tuple_pred(n, pn_DivMod_X_except, new_Bad());        /* no exception */
     set_Tuple_pred(n, pn_DivMod_res_div,  a);
@@ -1212,7 +1219,8 @@ static ir_node *equivalent_node_Phi(ir_node *n)
 }
 
 /**
- * optimize Proj(Tuple) and gigo() for ProjX in Bad block
+ * optimize Proj(Tuple) and gigo() for ProjX in Bad block,
+ * ProjX(Load) and ProjX(Store)
  */
 static ir_node *equivalent_node_Proj(ir_node *n)
 {
@@ -1235,6 +1243,20 @@ static ir_node *equivalent_node_Proj(ir_node *n)
       /* Remove dead control flow -- early gigo(). */
       n = new_Bad();
     }
+    else if (get_opt_ldst_only_null_ptr_exceptions()) {
+      ir_op *op = get_irn_op(a);
+
+      if (op == op_Load || op == op_Store) {
+        /* get the load/store address */
+        ir_node *addr = get_irn_n(a, 1);
+        if (value_not_null(addr)) {
+          /* this node may float */
+          set_irn_pinned(a, op_pin_state_floats);
+          DBG_OPT_EXC_REM(n);
+          return new_Bad();
+        }
+      }
+    }
   }
 
   return n;
@@ -1363,7 +1385,7 @@ static ir_node *equivalent_node_Confirm(ir_node *n)
      * rare case: two identical Confirms one after another,
      * replace the second one with the first.
      */
-    return pred;
+    n = pred;
   }
   if (pnc == pn_Cmp_Eq) {
     ir_node *bound = get_Confirm_bound(n);
@@ -1377,7 +1399,7 @@ static ir_node *equivalent_node_Confirm(ir_node *n)
       return bound;
     }
   }
-  return get_opt_remove_Confirm() ? get_Confirm_value(n) : n;
+  return get_opt_remove_confirm() ? get_Confirm_value(n) : n;
 }
 
 /**
@@ -1399,6 +1421,54 @@ static ir_node *equivalent_node_CopyB(ir_node *n)
   return n;
 }
 
+/**
+ * Optimize Bounds(idx, idx, upper) into idx.
+ */
+static ir_node *equivalent_node_Bound(ir_node *n)
+{
+  ir_node *idx   = get_Bound_index(n);
+  ir_node *lower = get_Bound_lower(n);
+  int ret_tuple = 0;
+
+  /* By definition lower < upper, so if idx == lower -->
+     lower <= idx && idx < upper */
+  if (idx == lower) {
+    /* Turn Bound into a tuple (mem, bad, idx) */
+    ret_tuple = 1;
+  }
+  else {
+    ir_node *pred = skip_Proj(idx);
+
+    if (get_irn_op(pred) == op_Bound) {
+      /*
+       * idx was Bounds_check previously, it is still valid if
+       * lower <= pred_lower && pred_upper <= upper.
+       */
+      ir_node *upper = get_Bound_upper(n);
+       if (get_Bound_lower(pred) == lower &&
+           get_Bound_upper(pred) == upper) {
+         /*
+          * One could expect that we simple return the previous
+          * Bound here. However, this would be wrong, as we could
+          * add an exception Proj to a new location than.
+          * So, we must turn in into a tuple
+          */
+         ret_tuple = 1;
+       }
+    }
+  }
+  if (ret_tuple) {
+    /* Turn Bound into a tuple (mem, bad, idx) */
+    ir_node *mem = get_Bound_mem(n);
+    turn_into_tuple(n, pn_Bound_max);
+    set_Tuple_pred(n, pn_Bound_M_regular, mem);
+    set_Tuple_pred(n, pn_Bound_X_except,  new_Bad());       /* no exception */
+    set_Tuple_pred(n, pn_Bound_res,       idx);
+    set_Tuple_pred(n, pn_Bound_M_except,  mem);
+  }
+  return n;
+}
+
 /**
  * equivalent_node() returns a node equivalent to input n. It skips all nodes that
  * perform no actual computation, as, e.g., the Id nodes.  It does not create
@@ -1409,22 +1479,28 @@ static ir_node *equivalent_node_CopyB(ir_node *n)
 ir_node *
 equivalent_node(ir_node *n)
 {
-  if (n->op->equivalent_node)
-    return n->op->equivalent_node(n);
+  if (n->op->ops.equivalent_node)
+    return n->op->ops.equivalent_node(n);
   return n;
 }
 
 /**
- * set the default equivalent node operation
+ * sets the default equivalent node operation for an ir_op_ops.
+ *
+ * @param code   the opcode for the default operation
+ * @param ops    the operations initialized
+ *
+ * @return
+ *    The operations.
  */
-static ir_op *firm_set_default_equivalent_node(ir_op *op)
+static ir_op_ops *firm_set_default_equivalent_node(opcode code, ir_op_ops *ops)
 {
 #define CASE(a)                                 \
   case iro_##a:                                 \
-    op->equivalent_node  = equivalent_node_##a; \
+    ops->equivalent_node  = equivalent_node_##a; \
     break
 
-  switch (op->code) {
+  switch (code) {
   CASE(Block);
   CASE(Jmp);
   CASE(Raise);
@@ -1451,11 +1527,12 @@ static ir_op *firm_set_default_equivalent_node(ir_op *op)
   CASE(Cmp);
   CASE(Confirm);
   CASE(CopyB);
+  CASE(Bound);
   default:
-    op->equivalent_node  = NULL;
+    /* leave NULL */;
   }
 
-  return op;
+  return ops;
 #undef CASE
 }
 
@@ -1556,7 +1633,9 @@ static ir_node *transform_node_AddSub(ir_node *n)
 }
 
 /**
- * Do the AddSub optimization, then Transform Add(a,a) into Mul(a, 2)
+ * Do the AddSub optimization, then Transform
+ *   Add(a,a)          -> Mul(a, 2)
+ *   Add(Mul(a, x), a) -> Mul(a, x+1)
  * if the mode is integer or float.
  * Transform Add(a,-b) into Sub(a,b).
  * Reassociation might fold this further.
@@ -1571,8 +1650,9 @@ static ir_node *transform_node_Add(ir_node *n)
   mode = get_irn_mode(n);
   if (mode_is_num(mode)) {
     ir_node *a = get_Add_left(n);
+    ir_node *b = get_Add_right(n);
 
-    if (a == get_Add_right(n)) {
+    if (a == b) {
       ir_node *block = get_irn_n(n, -1);
 
       n = new_rd_Mul(
@@ -1584,28 +1664,88 @@ static ir_node *transform_node_Add(ir_node *n)
             mode);
       DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_A);
     }
-    else {
-      ir_node *b = get_Add_right(n);
-
-      if (get_irn_op(a) == op_Minus) {
-        n = new_rd_Sub(
-            get_irn_dbg_info(n),
-            current_ir_graph,
-            get_irn_n(n, -1),
-            b,
-            get_Minus_op(a),
-            mode);
-        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
+    else if (get_irn_op(a) == op_Minus) {
+      n = new_rd_Sub(
+          get_irn_dbg_info(n),
+          current_ir_graph,
+          get_irn_n(n, -1),
+          b,
+          get_Minus_op(a),
+          mode);
+      DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
+    }
+    else if (get_irn_op(b) == op_Minus) {
+      n = new_rd_Sub(
+          get_irn_dbg_info(n),
+          current_ir_graph,
+          get_irn_n(n, -1),
+          a,
+          get_Minus_op(b),
+          mode);
+      DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
+    }
+    /* do NOT execute this code if reassociation is enabled, it does the inverse! */
+    else if (!get_opt_reassociation() && get_irn_op(a) == op_Mul) {
+      ir_node *ma = get_Mul_left(a);
+      ir_node *mb = get_Mul_right(a);
+
+      if (b == ma) {
+        ir_node *blk = get_irn_n(n, -1);
+        n = new_rd_Mul(
+          get_irn_dbg_info(n), current_ir_graph, blk,
+          ma,
+          new_rd_Add(
+            get_irn_dbg_info(n), current_ir_graph, blk,
+            mb,
+            new_r_Const_long(current_ir_graph, blk, mode, 1),
+            mode),
+          mode);
+        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_MUL_A_X_A);
       }
-      else if (get_irn_op(b) == op_Minus) {
-        n = new_rd_Sub(
-            get_irn_dbg_info(n),
-            current_ir_graph,
-            get_irn_n(n, -1),
-            a,
-            get_Minus_op(b),
-            mode);
-        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_A_MINUS_B);
+      else if (b == mb) {
+        ir_node *blk = get_irn_n(n, -1);
+        n = new_rd_Mul(
+          get_irn_dbg_info(n), current_ir_graph, blk,
+          mb,
+          new_rd_Add(
+            get_irn_dbg_info(n), current_ir_graph, blk,
+            ma,
+            new_r_Const_long(current_ir_graph, blk, mode, 1),
+            mode),
+          mode);
+        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_MUL_A_X_A);
+      }
+    }
+    /* do NOT execute this code if reassociation is enabled, it does the inverse! */
+    else if (!get_opt_reassociation() && get_irn_op(b) == op_Mul) {
+      ir_node *ma = get_Mul_left(b);
+      ir_node *mb = get_Mul_right(b);
+
+      if (a == ma) {
+        ir_node *blk = get_irn_n(n, -1);
+        n = new_rd_Mul(
+          get_irn_dbg_info(n), current_ir_graph, blk,
+          ma,
+          new_rd_Add(
+            get_irn_dbg_info(n), current_ir_graph, blk,
+            mb,
+            new_r_Const_long(current_ir_graph, blk, mode, 1),
+            mode),
+          mode);
+        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_MUL_A_X_A);
+      }
+      else if (a == mb) {
+        ir_node *blk = get_irn_n(n, -1);
+        n = new_rd_Mul(
+          get_irn_dbg_info(n), current_ir_graph, blk,
+          mb,
+          new_rd_Add(
+            get_irn_dbg_info(n), current_ir_graph, blk,
+            ma,
+            new_r_Const_long(current_ir_graph, blk, mode, 1),
+            mode),
+          mode);
+        DBG_OPT_ALGSIM0(oldn, n, FS_OPT_ADD_MUL_A_X_A);
       }
     }
   }
@@ -1613,25 +1753,66 @@ static ir_node *transform_node_Add(ir_node *n)
 }
 
 /**
- * Do the AddSub optimization, then Transform Sub(0,a) into Minus(a).
+ * Do the AddSub optimization, then Transform
+ *   Sub(0,a)          -> Minus(a)
+ *   Sub(Mul(a, x), a) -> Mul(a, x-1)
  */
 static ir_node *transform_node_Sub(ir_node *n)
 {
   ir_mode *mode;
   ir_node *oldn = n;
+  ir_node *a, *b;
 
   n = transform_node_AddSub(n);
 
   mode = get_irn_mode(n);
-  if (mode_is_num(mode) && (classify_Const(get_Sub_left(n)) == CNST_NULL)) {
+  a    = get_Sub_left(n);
+  b    = get_Sub_right(n);
+  if (mode_is_num(mode) && (classify_Const(a) == CNST_NULL)) {
     n = new_rd_Minus(
           get_irn_dbg_info(n),
           current_ir_graph,
           get_irn_n(n, -1),
-          get_Sub_right(n),
+          b,
           mode);
     DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_0_A);
   }
+  /* do NOT execute this code if reassociation is enabled, it does the inverse! */
+  else if (get_opt_reassociation() && get_irn_op(a) == op_Mul) {
+    ir_node *ma = get_Mul_left(a);
+    ir_node *mb = get_Mul_right(a);
+
+    if (ma == b) {
+      ir_node *blk = get_irn_n(n, -1);
+      n = new_rd_Mul(
+        get_irn_dbg_info(n),
+        current_ir_graph, blk,
+        ma,
+        new_rd_Sub(
+          get_irn_dbg_info(n),
+          current_ir_graph, blk,
+          mb,
+          new_r_Const_long(current_ir_graph, blk, mode, 1),
+          mode),
+        mode);
+      DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
+    }
+    else if (mb == b) {
+      ir_node *blk = get_irn_n(n, -1);
+      n = new_rd_Mul(
+        get_irn_dbg_info(n),
+        current_ir_graph, blk,
+        mb,
+        new_rd_Sub(
+          get_irn_dbg_info(n),
+          current_ir_graph, blk,
+          ma,
+          new_r_Const_long(current_ir_graph, blk, mode, 1),
+          mode),
+        mode);
+      DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
+    }
+  }
 
   return n;
 }
@@ -1714,7 +1895,7 @@ static ir_node *transform_node_Mod(ir_node *n)
     /* Turn Mod into a tuple (mem, bad, value) */
     ir_node *mem = get_Mod_mem(n);
 
-    turn_into_tuple(n, 3);
+    turn_into_tuple(n, pn_Mod_max);
     set_Tuple_pred(n, pn_Mod_M, mem);
     set_Tuple_pred(n, pn_Mod_X_except, new_Bad());
     set_Tuple_pred(n, pn_Mod_res, value);
@@ -1773,7 +1954,7 @@ static ir_node *transform_node_DivMod(ir_node *n)
 
   if (evaluated) { /* replace by tuple */
     ir_node *mem = get_DivMod_mem(n);
-    turn_into_tuple(n, 4);
+    turn_into_tuple(n, pn_DivMod_max);
     set_Tuple_pred(n, pn_DivMod_M,        mem);
     set_Tuple_pred(n, pn_DivMod_X_except, new_Bad());  /* no exception */
     set_Tuple_pred(n, pn_DivMod_res_div,  a);
@@ -1839,7 +2020,7 @@ static ir_node *transform_node_Cond(ir_node *n)
     /* It's a boolean Cond, branching on a boolean constant.
                Replace it by a tuple (Bad, Jmp) or (Jmp, Bad) */
     jmp = new_r_Jmp(current_ir_graph, get_nodes_block(n));
-    turn_into_tuple(n, 2);
+    turn_into_tuple(n, pn_Cond_max);
     if (ta == tarval_b_true) {
       set_Tuple_pred(n, pn_Cond_false, new_Bad());
       set_Tuple_pred(n, pn_Cond_true, jmp);
@@ -1919,7 +2100,7 @@ static ir_node *transform_node_Not(ir_node *n)
 static ir_node *transform_node_Cast(ir_node *n) {
   ir_node *oldn = n;
   ir_node *pred = get_Cast_op(n);
-  type *tp = get_irn_type(n);
+  ir_type *tp = get_irn_type(n);
 
   if (get_irn_op(pred) == op_Const && get_Const_type(pred) != tp) {
     n = new_rd_Const_type(NULL, current_ir_graph, get_irn_n(pred, -1), get_irn_mode(pred),
@@ -1953,6 +2134,7 @@ static ir_node *transform_node_Proj_Div(ir_node *proj)
 
     if (proj_nr == pn_Div_X_except) {
       /* we found an exception handler, remove it */
+      DBG_OPT_EXC_REM(proj);
       return new_Bad();
     } else if (proj_nr == pn_Div_M) {
       /* the memory Proj can be removed */
@@ -1984,6 +2166,7 @@ static ir_node *transform_node_Proj_Mod(ir_node *proj)
 
     if (proj_nr == pn_Mod_X_except) {
       /* we found an exception handler, remove it */
+      DBG_OPT_EXC_REM(proj);
       return new_Bad();
     } else if (proj_nr == pn_Mod_M) {
       /* the memory Proj can be removed */
@@ -2023,6 +2206,7 @@ static ir_node *transform_node_Proj_DivMod(ir_node *proj)
 
     if (proj_nr == pn_DivMod_X_except) {
       /* we found an exception handler, remove it */
+      DBG_OPT_EXC_REM(proj);
       return new_Bad();
     }
     else if (proj_nr == pn_DivMod_M) {
@@ -2759,22 +2943,28 @@ static ir_node *transform_node_Mux(ir_node *n)
  */
 static ir_node *transform_node(ir_node *n)
 {
-  if (n->op->transform_node)
-    n = n->op->transform_node(n);
+  if (n->op->ops.transform_node)
+    n = n->op->ops.transform_node(n);
   return n;
 }
 
 /**
- * set the default transform node operation
+ * sSets the default transform node operation for an ir_op_ops.
+ *
+ * @param code   the opcode for the default operation
+ * @param ops    the operations initialized
+ *
+ * @return
+ *    The operations.
  */
-static ir_op *firm_set_default_transform_node(ir_op *op)
+static ir_op_ops *firm_set_default_transform_node(opcode code, ir_op_ops *ops)
 {
 #define CASE(a)                                 \
   case iro_##a:                                 \
-    op->transform_node  = transform_node_##a;   \
+    ops->transform_node  = transform_node_##a;   \
     break
 
-  switch (op->code) {
+  switch (code) {
   CASE(Add);
   CASE(Sub);
   CASE(Mul);
@@ -2795,10 +2985,10 @@ static ir_op *firm_set_default_transform_node(ir_op *op)
   CASE(End);
   CASE(Mux);
   default:
-    op->transform_node = NULL;
+    /* leave NULL */;
   }
 
-  return op;
+  return ops;
 #undef CASE
 }
 
@@ -2904,16 +3094,22 @@ static int node_cmp_attr_Confirm(ir_node *a, ir_node *b)
 }
 
 /**
- * set the default node attribute compare operation
+ * Set the default node attribute compare operation for an ir_op_ops.
+ *
+ * @param code   the opcode for the default operation
+ * @param ops    the operations initialized
+ *
+ * @return
+ *    The operations.
  */
-static ir_op *firm_set_default_node_cmp_attr(ir_op *op)
+static ir_op_ops *firm_set_default_node_cmp_attr(opcode code, ir_op_ops *ops)
 {
-#define CASE(a)                             \
-  case iro_##a:                             \
-    op->node_cmp_attr  = node_cmp_attr_##a; \
+#define CASE(a)                              \
+  case iro_##a:                              \
+    ops->node_cmp_attr  = node_cmp_attr_##a; \
     break
 
-  switch (op->code) {
+  switch (code) {
   CASE(Const);
   CASE(Proj);
   CASE(Filter);
@@ -2928,19 +3124,18 @@ static ir_op *firm_set_default_node_cmp_attr(ir_op *op)
   CASE(Store);
   CASE(Confirm);
   default:
-    op->node_cmp_attr  = NULL;
+    /* leave NULL */;
   }
 
-  return op;
+  return ops;
 #undef CASE
 }
 
-/**
+/*
  * Compare function for two nodes in the hash table. Gets two
  * nodes as parameters.  Returns 0 if the nodes are a cse.
  */
-static int
-vt_cmp (const void *elt, const void *key)
+int identities_cmp(const void *elt, const void *key)
 {
   ir_node *a, *b;
   int i, irn_arity_a;
@@ -2973,8 +3168,8 @@ vt_cmp (const void *elt, const void *key)
    * here, we already now that the nodes are identical except their
    * attributes
    */
-  if (a->op->node_cmp_attr)
-    return a->op->node_cmp_attr(a, b);
+  if (a->op->ops.node_cmp_attr)
+    return a->op->ops.node_cmp_attr(a, b);
 
   return 0;
 }
@@ -3017,7 +3212,7 @@ ir_node_hash (ir_node *node)
 
 pset *
 new_identities(void) {
-  return new_pset(vt_cmp, N_IR_NODES);
+  return new_pset(identities_cmp, N_IR_NODES);
 }
 
 void
@@ -3076,12 +3271,12 @@ identify_cons (pset *value_table, ir_node *n) {
   return n;
 }
 
-/**
+/*
  * Return the canonical node computing the same value as n.
  * Looks up the node in a hash table, enters it in the table
  * if it isn't there yet.
  */
-static ir_node *
+ir_node *
 identify_remember (pset *value_table, ir_node *n)
 {
   ir_node *o = NULL;
@@ -3210,7 +3405,7 @@ optimize_node(ir_node *n)
       tv = computed_value(n);
       if (tv != tarval_bad) {
         ir_node *nw;
-        type *old_tp = get_irn_type(n);
+        ir_type *old_tp = get_irn_type(n);
         int i, arity = get_irn_arity(n);
         int node_size;
 
@@ -3321,7 +3516,7 @@ optimize_in_place_2 (ir_node *n)
       tv = computed_value(n);
       if (tv != tarval_bad) {
         /* evaluation was successful -- replace the node. */
-        type *old_tp = get_irn_type(n);
+        ir_type *old_tp = get_irn_type(n);
         int i, arity = get_irn_arity(n);
 
         /*
@@ -3398,23 +3593,24 @@ optimize_in_place (ir_node *n)
   if (get_irg_outs_state(current_ir_graph) == outs_consistent)
     set_irg_outs_inconsistent(current_ir_graph);
 
-  /* Maybe we could also test whether optimizing the node can
+  /* FIXME: Maybe we could also test whether optimizing the node can
      change the control graph. */
-  if (get_irg_dom_state(current_ir_graph) == dom_consistent)
-    set_irg_dom_inconsistent(current_ir_graph);
+  set_irg_doms_inconsistent(current_ir_graph);
   return optimize_in_place_2 (n);
 }
 
-/**
- * set the default ir op operations
+/*
+ * Sets the default operation for an ir_ops.
  */
-ir_op *firm_set_default_operations(ir_op *op)
+ir_op_ops *firm_set_default_operations(opcode code, ir_op_ops *ops)
 {
-  op = firm_set_default_computed_value(op);
-  op = firm_set_default_equivalent_node(op);
-  op = firm_set_default_transform_node(op);
-  op = firm_set_default_node_cmp_attr(op);
-  op = firm_set_default_get_type(op);
+  ops = firm_set_default_computed_value(code, ops);
+  ops = firm_set_default_equivalent_node(code, ops);
+  ops = firm_set_default_transform_node(code, ops);
+  ops = firm_set_default_node_cmp_attr(code, ops);
+  ops = firm_set_default_get_type(code, ops);
+  ops = firm_set_default_get_type_attr(code, ops);
+  ops = firm_set_default_get_entity_attr(code, ops);
 
-  return op;
+  return ops;
 }