cleaned up: use new trouts functionality
[libfirm] / ir / ana / irsimpletype.c
index dc14cea..7266ba7 100644 (file)
@@ -29,6 +29,7 @@
 # include "irprog_t.h"
 # include "irgwalk.h"
 # include "ident.h"
+# include "trouts.h"
 
 #define VERBOSE_UNKNOWN_TYPE(s) printf s
 
@@ -38,8 +39,9 @@ static type *phi_cycle_type = NULL;
 /* ------------ Building and Removing the type information  ----------- */
 
 
-/* init type link field so that types point to their pointers. */
+/* Init type link field so that types point to their pointers. */
 void precompute_pointer_types(void) {
+#if 0
   int i;
   set_type_link(firm_unknown_type, firm_unknown_type);
   set_type_link(firm_none_type,    firm_unknown_type);
@@ -50,17 +52,29 @@ void precompute_pointer_types(void) {
     if (is_Pointer_type(tp))
       set_type_link(get_pointer_points_to_type(tp), (void *)tp);
   }
+#else
+  compute_trouts();
+#endif
 }
 
 /* Store pointer in link to speed up search of pointer type. */
 static type *find_pointer_type_to (type *tp) {
+#if 0
   return (type *)get_type_link(tp);
+#else
+  if (get_type_n_pointertypes_to(tp) > 0)
+    return get_type_pointertype_to(tp, 0);
+  else
+    return firm_unknown_type;
+#endif
 }
 
 static type* compute_irn_type(ir_node *n);
 
 static type *find_type_for_Proj(ir_node *n) {
   type *tp;
+
+  /* Avoid nested Tuples. */
   ir_node *pred = skip_Tuple(get_Proj_pred(n));
   ir_mode *m = get_irn_mode(n);
 
@@ -83,6 +97,8 @@ static type *find_type_for_Proj(ir_node *n) {
     } else if (get_irn_op(pred_pred) == op_Call) {
       type *mtp = get_Call_type(pred_pred);
       tp = get_method_res_type(mtp, get_Proj_proj(n));
+    } else if (get_irn_op(pred_pred) == op_Tuple) {
+      assert(0 && "Encountered nested Tuple");
     } else {
       VERBOSE_UNKNOWN_TYPE(("Proj %ld from Proj from ??: unknown type\n", get_irn_node_nr(n)));
       tp = firm_unknown_type;
@@ -112,6 +128,9 @@ static type *find_type_for_Proj(ir_node *n) {
       tp = firm_unknown_type;
     }
   } break;
+  case iro_Tuple: {
+    tp = compute_irn_type(get_Tuple_pred(pred, get_Proj_proj(n)));
+  } break;
   default:
     tp = compute_irn_type(pred);
   }
@@ -226,7 +245,7 @@ static type *find_type_for_node(ir_node *n) {
 
     if (tp1 == tp2) { tp = tp1; break; }
 
-    if (get_firm_verbosity() > 1) {
+    if (get_firm_verbosity() > 55) {  // Do not commit 55! should be 1.
       VERBOSE_UNKNOWN_TYPE(("Phi %ld with two different types: %s, %s: unknown type.\n", get_irn_node_nr(n),
                            get_type_name(tp1), get_type_name(tp2)));
     }
@@ -313,7 +332,7 @@ static type *find_type_for_node(ir_node *n) {
              tp = phi_cycle_type;
              break;
       }
-      if (get_firm_verbosity() > 1) {
+      if (get_firm_verbosity() > 55) {
        VERBOSE_UNKNOWN_TYPE(("Binop %ld with two different types: %s, %s: unknown type \n", get_irn_node_nr(n),
                              get_type_name(tp1), get_type_name(tp2)));
       }