tree-ssa-operands.h (struct ssa_operands): New.
authorJan Hubicka <jh@suse.cz>
Thu, 30 Nov 2006 15:30:01 +0000 (16:30 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 30 Nov 2006 15:30:01 +0000 (15:30 +0000)
* tree-ssa-operands.h (struct ssa_operands): New.
* tree-flow-inline.h (gimple_ssa_operands): New function.
* tree-flow.h: (struct gimple_df): Add ssa_operands.
* Makefile.in: Remove gt-tree-ssa-operands.h
* tree-ssa-operands.c: Do not include gt-tree-ssa-operands.h
(free_defs, free_uses, free_vuses, free_maydefs, free_mustdefs,
operand_memory, operand_memory_index, ops_active): Remove statics.
(ALLOC_OPTYPE): Update.
(operand_build_sort_virtual): Update.
(ssa_operands_active): Update.
(init_ssa_operands): Update.
(fini_ssa_operands): Update.
(ssa_operand_alloc): Update.
(INITIALIZE_USE): Update.
(finalize_ssa_use_ops): Update.
(finalize_ssa_v_may_def_ops): Update.
(finalize_ssa_vuse_ops): Update.
(finalize_ssa_v_must_def_ops): Update.

From-SVN: r119363

gcc/ChangeLog
gcc/Makefile.in
gcc/tree-flow-inline.h
gcc/tree-flow.h
gcc/tree-ssa-operands.c
gcc/tree-ssa-operands.h

index a73f82a..2da6dab 100644 (file)
@@ -1,3 +1,24 @@
+2006-11-30  Jan Hubicka  <jh@suse.cz>
+
+       * tree-ssa-operands.h (struct ssa_operands): New.
+       * tree-flow-inline.h (gimple_ssa_operands): New function.
+       * tree-flow.h: (struct gimple_df): Add ssa_operands.
+       * Makefile.in: Remove gt-tree-ssa-operands.h
+       * tree-ssa-operands.c: Do not include gt-tree-ssa-operands.h
+       (free_defs, free_uses, free_vuses, free_maydefs, free_mustdefs,
+       operand_memory, operand_memory_index, ops_active): Remove statics.
+       (ALLOC_OPTYPE): Update.
+       (operand_build_sort_virtual): Update.
+       (ssa_operands_active): Update.
+       (init_ssa_operands): Update.
+       (fini_ssa_operands): Update.
+       (ssa_operand_alloc): Update.
+       (INITIALIZE_USE): Update.
+       (finalize_ssa_use_ops): Update.
+       (finalize_ssa_v_may_def_ops): Update.
+       (finalize_ssa_vuse_ops): Update.
+       (finalize_ssa_v_must_def_ops): Update.
+
 2006-11-30  Richard Guenther  <rguenther@suse.de>
 
        * tree-vectorizer.h (vectorizable_function): Export.
index 290e8f3..4c46cd3 100644 (file)
@@ -1972,7 +1972,7 @@ tree-dfa.o : tree-dfa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
 tree-ssa-operands.o : tree-ssa-operands.c $(TREE_FLOW_H) $(CONFIG_H) \
    $(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TREE_INLINE_H) \
    $(FLAGS_H) $(FUNCTION_H) $(TM_H) $(TIMEVAR_H) tree-pass.h toplev.h \
-   gt-tree-ssa-operands.h coretypes.h langhooks.h $(IPA_REFERENCE_H)
+   coretypes.h langhooks.h $(IPA_REFERENCE_H)
 tree-eh.o : tree-eh.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_H) $(FLAGS_H) $(FUNCTION_H) except.h langhooks.h \
    $(GGC_H) tree-pass.h coretypes.h $(TIMEVAR_H) $(TM_P_H) \
@@ -2868,7 +2868,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
   $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
   $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
-  $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
+  $(srcdir)/tree-ssa-operands.h \
   $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
   $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
   $(srcdir)/tree-ssa-structalias.c \
@@ -2903,7 +2903,7 @@ gt-tree-mudflap.h gt-tree-vect-generic.h \
 gt-tree-profile.h gt-tree-ssa-address.h \
 gt-tree-iterator.h gt-gimplify.h \
 gt-tree-phinodes.h gt-tree-nested.h \
-gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
+gt-tree-ssa-propagate.h \
 gt-tree-ssa-structalias.h gt-ipa-inline.h gt-cgraphunit.h \
 gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
 
index ae937b1..5040375 100644 (file)
@@ -1726,4 +1726,10 @@ get_value_handle (tree expr)
     gcc_unreachable ();
 }
 
+/* Accessor to tree-ssa-operands.c caches.  */
+static inline struct ssa_operands *
+gimple_ssa_operands (struct function *fun)
+{
+  return &fun->gimple_df->ssa_operands;
+}
 #endif /* _TREE_FLOW_INLINE_H  */
index fad1686..fb7b02f 100644 (file)
@@ -88,6 +88,8 @@ struct gimple_df GTY(()) {
 
   /* True if the code is in ssa form.  */
   unsigned int in_ssa_p : 1;
+
+  struct ssa_operands ssa_operands;
 };
 
 /* Accessors for internal use only.  Generic code should use abstraction
index a594d4d..a3c453d 100644 (file)
@@ -116,19 +116,10 @@ static VEC(tree,heap) *build_vuses;
 /* Array for building all the V_MUST_DEF operands.  */
 static VEC(tree,heap) *build_v_must_defs;
 
-/* These arrays are the cached operand vectors for call clobbered calls.  */
-static bool ops_active = false;
-
-static GTY (()) struct ssa_operand_memory_d *operand_memory = NULL;
-static unsigned operand_memory_index;
-
 static void get_expr_operands (tree, tree *, int);
 
-static def_optype_p free_defs = NULL;
-static use_optype_p free_uses = NULL;
-static vuse_optype_p free_vuses = NULL;
-static maydef_optype_p free_maydefs = NULL;
-static mustdef_optype_p free_mustdefs = NULL;
+/* Number of functions with initialized ssa_operands.  */
+static int n_initialized = 0;
 
 /* Allocates operand OP of given TYPE from the appropriate free list,
    or of the new value if the list is empty.  */
@@ -136,9 +127,11 @@ static mustdef_optype_p free_mustdefs = NULL;
 #define ALLOC_OPTYPE(OP, TYPE)                         \
   do                                                   \
     {                                                  \
-      TYPE##_optype_p ret = free_##TYPE##s;            \
+      TYPE##_optype_p ret                              \
+        = gimple_ssa_operands (cfun)->free_##TYPE##s;  \
       if (ret)                                         \
-       free_##TYPE##s = ret->next;                     \
+       gimple_ssa_operands (cfun)->free_##TYPE##s      \
+        = ret->next;                                   \
       else                                             \
        ret = ssa_operand_alloc (sizeof (*ret));        \
       (OP) = ret;                                      \
@@ -212,7 +205,7 @@ operand_build_sort_virtual (VEC(tree,heap) *list)
 bool
 ssa_operands_active (void)
 {
-  return ops_active;
+  return cfun->gimple_df && gimple_ssa_operands (cfun)->ops_active;
 }
 
 
@@ -250,15 +243,18 @@ static struct
 void
 init_ssa_operands (void)
 {
-  build_defs = VEC_alloc (tree, heap, 5);
-  build_uses = VEC_alloc (tree, heap, 10);
-  build_vuses = VEC_alloc (tree, heap, 25);
-  build_v_may_defs = VEC_alloc (tree, heap, 25);
-  build_v_must_defs = VEC_alloc (tree, heap, 25);
-
-  gcc_assert (operand_memory == NULL);
-  operand_memory_index = SSA_OPERAND_MEMORY_SIZE;
-  ops_active = true;
+  if (!n_initialized++)
+    {
+      build_defs = VEC_alloc (tree, heap, 5);
+      build_uses = VEC_alloc (tree, heap, 10);
+      build_vuses = VEC_alloc (tree, heap, 25);
+      build_v_may_defs = VEC_alloc (tree, heap, 25);
+      build_v_must_defs = VEC_alloc (tree, heap, 25);
+    }
+
+  gcc_assert (gimple_ssa_operands (cfun)->operand_memory == NULL);
+  gimple_ssa_operands (cfun)->operand_memory_index = SSA_OPERAND_MEMORY_SIZE;
+  gimple_ssa_operands (cfun)->ops_active = true;
   memset (&clobber_stats, 0, sizeof (clobber_stats));
 }
 
@@ -269,23 +265,27 @@ void
 fini_ssa_operands (void)
 {
   struct ssa_operand_memory_d *ptr;
-  VEC_free (tree, heap, build_defs);
-  VEC_free (tree, heap, build_uses);
-  VEC_free (tree, heap, build_v_must_defs);
-  VEC_free (tree, heap, build_v_may_defs);
-  VEC_free (tree, heap, build_vuses);
-  free_defs = NULL;
-  free_uses = NULL;
-  free_vuses = NULL;
-  free_maydefs = NULL;
-  free_mustdefs = NULL;
-  while ((ptr = operand_memory) != NULL)
+  if (!--n_initialized)
+    {
+      VEC_free (tree, heap, build_defs);
+      VEC_free (tree, heap, build_uses);
+      VEC_free (tree, heap, build_v_must_defs);
+      VEC_free (tree, heap, build_v_may_defs);
+      VEC_free (tree, heap, build_vuses);
+    }
+  gimple_ssa_operands (cfun)->free_defs = NULL;
+  gimple_ssa_operands (cfun)->free_uses = NULL;
+  gimple_ssa_operands (cfun)->free_vuses = NULL;
+  gimple_ssa_operands (cfun)->free_maydefs = NULL;
+  gimple_ssa_operands (cfun)->free_mustdefs = NULL;
+  while ((ptr = gimple_ssa_operands (cfun)->operand_memory) != NULL)
     {
-      operand_memory = operand_memory->next;
+      gimple_ssa_operands (cfun)->operand_memory
+       = gimple_ssa_operands (cfun)->operand_memory->next;
       ggc_free (ptr);
     }
 
-  ops_active = false;
+  gimple_ssa_operands (cfun)->ops_active = false;
   
   if (dump_file && (dump_flags & TDF_STATS))
     {
@@ -311,16 +311,18 @@ static inline void *
 ssa_operand_alloc (unsigned size)
 {
   char *ptr;
-  if (operand_memory_index + size >= SSA_OPERAND_MEMORY_SIZE)
+  if (gimple_ssa_operands (cfun)->operand_memory_index + size
+        >= SSA_OPERAND_MEMORY_SIZE)
     {
       struct ssa_operand_memory_d *ptr;
       ptr = GGC_NEW (struct ssa_operand_memory_d);
-      ptr->next = operand_memory;
-      operand_memory = ptr;
-      operand_memory_index = 0;
+      ptr->next = gimple_ssa_operands (cfun)->operand_memory;
+      gimple_ssa_operands (cfun)->operand_memory = ptr;
+      gimple_ssa_operands (cfun)->operand_memory_index = 0;
     }
-  ptr = &(operand_memory->mem[operand_memory_index]);
-  operand_memory_index += size;
+  ptr = &(gimple_ssa_operands (cfun)->operand_memory
+         ->mem[gimple_ssa_operands (cfun)->operand_memory_index]);
+  gimple_ssa_operands (cfun)->operand_memory_index += size;
   return ptr;
 }
 
@@ -366,8 +368,9 @@ set_virtual_use_link (use_operand_p ptr, tree stmt)
   do                                                   \
     {                                                  \
       TYPE##_optype_p next = (OP)->next;               \
-      (OP)->next = free_##TYPE##s;                     \
-      free_##TYPE##s = (OP);                           \
+      (OP)->next                                       \
+        = gimple_ssa_operands (cfun)->free_##TYPE##s;  \
+      gimple_ssa_operands (cfun)->free_##TYPE##s = (OP);\
       (OP) = next;                                     \
     } while (0)
 
@@ -503,8 +506,8 @@ finalize_ssa_def_ops (tree stmt)
   /* If there is anything in the old list, free it.  */
   if (old_ops)
     {
-      old_ops->next = free_defs;
-      free_defs = old_ops;
+      old_ops->next = gimple_ssa_operands (cfun)->free_defs;
+      gimple_ssa_operands (cfun)->free_defs = old_ops;
     }
 
   /* Now set the stmt's operands.  */
@@ -558,8 +561,8 @@ finalize_ssa_use_ops (tree stmt)
     {
       for (ptr = old_ops; ptr; ptr = ptr->next)
        delink_imm_use (USE_OP_PTR (ptr));
-      old_ops->next = free_uses;
-      free_uses = old_ops;
+      old_ops->next = gimple_ssa_operands (cfun)->free_uses;
+      gimple_ssa_operands (cfun)->free_uses = old_ops;
     }
 
   /* Now create nodes for all the new nodes.  */
@@ -661,8 +664,8 @@ finalize_ssa_v_may_def_ops (tree stmt)
     {
       for (ptr = old_ops; ptr; ptr = ptr->next)
        delink_imm_use (MAYDEF_OP_PTR (ptr));
-      old_ops->next = free_maydefs;
-      free_maydefs = old_ops;
+      old_ops->next = gimple_ssa_operands (cfun)->free_maydefs;
+      gimple_ssa_operands (cfun)->free_maydefs = old_ops;
     }
 
   /* Now set the stmt's operands.  */
@@ -763,8 +766,8 @@ finalize_ssa_vuse_ops (tree stmt)
     {
       for (ptr = old_ops; ptr; ptr = ptr->next)
        delink_imm_use (VUSE_OP_PTR (ptr));
-      old_ops->next = free_vuses;
-      free_vuses = old_ops;
+      old_ops->next = gimple_ssa_operands (cfun)->free_vuses;
+      gimple_ssa_operands (cfun)->free_vuses = old_ops;
     }
 
   /* Now set the stmt's operands.  */
@@ -904,8 +907,8 @@ finalize_ssa_v_must_def_ops (tree stmt)
     {
       for (ptr = old_ops; ptr; ptr = ptr->next)
        delink_imm_use (MUSTDEF_KILL_PTR (ptr));
-      old_ops->next = free_mustdefs;
-      free_mustdefs = old_ops;
+      old_ops->next = gimple_ssa_operands (cfun)->free_mustdefs;
+      gimple_ssa_operands (cfun)->free_mustdefs = old_ops;
     }
 
   /* Now set the stmt's operands.  */
@@ -2582,5 +2585,3 @@ debug_immediate_uses_for (tree var)
 {
   dump_immediate_uses_for (stderr, var);
 }
-
-#include "gt-tree-ssa-operands.h"
index daf2dce..aecbcdc 100644 (file)
@@ -88,6 +88,19 @@ struct ssa_operand_memory_d GTY((chain_next("%h.next")))
   char mem[SSA_OPERAND_MEMORY_SIZE];
 };
 
+/* Per-function operand caches.  */
+struct ssa_operands GTY(()) {
+   struct ssa_operand_memory_d *operand_memory;
+   unsigned operand_memory_index;
+
+   bool ops_active;
+
+   struct def_optype_d * GTY ((skip (""))) free_defs;
+   struct use_optype_d * GTY ((skip (""))) free_uses;
+   struct vuse_optype_d * GTY ((skip (""))) free_vuses;
+   struct maydef_optype_d * GTY ((skip (""))) free_maydefs;
+   struct mustdef_optype_d * GTY ((skip (""))) free_mustdefs;
+};
 
 /* This represents the operand cache for a stmt.  */
 struct stmt_operands_d