OSDN Git Service

compiler: No error if shift operand inherits interface type.
[pf3gnuchains/gcc-fork.git] / gcc / sese.h
index 73d5ade..7c6a9c6 100644 (file)
@@ -1,5 +1,6 @@
 /* Single entry single exit control flow regions.
-   Copyright (C) 2008, 2009  Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Jan Sjodin <jan.sjodin@amd.com> and
    Sebastian Pop <sebastian.pop@amd.com>.
 
@@ -32,12 +33,6 @@ typedef struct sese_s
   /* Parameters used within the SCOP.  */
   VEC (tree, heap) *params;
 
-  /* Used to quickly retrieve the index of a parameter in PARAMS.  */
-  htab_t params_index;
-
-  /* Store the names of the parameters that are passed to CLooG.  */
-  char **params_names;
-
   /* Loops completely contained in the SCOP.  */
   bitmap loops;
   VEC (loop_p, heap) *loop_nest;
@@ -53,8 +48,6 @@ typedef struct sese_s
 #define SESE_EXIT(S) (S->exit)
 #define SESE_EXIT_BB(S) (S->exit->dest)
 #define SESE_PARAMS(S) (S->params)
-#define SESE_PARAMS_INDEX(S) (S->params_index)
-#define SESE_PARAMS_NAMES(S) (S->params_names)
 #define SESE_LOOPS(S) (S->loops)
 #define SESE_LOOP_NEST(S) (S->loop_nest)
 #define SESE_ADD_PARAMS(S) (S->add_params)
@@ -62,9 +55,9 @@ typedef struct sese_s
 extern sese new_sese (edge, edge);
 extern void free_sese (sese);
 extern void sese_insert_phis_for_liveouts (sese, basic_block, edge, edge);
-extern void sese_adjust_liveout_phis (sese, htab_t, basic_block, edge, edge);
 extern void build_sese_loop_nests (sese);
-extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge, htab_t);
+extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge,
+                                           VEC (tree, heap) *, bool *);
 extern struct loop *outermost_loop_in_sese (sese, basic_block);
 extern void insert_loop_close_phis (htab_t, loop_p);
 extern void insert_guard_phis (basic_block, edge, edge, htab_t, htab_t);
@@ -101,10 +94,6 @@ bb_in_region (basic_block bb, basic_block entry, basic_block exit)
        predecessors of EXIT are dominated by ENTRY.  */
     FOR_EACH_EDGE (e, ei, exit->preds)
       dominated_by_p (CDI_DOMINATORS, e->src, entry);
-    /* Check that there are no edges going out of the region: the
-       entry is post-dominated by the exit.  FIXME: This cannot be
-       checked right now as the CDI_POST_DOMINATORS are needed.  */
   }
 #endif
 
@@ -125,20 +114,27 @@ bb_in_sese_p (basic_block bb, sese region)
   return bb_in_region (bb, entry, exit);
 }
 
+/* Returns true when STMT is defined in REGION.  */
+
+static inline bool
+stmt_in_sese_p (gimple stmt, sese region)
+{
+  basic_block bb = gimple_bb (stmt);
+  return bb && bb_in_sese_p (bb, region);
+}
+
 /* Returns true when NAME is defined in REGION.  */
 
 static inline bool
 defined_in_sese_p (tree name, sese region)
 {
   gimple stmt = SSA_NAME_DEF_STMT (name);
-  basic_block bb = gimple_bb (stmt);
-
-  return bb && bb_in_sese_p (bb, region);
+  return stmt_in_sese_p (stmt, region);
 }
 
 /* Returns true when LOOP is in REGION.  */
 
-static inline bool 
+static inline bool
 loop_in_sese_p (struct loop *loop, sese region)
 {
   return (bb_in_sese_p (loop->header, region)
@@ -153,7 +149,7 @@ loop_in_sese_p (struct loop *loop, sese region)
    loop_0
      loop_1
        {
-         S0 
+         S0
             <- region start
          S1
 
@@ -162,7 +158,7 @@ loop_in_sese_p (struct loop *loop, sese region)
 
          S3
             <- region end
-       } 
+       }
 
     loop_0 does not exist in the region -> invalid
     loop_1 exists, but is not completely contained in the region -> depth 0
@@ -222,105 +218,6 @@ block_before_sese (sese sese)
   return SESE_ENTRY (sese)->src;
 }
 
-/* Stores the INDEX in a vector for a given clast NAME.  */
-
-typedef struct clast_name_index {
-  int index;
-  const char *name;
-} *clast_name_index_p;
-
-/* Returns a pointer to a new element of type clast_name_index_p built
-   from NAME and INDEX.  */
-
-static inline clast_name_index_p
-new_clast_name_index (const char *name, int index)
-{
-  clast_name_index_p res = XNEW (struct clast_name_index);
-
-  res->name = name;
-  res->index = index;
-  return res;
-}
-
-/* For a given clast NAME, returns -1 if it does not correspond to any
-   parameter, or otherwise, returns the index in the PARAMS or
-   SCATTERING_DIMENSIONS vector.  */
-
-static inline int
-clast_name_to_index (const char *name, htab_t index_table)
-{
-  struct clast_name_index tmp;
-  PTR *slot;
-
-  tmp.name = name;
-  slot = htab_find_slot (index_table, &tmp, NO_INSERT);
-
-  if (slot && *slot)
-    return ((struct clast_name_index *) *slot)->index;
-
-  return -1;
-}
-
-/* Records in INDEX_TABLE the INDEX for NAME.  */
-
-static inline void
-save_clast_name_index (htab_t index_table, const char *name, int index)
-{
-  struct clast_name_index tmp;
-  PTR *slot;
-
-  tmp.name = name;
-  slot = htab_find_slot (index_table, &tmp, INSERT);
-
-  if (slot)
-    *slot = new_clast_name_index (name, index);
-}
-
-/* Print to stderr the element ELT.  */
-
-static inline void
-debug_clast_name_index (clast_name_index_p elt)
-{
-  fprintf (stderr, "(index = %d, name = %s)\n", elt->index, elt->name);
-}
-
-/* Helper function for debug_rename_map.  */
-
-static inline int
-debug_clast_name_indexes_1 (void **slot, void *s ATTRIBUTE_UNUSED)
-{
-  struct clast_name_index *entry = (struct clast_name_index *) *slot;
-  debug_clast_name_index (entry);
-  return 1;
-}
-
-/* Print to stderr all the elements of MAP.  */
-
-static inline void
-debug_clast_name_indexes (htab_t map)
-{
-  htab_traverse (map, debug_clast_name_indexes_1, NULL);
-}
-
-/* Computes a hash function for database element ELT.  */
-
-static inline hashval_t
-clast_name_index_elt_info (const void *elt)
-{
-  return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
-}
-
-/* Compares database elements E1 and E2.  */
-
-static inline int
-eq_clast_name_indexes (const void *e1, const void *e2)
-{
-  const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
-  const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
-
-  return (elt1->name == elt2->name);
-}
-
 \f
 
 /* A single entry single exit specialized for conditions.  */
@@ -332,10 +229,10 @@ typedef struct ifsese_s {
 } *ifsese;
 
 extern void if_region_set_false_region (ifsese, sese);
-extern ifsese create_if_region_on_edge (edge, tree);
 extern ifsese move_sese_in_condition (sese);
 extern edge get_true_edge_from_guard_bb (basic_block);
 extern edge get_false_edge_from_guard_bb (basic_block);
+extern void set_ifsese_condition (ifsese, tree);
 
 static inline edge
 if_region_entry (ifsese if_region)
@@ -368,7 +265,6 @@ DEF_VEC_ALLOC_P (rename_map_elt, heap);
 extern void debug_rename_map (htab_t);
 extern hashval_t rename_map_elt_info (const void *);
 extern int eq_rename_map_elts (const void *, const void *);
-extern void set_rename (htab_t, tree, tree);
 
 /* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW.  */
 
@@ -376,7 +272,7 @@ static inline rename_map_elt
 new_rename_map_elt (tree old_name, tree expr)
 {
   rename_map_elt res;
-  
+
   res = XNEW (struct rename_map_elt_s);
   res->old_name = old_name;
   res->expr = expr;
@@ -402,7 +298,7 @@ static inline ivtype_map_elt
 new_ivtype_map_elt (const char *cloog_iv, tree type)
 {
   ivtype_map_elt res;
-  
+
   res = XNEW (struct ivtype_map_elt_s);
   res->cloog_iv = cloog_iv;
   res->type = type;
@@ -417,31 +313,30 @@ recompute_all_dominators (void)
 {
   mark_irreducible_loops ();
   free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
   calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
 }
 
 typedef struct gimple_bb
 {
   basic_block bb;
+  struct poly_bb *pbb;
 
   /* Lists containing the restrictions of the conditional statements
      dominating this bb.  This bb can only be executed, if all conditions
      are true.
+
      Example:
+
      for (i = 0; i <= 20; i++)
      {
        A
+
        if (2i <= 8)
          B
      }
+
      So for B there is an additional condition (2i <= 8).
+
      List of COND_EXPR and SWITCH_EXPR.  A COND_EXPR is true only if the
      corresponding element in CONDITION_CASES is not NULL_TREE.  For a
      SWITCH_EXPR the corresponding element in CONDITION_CASES is a
@@ -449,14 +344,13 @@ typedef struct gimple_bb
   VEC (gimple, heap) *conditions;
   VEC (gimple, heap) *condition_cases;
   VEC (data_reference_p, heap) *data_refs;
-  htab_t cloog_iv_types;
 } *gimple_bb_p;
 
-#define GBB_BB(GBB) GBB->bb
-#define GBB_DATA_REFS(GBB) GBB->data_refs
-#define GBB_CONDITIONS(GBB) GBB->conditions
-#define GBB_CONDITION_CASES(GBB) GBB->condition_cases
-#define GBB_CLOOG_IV_TYPES(GBB) GBB->cloog_iv_types
+#define GBB_BB(GBB) (GBB)->bb
+#define GBB_PBB(GBB) (GBB)->pbb
+#define GBB_DATA_REFS(GBB) (GBB)->data_refs
+#define GBB_CONDITIONS(GBB) (GBB)->conditions
+#define GBB_CONDITION_CASES(GBB) (GBB)->condition_cases
 
 /* Return the innermost loop that contains the basic block GBB.  */
 
@@ -466,7 +360,7 @@ gbb_loop (struct gimple_bb *gbb)
   return GBB_BB (gbb)->loop_father;
 }
 
-/* Returns the gimple loop, that corresponds to the loop_iterator_INDEX.  
+/* Returns the gimple loop, that corresponds to the loop_iterator_INDEX.
    If there is no corresponding gimple loop, we return NULL.  */
 
 static inline loop_p
@@ -491,11 +385,38 @@ nb_common_loops (sese region, gimple_bb_p gbb1, gimple_bb_p gbb2)
   loop_p l1 = gbb_loop (gbb1);
   loop_p l2 = gbb_loop (gbb2);
   loop_p common = find_common_loop (l1, l2);
-  
+
   return sese_loop_depth (region, common);
 }
 
-extern void print_gimple_bb (FILE *, gimple_bb_p, int, int);
-extern void debug_gbb (gimple_bb_p, int);
+/* Return true when DEF can be analyzed in REGION by the scalar
+   evolution analyzer.  */
+
+static inline bool
+scev_analyzable_p (tree def, sese region)
+{
+  loop_p loop;
+  tree scev;
+  tree type = TREE_TYPE (def);
+
+  /* When Graphite generates code for a scev, the code generator
+     expresses the scev in function of a single induction variable.
+     This is unsafe for floating point computations, as it may replace
+     a floating point sum reduction with a multiplication.  The
+     following test returns false for non integer types to avoid such
+     problems.  */
+  if (!INTEGRAL_TYPE_P (type)
+      && !POINTER_TYPE_P (type))
+    return false;
+
+  loop = loop_containing_stmt (SSA_NAME_DEF_STMT (def));
+  scev = scalar_evolution_in_region (region, loop, def);
+
+  return !chrec_contains_undetermined (scev)
+    && (TREE_CODE (scev) != SSA_NAME
+       || !defined_in_sese_p (scev, region))
+    && (tree_does_not_contain_chrecs (scev)
+       || evolution_function_is_affine_p (scev));
+}
 
 #endif