OSDN Git Service

2006-05-15 Mircea Namolaru <namolaru@il.ibm.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-complex.c
index 63295fe..65466bb 100644 (file)
@@ -31,6 +31,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "tree-iterator.h"
 #include "tree-pass.h"
 #include "tree-ssa-propagate.h"
+#include "diagnostic.h"
 
 
 /* For each complex ssa name, a lattice value.  We're interested in finding
@@ -78,7 +79,7 @@ cvc_insert (unsigned int uid, tree to)
   struct int_tree_map *h;
   void **loc;
 
-  h = xmalloc (sizeof (struct int_tree_map));
+  h = XNEW (struct int_tree_map);
   h->uid = uid;
   h->to = to;
   loc = htab_find_slot_with_hash (complex_variable_components, h,
@@ -501,7 +502,7 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
     ;
 
   /* If we've nothing assigned, and the value we're given is already stable,
-     then install that as the value for this SSA_NAME.  This pre-emptively
+     then install that as the value for this SSA_NAME.  This preemptively
      copy-propagates the value, which avoids unnecessary memory allocation.  */
   else if (is_gimple_min_invariant (value))
     {
@@ -517,7 +518,7 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
          && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
        {
          comp = get_component_var (SSA_NAME_VAR (ssa_name), imag_p);
-         SSA_NAME_VAR (value) = comp;
+         replace_ssa_name_symbol (value, comp);
        }
 
       VEC_replace (tree, complex_ssa_name_components, ssa_name_index, value);
@@ -557,6 +558,7 @@ extract_component (block_stmt_iterator *bsi, tree t, bool imagpart_p,
       return TREE_OPERAND (t, imagpart_p);
 
     case VAR_DECL:
+    case RESULT_DECL:
     case PARM_DECL:
     case INDIRECT_REF:
     case COMPONENT_REF:
@@ -627,7 +629,7 @@ update_complex_assignment (block_stmt_iterator *bsi, tree r, tree i)
     update_complex_components (bsi, stmt, r, i);
   
   type = TREE_TYPE (TREE_OPERAND (mod, 1));
-  TREE_OPERAND (mod, 1) = build (COMPLEX_EXPR, type, r, i);
+  TREE_OPERAND (mod, 1) = build2 (COMPLEX_EXPR, type, r, i);
   update_stmt (stmt);
 }
 
@@ -650,6 +652,8 @@ update_parameter_components (void)
 
       type = TREE_TYPE (type);
       ssa_name = default_def (parm);
+      if (!ssa_name)
+       continue;
 
       r = build1 (REALPART_EXPR, type, ssa_name);
       i = build1 (IMAGPART_EXPR, type, ssa_name);
@@ -843,7 +847,7 @@ expand_complex_addition (block_stmt_iterator *bsi, tree inner_type,
 
     case PAIR (VARYING, ONLY_IMAG):
       rr = ar;
-      ri = gimplify_build2 (bsi, MINUS_EXPR, inner_type, ai, bi);
+      ri = gimplify_build2 (bsi, code, inner_type, ai, bi);
       break;
 
     case PAIR (ONLY_REAL, VARYING):
@@ -857,7 +861,7 @@ expand_complex_addition (block_stmt_iterator *bsi, tree inner_type,
       if (code == MINUS_EXPR)
        goto general;
       rr = br;
-      ri = gimplify_build2 (bsi, MINUS_EXPR, inner_type, ai, bi);
+      ri = gimplify_build2 (bsi, code, inner_type, ai, bi);
       break;
 
     case PAIR (VARYING, VARYING):
@@ -1053,7 +1057,7 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
     {
       edge e;
 
-      cond = build (COND_EXPR, void_type_node, cond, NULL, NULL);
+      cond = build3 (COND_EXPR, void_type_node, cond, NULL_TREE, NULL_TREE);
       bsi_insert_before (bsi, cond, BSI_SAME_STMT);
 
       /* Split the original block, and create the TRUE and FALSE blocks.  */
@@ -1063,8 +1067,8 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
       bb_true = create_empty_bb (bb_cond);
       bb_false = create_empty_bb (bb_true);
 
-      t1 = build (GOTO_EXPR, void_type_node, tree_block_label (bb_true));
-      t2 = build (GOTO_EXPR, void_type_node, tree_block_label (bb_false));
+      t1 = build1 (GOTO_EXPR, void_type_node, tree_block_label (bb_true));
+      t2 = build1 (GOTO_EXPR, void_type_node, tree_block_label (bb_false));
       COND_EXPR_THEN (cond) = t1;
       COND_EXPR_ELSE (cond) = t2;
 
@@ -1118,11 +1122,11 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
 
      if (bb_true)
        {
-        t1 = build (MODIFY_EXPR, inner_type, rr, tr);
+        t1 = build2 (MODIFY_EXPR, inner_type, rr, tr);
         bsi_insert_before (bsi, t1, BSI_SAME_STMT);
-        t1 = build (MODIFY_EXPR, inner_type, ri, ti);
+        t1 = build2 (MODIFY_EXPR, inner_type, ri, ti);
         bsi_insert_before (bsi, t1, BSI_SAME_STMT);
-        bsi_remove (bsi);
+        bsi_remove (bsi, true);
        }
     }
 
@@ -1157,11 +1161,11 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type,
 
      if (bb_false)
        {
-        t1 = build (MODIFY_EXPR, inner_type, rr, tr);
+        t1 = build2 (MODIFY_EXPR, inner_type, rr, tr);
         bsi_insert_before (bsi, t1, BSI_SAME_STMT);
-        t1 = build (MODIFY_EXPR, inner_type, ri, ti);
+        t1 = build2 (MODIFY_EXPR, inner_type, ri, ti);
         bsi_insert_before (bsi, t1, BSI_SAME_STMT);
-        bsi_remove (bsi);
+        bsi_remove (bsi, true);
        }
     }
 
@@ -1478,7 +1482,7 @@ expand_complex_operations_1 (block_stmt_iterator *bsi)
 \f
 /* Entry point for complex operation lowering during optimization.  */
 
-static void
+static unsigned int
 tree_lower_complex (void)
 {
   int old_last_basic_block;
@@ -1486,7 +1490,7 @@ tree_lower_complex (void)
   basic_block bb;
 
   if (!init_dont_simulate_again ())
-    return;
+    return 0;
 
   complex_lattice_values = VEC_alloc (complex_lattice_t, heap, num_ssa_names);
   VEC_safe_grow (complex_lattice_t, heap,
@@ -1523,6 +1527,7 @@ tree_lower_complex (void)
   htab_delete (complex_variable_components);
   VEC_free (tree, heap, complex_ssa_name_components);
   VEC_free (complex_lattice_t, heap, complex_lattice_values);
+  return 0;
 }
 
 struct tree_opt_pass pass_lower_complex = 
@@ -1547,7 +1552,7 @@ struct tree_opt_pass pass_lower_complex =
 \f
 /* Entry point for complex operation lowering without optimization.  */
 
-static void
+static unsigned int
 tree_lower_complex_O0 (void)
 {
   int old_last_basic_block = last_basic_block;
@@ -1561,12 +1566,15 @@ tree_lower_complex_O0 (void)
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
        expand_complex_operations_1 (&bsi);
     }
+  return 0;
 }
 
 static bool
 gate_no_optimization (void)
 {
-  return optimize == 0;
+  /* With errors, normal optimization passes are not run.  If we don't
+     lower complex operations at all, rtl expansion will abort.  */
+  return optimize == 0 || sorrycount || errorcount;
 }
 
 struct tree_opt_pass pass_lower_complex_O0 =