OSDN Git Service

2009-06-16 Olatunji Ruwase <tjruwase@google.com>
[pf3gnuchains/gcc-fork.git] / gcc / graphite.c
index 58b67f4..90e11ac 100644 (file)
@@ -56,6 +56,13 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple.h"
 
 #ifdef HAVE_cloog
+
+/* The CLooG header file is not -Wc++-compat ready as of 2009-05-11.
+   This #pragma should be removed when it is ready.  */
+#if GCC_VERSION >= 4003
+#pragma GCC diagnostic warning "-Wc++-compat"
+#endif
+
 #include "cloog/cloog.h"
 #include "graphite.h"
 
@@ -174,7 +181,7 @@ register_bb_in_sese (basic_block entry_bb, basic_block exit_bb, sese region)
 sese
 new_sese (edge entry, edge exit)
 {
-  sese res = XNEW (struct sese);
+  sese res = XNEW (struct sese_d);
 
   SESE_ENTRY (res) = entry;
   SESE_EXIT (res) = exit;
@@ -267,7 +274,7 @@ static void
 loop_iv_stack_push_iv (loop_iv_stack stack, tree iv, const char *name)
 {
   iv_stack_entry *entry = XNEW (iv_stack_entry);
-  name_tree named_iv = XNEW (struct name_tree);
+  name_tree named_iv = XNEW (struct name_tree_d);
 
   named_iv->t = iv;
   named_iv->name = name;
@@ -389,7 +396,7 @@ free_loop_iv_stack (loop_iv_stack stack)
 
 /* Structure containing the mapping between the CLooG's induction
    variable and the type of the old induction variable.  */
-typedef struct ivtype_map_elt
+typedef struct ivtype_map_elt_d
 {
   tree type;
   const char *cloog_iv;
@@ -410,7 +417,7 @@ debug_ivtype_elt (ivtype_map_elt elt)
 static int
 debug_ivtype_map_1 (void **slot, void *s ATTRIBUTE_UNUSED)
 {
-  struct ivtype_map_elt *entry = (struct ivtype_map_elt *) *slot;
+  struct ivtype_map_elt_d *entry = (struct ivtype_map_elt_d *) *slot;
   debug_ivtype_elt (entry);
   return 1;
 }
@@ -430,7 +437,7 @@ new_ivtype_map_elt (const char *cloog_iv, tree type)
 {
   ivtype_map_elt res;
   
-  res = XNEW (struct ivtype_map_elt);
+  res = XNEW (struct ivtype_map_elt_d);
   res->cloog_iv = cloog_iv;
   res->type = type;
 
@@ -442,7 +449,7 @@ new_ivtype_map_elt (const char *cloog_iv, tree type)
 static hashval_t
 ivtype_map_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct ivtype_map_elt *) elt)->cloog_iv);
+  return htab_hash_pointer (((const struct ivtype_map_elt_d *) elt)->cloog_iv);
 }
 
 /* Compares database elements E1 and E2.  */
@@ -450,8 +457,8 @@ ivtype_map_elt_info (const void *elt)
 static int
 eq_ivtype_map_elts (const void *e1, const void *e2)
 {
-  const struct ivtype_map_elt *elt1 = (const struct ivtype_map_elt *) e1;
-  const struct ivtype_map_elt *elt2 = (const struct ivtype_map_elt *) e2;
+  const struct ivtype_map_elt_d *elt1 = (const struct ivtype_map_elt_d *) e1;
+  const struct ivtype_map_elt_d *elt2 = (const struct ivtype_map_elt_d *) e2;
 
   return (elt1->cloog_iv == elt2->cloog_iv);
 }
@@ -465,7 +472,7 @@ eq_ivtype_map_elts (const void *e1, const void *e2)
 static tree
 gcc_type_for_cloog_iv (const char *cloog_iv, graphite_bb_p gbb)
 {
-  struct ivtype_map_elt tmp;
+  struct ivtype_map_elt_d tmp;
   PTR *slot;
 
   tmp.cloog_iv = cloog_iv;
@@ -1058,31 +1065,24 @@ loop_affine_expr (basic_block scop_entry, struct loop *loop, tree expr)
          || evolution_function_is_affine_multivariate_p (scev, n));
 }
 
-/* Return false if the tree_code of the operand OP or any of its operands
-   is component_ref.  */
+/* Return true if REF or any of its subtrees contains a
+   component_ref.  */
 
 static bool
-exclude_component_ref (tree op) 
+contains_component_ref_p (tree ref)
 {
-  int i;
-  int len;
+  if (!ref)
+    return false;
 
-  if (op)
+  while (handled_component_p (ref))
     {
-      if (TREE_CODE (op) == COMPONENT_REF)
-       return false;
-      else
-       {
-         len = TREE_OPERAND_LENGTH (op);         
-         for (i = 0; i < len; ++i)
-           {
-             if (!exclude_component_ref (TREE_OPERAND (op, i)))
-               return false;
-           }
-       }
+      if (TREE_CODE (ref) == COMPONENT_REF)
+       return true;
+
+      ref = TREE_OPERAND (ref, 0);
     }
 
-  return true;
+  return false;
 }
 
 /* Return true if the operand OP is simple.  */
@@ -1094,13 +1094,15 @@ is_simple_operand (loop_p loop, gimple stmt, tree op)
   if (DECL_P (op)
       /* or a structure,  */
       || AGGREGATE_TYPE_P (TREE_TYPE (op))
+      /* or a COMPONENT_REF,  */
+      || contains_component_ref_p (op)
       /* or a memory access that cannot be analyzed by the data
         reference analysis.  */
       || ((handled_component_p (op) || INDIRECT_REF_P (op))
          && !stmt_simple_memref_p (loop, stmt, op)))
     return false;
 
-  return exclude_component_ref (op);
+  return true;
 }
 
 /* Return true only when STMT is simple enough for being handled by
@@ -1337,7 +1339,7 @@ free_graphite_bb (struct graphite_bb *gbb)
 
 /* Structure containing the mapping between the old names and the new
    names used after block copy in the new loop context.  */
-typedef struct rename_map_elt
+typedef struct rename_map_elt_d
 {
   tree old_name, new_name;
 } *rename_map_elt;
@@ -1360,7 +1362,7 @@ debug_rename_elt (rename_map_elt elt)
 static int
 debug_rename_map_1 (void **slot, void *s ATTRIBUTE_UNUSED)
 {
-  struct rename_map_elt *entry = (struct rename_map_elt *) *slot;
+  struct rename_map_elt_d *entry = (struct rename_map_elt_d *) *slot;
   debug_rename_elt (entry);
   return 1;
 }
@@ -1380,7 +1382,7 @@ new_rename_map_elt (tree old_name, tree new_name)
 {
   rename_map_elt res;
   
-  res = XNEW (struct rename_map_elt);
+  res = XNEW (struct rename_map_elt_d);
   res->old_name = old_name;
   res->new_name = new_name;
 
@@ -1392,7 +1394,7 @@ new_rename_map_elt (tree old_name, tree new_name)
 static hashval_t
 rename_map_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct rename_map_elt *) elt)->old_name);
+  return htab_hash_pointer (((const struct rename_map_elt_d *) elt)->old_name);
 }
 
 /* Compares database elements E1 and E2.  */
@@ -1400,8 +1402,8 @@ rename_map_elt_info (const void *elt)
 static int
 eq_rename_map_elts (const void *e1, const void *e2)
 {
-  const struct rename_map_elt *elt1 = (const struct rename_map_elt *) e1;
-  const struct rename_map_elt *elt2 = (const struct rename_map_elt *) e2;
+  const struct rename_map_elt_d *elt1 = (const struct rename_map_elt_d *) e1;
+  const struct rename_map_elt_d *elt2 = (const struct rename_map_elt_d *) e2;
 
   return (elt1->old_name == elt2->old_name);
 }
@@ -1411,7 +1413,7 @@ eq_rename_map_elts (const void *e1, const void *e2)
 static tree
 get_new_name_from_old_name (htab_t map, tree old_name)
 {
-  struct rename_map_elt tmp;
+  struct rename_map_elt_d tmp;
   PTR *slot;
 
   tmp.old_name = old_name;
@@ -2417,7 +2419,7 @@ scop_record_loop (scop_p scop, loop_p loop)
   if (!induction_var)
     return false;
 
-  oldiv = XNEW (struct name_tree);
+  oldiv = XNEW (struct name_tree_d);
   oldiv->t = induction_var;
   oldiv->name = get_name (SSA_NAME_VAR (oldiv->t));
   oldiv->loop = loop;
@@ -2662,7 +2664,7 @@ param_index (tree var, scop_p scop)
 
   gcc_assert (SCOP_ADD_PARAMS (scop));
 
-  nvar = XNEW (struct name_tree);
+  nvar = XNEW (struct name_tree_d);
   nvar->t = var;
   nvar->name = NULL;
   VEC_safe_push (name_tree, heap, SCOP_PARAMS (scop), nvar);
@@ -3222,7 +3224,7 @@ add_conditions_to_domain (graphite_bb_p gb)
               }
           break;
           }
-        case SWITCH_EXPR:
+        case GIMPLE_SWITCH:
           /* Switch statements are not supported right know.  */
           gcc_unreachable ();
           break;
@@ -4124,7 +4126,7 @@ rename_variables_in_stmt (gimple stmt, htab_t map)
   ssa_op_iter iter;
   use_operand_p use_p;
 
-  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
+  FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
     {
       tree use = USE_FROM_PTR (use_p);
       tree new_name = get_new_name_from_old_name (map, use);
@@ -4243,8 +4245,6 @@ expand_scalar_variables_expr (tree type, tree op0, enum tree_code code,
            tree new_name = force_gimple_operand_gsi (gsi, expr, true, NULL,
                                                      true, GSI_SAME_STMT);
 
-           set_symbol_mem_tag (SSA_NAME_VAR (new_name),
-                               symbol_mem_tag (SSA_NAME_VAR (old_name)));
            return fold_build1 (code, type, new_name);
          }
 
@@ -4428,7 +4428,7 @@ build_iv_mapping (loop_iv_stack ivstack, htab_t map, gbb_p gbb, scop_p scop)
 
   for (i = 0; VEC_iterate (name_tree, SCOP_OLDIVS (scop), i, iv); i++)
     {
-      struct rename_map_elt tmp;
+      struct rename_map_elt_d tmp;
 
       if (!flow_bb_inside_loop_p (iv->loop, GBB_BB (gbb)))
        continue;
@@ -4450,7 +4450,7 @@ build_iv_mapping (loop_iv_stack ivstack, htab_t map, gbb_p gbb, scop_p scop)
 static void
 register_old_and_new_names (htab_t map, tree old_name, tree new_name)
 {
-  struct rename_map_elt tmp;
+  struct rename_map_elt_d tmp;
   PTR *slot;
 
   tmp.old_name = old_name;
@@ -4484,7 +4484,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t map)
         operands.  */
       copy = gimple_copy (stmt);
       gsi_insert_after (&gsi_tgt, copy, GSI_NEW_STMT);
-      mark_symbols_for_renaming (copy);
+      mark_sym_for_renaming (gimple_vop (cfun));
 
       region = lookup_stmt_eh_region (stmt);
       if (region >= 0)
@@ -4493,7 +4493,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t map)
 
       /* Create new names for all the definitions created by COPY and
         add replacement mappings for each new name.  */
-      FOR_EACH_SSA_DEF_OPERAND (def_p, copy, op_iter, SSA_OP_DEF)
+      FOR_EACH_SSA_DEF_OPERAND (def_p, copy, op_iter, SSA_OP_ALL_DEFS)
        {
          tree old_name = DEF_FROM_PTR (def_p);
          tree new_name = create_new_def_for (old_name, copy, def_p);
@@ -4549,7 +4549,7 @@ copy_bb_and_scalar_dependences (basic_block bb, scop_p scop,
 static int
 add_loop_exit_phis (void **slot, void *s)
 {
-  struct rename_map_elt *entry = (struct rename_map_elt *) *slot;
+  struct rename_map_elt_d *entry = (struct rename_map_elt_d *) *slot;
   tree new_name = entry->new_name;
   basic_block bb = (basic_block) s;
   gimple phi = create_phi_node (new_name, bb);
@@ -4606,7 +4606,7 @@ default_liveout_before_guard (htab_t liveout_before_guard, tree old_name)
 static int
 add_guard_exit_phis (void **slot, void *s)
 {
-  struct rename_map_elt *entry = (struct rename_map_elt *) *slot;
+  struct rename_map_elt_d *entry = (struct rename_map_elt_d *) *slot;
   struct igp *i = (struct igp *) s;
   basic_block bb = i->bb;
   edge true_edge = i->true_edge;
@@ -4661,11 +4661,11 @@ insert_guard_phis (scop_p scop, basic_block bb, edge true_edge,
 static int
 copy_renames (void **slot, void *s)
 {
-  struct rename_map_elt *entry = (struct rename_map_elt *) *slot;
+  struct rename_map_elt_d *entry = (struct rename_map_elt_d *) *slot;
   htab_t res = (htab_t) s;
   tree old_name = entry->old_name;
   tree new_name = entry->new_name;
-  struct rename_map_elt tmp;
+  struct rename_map_elt_d tmp;
   PTR *x;
 
   tmp.old_name = old_name;
@@ -4713,8 +4713,8 @@ translate_clast (scop_p scop, struct loop *context_loop,
                                               next_e, map);
       htab_delete (map);
       loop_iv_stack_remove_constants (ivstack);
-      update_ssa (TODO_update_ssa);
       recompute_all_dominators ();
+      update_ssa (TODO_update_ssa);
       graphite_verify ();
       return translate_clast (scop, context_loop, stmt->next, next_e, ivstack);
     }
@@ -5009,7 +5009,8 @@ remove_sese_region (sese region)
   VEC_free (basic_block, heap, bbs);
 }
 
-typedef struct ifsese {
+typedef struct ifsese_d
+{
   sese region;
   sese true_region;
   sese false_region;
@@ -5083,10 +5084,10 @@ create_if_region_on_edge (edge entry, tree condition)
 {
   edge e;
   edge_iterator ei;
-  sese sese_region = GGC_NEW (struct sese);
-  sese true_region = GGC_NEW (struct sese);
-  sese false_region = GGC_NEW (struct sese);
-  ifsese if_region = GGC_NEW (struct ifsese);
+  sese sese_region = GGC_NEW (struct sese_d);
+  sese true_region = GGC_NEW (struct sese_d);
+  sese false_region = GGC_NEW (struct sese_d);
+  ifsese if_region = GGC_NEW (struct ifsese_d);
   edge exit = create_empty_if_region_on_edge (entry, condition);
 
   if_region->region = sese_region;
@@ -5369,7 +5370,7 @@ compute_cloog_iv_types_1 (graphite_bb_p gbb,
   for (t = user_stmt->substitutions; t; t = t->next, index++)
     {
       PTR *slot;
-      struct ivtype_map_elt tmp;
+      struct ivtype_map_elt_d tmp;
       struct clast_expr *expr = (struct clast_expr *) 
        ((struct clast_assignment *)t)->RHS;