OSDN Git Service

2004-10-28 Frank Ch. Eigler <fche@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-operands.c
index 2506761..55cebf2 100644 (file)
@@ -32,7 +32,6 @@ Boston, MA 02111-1307, USA.  */
 #include "tree-pass.h"
 #include "ggc.h"
 #include "timevar.h"
-#include "cgraph.h"
 
 #include "langhooks.h"
 
@@ -135,8 +134,8 @@ static inline void append_def (tree *);
 static inline void append_use (tree *);
 static void append_v_may_def (tree);
 static void append_v_must_def (tree);
-static void add_call_clobber_ops (tree, tree);
-static void add_call_read_ops (tree, tree);
+static void add_call_clobber_ops (tree);
+static void add_call_read_ops (tree);
 static void add_stmt_operand (tree *, tree, int);
 
 /* Return a vector of contiguous memory for NUM def operands.  */
@@ -175,7 +174,7 @@ allocate_v_may_def_optype (unsigned num)
   v_may_def_optype v_may_def_ops;
   unsigned size;
   size = sizeof (struct v_may_def_optype_d) 
-          + sizeof (v_may_def_operand_type_t) * (num - 1);
+          + sizeof (v_def_use_operand_type_t) * (num - 1);
   v_may_def_ops =  ggc_alloc (size);
   v_may_def_ops->num_v_may_defs = num;
   return v_may_def_ops;
@@ -203,7 +202,7 @@ allocate_v_must_def_optype (unsigned num)
 {
   v_must_def_optype v_must_def_ops;
   unsigned size;
-  size = sizeof (struct v_must_def_optype_d) + sizeof (tree) * (num - 1);
+  size = sizeof (struct v_must_def_optype_d) + sizeof (v_def_use_operand_type_t) * (num - 1);
   v_must_def_ops =  ggc_alloc (size);
   v_must_def_ops->num_v_must_defs = num;
   return v_must_def_ops;
@@ -651,7 +650,7 @@ finalize_ssa_v_must_defs (v_must_def_optype *old_ops_p,
       build_diff = false;
       for (x = 0; x < num; x++)
         {
-         tree var = old_ops->v_must_defs[x];
+         tree var = old_ops->v_must_defs[x].def;
          if (TREE_CODE (var) == SSA_NAME)
            var = SSA_NAME_VAR (var);
          if (var != VARRAY_TREE (build_v_must_defs, x))
@@ -678,17 +677,21 @@ finalize_ssa_v_must_defs (v_must_def_optype *old_ops_p,
          /* Look for VAR in the original vector.  */
          for (i = 0; i < old_num; i++)
            {
-             result = old_ops->v_must_defs[i];
+             result = old_ops->v_must_defs[i].def;
              if (TREE_CODE (result) == SSA_NAME)
                result = SSA_NAME_VAR (result);
              if (result == var)
                {
-                 v_must_def_ops->v_must_defs[x] = old_ops->v_must_defs[i];
+                 v_must_def_ops->v_must_defs[x].def = old_ops->v_must_defs[i].def;
+                 v_must_def_ops->v_must_defs[x].use = old_ops->v_must_defs[i].use;
                  break;
                }
            }
          if (i == old_num)
-           v_must_def_ops->v_must_defs[x] = var;
+           {
+             v_must_def_ops->v_must_defs[x].def = var;
+             v_must_def_ops->v_must_defs[x].use = var;
+           }
        }
     }
   VARRAY_POP_ALL (build_v_must_defs);
@@ -1004,6 +1007,7 @@ get_expr_operands (tree stmt, tree *expr_p, int flags)
     case VAR_DECL:
     case PARM_DECL:
     case RESULT_DECL:
+    case CONST_DECL:
       /* If we found a variable, add it to DEFS or USES depending
         on the operand flags.  */
       add_stmt_operand (expr_p, stmt, flags);
@@ -1398,7 +1402,6 @@ get_call_expr_operands (tree stmt, tree expr)
 {
   tree op;
   int call_flags = call_expr_flags (expr);
-  tree callee = get_callee_fndecl (expr);
 
   /* Find uses in the called function.  */
   get_expr_operands (stmt, &TREE_OPERAND (expr, 0), opf_none);
@@ -1415,9 +1418,9 @@ get_call_expr_operands (tree stmt, tree expr)
         there is no point in recording that.  */ 
       if (TREE_SIDE_EFFECTS (expr)
          && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
-       add_call_clobber_ops (stmt, callee);
+       add_call_clobber_ops (stmt);
       else if (!(call_flags & ECF_CONST))
-       add_call_read_ops (stmt, callee);
+       add_call_read_ops (stmt);
     }
 }
 
@@ -1581,7 +1584,7 @@ note_addressable (tree var, stmt_ann_t s_ann)
    clobbered variables in the function.  */
 
 static void
-add_call_clobber_ops (tree stmt, tree callee)
+add_call_clobber_ops (tree stmt)
 {
   /* Functions that are not const, pure or never return may clobber
      call-clobbered variables.  */
@@ -1597,59 +1600,16 @@ add_call_clobber_ops (tree stmt, tree callee)
   else
     {
       size_t i;
-      bitmap not_read_b = NULL, not_written_b = NULL;
       bitmap_iterator bi;
 
-      /* Get info for module level statics.  There is a bit set for
-        each static if the call being processed does not read or
-        write that variable.  */
-
-      /* ??? Turn off the optimization until it gets fixed.  */
-      if (0 && callee)
-       {
-         not_read_b = get_global_statics_not_read (callee);
-         not_written_b = get_global_statics_not_written (callee);
-       }
-
       EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
        {
          tree var = referenced_var (i);
-
-         bool not_read
-           = not_read_b ? bitmap_bit_p (not_read_b, i) : false;
-         bool not_written
-           = not_written_b ? bitmap_bit_p (not_written_b, i) : false;
-
-         if (not_read)
-           {
-             /* The var is not read during the call.  */
-             if (!not_written)
-               add_stmt_operand (&var, stmt, opf_is_def);
-           }
+         if (TREE_READONLY (var)
+             && (TREE_STATIC (var) || DECL_EXTERNAL (var)))
+           add_stmt_operand (&var, stmt, opf_none);
          else
-           {
-             /* The var is read during the call.  */
-             if (not_written) 
-               add_stmt_operand (&var, stmt, opf_none);
-
-             /* The not_read and not_written bits are only set for module
-                static variables.  Neither is set here, so we may be dealing
-                with a module static or we may not.  So we still must look
-                anywhere else we can (such as the TREE_READONLY) to get
-                better info.  */
-
-             /* If VAR is read-only, don't add a V_MAY_DEF, just a
-                VUSE operand.  FIXME, this is quirky.  TREE_READONLY
-                by itself is not enough here.  We can only decide
-                that the call will not affect VAR if all these
-                conditions are met.  One would think that
-                TREE_READONLY should be sufficient.  */
-             else if (TREE_READONLY (var)
-                      && (TREE_STATIC (var) || DECL_EXTERNAL (var)))
-               add_stmt_operand (&var, stmt, opf_none);
-             else
-               add_stmt_operand (&var, stmt, opf_is_def);
-           }
+           add_stmt_operand (&var, stmt, opf_is_def);
        }
     }
 }
@@ -1659,7 +1619,7 @@ add_call_clobber_ops (tree stmt, tree callee)
    function.  */
 
 static void
-add_call_read_ops (tree stmt, tree callee)
+add_call_read_ops (tree stmt)
 {
   bitmap_iterator bi;
 
@@ -1672,15 +1632,10 @@ add_call_read_ops (tree stmt, tree callee)
   else
     {
       size_t i;
-      bitmap not_read_b = callee 
-       ? get_global_statics_not_read (callee) : NULL; 
-
+      
       EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
        {
          tree var = referenced_var (i);
-         bool not_read = not_read_b 
-           ? bitmap_bit_p(not_read_b, i) : false;
-         if (!not_read)
          add_stmt_operand (&var, stmt, opf_none);
        }
     }
@@ -1721,7 +1676,10 @@ copy_virtual_operands (tree dst, tree src)
     {
       *v_must_defs_new = allocate_v_must_def_optype (NUM_V_MUST_DEFS (v_must_defs));
       for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++)
-       SET_V_MUST_DEF_OP (*v_must_defs_new, i, V_MUST_DEF_OP (v_must_defs, i));
+       {
+         SET_V_MUST_DEF_RESULT (*v_must_defs_new, i, V_MUST_DEF_RESULT (v_must_defs, i));
+         SET_V_MUST_DEF_KILL (*v_must_defs_new, i, V_MUST_DEF_KILL (v_must_defs, i));
+       }
     }
 }
 
@@ -1750,7 +1708,7 @@ create_ssa_artficial_load_stmt (stmt_operands_p old_ops, tree new_stmt)
   free_vuses (&(ann->operands.vuse_ops));
   free_v_may_defs (&(ann->operands.v_may_def_ops));
   free_v_must_defs (&(ann->operands.v_must_def_ops));
-
+  
   /* For each VDEF on the original statement, we want to create a
      VUSE of the V_MAY_DEF result or V_MUST_DEF op on the new 
      statement.  */
@@ -1762,7 +1720,7 @@ create_ssa_artficial_load_stmt (stmt_operands_p old_ops, tree new_stmt)
     
   for (j = 0; j < NUM_V_MUST_DEFS (old_ops->v_must_def_ops); j++)
     {
-      op = V_MUST_DEF_OP (old_ops->v_must_def_ops, j);
+      op = V_MUST_DEF_RESULT (old_ops->v_must_def_ops, j);
       append_vuse (op);
     }