OSDN Git Service

* dwarf2asm.c (dw2_force_const_mem): Add new parameter 'public'.
[pf3gnuchains/gcc-fork.git] / gcc / tree-dfa.c
index fa8ee86..9fc48d5 100644 (file)
@@ -16,8 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include "config.h"
 #include "system.h"
@@ -31,7 +31,6 @@ Boston, MA 02111-1307, USA.  */
 #include "hard-reg-set.h"
 #include "basic-block.h"
 #include "output.h"
-#include "errors.h"
 #include "timevar.h"
 #include "expr.h"
 #include "ggc.h"
@@ -84,7 +83,7 @@ static void add_referenced_var (tree, struct walk_state *);
 /* Global declarations.  */
 
 /* Array of all variables referenced in the function.  */
-varray_type referenced_vars;
+htab_t referenced_vars;
 
 
 /*---------------------------------------------------------------------------
@@ -186,7 +185,6 @@ create_stmt_ann (tree t)
   return ann;
 }
 
-
 /* Create a new annotation for a tree T.  */
 
 tree_ann_t
@@ -232,14 +230,14 @@ make_rename_temp (tree type, const char *prefix)
 void
 dump_referenced_vars (FILE *file)
 {
-  size_t i;
-
+  tree var;
+  referenced_var_iterator rvi;
+  
   fprintf (file, "\nReferenced variables in %s: %u\n\n",
           get_name (current_function_decl), (unsigned) num_referenced_vars);
-
-  for (i = 0; i < num_referenced_vars; i++)
+  
+  FOR_EACH_REFERENCED_VAR (var, rvi)
     {
-      tree var = referenced_var (i);
       fprintf (file, "Variable: ");
       dump_variable (file, var);
       fprintf (file, "\n");
@@ -256,6 +254,37 @@ debug_referenced_vars (void)
 }
 
 
+/* Dump sub-variables for VAR to FILE.  */
+
+void
+dump_subvars_for (FILE *file, tree var)
+{
+  subvar_t sv = get_subvars_for_var (var);
+
+  if (!sv)
+    return;
+
+  fprintf (file, "{ ");
+
+  for (; sv; sv = sv->next)
+    {
+      print_generic_expr (file, sv->var, dump_flags);
+      fprintf (file, " ");
+    }
+
+  fprintf (file, "}");
+}
+
+
+/* Dumb sub-variables for VAR to stderr.  */
+
+void
+debug_subvars_for (tree var)
+{
+  dump_subvars_for (stderr, var);
+}
+
+
 /* Dump variable VAR and its may-aliases to FILE.  */
 
 void
@@ -280,18 +309,18 @@ dump_variable (FILE *file, tree var)
 
   ann = var_ann (var);
 
-  fprintf (file, ", UID %u", (unsigned) ann->uid);
+  fprintf (file, ", UID %u", (unsigned) DECL_UID (var));
 
   fprintf (file, ", ");
   print_generic_expr (file, TREE_TYPE (var), dump_flags);
 
-  if (ann->type_mem_tag)
+  if (ann && ann->type_mem_tag)
     {
       fprintf (file, ", type memory tag: ");
       print_generic_expr (file, ann->type_mem_tag, dump_flags);
     }
 
-  if (ann->is_alias_tag)
+  if (ann && ann->is_alias_tag)
     fprintf (file, ", is an alias tag");
 
   if (TREE_ADDRESSABLE (var))
@@ -306,18 +335,24 @@ dump_variable (FILE *file, tree var)
   if (is_call_clobbered (var))
     fprintf (file, ", call clobbered");
 
-  if (ann->default_def)
+  if (default_def (var))
     {
       fprintf (file, ", default def: ");
-      print_generic_expr (file, ann->default_def, dump_flags);
+      print_generic_expr (file, default_def (var), dump_flags);
     }
 
-  if (ann->may_aliases)
+  if (may_aliases (var))
     {
       fprintf (file, ", may aliases: ");
       dump_may_aliases_for (file, var);
     }
 
+  if (get_subvars_for_var (var))
+    {
+      fprintf (file, ", sub-vars: ");
+      dump_subvars_for (file, var);
+    }
+
   fprintf (file, "\n");
 }
 
@@ -428,7 +463,7 @@ debug_dfa_stats (void)
 }
 
 
-/* Collect DFA statistics and store them in the structure pointed by
+/* Collect DFA statistics and store them in the structure pointed to by
    DFA_STATS_P.  */
 
 static void
@@ -530,6 +565,50 @@ find_vars_r (tree *tp, int *walk_subtrees, void *data)
 }
 
 
+/* Lookup UID in the referenced_vars hashtable and return the associated
+   variable or NULL if it is not there.  */
+
+tree 
+referenced_var_lookup_if_exists (unsigned int uid)
+{
+  struct int_tree_map *h, in;
+  in.uid = uid;
+  h = htab_find_with_hash (referenced_vars, &in, uid);
+  if (h)
+    return h->to;
+  return NULL_TREE;
+}
+
+/* Lookup UID in the referenced_vars hashtable and return the associated
+   variable.  */
+
+tree 
+referenced_var_lookup (unsigned int uid)
+{
+  struct int_tree_map *h, in;
+  in.uid = uid;
+  h = htab_find_with_hash (referenced_vars, &in, uid);
+  gcc_assert (h || uid == 0);
+  if (h)
+    return h->to;
+  return NULL_TREE;
+}
+
+/* Insert the pair UID, TO into the referenced_vars hashtable.  */
+
+static void
+referenced_var_insert (unsigned int uid, tree to)
+{ 
+  struct int_tree_map *h;
+  void **loc;
+
+  h = ggc_alloc (sizeof (struct int_tree_map));
+  h->uid = uid;
+  h->to = to;
+  loc = htab_find_slot_with_hash (referenced_vars, h, uid, INSERT);
+  *(struct int_tree_map **)  loc = h;
+}
+
 /* Add VAR to the list of dereferenced variables.
 
    WALK_STATE contains a hash table used to avoid adding the same
@@ -557,8 +636,8 @@ add_referenced_var (tree var, struct walk_state *walk_state)
         intrinsic to the variable.  */
       if (slot)
        *slot = (void *) var;
-      v_ann->uid = num_referenced_vars;
-      VARRAY_PUSH_TREE (referenced_vars, var);
+      
+      referenced_var_insert (DECL_UID (var), var);
 
       /* Global variables are always call-clobbered.  */
       if (is_global_var (var))
@@ -572,9 +651,9 @@ add_referenced_var (tree var, struct walk_state *walk_state)
             optimizers.  */
           && !DECL_EXTERNAL (var)
          /* It's not necessary to walk the initial value of non-constant
-            public variables because it cannot be propagated by the
+            variables because it cannot be propagated by the
             optimizers.  */
-         && (!TREE_PUBLIC (var) || !TREE_CONSTANT (var)))
+         && (TREE_CONSTANT (var) || TREE_READONLY (var)))
        walk_tree (&DECL_INITIAL (var), find_vars_r, walk_state, 0);
     }
 }
@@ -629,6 +708,9 @@ mark_new_vars_to_rename (tree stmt)
   int v_may_defs_before, v_may_defs_after;
   int v_must_defs_before, v_must_defs_after;
 
+  if (TREE_CODE (stmt) == PHI_NODE)
+    return;
+
   vars_in_vops_to_rename = BITMAP_ALLOC (NULL);
 
   /* Before re-scanning the statement for operands, mark the existing
@@ -648,7 +730,7 @@ mark_new_vars_to_rename (tree stmt)
     {
       if (!DECL_P (val))
        val = SSA_NAME_VAR (val);
-      bitmap_set_bit (vars_in_vops_to_rename, var_ann (val)->uid);
+      bitmap_set_bit (vars_in_vops_to_rename, DECL_UID (val));
     }
 
   /* Now force an operand re-scan on the statement and mark any newly
@@ -713,8 +795,8 @@ find_new_referenced_vars (tree *stmt_p)
    size, in bits, of REF inside the return value.  */
 
 tree
-okay_component_ref_for_subvars (tree ref, HOST_WIDE_INT *poffset,
-                               HOST_WIDE_INT *psize)
+okay_component_ref_for_subvars (tree ref, unsigned HOST_WIDE_INT *poffset,
+                               unsigned HOST_WIDE_INT *psize)
 {
   tree result = NULL;
   HOST_WIDE_INT bitsize;