Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / graphite.c
index b013447..7511527 100644 (file)
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
 
 This file is part of GCC.
@@ -33,6 +33,17 @@ along with GCC; see the file COPYING3.  If not see
    the functions that are used for transforming the code.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/options.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#include <cloog/isl/cloog.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
@@ -47,8 +58,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef HAVE_cloog
 
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 #include "graphite-scop-detection.h"
 #include "graphite-clast-to-gimple.h"
@@ -87,7 +96,7 @@ print_global_statistics (FILE* file)
          n_p_loops += bb->count;
        }
 
-      if (VEC_length (edge, bb->succs) > 1)
+      if (EDGE_COUNT (bb->succs) > 1)
        {
          n_conditions++;
          n_p_conditions += bb->count;
@@ -139,7 +148,7 @@ print_graphite_scop_statistics (FILE* file, scop_p scop)
       n_bbs++;
       n_p_bbs += bb->count;
 
-      if (VEC_length (edge, bb->succs) > 1)
+      if (EDGE_COUNT (bb->succs) > 1)
        {
          n_conditions++;
          n_p_conditions += bb->count;
@@ -173,23 +182,21 @@ print_graphite_scop_statistics (FILE* file, scop_p scop)
 /* Print statistics for SCOPS to FILE.  */
 
 static void
-print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops)
+print_graphite_statistics (FILE* file, vec<scop_p> scops)
 {
   int i;
 
   scop_p scop;
 
-  FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
+  FOR_EACH_VEC_ELT (scops, i, scop)
     print_graphite_scop_statistics (file, scop);
 }
 
 /* Initialize graphite: when there are no loops returns false.  */
 
 static bool
-graphite_initialize (void)
+graphite_initialize (isl_ctx *ctx)
 {
-  int ppl_initialized;
-
   if (number_of_loops () <= 1
       /* FIXME: This limit on the number of basic blocks of a function
         should be removed when the SCOP detection is faster.  */
@@ -198,6 +205,7 @@ graphite_initialize (void)
       if (dump_file && (dump_flags & TDF_DETAILS))
        print_global_statistics (dump_file);
 
+      isl_ctx_free (ctx);
       return false;
     }
 
@@ -205,11 +213,7 @@ graphite_initialize (void)
   recompute_all_dominators ();
   initialize_original_copy_tables ();
 
-  ppl_initialized = ppl_initialize ();
-  gcc_assert (ppl_initialized == 0);
-
-  cloog_state = cloog_state_malloc ();
-  cloog_initialize ();
+  cloog_state = cloog_isl_state_malloc (ctx);
 
   if (dump_file && dump_flags)
     dump_function_to_file (current_function_decl, dump_file, dump_flags);
@@ -233,14 +237,14 @@ graphite_finalize (bool need_cfg_cleanup_p)
     }
 
   cloog_state_free (cloog_state);
-  cloog_finalize ();
-  ppl_finalize ();
   free_original_copy_tables ();
 
   if (dump_file && dump_flags)
     print_loops (dump_file, 3);
 }
 
+isl_ctx *the_isl_ctx;
+
 /* Perform a set of linear transforms on the loops of the current
    function.  */
 
@@ -250,12 +254,21 @@ graphite_transform_loops (void)
   int i;
   scop_p scop;
   bool need_cfg_cleanup_p = false;
-  VEC (scop_p, heap) *scops = NULL;
+  vec<scop_p> scops = vNULL;
   htab_t bb_pbb_mapping;
+  isl_ctx *ctx;
+
+  /* If a function is parallel it was most probably already run through graphite
+     once. No need to run again.  */
+  if (parallelized_function_p (cfun->decl))
+    return;
 
-  if (!graphite_initialize ())
+  ctx = isl_ctx_alloc ();
+  isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT);
+  if (!graphite_initialize (ctx))
     return;
 
+  the_isl_ctx = ctx;
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -266,9 +279,10 @@ graphite_transform_loops (void)
 
   bb_pbb_mapping = htab_create (10, bb_pbb_map_hash, eq_bb_pbb_map, free);
 
-  FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
+  FOR_EACH_VEC_ELT (scops, i, scop)
     if (dbg_cnt (graphite_scop))
       {
+       scop->ctx = ctx;
        build_poly_scop (scop);
 
        if (POLY_SCOP_P (scop)
@@ -280,6 +294,8 @@ graphite_transform_loops (void)
   htab_delete (bb_pbb_mapping);
   free_scops (scops);
   graphite_finalize (need_cfg_cleanup_p);
+  the_isl_ctx = NULL;
+  isl_ctx_free (ctx);
 }
 
 #else /* If Cloog is not available: #ifndef HAVE_cloog.  */