public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [graphite] Move to cloog.org interface
@ 2011-08-10 23:09 Tobias Grosser
  2011-08-11  5:44 ` Sebastian Pop
  0 siblings, 1 reply; 58+ messages in thread
From: Tobias Grosser @ 2011-08-10 23:09 UTC (permalink / raw)
  To: gcc-patches, Sebastian Pop

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

Hi,

this patch moves the graphite code to the documented cloog library 
interface and removes the use of old/deprecated interfaces. It ensures 
that graphite will also compile flawless with future cloog.org versions.

   * graphite-clast-to-gimple.c (new_clast_name_index): Store a copy
   of the string, no just a reference.
   (clast_name_index): Add a new field, that specifies if we need to 
free the
   name.
   (free_clast_name_index): If necessary, free the name string.
   (clast_name_index_elt_info): Calculate the hash based on the string 
content,
   not the memory location it is stored in.
   (clast_name_to_level): Specify that we do not need to free the name.
   (clast_name_to_index): Dito.
   (clast_name_to_lb_ub): Dito.
   (eq_clast_name_indexes): Compare the strings, not their base pointers.
   (free_scattering): Removed.
   (initialize_cloog_names): Renamed to add_names_to_union_domain().
   (add_names_to_union_domain): Changed to work on a union_domain, 
instead of a
   CloogNames structure.
   (build_cloog_prog): Removed.
   (build_cloog_union_domain): New.
   (generate_cloog_input): New.
   (scop_to_clast): Use CloogInput instead of CloogProgram.
   (print_generated_program): Adapt to new scop_to_clast() and do not
   print the CloogProgram any more.
   (create_params_index): Removed, functionality integrated in
   add_names_to_union_domain().
   (gloog): Adapt to new scop_to_clast().
   * graphite-clast-to-gimple.h (scop_to_clast): Remove.

This patch depends on my previous patches [1], that remove supports for 
cloog-ppl (which does not implement the new interface).

Bootstrapped and 'make check RUNTESTFLAGS=graphite.exp' tested on Linux 
amd64. OK to commit, after support for cloog-ppl was removed?

Cheers
Tobi

[1] http://gcc.gnu.org/ml/gcc-patches/2011-07/msg01892.html

[-- Attachment #2: 0001-Move-to-new-Cloog-interface.patch --]
[-- Type: text/x-diff, Size: 19094 bytes --]

From f07adb059a8793378073a2f4b2a6d1702c56771b Mon Sep 17 00:00:00 2001
From: Tobias Grosser <tobias@grosser.es>
Date: Tue, 9 Aug 2011 18:26:28 +0100
Subject: [PATCH] Move to new Cloog interface.

  * graphite-clast-to-gimple.c (new_clast_name_index): Store a copy
  of the string, no just a reference.
  (clast_name_index): Add a new field, that specifies if we need to free the
  name.
  (free_clast_name_index): If necessary, free the name string.
  (clast_name_index_elt_info): Calculate the hash based on the string content,
  not the memory location it is stored in.
  (clast_name_to_level): Specify that we do not need to free the name.
  (clast_name_to_index): Dito.
  (clast_name_to_lb_ub): Dito.
  (eq_clast_name_indexes): Compare the strings, not their base pointers.
  (free_scattering): Removed.
  (initialize_cloog_names): Renamed to add_names_to_union_domain().
  (add_names_to_union_domain): Changed to work on a union_domain, instead of a
  CloogNames structure.
  (build_cloog_prog): Removed.
  (build_cloog_union_domain): New.
  (generate_cloog_input): New.
  (scop_to_clast): Use CloogInput instead of CloogProgram.
  (print_generated_program): Adapt to new scop_to_clast() and do not
  print the CloogProgram any more.
  (create_params_index): Removed, functionality integrated in
  add_names_to_union_domain().
  (gloog): Adapt to new scop_to_clast().
  * graphite-clast-to-gimple.h (scop_to_clast): Remove.
---
 gcc/graphite-clast-to-gimple.c |  321 +++++++++++++++-------------------------
 gcc/graphite-clast-to-gimple.h |    1 -
 2 files changed, 123 insertions(+), 199 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index c8c5024..7a8e89d 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -70,6 +70,9 @@ typedef struct clast_name_index {
   int level;
   mpz_t bound_one, bound_two;
   const char *name;
+  /* If free_name is set, the content of name was allocated by us and needs
+     to be freed.  */
+  char *free_name;
 } *clast_name_index_p;
 
 /* Returns a pointer to a new element of type clast_name_index_p built
@@ -80,8 +83,11 @@ new_clast_name_index (const char *name, int index, int level,
 		      mpz_t bound_one, mpz_t bound_two)
 {
   clast_name_index_p res = XNEW (struct clast_name_index);
+  char *new_name = XNEWVEC(char, strlen(name) + 1);
+  strcpy(new_name, name);
 
-  res->name = name;
+  res->name = new_name;
+  res->free_name = new_name;
   res->level = level;
   res->index = index;
   mpz_init (res->bound_one);
@@ -97,6 +103,8 @@ static void
 free_clast_name_index (void *ptr)
 {
   struct clast_name_index *c = (struct clast_name_index *) ptr;
+  if (c->free_name)
+    free(c->free_name);
   mpz_clear (c->bound_one);
   mpz_clear (c->bound_two);
   free (ptr);
@@ -115,6 +123,7 @@ clast_name_to_level (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -136,6 +145,7 @@ clast_name_to_index (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -158,6 +168,7 @@ clast_name_to_lb_ub (clast_name_p name, htab_t index_table, mpz_t bound_one,
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -181,6 +192,7 @@ save_clast_name_index (htab_t index_table, const char *name,
   PTR *slot;
 
   tmp.name = name;
+  tmp.free_name = NULL;
   slot = htab_find_slot (index_table, &tmp, INSERT);
 
   if (slot)
@@ -196,7 +208,16 @@ save_clast_name_index (htab_t index_table, const char *name,
 static inline hashval_t
 clast_name_index_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
+  const struct clast_name_index *e = ((const struct clast_name_index *) elt);
+  hashval_t hash = 0;
+
+  int length = strlen(e->name);
+  int i;
+
+  for (i = 0; i < length; ++i)
+    hash = hash | (e->name[i] << (i % 4));
+
+  return hash;
 }
 
 /* Compares database elements E1 and E2.  */
@@ -207,7 +228,7 @@ 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);
+  return strcmp(elt1->name, elt2->name) == 0;
 }
 
 \f
@@ -1230,77 +1251,69 @@ translate_clast (loop_p context_loop, struct clast_stmt *stmt, edge next_e,
 			  level, ip);
 }
 
-/* Free the SCATTERING domain list.  */
+/* Add parameter and iterator names to the CloogUnionDomain.  */
 
-static void
-free_scattering (CloogScatteringList *scattering)
-{
-  while (scattering)
-    {
-      CloogScattering *dom = scattering->scatt;
-      CloogScatteringList *next = scattering->next;
-
-      cloog_scattering_free (dom);
-      free (scattering);
-      scattering = next;
-    }
-}
-
-/* Initialize Cloog's parameter names from the names used in GIMPLE.
-   Initialize Cloog's iterator names, using 'graphite_iterator_%d'
-   from 0 to scop_nb_loops (scop).  */
-
-static void
-initialize_cloog_names (scop_p scop, CloogProgram *prog)
+static CloogUnionDomain *
+add_names_to_union_domain(scop_p scop, CloogUnionDomain *union_domain,
+			  int nb_scattering_dims, htab_t params_index)
 {
   sese region = SCOP_REGION (scop);
   int i;
   int nb_iterators = scop_max_loop_depth (scop);
-  int nb_scattering = prog->nb_scattdims;
   int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
-  char **iterators = XNEWVEC (char *, nb_iterators * 2);
-  char **scattering = XNEWVEC (char *, nb_scattering);
-  char **parameters= XNEWVEC (char *, nb_parameters);
+  mpz_t bound_one, bound_two;
 
-  prog->names = cloog_names_malloc ();
+  mpz_init (bound_one);
+  mpz_init (bound_two);
 
   for (i = 0; i < nb_parameters; i++)
     {
       tree param = VEC_index (tree, SESE_PARAMS (region), i);
       const char *name = get_name (param);
       int len;
+      char *parameter;
 
       if (!name)
 	name = "T";
 
       len = strlen (name);
       len += 17;
-      parameters[i] = XNEWVEC (char, len + 1);
-      snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
+      parameter = XNEWVEC (char, len + 1);
+      snprintf (parameter, len, "%s_%d", name, SSA_NAME_VERSION (param));
+      save_clast_name_index (params_index, parameter, i, i, bound_one,
+			     bound_two);
+      union_domain = cloog_union_domain_set_name(union_domain, CLOOG_PARAM, i,
+						 parameter);
+      compute_bounds_for_param (scop, i, bound_one, bound_two);
+      free(parameter);
     }
 
-  prog->names->nb_parameters = nb_parameters;
-  prog->names->parameters = parameters;
+  mpz_clear (bound_one);
+  mpz_clear (bound_two);
 
   for (i = 0; i < nb_iterators; i++)
     {
       int len = 4 + 16;
-      iterators[i] = XNEWVEC (char, len);
-      snprintf (iterators[i], len, "git_%d", i);
+      char *iterator;
+      iterator = XNEWVEC (char, len);
+      snprintf (iterator, len, "git_%d", i);
+      union_domain = cloog_union_domain_set_name(union_domain, CLOOG_ITER, i,
+						 iterator);
+      free(iterator);
     }
 
-  prog->names->nb_iterators = nb_iterators;
-  prog->names->iterators = iterators;
-
-  for (i = 0; i < nb_scattering; i++)
+  for (i = 0; i < nb_scattering_dims; i++)
     {
       int len = 5 + 16;
-      scattering[i] = XNEWVEC (char, len);
-      snprintf (scattering[i], len, "scat_%d", i);
+      char *scattering;
+      scattering = XNEWVEC (char, len);
+      snprintf (scattering, len, "scat_%d", i);
+      union_domain = cloog_union_domain_set_name(union_domain, CLOOG_SCAT, i,
+						 scattering);
+      free(scattering);
     }
 
-  prog->names->nb_scattering = nb_scattering;
-  prog->names->scattering = scattering;
+  return union_domain;
 }
 
 /* Initialize a CLooG input file.  */
@@ -1328,129 +1341,40 @@ init_cloog_input_file (int scop_number)
   return graphite_out_file;
 }
 
-/* Build cloog program for SCoP.  */
+/* Build cloog union domain for SCoP.  */
 
-static void
-build_cloog_prog (scop_p scop, CloogProgram *prog,
-                  CloogOptions *options)
+static CloogUnionDomain *
+build_cloog_union_domain(scop_p scop)
 {
   int i;
-  int max_nb_loops = scop_max_loop_depth (scop);
   poly_bb_p pbb;
-  CloogLoop *loop_list = NULL;
-  CloogBlockList *block_list = NULL;
-  CloogScatteringList *scattering = NULL;
-  int nbs = 2 * max_nb_loops + 1;
-  int *scaldims;
-
-  prog->context =
-    new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
-						 scop_nb_params (scop),
-						 cloog_state);
-  nbs = unify_scattering_dimensions (scop);
-  scaldims = (int *) xmalloc (nbs * (sizeof (int)));
-  prog->nb_scattdims = nbs;
-  initialize_cloog_names (scop, prog);
+
+  CloogUnionDomain *union_domain =
+    cloog_union_domain_alloc(scop_nb_params(scop));
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
-      CloogStatement *stmt;
-      CloogBlock *block;
-      CloogDomain *dom;
+      CloogDomain *domain;
+      CloogScattering *scattering;
 
       /* Dead code elimination: when the domain of a PBB is empty,
 	 don't generate code for the PBB.  */
       if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PBB_DOMAIN (pbb)))
 	continue;
 
-      /* Build the new statement and its block.  */
-      stmt = cloog_statement_alloc (cloog_state, pbb_index (pbb));
-      dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
+      domain = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
                                                          scop_nb_params (scop),
                                                          cloog_state);
-      block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
-      stmt->usr = pbb;
-
-      /* Build loop list.  */
-      {
-        CloogLoop *new_loop_list = cloog_loop_malloc (cloog_state);
-        new_loop_list->next = loop_list;
-        new_loop_list->domain = dom;
-        new_loop_list->block = block;
-        loop_list = new_loop_list;
-      }
 
-      /* Build block list.  */
-      {
-        CloogBlockList *new_block_list = cloog_block_list_malloc ();
+      scattering = new_Cloog_Scattering_from_ppl_Polyhedron
+	(PBB_TRANSFORMED_SCATTERING (pbb), scop_nb_params (scop),
+	 pbb_nb_scattering_transform (pbb), cloog_state);
 
-        new_block_list->next = block_list;
-        new_block_list->block = block;
-        block_list = new_block_list;
-      }
-
-      /* Build scattering list.  */
-      {
-        /* XXX: Replace with cloog_domain_list_alloc(), when available.  */
-        CloogScatteringList *new_scattering
-	  = (CloogScatteringList *) xmalloc (sizeof (CloogScatteringList));
-        ppl_Polyhedron_t scat;
-	CloogScattering *dom;
-
-	scat = PBB_TRANSFORMED_SCATTERING (pbb);
-        dom = new_Cloog_Scattering_from_ppl_Polyhedron
-          (scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb),
-           cloog_state);
-
-        new_scattering->next = scattering;
-        new_scattering->scatt = dom;
-        scattering = new_scattering;
-      }
+      union_domain = cloog_union_domain_add_domain(union_domain, "", domain,
+						   scattering, pbb);
     }
 
-  prog->loop = loop_list;
-  prog->blocklist = block_list;
-
-  for (i = 0; i < nbs; i++)
-    scaldims[i] = 0 ;
-
-  prog->scaldims = scaldims;
-
-  /* Extract scalar dimensions to simplify the code generation problem.  */
-  cloog_program_extract_scalars (prog, scattering, options);
-
-  /* Dump a .cloog input file, if requested.  This feature is only
-     enabled in the Graphite branch.  */
-  if (0)
-    {
-      static size_t file_scop_number = 0;
-      FILE *cloog_file = init_cloog_input_file (file_scop_number);
-
-      cloog_program_dump_cloog (cloog_file, prog, scattering);
-      ++file_scop_number;
-    }
-
-  /* Apply scattering.  */
-  cloog_program_scatter (prog, scattering, options);
-  free_scattering (scattering);
-
-  /* Iterators corresponding to scalar dimensions have to be extracted.  */
-  cloog_names_scalarize (prog->names, nbs, prog->scaldims);
-
-  /* Free blocklist.  */
-  {
-    CloogBlockList *next = prog->blocklist;
-
-    while (next)
-      {
-        CloogBlockList *toDelete = next;
-        next = next->next;
-        toDelete->next =  NULL;
-        toDelete->block = NULL;
-        cloog_block_list_free (toDelete);
-      }
-    prog->blocklist = NULL;
-  }
+  return union_domain;
 }
 
 /* Return the options that will be used in GLOOG.  */
@@ -1515,24 +1439,52 @@ debug_clast_stmt (struct clast_stmt *stmt)
   print_clast_stmt (stderr, stmt);
 }
 
+static CloogInput *
+generate_cloog_input (scop_p scop, htab_t params_index)
+{
+  CloogUnionDomain *union_domain;
+  CloogInput *cloog_input;
+  CloogDomain *context;
+
+  int nb_scattering_dims = unify_scattering_dimensions (scop);
+  union_domain = build_cloog_union_domain (scop);
+  union_domain = add_names_to_union_domain(scop, union_domain,
+					   nb_scattering_dims,
+					   params_index);
+  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
+    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
+
+  cloog_input = cloog_input_alloc(context, union_domain);
+
+  return cloog_input;
+}
+
 /* Translate SCOP to a CLooG program and clast.  These two
    representations should be freed together: a clast cannot be used
    without a program.  */
 
-cloog_prog_clast
-scop_to_clast (scop_p scop)
+static struct clast_stmt *
+scop_to_clast (scop_p scop, htab_t params_index)
 {
+  CloogInput *cloog_input;
+  struct clast_stmt *clast;
   CloogOptions *options = set_cloog_options ();
-  cloog_prog_clast pc;
 
-  /* Connect new cloog prog generation to graphite.  */
-  pc.prog = cloog_program_malloc ();
-  build_cloog_prog (scop, pc.prog, options);
-  pc.prog = cloog_program_generate (pc.prog, options);
-  pc.stmt = cloog_clast_create (pc.prog, options);
+  cloog_input = generate_cloog_input(scop, params_index);
+
+  /* Dump a .cloog input file, if requested.  This feature is only
+   * enabled in the Graphite branch.  */
+  if (0)
+  {
+    static size_t file_scop_number = 0;
+    FILE *cloog_file = init_cloog_input_file (file_scop_number);
+    cloog_input_dump_cloog(cloog_file, cloog_input, options);
+  }
+
+  clast = cloog_clast_create_from_input(cloog_input, options);
 
   cloog_options_free (options);
-  return pc;
+  return clast;
 }
 
 /* Prints to FILE the code generated by CLooG for SCOP.  */
@@ -1541,20 +1493,20 @@ void
 print_generated_program (FILE *file, scop_p scop)
 {
   CloogOptions *options = set_cloog_options ();
+  htab_t params_index;
+  struct clast_stmt *clast;
 
-  cloog_prog_clast pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+            eq_clast_name_indexes, free_clast_name_index);
 
-  fprintf (file, "       (prog: \n");
-  cloog_program_print (file, pc.prog);
-  fprintf (file, "       )\n");
+  clast = scop_to_clast (scop, params_index);
 
   fprintf (file, "       (clast: \n");
-  clast_pprint (file, pc.stmt, 0, options);
+  clast_pprint (file, clast, 0, options);
   fprintf (file, "       )\n");
 
   cloog_options_free (options);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
 }
 
 /* Prints to STDERR the code generated by CLooG for SCOP.  */
@@ -1565,31 +1517,6 @@ debug_generated_program (scop_p scop)
   print_generated_program (stderr, scop);
 }
 
-/* Add CLooG names to parameter index.  The index is used to translate
-   back from CLooG names to GCC trees.  */
-
-static void
-create_params_index (scop_p scop, htab_t index_table, CloogProgram *prog) {
-  CloogNames* names = prog->names;
-  int nb_parameters = names->nb_parameters;
-  char **parameters = names->parameters;
-  int i;
-  mpz_t bound_one, bound_two;
-
-  mpz_init (bound_one);
-  mpz_init (bound_two);
-
-  for (i = 0; i < nb_parameters; i++)
-    {
-      compute_bounds_for_param (scop, i, bound_one, bound_two);
-      save_clast_name_index (index_table, parameters[i], i, i,
-			     bound_one, bound_two);
-    }
-
-  mpz_clear (bound_one);
-  mpz_clear (bound_two);
-}
-
 /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
    the given SCOP.  Return true if code generation succeeded.
    BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
@@ -1603,18 +1530,21 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   sese region = SCOP_REGION (scop);
   ifsese if_region = NULL;
   htab_t newivs_index, params_index;
-  cloog_prog_clast pc;
+  struct clast_stmt *clast;
   struct ivs_params ip;
 
   timevar_push (TV_GRAPHITE_CODE_GEN);
   gloog_error = false;
 
-  pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+			      eq_clast_name_indexes, free_clast_name_index);
+
+  clast = scop_to_clast (scop, params_index);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "\nCLAST generated by CLooG: \n");
-      print_clast_stmt (dump_file, pc.stmt);
+      print_clast_stmt (dump_file, clast);
       fprintf (dump_file, "\n");
     }
 
@@ -1632,10 +1562,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   context_loop = SESE_ENTRY (region)->src->loop_father;
   newivs_index = htab_create (10, clast_name_index_elt_info,
 			      eq_clast_name_indexes, free_clast_name_index);
-  params_index = htab_create (10, clast_name_index_elt_info,
-			      eq_clast_name_indexes, free_clast_name_index);
-
-  create_params_index (scop, params_index, pc.prog);
 
   ip.newivs = &newivs;
   ip.newivs_index = newivs_index;
@@ -1643,7 +1569,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   ip.params_index = params_index;
   ip.region = region;
 
-  translate_clast (context_loop, pc.stmt, if_region->true_region->entry,
+  translate_clast (context_loop, clast, if_region->true_region->entry,
 		   bb_pbb_mapping, 0, &ip);
   graphite_verify ();
   scev_reset ();
@@ -1660,8 +1586,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   htab_delete (newivs_index);
   htab_delete (params_index);
   VEC_free (tree, heap, newivs);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
   timevar_pop (TV_GRAPHITE_CODE_GEN);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h
index b5affd9..c82bb6a 100644
--- a/gcc/graphite-clast-to-gimple.h
+++ b/gcc/graphite-clast-to-gimple.h
@@ -41,7 +41,6 @@ typedef struct bb_pbb_def
 } bb_pbb_def;
 
 extern bool gloog (scop_p, htab_t);
-extern cloog_prog_clast scop_to_clast (scop_p);
 extern void debug_clast_stmt (struct clast_stmt *);
 extern void print_clast_stmt (FILE *, struct clast_stmt *);
 
-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-10 23:09 [graphite] Move to cloog.org interface Tobias Grosser
@ 2011-08-11  5:44 ` Sebastian Pop
  2011-08-11 18:13   ` Tobias Grosser
  0 siblings, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11  5:44 UTC (permalink / raw)
  To: Tobias Grosser; +Cc: gcc-patches

Hi Tobi,

The patch looks good modulo some formatting changes:

+    free(c->free_name);
+  int length = strlen(e->name);
[...]

Please follow the GNU style: there should be a space between the
function name and the open parenthesis.

-      dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
+      domain = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
                                                          scop_nb_params (scop),
                                                          cloog_state);

You would still need proper indentation on the last two lines.

+  /* Dump a .cloog input file, if requested.  This feature is only
+   * enabled in the Graphite branch.  */

Please remove the * from the beginning of the new line in this comment.

Ok with these changes and after the other patches are committed.

Thanks,
Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11  5:44 ` Sebastian Pop
@ 2011-08-11 18:13   ` Tobias Grosser
  2011-08-11 18:24     ` Sebastian Pop
  0 siblings, 1 reply; 58+ messages in thread
From: Tobias Grosser @ 2011-08-11 18:13 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 314 bytes --]

On 08/10/2011 11:41 PM, Sebastian Pop wrote:
> Hi Tobi,
>
> The patch looks good modulo some formatting changes:

Thanks for your review. I attached the updated patch.

I will commit this patch after the configure changes are in (and 
meanwhile no further improvements were suggested for this patch).

Cheers
Tobi

[-- Attachment #2: 0001-Move-to-new-Cloog-interface.patch --]
[-- Type: text/x-diff, Size: 19183 bytes --]

From f4f40f7a67710ac61c38991661e86b5a63820f2b Mon Sep 17 00:00:00 2001
From: Tobias Grosser <tobias@grosser.es>
Date: Tue, 9 Aug 2011 18:26:28 +0100
Subject: [PATCH] Move to new Cloog interface.

  * graphite-clast-to-gimple.c (new_clast_name_index): Store a copy
  of the string, no just a reference.
  (clast_name_index): Add a new field, that specifies if we need to free the
  name.
  (free_clast_name_index): If necessary, free the name string.
  (clast_name_index_elt_info): Calculate the hash based on the string content,
  not the memory location it is stored in.
  (clast_name_to_level): Specify that we do not need to free the name.
  (clast_name_to_index): Dito.
  (clast_name_to_lb_ub): Dito.
  (eq_clast_name_indexes): Compare the strings, not their base pointers.
  (free_scattering): Removed.
  (initialize_cloog_names): Renamed to add_names_to_union_domain().
  (add_names_to_union_domain): Changed to work on a union_domain, instead of a
  CloogNames structure.
  (build_cloog_prog): Removed.
  (build_cloog_union_domain): New.
  (generate_cloog_input): New.
  (scop_to_clast): Use CloogInput instead of CloogProgram.
  (print_generated_program): Adapt to new scop_to_clast() and do not
  print the CloogProgram any more.
  (create_params_index): Removed, functionality integrated in
  add_names_to_union_domain().
  (gloog): Adapt to new scop_to_clast().
  * graphite-clast-to-gimple.h (scop_to_clast): Remove.
---
 gcc/graphite-clast-to-gimple.c |  325 +++++++++++++++------------------------
 gcc/graphite-clast-to-gimple.h |    1 -
 2 files changed, 125 insertions(+), 201 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index c8c5024..a7d0ddc 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -70,6 +70,9 @@ typedef struct clast_name_index {
   int level;
   mpz_t bound_one, bound_two;
   const char *name;
+  /* If free_name is set, the content of name was allocated by us and needs
+     to be freed.  */
+  char *free_name;
 } *clast_name_index_p;
 
 /* Returns a pointer to a new element of type clast_name_index_p built
@@ -80,8 +83,11 @@ new_clast_name_index (const char *name, int index, int level,
 		      mpz_t bound_one, mpz_t bound_two)
 {
   clast_name_index_p res = XNEW (struct clast_name_index);
+  char *new_name = XNEWVEC (char, strlen (name) + 1);
+  strcpy (new_name, name);
 
-  res->name = name;
+  res->name = new_name;
+  res->free_name = new_name;
   res->level = level;
   res->index = index;
   mpz_init (res->bound_one);
@@ -97,6 +103,8 @@ static void
 free_clast_name_index (void *ptr)
 {
   struct clast_name_index *c = (struct clast_name_index *) ptr;
+  if (c->free_name)
+    free (c->free_name);
   mpz_clear (c->bound_one);
   mpz_clear (c->bound_two);
   free (ptr);
@@ -115,6 +123,7 @@ clast_name_to_level (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -136,6 +145,7 @@ clast_name_to_index (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -158,6 +168,7 @@ clast_name_to_lb_ub (clast_name_p name, htab_t index_table, mpz_t bound_one,
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -181,6 +192,7 @@ save_clast_name_index (htab_t index_table, const char *name,
   PTR *slot;
 
   tmp.name = name;
+  tmp.free_name = NULL;
   slot = htab_find_slot (index_table, &tmp, INSERT);
 
   if (slot)
@@ -196,7 +208,16 @@ save_clast_name_index (htab_t index_table, const char *name,
 static inline hashval_t
 clast_name_index_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
+  const struct clast_name_index *e = ((const struct clast_name_index *) elt);
+  hashval_t hash = 0;
+
+  int length = strlen (e->name);
+  int i;
+
+  for (i = 0; i < length; ++i)
+    hash = hash | (e->name[i] << (i % 4));
+
+  return hash;
 }
 
 /* Compares database elements E1 and E2.  */
@@ -207,7 +228,7 @@ 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);
+  return strcmp (elt1->name, elt2->name) == 0;
 }
 
 \f
@@ -1230,77 +1251,69 @@ translate_clast (loop_p context_loop, struct clast_stmt *stmt, edge next_e,
 			  level, ip);
 }
 
-/* Free the SCATTERING domain list.  */
-
-static void
-free_scattering (CloogScatteringList *scattering)
-{
-  while (scattering)
-    {
-      CloogScattering *dom = scattering->scatt;
-      CloogScatteringList *next = scattering->next;
-
-      cloog_scattering_free (dom);
-      free (scattering);
-      scattering = next;
-    }
-}
-
-/* Initialize Cloog's parameter names from the names used in GIMPLE.
-   Initialize Cloog's iterator names, using 'graphite_iterator_%d'
-   from 0 to scop_nb_loops (scop).  */
+/* Add parameter and iterator names to the CloogUnionDomain.  */
 
-static void
-initialize_cloog_names (scop_p scop, CloogProgram *prog)
+static CloogUnionDomain *
+add_names_to_union_domain (scop_p scop, CloogUnionDomain *union_domain,
+			   int nb_scattering_dims, htab_t params_index)
 {
   sese region = SCOP_REGION (scop);
   int i;
   int nb_iterators = scop_max_loop_depth (scop);
-  int nb_scattering = prog->nb_scattdims;
   int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
-  char **iterators = XNEWVEC (char *, nb_iterators * 2);
-  char **scattering = XNEWVEC (char *, nb_scattering);
-  char **parameters= XNEWVEC (char *, nb_parameters);
+  mpz_t bound_one, bound_two;
 
-  prog->names = cloog_names_malloc ();
+  mpz_init (bound_one);
+  mpz_init (bound_two);
 
   for (i = 0; i < nb_parameters; i++)
     {
       tree param = VEC_index (tree, SESE_PARAMS (region), i);
       const char *name = get_name (param);
       int len;
+      char *parameter;
 
       if (!name)
 	name = "T";
 
       len = strlen (name);
       len += 17;
-      parameters[i] = XNEWVEC (char, len + 1);
-      snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
+      parameter = XNEWVEC (char, len + 1);
+      snprintf (parameter, len, "%s_%d", name, SSA_NAME_VERSION (param));
+      save_clast_name_index (params_index, parameter, i, i, bound_one,
+			     bound_two);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_PARAM, i,
+						  parameter);
+      compute_bounds_for_param (scop, i, bound_one, bound_two);
+      free (parameter);
     }
 
-  prog->names->nb_parameters = nb_parameters;
-  prog->names->parameters = parameters;
+  mpz_clear (bound_one);
+  mpz_clear (bound_two);
 
   for (i = 0; i < nb_iterators; i++)
     {
       int len = 4 + 16;
-      iterators[i] = XNEWVEC (char, len);
-      snprintf (iterators[i], len, "git_%d", i);
+      char *iterator;
+      iterator = XNEWVEC (char, len);
+      snprintf (iterator, len, "git_%d", i);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_ITER, i,
+						  iterator);
+      free (iterator);
     }
 
-  prog->names->nb_iterators = nb_iterators;
-  prog->names->iterators = iterators;
-
-  for (i = 0; i < nb_scattering; i++)
+  for (i = 0; i < nb_scattering_dims; i++)
     {
       int len = 5 + 16;
-      scattering[i] = XNEWVEC (char, len);
-      snprintf (scattering[i], len, "scat_%d", i);
+      char *scattering;
+      scattering = XNEWVEC (char, len);
+      snprintf (scattering, len, "scat_%d", i);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_SCAT, i,
+						  scattering);
+      free (scattering);
     }
 
-  prog->names->nb_scattering = nb_scattering;
-  prog->names->scattering = scattering;
+  return union_domain;
 }
 
 /* Initialize a CLooG input file.  */
@@ -1328,129 +1341,40 @@ init_cloog_input_file (int scop_number)
   return graphite_out_file;
 }
 
-/* Build cloog program for SCoP.  */
+/* Build cloog union domain for SCoP.  */
 
-static void
-build_cloog_prog (scop_p scop, CloogProgram *prog,
-                  CloogOptions *options)
+static CloogUnionDomain *
+build_cloog_union_domain (scop_p scop)
 {
   int i;
-  int max_nb_loops = scop_max_loop_depth (scop);
   poly_bb_p pbb;
-  CloogLoop *loop_list = NULL;
-  CloogBlockList *block_list = NULL;
-  CloogScatteringList *scattering = NULL;
-  int nbs = 2 * max_nb_loops + 1;
-  int *scaldims;
-
-  prog->context =
-    new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
-						 scop_nb_params (scop),
-						 cloog_state);
-  nbs = unify_scattering_dimensions (scop);
-  scaldims = (int *) xmalloc (nbs * (sizeof (int)));
-  prog->nb_scattdims = nbs;
-  initialize_cloog_names (scop, prog);
+
+  CloogUnionDomain *union_domain =
+    cloog_union_domain_alloc (scop_nb_params (scop));
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
-      CloogStatement *stmt;
-      CloogBlock *block;
-      CloogDomain *dom;
+      CloogDomain *domain;
+      CloogScattering *scattering;
 
       /* Dead code elimination: when the domain of a PBB is empty,
 	 don't generate code for the PBB.  */
       if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PBB_DOMAIN (pbb)))
 	continue;
 
-      /* Build the new statement and its block.  */
-      stmt = cloog_statement_alloc (cloog_state, pbb_index (pbb));
-      dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
-                                                         scop_nb_params (scop),
-                                                         cloog_state);
-      block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
-      stmt->usr = pbb;
-
-      /* Build loop list.  */
-      {
-        CloogLoop *new_loop_list = cloog_loop_malloc (cloog_state);
-        new_loop_list->next = loop_list;
-        new_loop_list->domain = dom;
-        new_loop_list->block = block;
-        loop_list = new_loop_list;
-      }
-
-      /* Build block list.  */
-      {
-        CloogBlockList *new_block_list = cloog_block_list_malloc ();
-
-        new_block_list->next = block_list;
-        new_block_list->block = block;
-        block_list = new_block_list;
-      }
-
-      /* Build scattering list.  */
-      {
-        /* XXX: Replace with cloog_domain_list_alloc(), when available.  */
-        CloogScatteringList *new_scattering
-	  = (CloogScatteringList *) xmalloc (sizeof (CloogScatteringList));
-        ppl_Polyhedron_t scat;
-	CloogScattering *dom;
-
-	scat = PBB_TRANSFORMED_SCATTERING (pbb);
-        dom = new_Cloog_Scattering_from_ppl_Polyhedron
-          (scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb),
-           cloog_state);
-
-        new_scattering->next = scattering;
-        new_scattering->scatt = dom;
-        scattering = new_scattering;
-      }
-    }
-
-  prog->loop = loop_list;
-  prog->blocklist = block_list;
+      domain = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
+							    scop_nb_params (scop),
+							    cloog_state);
 
-  for (i = 0; i < nbs; i++)
-    scaldims[i] = 0 ;
+      scattering = new_Cloog_Scattering_from_ppl_Polyhedron
+	(PBB_TRANSFORMED_SCATTERING (pbb), scop_nb_params (scop),
+	 pbb_nb_scattering_transform (pbb), cloog_state);
 
-  prog->scaldims = scaldims;
-
-  /* Extract scalar dimensions to simplify the code generation problem.  */
-  cloog_program_extract_scalars (prog, scattering, options);
-
-  /* Dump a .cloog input file, if requested.  This feature is only
-     enabled in the Graphite branch.  */
-  if (0)
-    {
-      static size_t file_scop_number = 0;
-      FILE *cloog_file = init_cloog_input_file (file_scop_number);
-
-      cloog_program_dump_cloog (cloog_file, prog, scattering);
-      ++file_scop_number;
+      union_domain = cloog_union_domain_add_domain (union_domain, "", domain,
+						    scattering, pbb);
     }
 
-  /* Apply scattering.  */
-  cloog_program_scatter (prog, scattering, options);
-  free_scattering (scattering);
-
-  /* Iterators corresponding to scalar dimensions have to be extracted.  */
-  cloog_names_scalarize (prog->names, nbs, prog->scaldims);
-
-  /* Free blocklist.  */
-  {
-    CloogBlockList *next = prog->blocklist;
-
-    while (next)
-      {
-        CloogBlockList *toDelete = next;
-        next = next->next;
-        toDelete->next =  NULL;
-        toDelete->block = NULL;
-        cloog_block_list_free (toDelete);
-      }
-    prog->blocklist = NULL;
-  }
+  return union_domain;
 }
 
 /* Return the options that will be used in GLOOG.  */
@@ -1515,24 +1439,52 @@ debug_clast_stmt (struct clast_stmt *stmt)
   print_clast_stmt (stderr, stmt);
 }
 
+static CloogInput *
+generate_cloog_input (scop_p scop, htab_t params_index)
+{
+  CloogUnionDomain *union_domain;
+  CloogInput *cloog_input;
+  CloogDomain *context;
+
+  int nb_scattering_dims = unify_scattering_dimensions (scop);
+  union_domain = build_cloog_union_domain (scop);
+  union_domain = add_names_to_union_domain (scop, union_domain,
+					    nb_scattering_dims,
+					    params_index);
+  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
+    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
+
+  cloog_input = cloog_input_alloc (context, union_domain);
+
+  return cloog_input;
+}
+
 /* Translate SCOP to a CLooG program and clast.  These two
    representations should be freed together: a clast cannot be used
    without a program.  */
 
-cloog_prog_clast
-scop_to_clast (scop_p scop)
+static struct clast_stmt *
+scop_to_clast (scop_p scop, htab_t params_index)
 {
+  CloogInput *cloog_input;
+  struct clast_stmt *clast;
   CloogOptions *options = set_cloog_options ();
-  cloog_prog_clast pc;
 
-  /* Connect new cloog prog generation to graphite.  */
-  pc.prog = cloog_program_malloc ();
-  build_cloog_prog (scop, pc.prog, options);
-  pc.prog = cloog_program_generate (pc.prog, options);
-  pc.stmt = cloog_clast_create (pc.prog, options);
+  cloog_input = generate_cloog_input (scop, params_index);
+
+  /* Dump a .cloog input file, if requested.  This feature is only
+     enabled in the Graphite branch.  */
+  if (0)
+  {
+    static size_t file_scop_number = 0;
+    FILE *cloog_file = init_cloog_input_file (file_scop_number);
+    cloog_input_dump_cloog (cloog_file, cloog_input, options);
+  }
+
+  clast = cloog_clast_create_from_input (cloog_input, options);
 
   cloog_options_free (options);
-  return pc;
+  return clast;
 }
 
 /* Prints to FILE the code generated by CLooG for SCOP.  */
@@ -1541,20 +1493,20 @@ void
 print_generated_program (FILE *file, scop_p scop)
 {
   CloogOptions *options = set_cloog_options ();
+  htab_t params_index;
+  struct clast_stmt *clast;
 
-  cloog_prog_clast pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+            eq_clast_name_indexes, free_clast_name_index);
 
-  fprintf (file, "       (prog: \n");
-  cloog_program_print (file, pc.prog);
-  fprintf (file, "       )\n");
+  clast = scop_to_clast (scop, params_index);
 
   fprintf (file, "       (clast: \n");
-  clast_pprint (file, pc.stmt, 0, options);
+  clast_pprint (file, clast, 0, options);
   fprintf (file, "       )\n");
 
   cloog_options_free (options);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
 }
 
 /* Prints to STDERR the code generated by CLooG for SCOP.  */
@@ -1565,31 +1517,6 @@ debug_generated_program (scop_p scop)
   print_generated_program (stderr, scop);
 }
 
-/* Add CLooG names to parameter index.  The index is used to translate
-   back from CLooG names to GCC trees.  */
-
-static void
-create_params_index (scop_p scop, htab_t index_table, CloogProgram *prog) {
-  CloogNames* names = prog->names;
-  int nb_parameters = names->nb_parameters;
-  char **parameters = names->parameters;
-  int i;
-  mpz_t bound_one, bound_two;
-
-  mpz_init (bound_one);
-  mpz_init (bound_two);
-
-  for (i = 0; i < nb_parameters; i++)
-    {
-      compute_bounds_for_param (scop, i, bound_one, bound_two);
-      save_clast_name_index (index_table, parameters[i], i, i,
-			     bound_one, bound_two);
-    }
-
-  mpz_clear (bound_one);
-  mpz_clear (bound_two);
-}
-
 /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
    the given SCOP.  Return true if code generation succeeded.
    BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
@@ -1603,18 +1530,21 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   sese region = SCOP_REGION (scop);
   ifsese if_region = NULL;
   htab_t newivs_index, params_index;
-  cloog_prog_clast pc;
+  struct clast_stmt *clast;
   struct ivs_params ip;
 
   timevar_push (TV_GRAPHITE_CODE_GEN);
   gloog_error = false;
 
-  pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+			      eq_clast_name_indexes, free_clast_name_index);
+
+  clast = scop_to_clast (scop, params_index);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "\nCLAST generated by CLooG: \n");
-      print_clast_stmt (dump_file, pc.stmt);
+      print_clast_stmt (dump_file, clast);
       fprintf (dump_file, "\n");
     }
 
@@ -1632,10 +1562,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   context_loop = SESE_ENTRY (region)->src->loop_father;
   newivs_index = htab_create (10, clast_name_index_elt_info,
 			      eq_clast_name_indexes, free_clast_name_index);
-  params_index = htab_create (10, clast_name_index_elt_info,
-			      eq_clast_name_indexes, free_clast_name_index);
-
-  create_params_index (scop, params_index, pc.prog);
 
   ip.newivs = &newivs;
   ip.newivs_index = newivs_index;
@@ -1643,7 +1569,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   ip.params_index = params_index;
   ip.region = region;
 
-  translate_clast (context_loop, pc.stmt, if_region->true_region->entry,
+  translate_clast (context_loop, clast, if_region->true_region->entry,
 		   bb_pbb_mapping, 0, &ip);
   graphite_verify ();
   scev_reset ();
@@ -1660,8 +1586,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   htab_delete (newivs_index);
   htab_delete (params_index);
   VEC_free (tree, heap, newivs);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
   timevar_pop (TV_GRAPHITE_CODE_GEN);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h
index b5affd9..c82bb6a 100644
--- a/gcc/graphite-clast-to-gimple.h
+++ b/gcc/graphite-clast-to-gimple.h
@@ -41,7 +41,6 @@ typedef struct bb_pbb_def
 } bb_pbb_def;
 
 extern bool gloog (scop_p, htab_t);
-extern cloog_prog_clast scop_to_clast (scop_p);
 extern void debug_clast_stmt (struct clast_stmt *);
 extern void print_clast_stmt (FILE *, struct clast_stmt *);
 
-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 18:13   ` Tobias Grosser
@ 2011-08-11 18:24     ` Sebastian Pop
  2011-08-11 18:29       ` Tobias Grosser
  2011-08-11 19:02       ` Sebastian Pop
  0 siblings, 2 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 18:24 UTC (permalink / raw)
  To: Tobias Grosser; +Cc: gcc-patches

On Thu, Aug 11, 2011 at 12:52, Tobias Grosser <tobias@grosser.es> wrote:
> I will commit this patch after the configure changes are in (and meanwhile
> no further improvements were suggested for this patch).

Ok, thanks.  Let's hope we will have a configure maintainer that has some
spare cycles to go over your first 3 patches.

I will post my patches that convert graphite to ISL on top of your patches.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 18:24     ` Sebastian Pop
@ 2011-08-11 18:29       ` Tobias Grosser
  2011-08-11 19:02       ` Sebastian Pop
  1 sibling, 0 replies; 58+ messages in thread
From: Tobias Grosser @ 2011-08-11 18:29 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: gcc-patches

On 08/11/2011 07:03 PM, Sebastian Pop wrote:
> On Thu, Aug 11, 2011 at 12:52, Tobias Grosser<tobias@grosser.es>  wrote:
>> I will commit this patch after the configure changes are in (and meanwhile
>> no further improvements were suggested for this patch).
>
> Ok, thanks.  Let's hope we will have a configure maintainer that has some
> spare cycles to go over your first 3 patches.
>
> I will post my patches that convert graphite to ISL on top of your patches.

Nice. Let me know if I can help you with those patches somehow!

Cheers
Tobi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 18:24     ` Sebastian Pop
  2011-08-11 18:29       ` Tobias Grosser
@ 2011-08-11 19:02       ` Sebastian Pop
  2011-08-11 20:11         ` Tobias Grosser
  2011-08-11 20:24         ` Sven Verdoolaege
  1 sibling, 2 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 19:02 UTC (permalink / raw)
  To: Tobias Grosser, Sven Verdoolaege; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

On Thu, Aug 11, 2011 at 13:03, Sebastian Pop <sebpop@gmail.com> wrote:
> On Thu, Aug 11, 2011 at 12:52, Tobias Grosser <tobias@grosser.es> wrote:
>> I will commit this patch after the configure changes are in (and meanwhile
>> no further improvements were suggested for this patch).
>
> Ok, thanks.  Let's hope we will have a configure maintainer that has some
> spare cycles to go over your first 3 patches.
>
> I will post my patches that convert graphite to ISL on top of your patches.

I am following the PET (Polyhedral Extraction Tool) git://repo.or.cz/pet.git
code as suggested by Tobias and Sven in order to help with the translation
of graphite to ISL.

Here is where I am right now: I am building the ISL counterpart for
scop->context
pbb->domain
pdr->accesses
and I still have to translate to ISL the original and transformed scattering.

The plan is to build the ISL representation in parallel with PPL data structs,
then make sure that ISL sets and maps contain valid data, and then move
away from PPL data structures one by one.

I would appreciate preliminary remarks on these patches.

Thanks,
Sebastian

[-- Attachment #2: 0005-Remove-ATTRIBUTE_UNUSED.patch --]
[-- Type: text/x-patch, Size: 2023 bytes --]

From 8941dfbfe55e191ff3b546c8f0a002058c85a9a4 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Wed, 3 Aug 2011 13:34:39 -0500
Subject: [PATCH 05/10] Remove ATTRIBUTE_UNUSED

---
 gcc/graphite-cloog-util.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 9bc24a0..83cfb54 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -236,7 +236,7 @@ new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
 
 CloogDomain *
 new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
-                                      CloogState *state ATTRIBUTE_UNUSED)
+                                      CloogState *state)
 {
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params);
@@ -248,9 +248,9 @@ new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
 
 CloogScattering *
 new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
-                                          int nb_params ATTRIBUTE_UNUSED,
-                                          int nb_scatt ATTRIBUTE_UNUSED,
-                                          CloogState *state ATTRIBUTE_UNUSED)
+                                          int nb_params,
+                                          int nb_scatt,
+                                          CloogState *state)
 {
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogScattering *res = cloog_scattering_from_cloog_matrix (state, mat,
@@ -266,7 +266,7 @@ new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
 CloogDomain *
 new_Cloog_Domain_from_ppl_Pointset_Powerset
   (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params,
-   CloogState *state ATTRIBUTE_UNUSED)
+   CloogState *state)
 {
   CloogDomain *res = NULL;
   ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-- 
1.7.4.1


[-- Attachment #3: 0006-Add-ISL-data-structures.patch --]
[-- Type: text/x-patch, Size: 14151 bytes --]

From 227899954f776188fb34930bd5e64650a6a69d32 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Wed, 3 Aug 2011 12:10:44 -0500
Subject: [PATCH 06/10] Add ISL data structures

---
 gcc/graphite-blocking.c        |   12 +++++++++++-
 gcc/graphite-clast-to-gimple.c |    9 +++++++++
 gcc/graphite-cloog-util.c      |   11 ++++++++++-
 gcc/graphite-cloog-util.h      |    2 --
 gcc/graphite-dependences.c     |   11 ++++++++++-
 gcc/graphite-flattening.c      |   11 ++++++++++-
 gcc/graphite-interchange.c     |   12 +++++++++++-
 gcc/graphite-poly.c            |   12 +++++++++++-
 gcc/graphite-poly.h            |   40 +++++++++++++++++++++++-----------------
 gcc/graphite-ppl.c             |   11 ++++++++++-
 gcc/graphite-scop-detection.c  |   11 ++++++++++-
 gcc/graphite-sese-to-poly.c    |   10 ++++++++++
 gcc/graphite.c                 |   12 +++++++++++-
 13 files changed, 136 insertions(+), 28 deletions(-)

diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 967de9d..429b405 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -1,7 +1,7 @@
 /* Heuristics and transform for loop blocking and strip mining on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Pranav Garg  <pranav.garg2107@gmail.com>.
 
@@ -20,7 +20,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a76b01d..50e424c 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 83cfb54..82a49a1 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>
    and Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index da26ee9..07894ea 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -21,8 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GRAPHITE_CLOOG_UTIL_H
 #define GRAPHITE_CLOOG_UTIL_H
 
-#include "cloog/cloog.h"
-
 CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
 CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t,
 						   int, CloogState *);
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index fb49f16..9ba2731 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -1,5 +1,5 @@
 /* Data dependence analysis for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Konrad Trifunovic <konrad.trifunovic@inria.fr>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-flattening.c b/gcc/graphite-flattening.c
index ccd0f5f..c58d8a3 100644
--- a/gcc/graphite-flattening.c
+++ b/gcc/graphite-flattening.c
@@ -1,5 +1,5 @@
 /* Loop flattening for Graphite.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com>.
 
 This file is part of GCC.
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index cb4d32c..b819ece 100644
--- a/gcc/graphite-interchange.c
+++ b/gcc/graphite-interchange.c
@@ -1,7 +1,7 @@
 /* Interchange heuristics and transform for loop interchange on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Harsha Jagasia <harsha.jagasia@amd.com>.
 
@@ -20,7 +20,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index db5b0cb..af40d20 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1,5 +1,5 @@
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -18,7 +18,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 417e99e..3a5fddb 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1,5 +1,5 @@
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -180,7 +180,8 @@ struct poly_dr
      - P: Number of parameters.
 
      In the example, the vector "R C O I L P" is "7 7 3 2 0 1".  */
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses;
+  ppl_Pointset_Powerset_C_Polyhedron_t _accesses;
+  isl_map *accesses;
 
   /* Data reference's base object set number, we must assure 2 pdrs are in the
      same base object set before dependency checking.  */
@@ -195,7 +196,7 @@ struct poly_dr
 #define PDR_CDR(PDR) (PDR->compiler_dr)
 #define PDR_PBB(PDR) (PDR->pbb)
 #define PDR_TYPE(PDR) (PDR->type)
-#define PDR_ACCESSES(PDR) (PDR->accesses)
+#define PDR_ACCESSES(PDR) (PDR->_accesses)
 #define PDR_BASE_OBJECT_SET(PDR) (PDR->dr_base_object_set)
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
@@ -353,19 +354,23 @@ struct poly_bb
 
      The number of variables in the DOMAIN may change and is not
      related to the number of loops in the original code.  */
-  ppl_Pointset_Powerset_C_Polyhedron_t domain;
+  ppl_Pointset_Powerset_C_Polyhedron_t _domain;
+  isl_set *domain;
 
   /* The data references we access.  */
   VEC (poly_dr_p, heap) *drs;
 
   /* The original scattering.  */
-  poly_scattering_p original;
+  poly_scattering_p _original;
+  isl_map *original;
 
   /* The transformed scattering.  */
-  poly_scattering_p transformed;
+  poly_scattering_p _transformed;
+  isl_map *transformed;
 
   /* A copy of the transformed scattering.  */
-  poly_scattering_p saved;
+  poly_scattering_p _saved;
+  isl_map *saved;
 
   /* True when the PDR duplicates have already been removed.  */
   bool pdr_duplicates_removed;
@@ -376,15 +381,15 @@ struct poly_bb
 
 #define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
 #define PBB_SCOP(PBB) (PBB->scop)
-#define PBB_DOMAIN(PBB) (PBB->domain)
+#define PBB_DOMAIN(PBB) (PBB->_domain)
 #define PBB_DRS(PBB) (PBB->drs)
-#define PBB_ORIGINAL(PBB) (PBB->original)
-#define PBB_ORIGINAL_SCATTERING(PBB) (PBB->original->scattering)
-#define PBB_TRANSFORMED(PBB) (PBB->transformed)
-#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB->transformed->scattering)
-#define PBB_SAVED(PBB) (PBB->saved)
-#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
-#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
+#define PBB_ORIGINAL(PBB) (PBB->_original)
+#define PBB_ORIGINAL_SCATTERING(PBB) (PBB_ORIGINAL (PBB)->scattering)
+#define PBB_TRANSFORMED(PBB) (PBB->_transformed)
+#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB_TRANSFORMED (PBB)->scattering)
+#define PBB_SAVED(PBB) (PBB->_saved)
+#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB_TRANSFORMED (PBB)->nb_local_variables)
+#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB_TRANSFORMED (PBB)->nb_scattering)
 #define PBB_PDR_DUPLICATES_REMOVED(PBB) (PBB->pdr_duplicates_removed)
 #define PBB_IS_REDUCTION(PBB) (PBB->is_reduction)
 
@@ -1401,7 +1406,8 @@ struct scop
   -128 >= a >= 127
      0 >= b >= 65,535
      c = 2a + b  */
-  ppl_Pointset_Powerset_C_Polyhedron_t context;
+  ppl_Pointset_Powerset_C_Polyhedron_t _context;
+  isl_set *context;
 
   /* A hashtable of the data dependence relations for the original
      scattering.  */
@@ -1414,7 +1420,7 @@ struct scop
 
 #define SCOP_BBS(S) (S->bbs)
 #define SCOP_REGION(S) ((sese) S->region)
-#define SCOP_CONTEXT(S) (S->context)
+#define SCOP_CONTEXT(S) (S->_context)
 #define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs)
 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule)
 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule)
diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c
index 9762ca4..d449237 100644
--- a/gcc/graphite-ppl.c
+++ b/gcc/graphite-ppl.c
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com>
    and Tobias Grosser <grosser@fim.uni-passau.de>
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 3460568..4cd1643 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1,5 +1,5 @@
 /* Detection of Static Control Parts (SCoP) for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 7e23c9d..37383bb 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -19,6 +19,16 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite.c b/gcc/graphite.c
index e746c61..8f6d8a1 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -1,5 +1,6 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
 
 This file is part of GCC.
@@ -33,6 +34,15 @@ 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/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
-- 
1.7.4.1


[-- Attachment #4: 0007-Add-scop-context.patch --]
[-- Type: text/x-patch, Size: 18408 bytes --]

From 365577f56a237c6ebbad8dd0a6595037de91ebdc Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Thu, 4 Aug 2011 11:59:18 -0500
Subject: [PATCH 07/10] Add scop->context

---
 gcc/graphite-clast-to-gimple.c |   58 ++++++--
 gcc/graphite-cloog-util.c      |   37 +++++
 gcc/graphite-cloog-util.h      |   32 +++++
 gcc/graphite-poly.c            |   10 ++
 gcc/graphite-poly.h            |    3 +
 gcc/graphite-sese-to-poly.c    |  299 +++++++++++++++++++++++++++++++++++++++-
 gcc/graphite.c                 |    4 +
 7 files changed, 426 insertions(+), 17 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 50e424c..400a202 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -24,6 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/list.h>
+#include <isl/constraint.h>
+#include <isl/div.h>
+#include <isl/ilp.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
 #endif
@@ -755,16 +760,19 @@ graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt,
 static void
 compute_bounds_for_param (scop_p scop, int param, mpz_t low, mpz_t up)
 {
-  ppl_Linear_Expression_t le;
-
-  /* Prepare the linear expression corresponding to the parameter that
-     we want to maximize/minimize.  */
-  ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
-  ppl_set_coef (le, param, 1);
-
-  ppl_max_for_le_pointset (SCOP_CONTEXT (scop), le, up);
-  ppl_min_for_le_pointset (SCOP_CONTEXT (scop), le, low);
-  ppl_delete_Linear_Expression (le);
+  isl_int v;
+  isl_aff *aff = isl_aff_zero
+    (isl_local_space_from_dim (isl_set_get_dim (scop->context)));
+
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, param, 1);
+
+  isl_int_init (v);
+  isl_set_min (scop->context, aff, &v);
+  isl_int_get_gmp (v, low);
+  isl_set_max (scop->context, aff, &v);
+  isl_int_get_gmp (v, up);
+  isl_int_clear (v);
+  isl_aff_free (aff);
 }
 
 /* Compute the lower bound LOW and upper bound UP for the induction
@@ -1360,10 +1368,32 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
   int nbs = 2 * max_nb_loops + 1;
   int *scaldims;
 
-  prog->context =
-    new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
-						 scop_nb_params (scop),
-						 cloog_state);
+  if (1)
+    {
+      /* For now remove the isl_id's from the context before
+	 translating to CLooG: this code will be removed when the
+	 domain will also contain isl_id's.  */
+      isl_set *context = isl_set_project_out (isl_set_copy (scop->context),
+					      isl_dim_set, 0, number_of_loops ());
+      isl_printer *p = isl_printer_to_str (scop->ctx);
+      char *str;
+
+      p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
+      p = isl_printer_print_set (p, context);
+      isl_set_free (context);
+
+      str = isl_printer_get_str (p);
+      context = isl_set_read_from_str (scop->ctx, str,
+				       scop_nb_params (scop));
+      free (str);
+      isl_printer_free (p);
+      prog->context = cloog_domain_from_isl_set (context);
+    }
+  else
+    prog->context = cloog_domain_from_isl_set
+      (isl_set_project_out (isl_set_copy (scop->context), isl_dim_set, 0,
+			    number_of_loops ()));
+
   nbs = unify_scattering_dimensions (scop);
   scaldims = (int *) xmalloc (nbs * (sizeof (int)));
   prog->nb_scattdims = nbs;
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 82a49a1..c5abde8 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
 #endif
@@ -415,4 +416,40 @@ openscop_read_polyhedron_matrix (FILE *file, ppl_Polyhedron_t *ph,
     }
 }
 
+/* Prints an isl_set S to stderr.  */
+
+DEBUG_FUNCTION void
+debug_isl_set (isl_set *s)
+{
+  isl_ctx *ctx = isl_ctx_alloc ();
+  isl_printer *pp = isl_printer_to_file (ctx, stderr);
+  pp = isl_printer_print_set (pp, s);
+  isl_printer_free (pp);
+  isl_ctx_free (ctx);
+}
+
+/* Prints an isl_pw_aff A to stderr.  */
+
+DEBUG_FUNCTION void
+debug_isl_pwaff (isl_pw_aff *a)
+{
+  isl_ctx *ctx = isl_ctx_alloc ();
+  isl_printer *pp = isl_printer_to_file (ctx, stderr);
+  pp = isl_printer_print_pw_aff (pp, a);
+  isl_printer_free (pp);
+  isl_ctx_free (ctx);
+}
+
+/* Prints an isl_aff A to stderr.  */
+
+DEBUG_FUNCTION void
+debug_isl_aff (isl_aff *a)
+{
+  isl_ctx *ctx = isl_ctx_alloc ();
+  isl_printer *pp = isl_printer_to_file (ctx, stderr);
+  pp = isl_printer_print_aff (pp, a);
+  isl_printer_free (pp);
+  isl_ctx_free (ctx);
+}
+
 #endif
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index 07894ea..3d10845 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -35,5 +35,37 @@ void openscop_read_polyhedron_matrix (FILE *, ppl_Polyhedron_t *, int *, int *,
 	       			     int *, int *);
 
 extern int *openscop_read_N_int (FILE *, int);
+void debug_isl_set (isl_set *);
+void debug_isl_pwaff (isl_pw_aff *);
+void debug_isl_aff (isl_aff *);
+
+static inline bool
+isl_set_is_equal_ppl_polyhedron (isl_set *s1, ppl_const_Polyhedron_t ph,
+				 int nb_params, CloogState *state)
+{
+  isl_set *s2 = isl_set_from_cloog_domain
+    (new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state));
+  int res = isl_set_is_equal (s1, s2);
+  isl_set_free (s2);
+  return res;
+}
+
+static inline bool
+isl_set_is_equal_ppl_powerset (isl_set *s1, ppl_Pointset_Powerset_C_Polyhedron_t p,
+			       int nb_params, CloogState *state)
+{
+  isl_set *s2 = isl_set_from_cloog_domain
+    (new_Cloog_Domain_from_ppl_Pointset_Powerset (p, nb_params, state));
+  int res = isl_set_is_equal (s1, s2);
+  isl_set_free (s2);
+  return res;
+}
+
+/*
+  gcc_assert (isl_set_is_equal_ppl_powerset (scop->context,
+					     SCOP_CONTEXT (scop),
+					     scop_nb_params (scop),
+					     cloog_state));
+*/
 
 #endif /* GRAPHITE_CLOOG_UTIL_H */
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index af40d20..225c8a2 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1012,6 +1012,7 @@ new_scop (void *region)
   scop_p scop = XNEW (struct scop);
 
   SCOP_CONTEXT (scop) = NULL;
+  scop->context = NULL;
   scop_set_region (scop, region);
   SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
   SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
@@ -1040,6 +1041,9 @@ free_scop (scop_p scop)
   if (SCOP_CONTEXT (scop))
     ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
 
+  if (scop->context)
+    isl_set_free (scop->context);
+
   htab_delete (SCOP_ORIGINAL_PDDRS (scop));
   free_lst (SCOP_ORIGINAL_SCHEDULE (scop));
   free_lst (SCOP_TRANSFORMED_SCHEDULE (scop));
@@ -1401,6 +1405,12 @@ print_scop_context (FILE *file, scop_p scop, int verbosity)
   else
     fprintf (file, "0 %d\n", (int) scop_nb_params (scop) + 2);
 
+  if (scop->context)
+    {
+      isl_printer *p = isl_printer_to_file (scop->ctx, file);
+      isl_printer_print_set (p, scop->context);
+    }
+
   if (verbosity > 0)
     fprintf (file, "# )\n");
 }
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 3a5fddb..775c853 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1409,6 +1409,9 @@ struct scop
   ppl_Pointset_Powerset_C_Polyhedron_t _context;
   isl_set *context;
 
+  /* The context used internally by ISL.  */
+  isl_ctx *ctx;
+
   /* A hashtable of the data dependence relations for the original
      scattering.  */
   htab_t original_pddrs;
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 37383bb..d64ced7 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
@@ -595,6 +597,214 @@ build_scop_scattering (scop_p scop)
   ppl_delete_Linear_Expression (static_schedule);
 }
 
+static isl_pw_aff *extract_affine (scop_p, tree);
+
+/* Extract an affine expression from the chain of recurrence E.  */
+
+static isl_pw_aff *
+extract_affine_chrec (scop_p s, tree e)
+{
+  isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e));
+  isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e));
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
+  isl_local_space *ls = isl_local_space_from_dim (dim);
+  isl_aff *loop = isl_aff_set_coefficient_si
+    (isl_aff_zero (ls), isl_dim_set, CHREC_VARIABLE (e), 1);
+
+  return isl_pw_aff_add (lhs,
+			 isl_pw_aff_mul (rhs, isl_pw_aff_from_aff (loop)));
+}
+
+/* Extract an affine expression from the mult_expr E.  */
+
+static isl_pw_aff *
+extract_affine_mul (scop_p s, tree e)
+{
+  isl_pw_aff *lhs = extract_affine (s, TREE_OPERAND (e, 0));
+  isl_pw_aff *rhs = extract_affine (s, TREE_OPERAND (e, 1));
+
+  if (!isl_pw_aff_is_cst (lhs)
+      && !isl_pw_aff_is_cst (rhs))
+    {
+      isl_pw_aff_free (lhs);
+      isl_pw_aff_free (rhs);
+      return NULL;
+    }
+
+  return isl_pw_aff_mul (lhs, rhs);
+}
+
+/* Return an ISL identifier from the name of the ssa_name E.  */
+
+static isl_id *
+isl_id_for_ssa_name (scop_p s, tree e)
+{
+  const char *name = get_name (e);
+  isl_id *id;
+
+  if (name)
+    id = isl_id_alloc (s->ctx, name, e);
+  else
+    {
+      char *name1 = XNEWVEC (char, 16);
+      sprintf (name1, "P_%d", SSA_NAME_VERSION (e));
+      id = isl_id_alloc (s->ctx, name1, e);
+      XDELETEVEC (name1);
+    }
+
+  return id;
+}
+
+/* Return an ISL identifier from the name of the ssa_name E.  */
+
+static isl_id *
+isl_id_for_loop (scop_p s, loop_p l)
+{
+  isl_id *id;
+  char *name = XNEWVEC (char, 16);
+
+  sprintf (name, "L_%d", l ? l->num : -1);
+  id = isl_id_alloc (s->ctx, name, l);
+  XDELETEVEC (name);
+
+  return id;
+}
+
+/* Extract an affine expression from the ssa_name E.  */
+
+static isl_pw_aff *
+extract_affine_name (scop_p s, tree e)
+{
+  isl_aff *aff;
+  isl_set *dom;
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 1, number_of_loops ());
+
+  dim = isl_dim_set_dim_id (dim, isl_dim_param, 0, isl_id_for_ssa_name (s, e));
+  dom = isl_set_universe (isl_dim_copy (dim));
+  aff = isl_aff_zero (isl_local_space_from_dim (dim));
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, 0, 1);
+  return isl_pw_aff_alloc (dom, aff);
+}
+
+/* Extract an affine expression from the gmp constant G.  */
+
+static isl_pw_aff *
+extract_affine_gmp (scop_p s, mpz_t g)
+{
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
+  isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (dim));
+  isl_aff *aff = isl_aff_zero (ls);
+  isl_set *dom = isl_set_universe (dim);
+  isl_int v;
+
+  isl_int_init (v);
+  isl_int_set_gmp (v, g);
+  aff = isl_aff_add_constant (aff, v);
+  isl_int_clear (v);
+
+  return isl_pw_aff_alloc (dom, aff);
+}
+
+/* Extract an affine expression from the integer_cst E.  */
+
+static isl_pw_aff *
+extract_affine_int (scop_p s, tree e)
+{
+  isl_pw_aff *res;
+  mpz_t g;
+
+  mpz_init (g);
+  tree_int_to_gmp (e, g);
+  res = extract_affine_gmp (s, g);
+  mpz_clear (g);
+
+  return res;
+}
+
+/* Compute pwaff mod 2^width.  */
+
+static isl_pw_aff *
+wrap (isl_pw_aff *pwaff, unsigned width)
+{
+  isl_int mod;
+
+  isl_int_init (mod);
+  isl_int_set_si (mod, 1);
+  isl_int_mul_2exp (mod, mod, width);
+
+  pwaff = isl_pw_aff_mod (pwaff, mod);
+
+  isl_int_clear (mod);
+
+  return pwaff;
+}
+
+/* Extract an affine expression from the tree E in the scop S.  */
+
+static isl_pw_aff *
+extract_affine (scop_p s, tree e)
+{
+  isl_pw_aff *lhs, *rhs, *res;
+  tree type;
+
+  if (e == chrec_dont_know)
+    return NULL;
+
+  switch (TREE_CODE (e))
+    {
+    case POLYNOMIAL_CHREC:
+      res = extract_affine_chrec (s, e);
+      break;
+
+    case MULT_EXPR:
+      res = extract_affine_mul (s, e);
+      break;
+
+    case PLUS_EXPR:
+    case POINTER_PLUS_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1));
+      res = isl_pw_aff_add (lhs, rhs);
+      break;
+
+    case MINUS_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1));
+      res = isl_pw_aff_sub (lhs, rhs);
+      break;
+
+    case NEGATE_EXPR:
+    case BIT_NOT_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, integer_minus_one_node);
+      res = isl_pw_aff_mul (lhs, rhs);
+      break;
+
+    case SSA_NAME:
+      res = extract_affine_name (s, e);
+      break;
+
+    case INTEGER_CST:
+      res = extract_affine_int (s, e);
+      break;
+
+    CASE_CONVERT:
+    case NON_LVALUE_EXPR:
+      res = extract_affine (s, TREE_OPERAND (e, 0));
+      break;
+
+    default:
+      gcc_unreachable ();
+      break;
+    }
+
+  type = TREE_TYPE (e);
+  if (TYPE_UNSIGNED (type))
+    res = wrap (res, TYPE_PRECISION (type));
+
+  return res;
+}
+
 /* Add the value K to the dimension D of the linear expression EXPR.  */
 
 static void
@@ -931,6 +1141,7 @@ find_scop_parameters (scop_p scop)
   sese region = SCOP_REGION (scop);
   struct loop *loop;
   mpz_t one;
+  int nbp;
 
   mpz_init (one);
   mpz_set_si (one, 1);
@@ -953,11 +1164,28 @@ find_scop_parameters (scop_p scop)
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     find_params_in_bb (region, PBB_BLACK_BOX (pbb));
 
-  scop_set_nb_params (scop, sese_nb_params (region));
+  nbp = sese_nb_params (region);
+  scop_set_nb_params (scop, nbp);
   SESE_ADD_PARAMS (region) = false;
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension
-    (&SCOP_CONTEXT (scop), scop_nb_params (scop), 0);
+    (&SCOP_CONTEXT (scop), nbp, 0);
+
+  {
+    tree e;
+    unsigned nbl = number_of_loops ();
+    isl_dim *dim = isl_dim_set_alloc (scop->ctx, nbp, nbl);
+
+    FOR_EACH_VEC_ELT (tree, SESE_PARAMS (region), i, e)
+      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
+				isl_id_for_ssa_name (scop, e));
+
+    for (i = 0; i < nbl; i++)
+      dim = isl_dim_set_dim_id (dim, isl_dim_set, i,
+				isl_id_for_loop (scop, get_loop (i)));
+
+    scop->context = isl_set_universe (dim);
+  }
 }
 
 /* Insert in the SCOP context constraints from the estimation of the
@@ -1094,6 +1322,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       ppl_Constraint_t ub;
       ppl_Linear_Expression_t ub_expr;
       double_int nit;
+      isl_pw_aff *aff;
 
       mpz_init (one);
       mpz_set_si (one, 1);
@@ -1102,8 +1331,33 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       scan_tree_for_params (SCOP_REGION (scop), nb_iters, ub_expr, one);
       mpz_clear (one);
 
+      aff = extract_affine (scop, nb_iters);
+      scop->context = isl_set_intersect
+	(scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)));
+
       if (max_stmt_executions (loop, true, &nit))
-	add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
+	{
+	  add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
+
+	  {
+	    /* Insert in the context the constraints from the
+	       estimation of the number of iterations NIT and the
+	       symbolic number of iterations (involving parameter
+	       names) NB_ITERS.  First, build the affine expression
+	       "NIT - NB_ITERS" and then say that it is positive,
+	       i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS".  */
+	    isl_pw_aff *approx;
+	    mpz_t g;
+	    isl_set *x;
+
+	    mpz_init (g);
+	    mpz_set_double_int (g, nit, false);
+	    approx = extract_affine_gmp (scop, g);
+	    mpz_clear (g);
+	    x = isl_pw_aff_ge_set (approx, aff);
+	    scop->context = isl_set_intersect (scop->context, x);
+	  }
+	}
 
       /* loop_i <= expr_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
@@ -1463,6 +1717,26 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
       ppl_Polyhedron_add_constraint (context, cstr);
       ppl_delete_Linear_Expression (le);
       ppl_delete_Constraint (cstr);
+
+      {
+	isl_dim *dim = isl_set_get_dim (scop->context);
+	isl_constraint *c = isl_inequality_alloc (dim);
+	mpz_t g;
+	isl_int v;
+
+	mpz_init (g);
+	isl_int_init (v);
+	tree_int_to_gmp (lb, g);
+	isl_int_set_gmp (v, g);
+	isl_int_neg (v, v);
+	mpz_clear (g);
+	isl_constraint_set_constant (c, v);
+	isl_int_set_si (v, 1);
+	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
+	isl_int_clear (v);
+
+	scop->context = isl_set_add_constraint (scop->context, c);
+      }
     }
 
   if (ub)
@@ -1474,6 +1748,25 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
       ppl_Polyhedron_add_constraint (context, cstr);
       ppl_delete_Linear_Expression (le);
       ppl_delete_Constraint (cstr);
+
+      {
+	isl_dim *dim = isl_set_get_dim (scop->context);
+	isl_constraint *c = isl_inequality_alloc (dim);
+	mpz_t g;
+	isl_int v;
+
+	mpz_init (g);
+	isl_int_init (v);
+	tree_int_to_gmp (ub, g);
+	isl_int_set_gmp (v, g);
+	mpz_clear (g);
+	isl_constraint_set_constant (c, v);
+	isl_int_set_si (v, -1);
+	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
+	isl_int_clear (v);
+
+	scop->context = isl_set_add_constraint (scop->context, c);
+      }
     }
 }
 
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 8f6d8a1..b2cf7c6 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -260,10 +260,12 @@ graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
+  isl_ctx *ctx;
 
   if (!graphite_initialize ())
     return;
 
+  ctx = isl_ctx_alloc ();
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -277,6 +279,7 @@ graphite_transform_loops (void)
   FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
     if (dbg_cnt (graphite_scop))
       {
+	scop->ctx = ctx;
 	build_poly_scop (scop);
 
 	if (POLY_SCOP_P (scop)
@@ -288,6 +291,7 @@ graphite_transform_loops (void)
   htab_delete (bb_pbb_mapping);
   free_scops (scops);
   graphite_finalize (need_cfg_cleanup_p);
+  isl_ctx_free (ctx);
 }
 
 #else /* If Cloog is not available: #ifndef HAVE_cloog.  */
-- 
1.7.4.1


[-- Attachment #5: 0008-fix-memory-leak.patch --]
[-- Type: text/x-patch, Size: 731 bytes --]

From 2c431ec7d57bc5ba11ae37b7bb76ef843db0af26 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Wed, 10 Aug 2011 10:18:46 -0500
Subject: [PATCH 08/10] fix memory leak

---
 gcc/graphite-sese-to-poly.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index d64ced7..ad9cbc7 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2299,6 +2299,7 @@ build_scop_drs (scop_p scop)
     if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb))))
       {
 	free_gimple_bb (PBB_BLACK_BOX (pbb));
+	free_poly_bb (pbb);
 	VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
 	i--;
       }
-- 
1.7.4.1


[-- Attachment #6: 0009-add-pbb-domain.patch --]
[-- Type: text/x-patch, Size: 10386 bytes --]

From 737238be2840059073059090b51349f254379bfe Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Tue, 9 Aug 2011 20:19:59 -0500
Subject: [PATCH 09/10] add pbb->domain

---
 gcc/graphite-poly.c         |   29 ++++++++----
 gcc/graphite-poly.h         |    6 ++
 gcc/graphite-sese-to-poly.c |  107 ++++++++++++++++++++++++++++++++++++-------
 3 files changed, 116 insertions(+), 26 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 225c8a2..c5b32d6 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -880,6 +880,7 @@ new_poly_bb (scop_p scop, void *black_box)
   poly_bb_p pbb = XNEW (struct poly_bb);
 
   PBB_DOMAIN (pbb) = NULL;
+  pbb->domain = NULL;
   PBB_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
   PBB_TRANSFORMED (pbb) = NULL;
@@ -901,7 +902,11 @@ free_poly_bb (poly_bb_p pbb)
   int i;
   poly_dr_p pdr;
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
+  if (PBB_DOMAIN (pbb))
+    ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
+
+  if (pbb->domain)
+    isl_set_free (pbb->domain);
 
   if (PBB_TRANSFORMED (pbb))
     poly_scattering_free (PBB_TRANSFORMED (pbb));
@@ -1060,6 +1065,9 @@ openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
   graphite_dim_t i;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
 
+  if (isl_set_plain_is_empty (pbb->domain))
+    return;
+
   if (!PBB_DOMAIN (pbb))
     return;
 
@@ -1077,14 +1085,11 @@ openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
       fprintf (file, "    cst\n");
     }
 
-  if (PBB_DOMAIN (pbb))
-    openscop_print_powerset_matrix (file, PBB_DOMAIN (pbb),
-				    pbb_dim_iter_domain (pbb),
-				    0,
-				    0,
-				    pbb_nb_params (pbb));
-  else
-    fprintf (file, "0\n");
+  openscop_print_powerset_matrix (file, PBB_DOMAIN (pbb),
+				  pbb_dim_iter_domain (pbb),
+				  0,
+				  0,
+				  pbb_nb_params (pbb));
 
   if (verbosity > 0)
     fprintf (file, "#)\n");
@@ -1098,6 +1103,12 @@ print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
   graphite_dim_t i;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
 
+  {
+    isl_printer *pp = isl_printer_to_file (PBB_SCOP (pbb)->ctx, file);
+    pp = isl_printer_print_set (pp, pbb->domain);
+    isl_printer_free (pp);
+  }
+
   if (!PBB_DOMAIN (pbb))
     return;
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 775c853..0ca46ab 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -502,6 +502,12 @@ pbb_dim_iter_domain (const struct poly_bb *pbb)
 {
   scop_p scop = PBB_SCOP (pbb);
   ppl_dimension_type dim;
+  isl_dim *d = isl_set_get_dim (pbb->domain);
+  graphite_dim_t res = isl_dim_size (d, isl_dim_set);
+
+  isl_dim_free (d);
+  if (0)
+    return res;
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim);
   return dim - scop_nb_params (scop);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index ad9cbc7..dc1fad8 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1261,7 +1261,8 @@ add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit,
 static void
 build_loop_iteration_domains (scop_p scop, struct loop *loop,
                               ppl_Polyhedron_t outer_ph, int nb,
-			      ppl_Pointset_Powerset_C_Polyhedron_t *domains)
+			      ppl_Pointset_Powerset_C_Polyhedron_t *domains,
+			      isl_set *outer, isl_set **doms)
 {
   int i;
   ppl_Polyhedron_t ph;
@@ -1269,6 +1270,17 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
   ppl_dimension_type dim = nb + 1 + scop_nb_params (scop);
   sese region = SCOP_REGION (scop);
 
+  isl_set *inner = isl_set_copy (outer);
+  isl_dim *d = isl_set_get_dim (scop->context);
+  isl_id *id = isl_id_for_loop (scop, loop);
+  int pos = isl_dim_find_dim_by_id (d, isl_dim_set, id);
+  isl_int v;
+  mpz_t g;
+
+  isl_id_free (id);
+  mpz_init (g);
+  isl_int_init (v);
+
   {
     ppl_const_Constraint_System_t pcs;
     ppl_dimension_type *map
@@ -1299,8 +1311,17 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
     ppl_delete_Linear_Expression (lb_expr);
     ppl_Polyhedron_add_constraint (ph, lb);
     ppl_delete_Constraint (lb);
+
+    {
+      isl_constraint *c = isl_inequality_alloc (isl_dim_copy (d));
+
+      isl_int_set_si (v, 1);
+      isl_constraint_set_coefficient (c, isl_dim_set, pos, v);
+      inner = isl_set_add_constraint (inner, c);
+    }
   }
 
+  /* loop_i <= cst_nb_iters */
   if (TREE_CODE (nb_iters) == INTEGER_CST)
     {
       ppl_Constraint_t ub;
@@ -1308,14 +1329,26 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
 
       ppl_new_Linear_Expression_with_dimension (&ub_expr, dim);
 
-      /* loop_i <= cst_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
       ppl_set_inhomogeneous_tree (ub_expr, nb_iters);
       ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
       ppl_Polyhedron_add_constraint (ph, ub);
       ppl_delete_Linear_Expression (ub_expr);
       ppl_delete_Constraint (ub);
+
+      {
+	isl_constraint *c = isl_inequality_alloc (isl_dim_copy (d));
+
+	isl_int_set_si (v, -1);
+	isl_constraint_set_coefficient (c, isl_dim_set, pos, v);
+	tree_int_to_gmp (nb_iters, g);
+	isl_int_set_gmp (v, g);
+	isl_constraint_set_constant (c, v);
+	inner = isl_set_add_constraint (inner, c);
+      }
     }
+
+  /* loop_i <= expr_nb_iters */
   else if (!chrec_contains_undetermined (nb_iters))
     {
       mpz_t one;
@@ -1335,6 +1368,15 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       scop->context = isl_set_intersect
 	(scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)));
 
+      {
+	isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (d));
+	isl_aff *al = isl_aff_set_coefficient_si
+	  (isl_aff_zero (ls), isl_dim_set, pos, 1);
+	isl_set *le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al),
+					 isl_pw_aff_copy (aff));
+	inner = isl_set_intersect (inner, le);
+      }
+
       if (max_stmt_executions (loop, true, &nit))
 	{
 	  add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
@@ -1359,7 +1401,6 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
 	  }
 	}
 
-      /* loop_i <= expr_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
       ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
       ppl_Polyhedron_add_constraint (ph, ub);
@@ -1370,17 +1411,27 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
     gcc_unreachable ();
 
   if (loop->inner && loop_in_sese_p (loop->inner, region))
-    build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains);
+    build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains,
+				  isl_set_copy (inner), doms);
 
   if (nb != 0
       && loop->next
       && loop_in_sese_p (loop->next, region))
-    build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains);
+    build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains,
+				  isl_set_copy (outer), doms);
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
     (&domains[loop->num], ph);
-
   ppl_delete_Polyhedron (ph);
+
+  gcc_assert (doms[loop->num] == NULL);
+  doms[loop->num] = isl_set_copy (inner);
+
+  isl_set_free (inner);
+  isl_set_free (outer);
+  isl_dim_free (d);
+  isl_int_clear (v);
+  mpz_clear (g);
 }
 
 /* Returns a linear expression for tree T evaluated in PBB.  */
@@ -1810,31 +1861,50 @@ build_scop_iteration_domain (scop_p scop)
   int nb_loops = number_of_loops ();
   ppl_Pointset_Powerset_C_Polyhedron_t *domains
     = XNEWVEC (ppl_Pointset_Powerset_C_Polyhedron_t, nb_loops);
+  isl_set **doms = XNEWVEC (isl_set *, nb_loops);
 
   for (i = 0; i < nb_loops; i++)
-    domains[i] = NULL;
+    {
+      domains[i] = NULL;
+      doms[i] = NULL;
+    }
 
   ppl_new_C_Polyhedron_from_space_dimension (&ph, scop_nb_params (scop), 0);
 
   FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop)
     if (!loop_in_sese_p (loop_outer (loop), region))
-      build_loop_iteration_domains (scop, loop, ph, 0, domains);
+      build_loop_iteration_domains (scop, loop, ph, 0, domains,
+				    isl_set_copy (scop->context), doms);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
-    if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num])
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-	(&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t)
-	 domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
-    else
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-	(&PBB_DOMAIN (pbb), ph);
+    {
+      if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num])
+      	ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+	  (&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t)
+	   domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
+      else
+      	ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
+	  (&PBB_DOMAIN (pbb), ph);
+
+      if (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num])
+	pbb->domain = isl_set_copy (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
+      else
+	pbb->domain = isl_set_copy (scop->context);
+    }
 
   for (i = 0; i < nb_loops; i++)
-    if (domains[i])
-      ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]);
+    {
+      if (domains[i])
+	ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]);
+
+      if (doms[i])
+	isl_set_free (doms[i]);
+    }
 
   ppl_delete_Polyhedron (ph);
   free (domains);
+
+  free (doms);
 }
 
 /* Add a constrain to the ACCESSES polyhedron for the alias set of
@@ -1987,6 +2057,7 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb),
 						      &dom_nb_dims);
+
   accessp_nb_dims = dom_nb_dims + 1 + DR_NUM_DIMENSIONS (dr);
 
   ppl_new_C_Polyhedron_from_space_dimension (&accesses, accessp_nb_dims, 0);
@@ -2459,6 +2530,8 @@ new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb)
     ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
       (&PBB_DOMAIN (pbb1), PBB_DOMAIN (pbb));
 
+  pbb1->domain = isl_set_copy (pbb->domain);
+
   GBB_PBB (gbb1) = pbb1;
   GBB_CONDITIONS (gbb1) = VEC_copy (gimple, heap, GBB_CONDITIONS (gbb));
   GBB_CONDITION_CASES (gbb1) = VEC_copy (gimple, heap, GBB_CONDITION_CASES (gbb));
-- 
1.7.4.1


[-- Attachment #7: 0010-add-pdr-accesses-and-pdr-extent.patch --]
[-- Type: text/x-patch, Size: 12369 bytes --]

From 872bd33a1967d7a3dc00330f56d073f2a9f6fc13 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Wed, 10 Aug 2011 13:08:37 -0500
Subject: [PATCH 10/10] add pdr->accesses and pdr->extent

---
 gcc/graphite-cloog-util.c   |   24 +++++++
 gcc/graphite-cloog-util.h   |    2 +
 gcc/graphite-poly.c         |    7 ++-
 gcc/graphite-poly.h         |    4 +-
 gcc/graphite-sese-to-poly.c |  161 ++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 186 insertions(+), 12 deletions(-)

diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index c5abde8..8d46acb 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -428,6 +428,18 @@ debug_isl_set (isl_set *s)
   isl_ctx_free (ctx);
 }
 
+/* Prints an isl_map M to stderr.  */
+
+DEBUG_FUNCTION void
+debug_isl_map (isl_map *m)
+{
+  isl_ctx *ctx = isl_ctx_alloc ();
+  isl_printer *pp = isl_printer_to_file (ctx, stderr);
+  pp = isl_printer_print_map (pp, m);
+  isl_printer_free (pp);
+  isl_ctx_free (ctx);
+}
+
 /* Prints an isl_pw_aff A to stderr.  */
 
 DEBUG_FUNCTION void
@@ -452,4 +464,16 @@ debug_isl_aff (isl_aff *a)
   isl_ctx_free (ctx);
 }
 
+/* Prints an isl_id I to stderr.  */
+
+DEBUG_FUNCTION void
+debug_isl_id (isl_id *i)
+{
+  isl_ctx *ctx = isl_ctx_alloc ();
+  isl_printer *pp = isl_printer_to_file (ctx, stderr);
+  pp = isl_printer_print_id (pp, i);
+  isl_printer_free (pp);
+  isl_ctx_free (ctx);
+}
+
 #endif
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index 3d10845..a72ff6c 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -36,8 +36,10 @@ void openscop_read_polyhedron_matrix (FILE *, ppl_Polyhedron_t *, int *, int *,
 
 extern int *openscop_read_N_int (FILE *, int);
 void debug_isl_set (isl_set *);
+void debug_isl_map (isl_map *);
 void debug_isl_pwaff (isl_pw_aff *);
 void debug_isl_aff (isl_aff *);
+void debug_isl_id (isl_id *);
 
 static inline bool
 isl_set_is_equal_ppl_polyhedron (isl_set *s1, ppl_const_Polyhedron_t ph,
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index c5b32d6..c084634 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -847,7 +847,8 @@ pbb_remove_duplicate_pdrs (poly_bb_p pbb)
 void
 new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
 	     ppl_Pointset_Powerset_C_Polyhedron_t accesses,
-	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts)
+	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts,
+	     isl_map *acc, isl_set *extent)
 {
   static int id = 0;
   poly_dr_p pdr = XNEW (struct poly_dr);
@@ -857,6 +858,8 @@ new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
   PDR_NB_REFS (pdr) = 1;
   PDR_PBB (pdr) = pbb;
   PDR_ACCESSES (pdr) = accesses;
+  pdr->accesses = acc;
+  pdr->extent = extent;
   PDR_TYPE (pdr) = type;
   PDR_CDR (pdr) = cdr;
   PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
@@ -869,6 +872,8 @@ void
 free_poly_dr (poly_dr_p pdr)
 {
   ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr));
+  isl_map_free (pdr->accesses);
+  isl_set_free (pdr->extent);
   XDELETE (pdr);
 }
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 0ca46ab..019f99f 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -182,6 +182,7 @@ struct poly_dr
      In the example, the vector "R C O I L P" is "7 7 3 2 0 1".  */
   ppl_Pointset_Powerset_C_Polyhedron_t _accesses;
   isl_map *accesses;
+  isl_set *extent;
 
   /* Data reference's base object set number, we must assure 2 pdrs are in the
      same base object set before dependency checking.  */
@@ -201,7 +202,8 @@ struct poly_dr
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
 void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t,
-		  enum poly_dr_type, void *, graphite_dim_t);
+		  enum poly_dr_type, void *, graphite_dim_t, isl_map *,
+		  isl_set *);
 void free_poly_dr (poly_dr_p);
 void debug_pdr (poly_dr_p, int);
 void print_pdr (FILE *, poly_dr_p, int);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index dc1fad8..1d31392 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -670,6 +670,27 @@ isl_id_for_loop (scop_p s, loop_p l)
   return id;
 }
 
+/* Return an ISL identifier for the data reference DR.  */
+
+static isl_id *
+isl_id_for_dr (scop_p s, data_reference_p dr)
+{
+  isl_id *id;
+  const char *name = get_name (DR_BASE_OBJECT (dr));
+
+  if (name)
+    id = isl_id_alloc (s->ctx, name, dr);
+  else
+    {
+      char *name1 = XNEWVEC (char, 1);
+      sprintf (name1, "A");
+      id = isl_id_alloc (s->ctx, name1, dr);
+      XDELETEVEC (name1);
+    }
+
+  return id;
+}
+
 /* Extract an affine expression from the ssa_name E.  */
 
 static isl_pw_aff *
@@ -1912,8 +1933,9 @@ build_scop_iteration_domain (scop_p scop)
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_alias_set (isl_map *acc,
+		   ppl_Polyhedron_t accesses, data_reference_p dr,
 		   ppl_dimension_type accessp_nb_dims,
 		   ppl_dimension_type dom_nb_dims)
 {
@@ -1934,6 +1956,37 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
 
   ppl_delete_Linear_Expression (alias);
   ppl_delete_Constraint (cstr);
+
+  {
+    isl_constraint *c = isl_equality_alloc (isl_map_get_dim (acc));
+    c = isl_constraint_set_constant_si (c, -alias_set_num);
+    c = isl_constraint_set_coefficient_si (c, isl_dim_out, 0, 1);
+
+    return isl_map_add_constraint (acc, c);
+  }
+}
+
+/* Assign the affine expression INDEX to the output dimension POS of
+   MAP and return the result.  */
+
+static isl_map *
+set_index (isl_map *map, int pos, isl_pw_aff *index)
+{
+  isl_map *index_map;
+  int len = isl_map_dim (map, isl_dim_out);
+  isl_id *id;
+
+  index_map = isl_map_from_pw_aff (index);
+
+  /* FIXME: This function will be renamed isl_map_insert_dims and
+     documented in a later version of ISL (current ISL is 0.07).  */
+  index_map = isl_map_insert (index_map, isl_dim_out, 0, pos);
+  index_map = isl_map_add_dims (index_map, isl_dim_out, len - pos - 1);
+
+  id = isl_map_get_tuple_id (map, isl_dim_out);
+  index_map = isl_map_set_tuple_id (index_map, isl_dim_out, id);
+
+  return isl_map_intersect (map, index_map);
 }
 
 /* Add to ACCESSES polyhedron equalities defining the access functions
@@ -1941,8 +1994,9 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
    polyhedron, DOM_NB_DIMS is the dimension of the iteration domain.
    PBB is the poly_bb_p that contains the data reference DR.  */
 
-static void
-pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_memory_accesses (isl_map *acc,
+			 ppl_Polyhedron_t accesses, data_reference_p dr,
 			 ppl_dimension_type accessp_nb_dims,
 			 ppl_dimension_type dom_nb_dims,
 			 poly_bb_p pbb)
@@ -1975,9 +2029,13 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
       ppl_delete_Linear_Expression (fn);
       ppl_delete_Linear_Expression (access);
       ppl_delete_Constraint (cstr);
+
+      acc = set_index (acc, i + 1, extract_affine (scop, afn));
     }
 
   mpz_clear (v);
+
+  return acc;
 }
 
 /* Add constrains representing the size of the accessed data to the
@@ -1985,8 +2043,9 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_set *
+pdr_add_data_dimensions (isl_set *extent, scop_p scop,
+			 ppl_Polyhedron_t accesses, data_reference_p dr,
 			 ppl_dimension_type accessp_nb_dims,
 			 ppl_dimension_type dom_nb_dims)
 {
@@ -2024,6 +2083,52 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 
       high = array_ref_up_bound (ref);
 
+      if (host_integerp (low, 0)
+	  && high
+	  && host_integerp (high, 0)
+	  /* 1-element arrays at end of structures may extend over
+	     their declared size.  */
+	  && !(array_at_struct_end_p (ref)
+	       && operand_equal_p (low, high, 0)))
+	{
+	  isl_id *id;
+	  isl_aff *aff;
+	  isl_set *univ, *lbs, *ubs;
+	  isl_pw_aff *index;
+	  isl_dim *dim;
+	  isl_set *valid;
+	  int nbl = isl_set_dim (scop->context, isl_dim_set);
+	  int nbs = isl_set_dim (extent, isl_dim_set);
+	  isl_pw_aff *lb = extract_affine_int (scop, low);
+	  isl_pw_aff *ub = extract_affine_int (scop, high);
+
+	  /* high >= 0 */
+	  valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
+	  scop->context = isl_set_intersect (scop->context, valid);
+
+	  /* Make the dimension of LB and UB to be exactly NBS.  */
+	  lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1);
+	  ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1);
+	  lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1);
+	  ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1);
+
+	  dim = isl_set_get_dim (extent);
+	  aff = isl_aff_zero (isl_local_space_from_dim (dim));
+	  aff = isl_aff_add_coefficient_si (aff, isl_dim_set, i, 1);
+	  univ = isl_set_universe (isl_aff_get_dim (aff));
+	  index = isl_pw_aff_alloc (univ, aff);
+
+	  id = isl_set_get_tuple_id (extent);
+	  lb = isl_pw_aff_set_tuple_id (lb, isl_id_copy (id));
+	  ub = isl_pw_aff_set_tuple_id (ub, id);
+
+	  /* low <= sub_i <= high */
+	  lbs = isl_pw_aff_ge_set (isl_pw_aff_copy (index), lb);
+	  ubs = isl_pw_aff_le_set (index, ub);
+	  extent = isl_set_intersect (extent, lbs);
+	  extent = isl_set_intersect (extent, ubs);
+	}
+
       /* high - subscript >= 0 */
       if (high && host_integerp (high, 0)
 	  /* 1-element arrays at end of structures may extend over
@@ -2042,6 +2147,8 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 	  ppl_delete_Constraint (cstr);
 	}
     }
+
+  return extent;
 }
 
 /* Build data accesses for DR in PBB.  */
@@ -2054,6 +2161,9 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
   ppl_dimension_type dom_nb_dims;
   ppl_dimension_type accessp_nb_dims;
   int dr_base_object_set;
+  isl_map *acc;
+  isl_set *extent;
+  scop_p scop = PBB_SCOP (pbb);
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb),
 						      &dom_nb_dims);
@@ -2062,9 +2172,40 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 
   ppl_new_C_Polyhedron_from_space_dimension (&accesses, accessp_nb_dims, 0);
 
-  pdr_add_alias_set (accesses, dr, accessp_nb_dims, dom_nb_dims);
-  pdr_add_memory_accesses (accesses, dr, accessp_nb_dims, dom_nb_dims, pbb);
-  pdr_add_data_dimensions (accesses, dr, accessp_nb_dims, dom_nb_dims);
+  {
+    isl_dim *dc = isl_set_get_dim (scop->context);
+    int nb_in = isl_dim_size (dc, isl_dim_set);
+    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
+    int nbp = scop_nb_params (scop);
+    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
+    int i;
+
+    for (i = 0; i < nbp; i++)
+      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
+				isl_dim_get_dim_id (dc, isl_dim_param, i));
+    for (i = 0; i < nb_in; i++)
+      dim = isl_dim_set_dim_id (dim, isl_dim_in, i,
+				isl_dim_get_dim_id (dc, isl_dim_set, i));
+
+    acc = isl_map_universe (dim);
+    acc = isl_map_set_tuple_id (acc, isl_dim_out, isl_id_for_dr (scop, dr));
+    isl_dim_free (dc);
+  }
+
+  acc = pdr_add_alias_set (acc, accesses, dr, accessp_nb_dims, dom_nb_dims);
+  acc = pdr_add_memory_accesses (acc, accesses, dr, accessp_nb_dims,
+				 dom_nb_dims, pbb);
+
+  {
+    isl_id *id = isl_id_for_dr (scop, dr);
+    int nb = 1 + DR_NUM_DIMENSIONS (dr);
+    isl_dim *dim = isl_dim_set_alloc (scop->ctx, 0, nb);
+
+    dim = isl_dim_set_tuple_id (dim, isl_dim_set, id);
+    extent = isl_set_nat_universe (dim);
+    extent = pdr_add_data_dimensions (extent, scop, accesses, dr,
+				      accessp_nb_dims, dom_nb_dims);
+  }
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&accesses_ps,
 							    accesses);
@@ -2075,7 +2216,7 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 
   new_poly_dr (pbb, dr_base_object_set, accesses_ps,
 	       DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
-	       dr, DR_NUM_DIMENSIONS (dr));
+	       dr, DR_NUM_DIMENSIONS (dr), acc, extent);
 }
 
 /* Write to FILE the alias graph of data references in DIMACS format.  */
-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 19:02       ` Sebastian Pop
@ 2011-08-11 20:11         ` Tobias Grosser
  2011-08-11 20:56           ` Sebastian Pop
  2011-08-11 22:00           ` Sven Verdoolaege
  2011-08-11 20:24         ` Sven Verdoolaege
  1 sibling, 2 replies; 58+ messages in thread
From: Tobias Grosser @ 2011-08-11 20:11 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Sven Verdoolaege, gcc-patches

On 08/11/2011 07:16 PM, Sebastian Pop wrote:
> On Thu, Aug 11, 2011 at 13:03, Sebastian Pop<sebpop@gmail.com>  wrote:
>> >  On Thu, Aug 11, 2011 at 12:52, Tobias Grosser<tobias@grosser.es>  wrote:
>>> >>  I will commit this patch after the configure changes are in (and meanwhile
>>> >>  no further improvements were suggested for this patch).
>> >
>> >  Ok, thanks.  Let's hope we will have a configure maintainer that has some
>> >  spare cycles to go over your first 3 patches.
>> >
>> >  I will post my patches that convert graphite to ISL on top of your patches.
> I am following the PET (Polyhedral Extraction Tool) git://repo.or.cz/pet.git
> code as suggested by Tobias and Sven in order to help with the translation
> of graphite to ISL.
>
> Here is where I am right now: I am building the ISL counterpart for
> scop->context
> pbb->domain
> pdr->accesses
> and I still have to translate to ISL the original and transformed scattering.
>
> The plan is to build the ISL representation in parallel with PPL data structs,
> then make sure that ISL sets and maps contain valid data, and then move
> away from PPL data structures one by one.
>
> I would appreciate preliminary remarks on these patches.

Hey,

wonderful. Here my first remarks:

> 0005-Remove-ATTRIBUTE_UNUSED.patch
No comment.

> 0006-Add-ISL-data-structures.patch
> 0007-Add-scop-context.patch
>   /* Compute the lower bound LOW and upper bound UP for the induction
> @@ -1360,10 +1368,32 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,

This needs to be adapted to my cloog.org interface patch.

> +/* Prints an isl_set S to stderr.  */
> +
> +DEBUG_FUNCTION void
> +debug_isl_set (isl_set *s)
> +{
> +  isl_ctx *ctx = isl_ctx_alloc ();
> +  isl_printer *pp = isl_printer_to_file (ctx, stderr);
> +  pp = isl_printer_print_set (pp, s);
> +  isl_printer_free (pp);
> +  isl_ctx_free (ctx);
> +}
> +
> +/* Prints an isl_pw_aff A to stderr.  */
> +
> +DEBUG_FUNCTION void
> +debug_isl_pwaff (isl_pw_aff *a)
> +{
> +  isl_ctx *ctx = isl_ctx_alloc ();
> +  isl_printer *pp = isl_printer_to_file (ctx, stderr);
> +  pp = isl_printer_print_pw_aff (pp, a);
> +  isl_printer_free (pp);
> +  isl_ctx_free (ctx);
> +}
> +
> +/* Prints an isl_aff A to stderr.  */
> +
> +DEBUG_FUNCTION void
> +debug_isl_aff (isl_aff *a)
> +{
> +  isl_ctx *ctx = isl_ctx_alloc ();
> +  isl_printer *pp = isl_printer_to_file (ctx, stderr);
> +  pp = isl_printer_print_aff (pp, a);
> +  isl_printer_free (pp);
> +  isl_ctx_free (ctx);
> +}

No need to define these. isl_set_dump(isl_set *) should do what you 
want. Similar functions are defined for other data types.
Furthermore, gdb should also automatically an islprint method, that
allows you to dump (almost) any isl type.

> +static inline bool
> +isl_set_is_equal_ppl_polyhedron (isl_set *s1, ppl_const_Polyhedron_t ph,
> +				 int nb_params, CloogState *state)
> +{
> +  isl_set *s2 = isl_set_from_cloog_domain
> +    (new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state));
> +  int res = isl_set_is_equal (s1, s2);
> +  isl_set_free (s2);
> +  return res;
> +}
Clever. ;-)

> +/*
> +  gcc_assert (isl_set_is_equal_ppl_powerset (scop->context,
> +					     SCOP_CONTEXT (scop),
> +					     scop_nb_params (scop),
> +					     cloog_state));
> +*/
Seems to be useless.

>   #endif /* GRAPHITE_CLOOG_UTIL_H */
> diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
> index af40d20..225c8a2 100644
> --- a/gcc/graphite-poly.c
> +++ b/gcc/graphite-poly.c
> @@ -1012,6 +1012,7 @@ new_scop (void *region)
>     scop_p scop = XNEW (struct scop);
>
>     SCOP_CONTEXT (scop) = NULL;
> +  scop->context = NULL;
>     scop_set_region (scop, region);
>     SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
>     SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
> @@ -1040,6 +1041,9 @@ free_scop (scop_p scop)
>     if (SCOP_CONTEXT (scop))
>       ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
>
> +  if (scop->context)
> +    isl_set_free (scop->context);
The if is most probably not needed. Sven recently stated, that passing 
NULL to
isl_*_free functions has defined semantics.

> diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
> index 3a5fddb..775c853 100644
> --- a/gcc/graphite-poly.h
> +++ b/gcc/graphite-poly.h
> @@ -1409,6 +1409,9 @@ struct scop
>     ppl_Pointset_Powerset_C_Polyhedron_t _context;
>     isl_set *context;
>
> +  /* The context used internally by ISL.  */
> +  isl_ctx *ctx;
> +
>     /* A hashtable of the data dependence relations for the original
>        scattering.  */
>     htab_t original_pddrs;

> +/* Return an ISL identifier from the name of the ssa_name E.  */
> +
> +static isl_id *
> +isl_id_for_ssa_name (scop_p s, tree e)
> +{
> +  const char *name = get_name (e);
> +  isl_id *id;
> +
> +  if (name)
> +    id = isl_id_alloc (s->ctx, name, e);
Does get_name() return always a unique name or is just the tuple 
(get_name(e), SSA_NAME_VERSION(e)) unique?

> +/* Return an ISL identifier from the name of the ssa_name E.  */
> +
> +static isl_id *
> +isl_id_for_loop (scop_p s, loop_p l)

The comment for this function does not match.

> +/* Compute pwaff mod 2^width.  */
> +
> +static isl_pw_aff *
> +wrap (isl_pw_aff *pwaff, unsigned width)
> +{
> +  isl_int mod;
> +
> +  isl_int_init (mod);
> +  isl_int_set_si (mod, 1);
> +  isl_int_mul_2exp (mod, mod, width);
> +
> +  pwaff = isl_pw_aff_mod (pwaff, mod);
> +
> +  isl_int_clear (mod);
> +
> +  return pwaff;
> +}

You may just want to use isl_pw_aff_mod().
> diff --git a/gcc/graphite.c b/gcc/graphite.c
> index 8f6d8a1..b2cf7c6 100644
> --- a/gcc/graphite.c
> +++ b/gcc/graphite.c
> @@ -260,10 +260,12 @@ graphite_transform_loops (void)
>     bool need_cfg_cleanup_p = false;
>     VEC (scop_p, heap) *scops = NULL;
>     htab_t bb_pbb_mapping;
> +  isl_ctx *ctx;
>
>     if (!graphite_initialize ())
>       return;t
>
> +  ctx = isl_ctx_alloc ();
>     build_scops (&scops);
>
>     if (dump_file&&  (dump_flags&  TDF_DETAILS))
> @@ -277,6 +279,7 @@ graphite_transform_loops (void)
>     FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
>       if (dbg_cnt (graphite_scop))
>         {
> +	scop->ctx = ctx;
>   	build_poly_scop (scop);
>
>   	if (POLY_SCOP_P (scop)
> @@ -288,6 +291,7 @@ graphite_transform_loops (void)
>     htab_delete (bb_pbb_mapping);
>     free_scops (scops);
>     graphite_finalize (need_cfg_cleanup_p);
> +  isl_ctx_free (ctx);

We should check with Sven if there will be any troubles/problems, 
because ClooG is allocating its own context and we are passing 
isl_objects between those two contexts.

I think the best would be to provide our ctx to cloog when allocating
the CloogState.

> 0008-fix-memory-leak.patch
No comment.

> 0009-add-pbb-domain.patch
> diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
> index 225c8a2..c5b32d6 100644
> --- a/gcc/graphite-poly.c
> +++ b/gcc/graphite-poly.c
> @@ -901,7 +902,11 @@ free_poly_bb (poly_bb_p pbb)
>     int i;
>     poly_dr_p pdr;
>
> -  ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
> +  if (PBB_DOMAIN (pbb))
> +    ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
> +
> +  if (pbb->domain)
> +    isl_set_free (pbb->domain);
The if is not needed here.

>     if (PBB_TRANSFORMED (pbb))
>       poly_scattering_free (PBB_TRANSFORMED (pbb));
> @@ -1060,6 +1065,9 @@ openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
>     graphite_dim_t i;
>     gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
>
> +  if (isl_set_plain_is_empty (pbb->domain))
> +    return;

Why do we return if a domain is empty. There may be cases where the 
domain is empty because some constraints show us that the code will 
never be executed. Still, I think it is good to show that this PBB
has a valid, though empty, domain.

> 0010-add-pdr-accesses-and-pdr-extent.patch
> +/* Prints an isl_map M to stderr.  */
> +
> +DEBUG_FUNCTION void
> +debug_isl_map (isl_map *m)
> +{
> +  isl_ctx *ctx = isl_ctx_alloc ();
> +  isl_printer *pp = isl_printer_to_file (ctx, stderr);
> +  pp = isl_printer_print_map (pp, m);
> +  isl_printer_free (pp);
> +  isl_ctx_free (ctx);
> +}
> +

Not needed. Use isl_map_dump(isl_map*).

> +DEBUG_FUNCTION void
> +debug_isl_id (isl_id *i)
> +{
> +  isl_ctx *ctx = isl_ctx_alloc ();
> +  isl_printer *pp = isl_printer_to_file (ctx, stderr);
> +  pp = isl_printer_print_id (pp, i);
> +  isl_printer_free (pp);
> +  isl_ctx_free (ctx);
> +}
Does isl also have a dump function for this?

That's from my side. I am extremely impressed by your progress, and 
believe this move makes the code of graphite both a lot more readable 
and hopefully also a lot more correct.

Cheers and thanks for all the work!
Tobi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 19:02       ` Sebastian Pop
  2011-08-11 20:11         ` Tobias Grosser
@ 2011-08-11 20:24         ` Sven Verdoolaege
  2011-08-11 20:54           ` Sebastian Pop
  1 sibling, 1 reply; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-11 20:24 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 01:16:45PM -0500, Sebastian Pop wrote:
> +  if (1)
> +    {
> +      /* For now remove the isl_id's from the context before
> +	 translating to CLooG: this code will be removed when the
> +	 domain will also contain isl_id's.  */
> +      isl_set *context = isl_set_project_out (isl_set_copy (scop->context),
> +					      isl_dim_set, 0, number_of_loops ());
> +      isl_printer *p = isl_printer_to_str (scop->ctx);
> +      char *str;
> +
> +      p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
> +      p = isl_printer_print_set (p, context);
> +      isl_set_free (context);
> +
> +      str = isl_printer_get_str (p);
> +      context = isl_set_read_from_str (scop->ctx, str,
> +				       scop_nb_params (scop));
> +      free (str);
> +      isl_printer_free (p);

Hmm.... are you saying you would like a isl_set_reset_dim_id?

> @@ -415,4 +416,40 @@ openscop_read_polyhedron_matrix (FILE *file, ppl_Polyhedron_t *ph,
>      }
>  }
>  
> +/* Prints an isl_set S to stderr.  */
> +
> +DEBUG_FUNCTION void
> +debug_isl_set (isl_set *s)

You could use isl_set_dump.
It's not documented because I don't want people to depend on the output,
but for debugging it should be just fine.

> @@ -1040,6 +1041,9 @@ free_scop (scop_p scop)
>    if (SCOP_CONTEXT (scop))
>      ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
>  
> +  if (scop->context)
> +    isl_set_free (scop->context);
> +

isl_set_free will handle NULL input just fine.

> +static isl_pw_aff *
> +extract_affine_chrec (scop_p s, tree e)
> +{
> +  isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e));
> +  isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e));
> +  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
> +  isl_local_space *ls = isl_local_space_from_dim (dim);
> +  isl_aff *loop = isl_aff_set_coefficient_si
> +    (isl_aff_zero (ls), isl_dim_set, CHREC_VARIABLE (e), 1);
> +
> +  return isl_pw_aff_add (lhs,
> +			 isl_pw_aff_mul (rhs, isl_pw_aff_from_aff (loop)));

You should test that at least one of your arguments is constant.
Alternatively, if you want to construct polynomials, you should
use isl_pw_qpolynomials instead.

> +  isl_set *inner = isl_set_copy (outer);
> +  isl_dim *d = isl_set_get_dim (scop->context);
> +  isl_id *id = isl_id_for_loop (scop, loop);
> +  int pos = isl_dim_find_dim_by_id (d, isl_dim_set, id);

This is dangerous.  You cannot depend on non-parameters
keeping their ids across operations.  Don't you already
know the position somehow?  When you are using PPL,
you must keep track of this information, no?

> +
> +  /* FIXME: This function will be renamed isl_map_insert_dims and
> +     documented in a later version of ISL (current ISL is 0.07).  */

Since you are using isl_ids, 0.07 won't work for you.

> +	  /* Make the dimension of LB and UB to be exactly NBS.  */
> +	  lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1);
> +	  ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1);
> +	  lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1);
> +	  ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1);

This looks fishy.  Are you sure the expressions don't depend on the
set variables?

> +  {
> +    isl_dim *dc = isl_set_get_dim (scop->context);
> +    int nb_in = isl_dim_size (dc, isl_dim_set);
> +    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
> +    int nbp = scop_nb_params (scop);
> +    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
> +    int i;
> +
> +    for (i = 0; i < nbp; i++)
> +      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
> +				isl_dim_get_dim_id (dc, isl_dim_param, i));
> +    for (i = 0; i < nb_in; i++)
> +      dim = isl_dim_set_dim_id (dim, isl_dim_in, i,
> +				isl_dim_get_dim_id (dc, isl_dim_set, i));

This is dangerous too.  Why don't you derive dim directly from dc
instead of creating a fresh dim and then trying to copy some information?

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:24         ` Sven Verdoolaege
@ 2011-08-11 20:54           ` Sebastian Pop
  2011-08-11 22:06             ` Sven Verdoolaege
  2011-08-11 22:45             ` Sebastian Pop
  0 siblings, 2 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 20:54 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 14:28, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Thu, Aug 11, 2011 at 01:16:45PM -0500, Sebastian Pop wrote:
>> +  if (1)
>> +    {
>> +      /* For now remove the isl_id's from the context before
>> +      translating to CLooG: this code will be removed when the
>> +      domain will also contain isl_id's.  */
>> +      isl_set *context = isl_set_project_out (isl_set_copy (scop->context),
>> +                                           isl_dim_set, 0, number_of_loops ());
>> +      isl_printer *p = isl_printer_to_str (scop->ctx);
>> +      char *str;
>> +
>> +      p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
>> +      p = isl_printer_print_set (p, context);
>> +      isl_set_free (context);
>> +
>> +      str = isl_printer_get_str (p);
>> +      context = isl_set_read_from_str (scop->ctx, str,
>> +                                    scop_nb_params (scop));
>> +      free (str);
>> +      isl_printer_free (p);
>
> Hmm.... are you saying you would like a isl_set_reset_dim_id?

No thanks: this is just a hack that will disappear when all the data structs
will be in ISL format.  I had this a bug with ISL complained during cloog
codegen that some maps had ids and some other maps did not.

>> +  return isl_pw_aff_add (lhs,
>> +                      isl_pw_aff_mul (rhs, isl_pw_aff_from_aff (loop)));
>
> You should test that at least one of your arguments is constant.
> Alternatively, if you want to construct polynomials, you should
> use isl_pw_qpolynomials instead.

Ok, good to know, I remember also the manual warning on this point.

I think that, in this case, it is safe, as at this point we are working on
code that has already been filtered out of other things than affine
expressions.  I should then assert that at least one of the args
is constant.

>> +  isl_set *inner = isl_set_copy (outer);
>> +  isl_dim *d = isl_set_get_dim (scop->context);
>> +  isl_id *id = isl_id_for_loop (scop, loop);
>> +  int pos = isl_dim_find_dim_by_id (d, isl_dim_set, id);
>
> This is dangerous.  You cannot depend on non-parameters
> keeping their ids across operations.

Ok.  Could you please document this in the ISL user manual?

> Don't you already know the position somehow?

Yes, I could be using the index of the loop (loop->num) here,
as the scop->context contains dimensions for all the existing
loops in the program.

>
>> +
>> +  /* FIXME: This function will be renamed isl_map_insert_dims and
>> +     documented in a later version of ISL (current ISL is 0.07).  */
>
> Since you are using isl_ids, 0.07 won't work for you.

For now I'm using the ISL that is distributed with cloog-isl.
What version of ISL should I use to have isl_ids working?

>
>> +       /* Make the dimension of LB and UB to be exactly NBS.  */
>> +       lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1);
>> +       ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1);
>> +       lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1);
>> +       ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1);
>
> This looks fishy.  Are you sure the expressions don't depend on the
> set variables?

Yes, the lb and ub in this particular case are integers only:
the weird condition that we have just before ensures that.

+      if (host_integerp (low, 0)
+	  && high
+	  && host_integerp (high, 0)
+	  /* 1-element arrays at end of structures may extend over
+	     their declared size.  */
+	  && !(array_at_struct_end_p (ref)
+	       && operand_equal_p (low, high, 0)))

>
>> +  {
>> +    isl_dim *dc = isl_set_get_dim (scop->context);
>> +    int nb_in = isl_dim_size (dc, isl_dim_set);
>> +    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
>> +    int nbp = scop_nb_params (scop);
>> +    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
>> +    int i;
>> +
>> +    for (i = 0; i < nbp; i++)
>> +      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
>> +                             isl_dim_get_dim_id (dc, isl_dim_param, i));
>> +    for (i = 0; i < nb_in; i++)
>> +      dim = isl_dim_set_dim_id (dim, isl_dim_in, i,
>> +                             isl_dim_get_dim_id (dc, isl_dim_set, i));
>
> This is dangerous too.  Why don't you derive dim directly from dc
> instead of creating a fresh dim and then trying to copy some information?

Yes, thanks for pointing this out.  I will fix this.

Thanks,
Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:11         ` Tobias Grosser
@ 2011-08-11 20:56           ` Sebastian Pop
  2011-08-11 22:45             ` Sven Verdoolaege
  2011-08-11 22:00           ` Sven Verdoolaege
  1 sibling, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 20:56 UTC (permalink / raw)
  To: Tobias Grosser; +Cc: Sven Verdoolaege, gcc-patches

On Thu, Aug 11, 2011 at 14:14, Tobias Grosser <tobias@grosser.es> wrote:
> This needs to be adapted to my cloog.org interface patch.

I will adapt my patch set to be on top of your patch.

>> +/* Return an ISL identifier from the name of the ssa_name E.  */
>> +
>> +static isl_id *
>> +isl_id_for_ssa_name (scop_p s, tree e)
>> +{
>> +  const char *name = get_name (e);
>> +  isl_id *id;
>> +
>> +  if (name)
>> +    id = isl_id_alloc (s->ctx, name, e);
>
> Does get_name() return always a unique name or is just the tuple
> (get_name(e), SSA_NAME_VERSION(e)) unique?

As we are using this function only on parameters, get_name should
return a unique name.  I guess that the name in isl_id is only used
for debugging purposes, as the ISL manual states that "Identifiers
with the same name but different pointer values are considered to
be distinct."

>> @@ -1060,6 +1065,9 @@ openscop_print_pbb_domain (FILE *file, poly_bb_p
>> pbb, int verbosity)
>>    graphite_dim_t i;
>>    gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
>>
>> +  if (isl_set_plain_is_empty (pbb->domain))
>> +    return;
>
> Why do we return if a domain is empty. There may be cases where the domain

This change is in untested "feature" (read "bug") code: there are no
testcase, and the code of openscop is not enabled in trunk.  I will
remove the code for openscop and let somebody else do the ISL
port for it and re-enable if needed.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:11         ` Tobias Grosser
  2011-08-11 20:56           ` Sebastian Pop
@ 2011-08-11 22:00           ` Sven Verdoolaege
  1 sibling, 0 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-11 22:00 UTC (permalink / raw)
  To: Tobias Grosser; +Cc: Sebastian Pop, gcc-patches

On Thu, Aug 11, 2011 at 08:14:05PM +0100, Tobias Grosser wrote:
> I think the best would be to provide our ctx to cloog when allocating
> the CloogState.

Yes.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:54           ` Sebastian Pop
@ 2011-08-11 22:06             ` Sven Verdoolaege
  2011-08-11 22:45               ` Sebastian Pop
  2011-08-11 22:45             ` Sebastian Pop
  1 sibling, 1 reply; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-11 22:06 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 03:10:30PM -0500, Sebastian Pop wrote:
> On Thu, Aug 11, 2011 at 14:28, Sven Verdoolaege <skimo@kotnet.org> wrote:
> > On Thu, Aug 11, 2011 at 01:16:45PM -0500, Sebastian Pop wrote:
> >> +
> >> +  /* FIXME: This function will be renamed isl_map_insert_dims and
> >> +     documented in a later version of ISL (current ISL is 0.07).  */
> >
> > Since you are using isl_ids, 0.07 won't work for you.
> 
> For now I'm using the ISL that is distributed with cloog-isl.

Which version?

> What version of ISL should I use to have isl_ids working?

0.08.  While you are developing, you can use the latest
git version and just tell CLooG to use that version.
While I will not be maintaining CLooG this year, I will
provide updates if I change isl in some incompatible way.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 02/11] Require cloog 0.16.3
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (3 preceding siblings ...)
  2011-08-11 22:45                   ` [PATCH 06/11] Remove ATTRIBUTE_UNUSED Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 03/11] Remove code that supported legacy CLooG Sebastian Pop
                                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

2011-07-21  Tobias Grosser  <tobias@grosser.es>

	* configure: Regenerated.
	* configure.ac: Require cloog isl 0.16.3

Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 ChangeLog    |    5 +++++
 configure    |    6 +++---
 configure.ac |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aeb3f14..0c721d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2011-07-21  Tobias Grosser  <tobias@grosser.es>
 
 	* configure: Regenerated.
+	* configure.ac: Require cloog isl 0.16.3
+
+2011-07-21  Tobias Grosser  <tobias@grosser.es>
+
+	* configure: Regenerated.
 	* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
 	both cloog.org and legacy versions. The only supported version will
 	be CLooG with the isl backend.
diff --git a/configure b/configure
index fbb29e0..86aa457 100755
--- a/configure
+++ b/configure
@@ -5835,8 +5835,8 @@ $as_echo "$gcc_cv_cloog_type" >&6; }
     CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
     LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.1 of CLooG" >&5
-$as_echo_n "checking for version 0.16.1 of CLooG... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.3 of CLooG" >&5
+$as_echo_n "checking for version 0.16.3 of CLooG... " >&6; }
 if test "${gcc_cv_cloog+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
@@ -5848,7 +5848,7 @@ main ()
 {
 #if CLOOG_VERSION_MAJOR != 0 \
     || CLOOG_VERSION_MINOR != 16 \
-    || CLOOG_VERSION_REVISION < 1
+    || CLOOG_VERSION_REVISION < 3
     choke me
    #endif
   ;
diff --git a/configure.ac b/configure.ac
index 4cf1160..0ef2180 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,7 +1589,7 @@ if test "x$with_cloog" != "xno"; then
   dnl
   dnl If we use CLooG-Legacy, the provided version information is
   dnl ignored.
-  CLOOG_CHECK_VERSION(0,16,1)
+  CLOOG_CHECK_VERSION(0,16,3)
 
   dnl Only execute fail-action, if CLooG has been requested.
   CLOOG_IF_FAILED([
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 06/11] Remove ATTRIBUTE_UNUSED
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (2 preceding siblings ...)
  2011-08-11 22:45                   ` [PATCH 10/11] add pbb->domain Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 02/11] Require cloog 0.16.3 Sebastian Pop
                                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-cloog-util.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 9bc24a0..83cfb54 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -236,7 +236,7 @@ new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
 
 CloogDomain *
 new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
-                                      CloogState *state ATTRIBUTE_UNUSED)
+                                      CloogState *state)
 {
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params);
@@ -248,9 +248,9 @@ new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
 
 CloogScattering *
 new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
-                                          int nb_params ATTRIBUTE_UNUSED,
-                                          int nb_scatt ATTRIBUTE_UNUSED,
-                                          CloogState *state ATTRIBUTE_UNUSED)
+                                          int nb_params,
+                                          int nb_scatt,
+                                          CloogState *state)
 {
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogScattering *res = cloog_scattering_from_cloog_matrix (state, mat,
@@ -266,7 +266,7 @@ new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
 CloogDomain *
 new_Cloog_Domain_from_ppl_Pointset_Powerset
   (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params,
-   CloogState *state ATTRIBUTE_UNUSED)
+   CloogState *state)
 {
   CloogDomain *res = NULL;
   ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:56           ` Sebastian Pop
@ 2011-08-11 22:45             ` Sven Verdoolaege
  0 siblings, 0 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-11 22:45 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 03:23:13PM -0500, Sebastian Pop wrote:
> As we are using this function only on parameters, get_name should
> return a unique name.  I guess that the name in isl_id is only used
> for debugging purposes, as the ISL manual states that "Identifiers
> with the same name but different pointer values are considered to
> be distinct."

Identifiers with different names are (obviously) also considered
to be distinct.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 03/11] Remove code that supported legacy CLooG.
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (4 preceding siblings ...)
  2011-08-11 22:45                   ` [PATCH 02/11] Require cloog 0.16.3 Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
                                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

2011-07-21  Tobias Grosser  <tobias@grosser.es>

	* configure: Regenerated.
	* config/cloog.m4: Do not define CLOOG_ORG

and in gcc/

2011-07-21  Tobias Grosser  <tobias@grosser.es>

	* Makefile.in (graphite-clast-to-gimple.o, graphite-cloog-util.o):
	Remove graphite-cloog-util.h.
	* graphite-clast-to-gimple.c (gcc_type_for_iv_of_clast_loop,
	build_iv_mapping, translate_clast_user, translate_clast,
	free_scattering, initialize_cloog_names, build_cloog_prog,
	create_params_index): Do not use old compatibility functions.
	(clast_name_to_index, set_cloog_options): Remove code for legacy cloog.
	* graphite-cloog-util.c (openscop_print_cloog_matrix): Do not use old
	compatibility functions.
	(new_Cloog_Scattering_from_ppl_Polyhedron): Remove code for legacy
	cloog.
	* graphite-cloog-util.h: Remove include of graphite-cloog-util.h.
	* graphite.c (graphite.c): Do not call outdated cloog_initialize() and
	cloog_finalize().
	* graphite-cloog-compat.h: Remove.

Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 ChangeLog                      |    5 +
 config/cloog.m4                |    2 +-
 configure                      |    2 +-
 gcc/ChangeLog                  |   18 +++
 gcc/Makefile.in                |    4 +-
 gcc/graphite-clast-to-gimple.c |   96 ++++++--------
 gcc/graphite-cloog-compat.h    |  275 ----------------------------------------
 gcc/graphite-cloog-util.c      |   15 +--
 gcc/graphite-cloog-util.h      |    1 -
 gcc/graphite.c                 |    2 -
 10 files changed, 74 insertions(+), 346 deletions(-)
 delete mode 100644 gcc/graphite-cloog-compat.h

diff --git a/ChangeLog b/ChangeLog
index 0c721d3..6980618 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2011-07-21  Tobias Grosser  <tobias@grosser.es>
 
 	* configure: Regenerated.
+	* config/cloog.m4: Do not define CLOOG_ORGt 
+
+2011-07-21  Tobias Grosser  <tobias@grosser.es>
+
+	* configure: Regenerated.
 	* configure.ac: Require cloog isl 0.16.3
 
 2011-07-21  Tobias Grosser  <tobias@grosser.es>
diff --git a/config/cloog.m4 b/config/cloog.m4
index 8662acd..9c42445 100644
--- a/config/cloog.m4
+++ b/config/cloog.m4
@@ -109,7 +109,7 @@ AC_DEFUN([CLOOG_FIND_FLAGS],
   _cloog_saved_LDFLAGS=$LDFLAGS
   _cloog_saved_LIBS=$LIBS
 
-  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  _cloogorginc="-DCLOOG_INT_GMP"
  
   dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
   CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
diff --git a/configure b/configure
index 86aa457..59644c2 100755
--- a/configure
+++ b/configure
@@ -5772,7 +5772,7 @@ if test "x$with_cloog" != "xno"; then
   _cloog_saved_LDFLAGS=$LDFLAGS
   _cloog_saved_LIBS=$LIBS
 
-  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  _cloogorginc="-DCLOOG_INT_GMP"
 
     CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 580c12f..fb298d2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2011-07-21  Tobias Grosser  <tobias@grosser.es>
+
+	* Makefile.in (graphite-clast-to-gimple.o, graphite-cloog-util.o):
+	Remove graphite-cloog-util.h.
+	* graphite-clast-to-gimple.c (gcc_type_for_iv_of_clast_loop,
+	build_iv_mapping, translate_clast_user, translate_clast,
+	free_scattering, initialize_cloog_names, build_cloog_prog,
+	create_params_index): Do not use old compatibility functions.
+	(clast_name_to_index, set_cloog_options): Remove code for legacy cloog.
+	* graphite-cloog-util.c (openscop_print_cloog_matrix): Do not use old
+	compatibility functions.
+	(new_Cloog_Scattering_from_ppl_Polyhedron): Remove code for legacy
+	cloog.
+	* graphite-cloog-util.h: Remove include of graphite-cloog-util.h.
+	* graphite.c (graphite.c): Do not call outdated cloog_initialize() and
+	cloog_finalize().
+	* graphite-cloog-compat.h: Remove.
+
 2011-08-01  Richard Henderson  <rth@redhat.com>
 
 	PR target/49881
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 593c951..2a9e877 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2690,9 +2690,9 @@ graphite-clast-to-gimple.o : graphite-clast-to-gimple.c $(CONFIG_H) \
    $(SYSTEM_H) coretypes.h $(DIAGNOSTIC_CORE_H) $(TREE_FLOW_H) $(TREE_DUMP_H) \
    $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h graphite-cloog-util.h \
    graphite-ppl.h graphite-poly.h graphite-clast-to-gimple.h \
-   graphite-dependences.h graphite-cloog-compat.h
+   graphite-dependences.h
 graphite-cloog-util.o : graphite-cloog-util.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h graphite-cloog-util.h graphite-cloog-compat.h
+   coretypes.h graphite-cloog-util.h
 graphite-dependences.o : graphite-dependences.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
    sese.h graphite-ppl.h graphite-poly.h graphite-dependences.h \
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 5f7a747..a76b01d 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -38,7 +38,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "graphite-poly.h"
 #include "graphite-clast-to-gimple.h"
 #include "graphite-dependences.h"
-#include "graphite-cloog-compat.h"
+
+typedef const struct clast_expr *clast_name_p;
 
 #ifndef CLOOG_LANGUAGE_C
 #define CLOOG_LANGUAGE_C LANGUAGE_C
@@ -112,12 +113,8 @@ clast_name_to_level (clast_name_p name, htab_t index_table)
   struct clast_name_index tmp;
   PTR *slot;
 
-#ifdef CLOOG_ORG
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
-#else
-  tmp.name = name;
-#endif
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -870,7 +867,7 @@ graphite_create_new_loop (edge entry_edge, struct clast_for *stmt,
 
   struct clast_user_stmt *body
     = clast_get_body_of_loop ((struct clast_stmt *) stmt);
-  poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (body->statement);
+  poly_bb_p pbb = (poly_bb_p) body->statement->usr;
 
   tree stride = gmp_cst_to_tree (type, stmt->stride);
   tree ivvar = create_tmp_var (type, "graphite_IV");
@@ -902,7 +899,7 @@ build_iv_mapping (VEC (tree, heap) *iv_map, struct clast_user_stmt *user_stmt,
   struct clast_stmt *t;
   int depth = 0;
   CloogStatement *cs = user_stmt->statement;
-  poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs);
+  poly_bb_p pbb = (poly_bb_p) cs->usr;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
   mpz_t bound_one, bound_two;
 
@@ -1019,7 +1016,7 @@ translate_clast_user (struct clast_user_stmt *stmt, edge next_e,
 {
   int i, nb_loops;
   basic_block new_bb;
-  poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (stmt->statement);
+  poly_bb_p pbb = (poly_bb_p) stmt->statement->usr;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
   VEC (tree, heap) *iv_map;
 
@@ -1248,8 +1245,8 @@ free_scattering (CloogScatteringList *scattering)
 {
   while (scattering)
     {
-      CloogScattering *dom = cloog_scattering (scattering);
-      CloogScatteringList *next = cloog_next_scattering (scattering);
+      CloogScattering *dom = scattering->scatt;
+      CloogScatteringList *next = scattering->next;
 
       cloog_scattering_free (dom);
       free (scattering);
@@ -1267,13 +1264,13 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
   sese region = SCOP_REGION (scop);
   int i;
   int nb_iterators = scop_max_loop_depth (scop);
-  int nb_scattering = cloog_program_nb_scattdims (prog);
+  int nb_scattering = prog->nb_scattdims;
   int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
   char **iterators = XNEWVEC (char *, nb_iterators * 2);
   char **scattering = XNEWVEC (char *, nb_scattering);
   char **parameters= XNEWVEC (char *, nb_parameters);
 
-  cloog_program_set_names (prog, cloog_names_malloc ());
+  prog->names = cloog_names_malloc ();
 
   for (i = 0; i < nb_parameters; i++)
     {
@@ -1290,8 +1287,8 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
       snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
     }
 
-  cloog_names_set_nb_parameters (cloog_program_names (prog), nb_parameters);
-  cloog_names_set_parameters (cloog_program_names (prog), parameters);
+  prog->names->nb_parameters = nb_parameters;
+  prog->names->parameters = parameters;
 
   for (i = 0; i < nb_iterators; i++)
     {
@@ -1300,10 +1297,8 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
       snprintf (iterators[i], len, "git_%d", i);
     }
 
-  cloog_names_set_nb_iterators (cloog_program_names (prog),
-				nb_iterators);
-  cloog_names_set_iterators (cloog_program_names (prog),
-			     iterators);
+  prog->names->nb_iterators = nb_iterators;
+  prog->names->iterators = iterators;
 
   for (i = 0; i < nb_scattering; i++)
     {
@@ -1312,10 +1307,8 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
       snprintf (scattering[i], len, "scat_%d", i);
     }
 
-  cloog_names_set_nb_scattering (cloog_program_names (prog),
-				 nb_scattering);
-  cloog_names_set_scattering (cloog_program_names (prog),
-			      scattering);
+  prog->names->nb_scattering = nb_scattering;
+  prog->names->scattering = scattering;
 }
 
 /* Initialize a CLooG input file.  */
@@ -1358,12 +1351,13 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
   int nbs = 2 * max_nb_loops + 1;
   int *scaldims;
 
-  cloog_program_set_context
-    (prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
-      scop_nb_params (scop), cloog_state));
+  prog->context =
+    new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
+						 scop_nb_params (scop),
+						 cloog_state);
   nbs = unify_scattering_dimensions (scop);
   scaldims = (int *) xmalloc (nbs * (sizeof (int)));
-  cloog_program_set_nb_scattdims (prog, nbs);
+  prog->nb_scattdims = nbs;
   initialize_cloog_names (scop, prog);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
@@ -1383,14 +1377,14 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
                                                          scop_nb_params (scop),
                                                          cloog_state);
       block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
-      cloog_statement_set_usr (stmt, pbb);
+      stmt->usr = pbb;
 
       /* Build loop list.  */
       {
         CloogLoop *new_loop_list = cloog_loop_malloc (cloog_state);
-        cloog_loop_set_next (new_loop_list, loop_list);
-        cloog_loop_set_domain (new_loop_list, dom);
-        cloog_loop_set_block (new_loop_list, block);
+        new_loop_list->next = loop_list;
+        new_loop_list->domain = dom;
+        new_loop_list->block = block;
         loop_list = new_loop_list;
       }
 
@@ -1398,8 +1392,8 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
       {
         CloogBlockList *new_block_list = cloog_block_list_malloc ();
 
-        cloog_block_list_set_next (new_block_list, block_list);
-        cloog_block_list_set_block (new_block_list, block);
+        new_block_list->next = block_list;
+        new_block_list->block = block;
         block_list = new_block_list;
       }
 
@@ -1416,19 +1410,19 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
           (scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb),
            cloog_state);
 
-        cloog_set_next_scattering (new_scattering, scattering);
-        cloog_set_scattering (new_scattering, dom);
+        new_scattering->next = scattering;
+        new_scattering->scatt = dom;
         scattering = new_scattering;
       }
     }
 
-  cloog_program_set_loop (prog, loop_list);
-  cloog_program_set_blocklist (prog, block_list);
+  prog->loop = loop_list;
+  prog->blocklist = block_list;
 
   for (i = 0; i < nbs; i++)
     scaldims[i] = 0 ;
 
-  cloog_program_set_scaldims (prog, scaldims);
+  prog->scaldims = scaldims;
 
   /* Extract scalar dimensions to simplify the code generation problem.  */
   cloog_program_extract_scalars (prog, scattering, options);
@@ -1449,22 +1443,21 @@ build_cloog_prog (scop_p scop, CloogProgram *prog,
   free_scattering (scattering);
 
   /* Iterators corresponding to scalar dimensions have to be extracted.  */
-  cloog_names_scalarize (cloog_program_names (prog), nbs,
-			 cloog_program_scaldims (prog));
+  cloog_names_scalarize (prog->names, nbs, prog->scaldims);
 
   /* Free blocklist.  */
   {
-    CloogBlockList *next = cloog_program_blocklist (prog);
+    CloogBlockList *next = prog->blocklist;
 
     while (next)
       {
         CloogBlockList *toDelete = next;
-        next = cloog_block_list_next (next);
-        cloog_block_list_set_next (toDelete, NULL);
-        cloog_block_list_set_block (toDelete, NULL);
+        next = next->next;
+        toDelete->next =  NULL;
+        toDelete->block = NULL;
         cloog_block_list_free (toDelete);
       }
-    cloog_program_set_blocklist (prog, NULL);
+    prog->blocklist = NULL;
   }
 }
 
@@ -1486,14 +1479,8 @@ set_cloog_options (void)
      GLooG.  */
   options->esp = 1;
 
-#ifdef CLOOG_ORG
   /* Silence CLooG to avoid failing tests due to debug output to stderr.  */
   options->quiet = 1;
-#else
-  /* Enable C pretty-printing mode: normalizes the substitution
-     equations for statements.  */
-  options->cpp = 1;
-#endif
 
   /* Allow cloog to build strides with a stride width different to one.
      This example has stride = 4:
@@ -1590,10 +1577,11 @@ debug_generated_program (scop_p scop)
    back from CLooG names to GCC trees.  */
 
 static void
-create_params_index (scop_p scop, htab_t index_table, CloogProgram *prog) {
-  CloogNames* names = cloog_program_names (prog);
-  int nb_parameters = cloog_names_nb_parameters (names);
-  char **parameters = cloog_names_parameters (names);
+create_params_index (scop_p scop, htab_t index_table, CloogProgram *prog)
+{
+  CloogNames *names = prog->names;
+  int nb_parameters = names->nb_parameters;
+  char **parameters = names->parameters;
   int i;
   mpz_t bound_one, bound_two;
 
diff --git a/gcc/graphite-cloog-compat.h b/gcc/graphite-cloog-compat.h
deleted file mode 100644
index 011377d..0000000
--- a/gcc/graphite-cloog-compat.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Compatibility layer for using upstream CLooG versions with
-   CLooG legacy code.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
-   Contributed by Andreas Simbuerger <simbuerg@fim.uni-passau.de>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-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 COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#ifndef GRAPHITE_CLOOG_COMPAT_H
-#define GRAPHITE_CLOOG_COMPAT_H
-
-/* Restore compatibility to CLooG Legacy.  */
-#ifdef CLOOG_ORG
-typedef const struct clast_expr *clast_name_p;
-#else
-typedef const char *clast_name_p;
-#endif
-
-#ifdef CLOOG_ORG
-#define cloog_initialize()
-#define cloog_finalize()
-#endif
-
-#ifndef CLOOG_ORG
-
-/* CloogOptions compatibility.  */
-#define build_cloog_prog(SCOP, PROG, OPT)\
-  build_cloog_prog (SCOP, PROG)
-#define cloog_program_extract_scalars(PROG, SCATT, OPT)\
-  cloog_program_extract_scalars (PROG, SCATT)
-#define cloog_program_scatter(PROG, SCATT, OPT)\
-  cloog_program_scatter (PROG, SCATT)
-
-/* CLAST compatibility.  */
-#define clast_expr_term expr_term
-#define clast_expr_red expr_red
-#define clast_expr_bin expr_bin
-#define clast_pprint pprint
-
-/* CloogState compatibility.  */
-#define CloogState void
-#define cloog_state_malloc() NULL
-#define cloog_state_free(STATE)
-#define cloog_loop_malloc(STATE) cloog_loop_malloc ()
-#define cloog_options_malloc(STATE) cloog_options_malloc ()
-#define cloog_statement_alloc(STATE, INDEX) cloog_statement_alloc (INDEX)
-#define new_Cloog_Domain_from_ppl_Pointset_Powerset(PSPS, NB, STATE)\
-  new_Cloog_Domain_from_ppl_Pointset_Powerset (PSPS)
-#define new_Cloog_Domain_from_ppl_Polyhedron(POLY, NB, STATE)\
-  new_Cloog_Domain_from_ppl_Polyhedron (POLY)
-#define cloog_domain_from_cloog_matrix(STATE, MAT, NB)\
-  cloog_domain_matrix2domain (MAT)
-
-/* CloogScatteringList compatibility.  */
-#define CloogScatteringList CloogDomainList
-#define CloogScattering CloogDomain
-#define cloog_set_next_scattering cloog_set_next_domain
-#define cloog_set_scattering cloog_set_domain
-#define cloog_scattering cloog_domain
-#define cloog_next_scattering cloog_next_domain
-#define cloog_scattering_free cloog_domain_free
-#define cloog_program_dump_cloog(DUMPFILE, PROGRAM, SCATTERINGLIST)\
-  cloog_program_dump_cloog (DUMPFILE, PROGRAM)
-
-#endif
-
-/* Adapt CLooG accessors from CLooG legacy to
-   newer CLooG versions.  */
-
-#ifdef CLOOG_ORG
-
-static inline void *
-cloog_statement_usr (CloogStatement *cs)
-{
-  return cs->usr;
-}
-
-static inline CloogScattering *
-cloog_scattering (CloogScatteringList *sl)
-{
-  return sl->scatt;
-}
-
-static inline void
-cloog_set_scattering (CloogScatteringList *sl, CloogScattering *scatt)
-{
-  sl->scatt = scatt;
-}
-
-static inline CloogScatteringList *
-cloog_next_scattering (CloogScatteringList *sl)
-{
-  return sl->next;
-}
-
-static inline void
-cloog_set_next_scattering (CloogScatteringList *sl, CloogScatteringList *next)
-{
-  sl->next = next;
-}
-
-static inline int
-cloog_program_nb_scattdims (CloogProgram *prog)
-{
-  return prog->nb_scattdims;
-}
-
-static inline void
-cloog_program_set_nb_scattdims (CloogProgram *prog, int nb_scattdims)
-{
-  prog->nb_scattdims = nb_scattdims;
-}
-
-static inline CloogNames *
-cloog_program_names (CloogProgram *prog)
-{
-  return prog->names;
-}
-
-static inline void
-cloog_program_set_names (CloogProgram *prog, CloogNames *names)
-{
-  prog->names = names;
-}
-
-static inline void
-cloog_program_set_context (CloogProgram *prog, CloogDomain *domain)
-{
-  prog->context = domain;
-}
-
-static inline void
-cloog_program_set_loop (CloogProgram *prog, CloogLoop *loop)
-{
-  prog->loop = loop;
-}
-
-static inline CloogBlockList *
-cloog_program_blocklist (CloogProgram *prog)
-{
-  return prog->blocklist;
-}
-
-static inline void
-cloog_program_set_blocklist (CloogProgram *prog, CloogBlockList *bl)
-{
-  prog->blocklist = bl;
-}
-
-static inline int *
-cloog_program_scaldims (CloogProgram *prog)
-{
-  return prog->scaldims;
-}
-
-static inline void
-cloog_program_set_scaldims (CloogProgram *prog, int *s)
-{
-  prog->scaldims = s;
-}
-
-static inline int
-cloog_names_nb_parameters (CloogNames *names)
-{
-  return names->nb_parameters;
-}
-
-static inline void
-cloog_names_set_nb_parameters (CloogNames *names, int nb_parameters)
-{
-  names->nb_parameters = nb_parameters;
-}
-
-static inline char **
-cloog_names_parameters (CloogNames *names)
-{
-  return names->parameters;
-}
-
-static inline void
-cloog_names_set_parameters (CloogNames *names, char **parameters)
-{
-  names->parameters = parameters;
-}
-
-static inline void
-cloog_names_set_nb_iterators (CloogNames *names, int nb_iterators)
-{
-  names->nb_iterators = nb_iterators;
-}
-
-static inline void
-cloog_names_set_iterators (CloogNames *names, char **iterators)
-{
-  names->iterators = iterators;
-}
-
-static inline void
-cloog_names_set_nb_scattering (CloogNames *names, int nb_scattering)
-{
-  names->nb_scattering = nb_scattering;
-}
-
-static inline void
-cloog_names_set_scattering (CloogNames *names, char **scattering)
-{
-  names->scattering = scattering;
-}
-
-static inline void
-cloog_statement_set_usr (CloogStatement *cs, void *u)
-{
-  cs->usr = u;
-}
-
-static inline void
-cloog_loop_set_next (CloogLoop *loop, CloogLoop *next)
-{
-  loop->next = next;
-}
-
-static inline void
-cloog_loop_set_domain (CloogLoop *loop, CloogDomain *domain)
-{
-  loop->domain = domain;
-}
-
-static inline void
-cloog_loop_set_block (CloogLoop *loop, CloogBlock *block)
-{
-  loop->block = block;
-}
-
-static inline CloogBlockList *
-cloog_block_list_next (CloogBlockList *bl)
-{
-  return bl->next;
-}
-
-static inline void
-cloog_block_list_set_next (CloogBlockList *bl, CloogBlockList *next)
-{
-  bl->next = next;
-}
-
-static inline void
-cloog_block_list_set_block (CloogBlockList *bl, CloogBlock *block)
-{
-  bl->block = block;
-}
-
-static inline int cloog_matrix_ncolumns (CloogMatrix * m)
-{
-  return m->NbColumns;
-}
-
-static inline int cloog_matrix_nrows (CloogMatrix * m)
-{
-   return m->NbRows;
-}
-#endif /* CLOOG_ORG  */
-#endif /* GRAPHITE_CLOOG_COMPAT_H  */
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index c3d0cc1..9bc24a0 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -28,7 +28,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "ppl_c.h"
 #include "cloog/cloog.h"
 #include "graphite-cloog-util.h"
-#include "graphite-cloog-compat.h"
 
 /* Counts the number of constraints in PCS.  */
 
@@ -253,7 +252,6 @@ new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
                                           int nb_scatt ATTRIBUTE_UNUSED,
                                           CloogState *state ATTRIBUTE_UNUSED)
 {
-#ifdef CLOOG_ORG
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogScattering *res = cloog_scattering_from_cloog_matrix (state, mat,
                                                              nb_scatt,
@@ -261,9 +259,6 @@ new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
 
   cloog_matrix_free (mat);
   return res;
-#else
-  return new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state);
-#endif
 }
 
 /* Creates a CloogDomain from a pointset powerset PS.  */
@@ -314,14 +309,14 @@ openscop_print_cloog_matrix (FILE *file, CloogMatrix *mat,
 			     int output, int input, int locals,
 			     int params)
 {
-  int i, j;
+  unsigned i, j;
 
-  fprintf (file, "%d %d %d %d %d %d \n", cloog_matrix_nrows (mat),
-	   cloog_matrix_ncolumns (mat), output, input, locals, params);
+  fprintf (file, "%d %d %d %d %d %d \n", mat->NbRows,
+	   mat->NbColumns, output, input, locals, params);
 
-  for (i = 0; i < cloog_matrix_nrows (mat); i++)
+  for (i = 0; i < mat->NbRows; i++)
     {
-      for (j = 0; j < cloog_matrix_ncolumns (mat); j++)
+      for (j = 0; j < mat->NbColumns; j++)
         if (j == 0)
 	  fprintf (file, "%ld ", mpz_get_si (mat->p[i][j]));
         else
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index 9686e7c..da26ee9 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -22,7 +22,6 @@ along with GCC; see the file COPYING3.  If not see
 #define GRAPHITE_CLOOG_UTIL_H
 
 #include "cloog/cloog.h"
-#include "graphite-cloog-compat.h"
 
 CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
 CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t,
diff --git a/gcc/graphite.c b/gcc/graphite.c
index b013447..e746c61 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -209,7 +209,6 @@ graphite_initialize (void)
   gcc_assert (ppl_initialized == 0);
 
   cloog_state = cloog_state_malloc ();
-  cloog_initialize ();
 
   if (dump_file && dump_flags)
     dump_function_to_file (current_function_decl, dump_file, dump_flags);
@@ -233,7 +232,6 @@ graphite_finalize (bool need_cfg_cleanup_p)
     }
 
   cloog_state_free (cloog_state);
-  cloog_finalize ();
   ppl_finalize ();
   free_original_copy_tables ();
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 04/11] Document CLooG-ISL requirement for Graphite
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 05/11] Move to new Cloog interface Sebastian Pop
                                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

2011-07-26  Sebastian Pop  <sebastian.pop@amd.com>

        * doc/invoke.texi: Document CLooG-ISL requirement for Graphite.

Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/doc/install.texi |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 9b1b037..368221f 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -365,26 +365,18 @@ distribution is found in a subdirectory of your GCC sources named
 Necessary to build GCC with the Graphite loop optimizations.
 It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
 
-The @option{--with-ppl} configure option should be used if PPL is not
+The configure option @option{--with-ppl} should be used if PPL is not
 installed in your default library search path.
 
-@item CLooG-PPL version 0.15 or CLooG 0.16
+@item CLooG-ISL 0.16
 
-Necessary to build GCC with the Graphite loop optimizations.  There
-are two versions available.  CLooG-PPL 0.15 as well as CLooG 0.16.
-The former is the default right now.  It can be downloaded from
-@uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
-@file{cloog-ppl-0.15.tar.gz}.
+Necessary to build GCC with the Graphite loop optimizations.  It is
+available from @uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
+@file{cloog-0.16.3.tar.gz}.  Even if CLooG 0.16 does not use PPL, PPL
+is still required for Graphite.
 
-CLooG 0.16 support is still in testing stage, but will be the
-default in future GCC releases.  It is also available at
-@uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
-@file{cloog-0.16.1.tar.gz}.  To use it add the additional configure
-option @option{--enable-cloog-backend=isl}.  Even if CLooG 0.16
-does not use PPL, PPL is still required for Graphite.
-
-In both cases @option{--with-cloog} configure option should be used
-if CLooG is not installed in your default library search path.
+The configure option @option{--with-cloog} should be used if CLooG is
+not installed in your default library search path.
 
 @end table
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 22:06             ` Sven Verdoolaege
@ 2011-08-11 22:45               ` Sebastian Pop
  0 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 16:00, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Thu, Aug 11, 2011 at 03:10:30PM -0500, Sebastian Pop wrote:
>> On Thu, Aug 11, 2011 at 14:28, Sven Verdoolaege <skimo@kotnet.org> wrote:
>> > On Thu, Aug 11, 2011 at 01:16:45PM -0500, Sebastian Pop wrote:
>> >> +
>> >> +  /* FIXME: This function will be renamed isl_map_insert_dims and
>> >> +     documented in a later version of ISL (current ISL is 0.07).  */
>> >
>> > Since you are using isl_ids, 0.07 won't work for you.
>>
>> For now I'm using the ISL that is distributed with cloog-isl.
>
> Which version?

commit 225c2ed62fe37a4db22bf4b95c3731dab1a50dde
Author: Sven Verdoolaege <skimo@kotnet.org>
Date:   Sun Jul 10 09:27:24 2011 +0200

    CLooG 0.16.3

    Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>

>> What version of ISL should I use to have isl_ids working?
>
> 0.08.  While you are developing, you can use the latest
> git version and just tell CLooG to use that version.

Ok, I think I do use a quite recent version:

commit 3fbc27ff19492e6ae0975ac26d006a7d93ebe39b
Author: Sven Verdoolaege <skimo@kotnet.org>
Date:   Sun Jul 31 12:57:01 2011 +0200

    isl_aff_floor: reduce coefficients of newly created div

    Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>

I will still pull the latest changes from ISL.

> While I will not be maintaining CLooG this year, I will
> provide updates if I change isl in some incompatible way.

Ok.

Thanks,
Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 10/11] add pbb->domain
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 04/11] Document CLooG-ISL requirement for Graphite Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 05/11] Move to new Cloog interface Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 06/11] Remove ATTRIBUTE_UNUSED Sebastian Pop
                                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-poly.c         |   12 ++++-
 gcc/graphite-poly.h         |    6 ++
 gcc/graphite-sese-to-poly.c |  122 ++++++++++++++++++++++++++++++------------
 3 files changed, 104 insertions(+), 36 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index fd2703b..ce0649b 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -880,6 +880,7 @@ new_poly_bb (scop_p scop, void *black_box)
   poly_bb_p pbb = XNEW (struct poly_bb);
 
   PBB_DOMAIN (pbb) = NULL;
+  pbb->domain = NULL;
   PBB_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
   PBB_TRANSFORMED (pbb) = NULL;
@@ -901,7 +902,10 @@ free_poly_bb (poly_bb_p pbb)
   int i;
   poly_dr_p pdr;
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
+  if (PBB_DOMAIN (pbb))
+    ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
+
+  isl_set_free (pbb->domain);
 
   if (PBB_TRANSFORMED (pbb))
     poly_scattering_free (PBB_TRANSFORMED (pbb));
@@ -1096,6 +1100,12 @@ print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
   graphite_dim_t i;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
 
+  {
+    isl_printer *pp = isl_printer_to_file (PBB_SCOP (pbb)->ctx, file);
+    pp = isl_printer_print_set (pp, pbb->domain);
+    isl_printer_free (pp);
+  }
+
   if (!PBB_DOMAIN (pbb))
     return;
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index bb8771d..3483ef0 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -502,6 +502,12 @@ pbb_dim_iter_domain (const struct poly_bb *pbb)
 {
   scop_p scop = PBB_SCOP (pbb);
   ppl_dimension_type dim;
+  isl_dim *d = isl_set_get_dim (pbb->domain);
+  graphite_dim_t res = isl_dim_size (d, isl_dim_set);
+
+  isl_dim_free (d);
+  if (0)
+    return res;
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim);
   return dim - scop_nb_params (scop);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 69392a9..75355e9 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -658,20 +658,6 @@ isl_id_for_ssa_name (scop_p s, tree e)
   return id;
 }
 
-/* Return an ISL identifier from the loop L.  */
-
-static isl_id *
-isl_id_for_loop (scop_p s, loop_p l)
-{
-  isl_id *id;
-  char name[50];
-
-  snprintf (name, sizeof (name), "L_%d", l ? l->num : -1);
-  id = isl_id_alloc (s->ctx, name, l);
-
-  return id;
-}
-
 /* Extract an affine expression from the ssa_name E.  */
 
 static isl_pw_aff *
@@ -1182,10 +1168,6 @@ find_scop_parameters (scop_p scop)
       dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
 				isl_id_for_ssa_name (scop, e));
 
-    for (i = 0; i < nbl; i++)
-      dim = isl_dim_set_dim_id (dim, isl_dim_set, i,
-				isl_id_for_loop (scop, get_loop (i)));
-
     scop->context = isl_set_universe (dim);
   }
 }
@@ -1263,7 +1245,8 @@ add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit,
 static void
 build_loop_iteration_domains (scop_p scop, struct loop *loop,
                               ppl_Polyhedron_t outer_ph, int nb,
-			      ppl_Pointset_Powerset_C_Polyhedron_t *domains)
+			      ppl_Pointset_Powerset_C_Polyhedron_t *domains,
+			      isl_set *outer, isl_set **doms)
 {
   int i;
   ppl_Polyhedron_t ph;
@@ -1271,6 +1254,15 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
   ppl_dimension_type dim = nb + 1 + scop_nb_params (scop);
   sese region = SCOP_REGION (scop);
 
+  isl_set *inner = isl_set_copy (outer);
+  isl_dim *dimension = isl_set_get_dim (scop->context);
+  int pos = loop->num;
+  isl_int v;
+  mpz_t g;
+
+  mpz_init (g);
+  isl_int_init (v);
+
   {
     ppl_const_Constraint_System_t pcs;
     ppl_dimension_type *map
@@ -1301,8 +1293,17 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
     ppl_delete_Linear_Expression (lb_expr);
     ppl_Polyhedron_add_constraint (ph, lb);
     ppl_delete_Constraint (lb);
+
+    {
+      isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension));
+
+      isl_int_set_si (v, 1);
+      isl_constraint_set_coefficient (c, isl_dim_set, pos, v);
+      inner = isl_set_add_constraint (inner, c);
+    }
   }
 
+  /* loop_i <= cst_nb_iters */
   if (TREE_CODE (nb_iters) == INTEGER_CST)
     {
       ppl_Constraint_t ub;
@@ -1310,14 +1311,26 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
 
       ppl_new_Linear_Expression_with_dimension (&ub_expr, dim);
 
-      /* loop_i <= cst_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
       ppl_set_inhomogeneous_tree (ub_expr, nb_iters);
       ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
       ppl_Polyhedron_add_constraint (ph, ub);
       ppl_delete_Linear_Expression (ub_expr);
       ppl_delete_Constraint (ub);
+
+      {
+	isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension));
+
+	isl_int_set_si (v, -1);
+	isl_constraint_set_coefficient (c, isl_dim_set, pos, v);
+	tree_int_to_gmp (nb_iters, g);
+	isl_int_set_gmp (v, g);
+	isl_constraint_set_constant (c, v);
+	inner = isl_set_add_constraint (inner, c);
+      }
     }
+
+  /* loop_i <= expr_nb_iters */
   else if (!chrec_contains_undetermined (nb_iters))
     {
       mpz_t one;
@@ -1337,6 +1350,15 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       scop->context = isl_set_intersect
 	(scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)));
 
+      {
+	isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (dimension));
+	isl_aff *al = isl_aff_set_coefficient_si
+	  (isl_aff_zero (ls), isl_dim_set, pos, 1);
+	isl_set *le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al),
+					 isl_pw_aff_copy (aff));
+	inner = isl_set_intersect (inner, le);
+      }
+
       if (max_stmt_executions (loop, true, &nit))
 	{
 	  add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
@@ -1361,7 +1383,6 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
 	  }
 	}
 
-      /* loop_i <= expr_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
       ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
       ppl_Polyhedron_add_constraint (ph, ub);
@@ -1372,17 +1393,27 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
     gcc_unreachable ();
 
   if (loop->inner && loop_in_sese_p (loop->inner, region))
-    build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains);
+    build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains,
+				  isl_set_copy (inner), doms);
 
   if (nb != 0
       && loop->next
       && loop_in_sese_p (loop->next, region))
-    build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains);
+    build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains,
+				  isl_set_copy (outer), doms);
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
     (&domains[loop->num], ph);
-
   ppl_delete_Polyhedron (ph);
+
+  gcc_assert (doms[loop->num] == NULL);
+  doms[loop->num] = isl_set_copy (inner);
+
+  isl_set_free (inner);
+  isl_set_free (outer);
+  isl_dim_free (dimension);
+  isl_int_clear (v);
+  mpz_clear (g);
 }
 
 /* Returns a linear expression for tree T evaluated in PBB.  */
@@ -1812,31 +1843,50 @@ build_scop_iteration_domain (scop_p scop)
   int nb_loops = number_of_loops ();
   ppl_Pointset_Powerset_C_Polyhedron_t *domains
     = XNEWVEC (ppl_Pointset_Powerset_C_Polyhedron_t, nb_loops);
+  isl_set **doms = XNEWVEC (isl_set *, nb_loops);
 
   for (i = 0; i < nb_loops; i++)
-    domains[i] = NULL;
+    {
+      domains[i] = NULL;
+      doms[i] = NULL;
+    }
 
   ppl_new_C_Polyhedron_from_space_dimension (&ph, scop_nb_params (scop), 0);
 
   FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop)
     if (!loop_in_sese_p (loop_outer (loop), region))
-      build_loop_iteration_domains (scop, loop, ph, 0, domains);
+      build_loop_iteration_domains (scop, loop, ph, 0, domains,
+				    isl_set_copy (scop->context), doms);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
-    if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num])
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-	(&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t)
-	 domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
-    else
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-	(&PBB_DOMAIN (pbb), ph);
+    {
+      if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num])
+      	ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+	  (&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t)
+	   domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
+      else
+      	ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
+	  (&PBB_DOMAIN (pbb), ph);
+
+      if (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num])
+	pbb->domain = isl_set_copy (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
+      else
+	pbb->domain = isl_set_copy (scop->context);
+    }
 
   for (i = 0; i < nb_loops; i++)
-    if (domains[i])
-      ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]);
+    {
+      if (domains[i])
+	ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]);
+
+      if (doms[i])
+	isl_set_free (doms[i]);
+    }
 
   ppl_delete_Polyhedron (ph);
   free (domains);
+
+  free (doms);
 }
 
 /* Add a constrain to the ACCESSES polyhedron for the alias set of
@@ -2461,6 +2511,8 @@ new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb)
     ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
       (&PBB_DOMAIN (pbb1), PBB_DOMAIN (pbb));
 
+  pbb1->domain = isl_set_copy (pbb->domain);
+
   GBB_PBB (gbb1) = pbb1;
   GBB_CONDITIONS (gbb1) = VEC_copy (gimple, heap, GBB_CONDITIONS (gbb));
   GBB_CONDITION_CASES (gbb1) = VEC_copy (gimple, heap, GBB_CONDITION_CASES (gbb));
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 00/11] Partial conversion of Graphite to ISL
  2011-08-11 22:45               ` Sven Verdoolaege
@ 2011-08-11 22:45                 ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 04/11] Document CLooG-ISL requirement for Graphite Sebastian Pop
                                     ` (10 more replies)
  0 siblings, 11 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

Hi,

here are the updated patches for the conversion of Graphite to
ISL following the comments from Tobias and Sven.  The patches
are passing regression testing on amd64-linux.

cd .../build/gcc/
make -k check RUNTESTFLAGS=graphite.exp
cd .../build/x86_64-unknown-linux-gnu/libgomp/testsuite
make -k check RUNTESTFLAGS=graphite.exp

Thanks,
Sebastian

Sebastian Pop (11):
  Make CLooG-ISL the only supported CLooG version.
  Require cloog 0.16.3
  Remove code that supported legacy CLooG.
  Document CLooG-ISL requirement for Graphite
  Move to new Cloog interface.
  Remove ATTRIBUTE_UNUSED
  fix memory leak
  Add ISL data structures
  Add scop->context
  add pbb->domain
  add pdr->accesses and pdr->extent

 ChangeLog                      |   17 ++
 config/cloog.m4                |  109 +-------
 configure                      |  176 +------------
 configure.ac                   |    2 +-
 gcc/ChangeLog                  |   18 ++
 gcc/Makefile.in                |    4 +-
 gcc/doc/install.texi           |   24 +--
 gcc/graphite-blocking.c        |   12 +-
 gcc/graphite-clast-to-gimple.c |  414 +++++++++++++-----------------
 gcc/graphite-clast-to-gimple.h |    1 -
 gcc/graphite-cloog-compat.h    |  275 --------------------
 gcc/graphite-cloog-util.c      |   37 ++--
 gcc/graphite-cloog-util.h      |    3 -
 gcc/graphite-dependences.c     |   11 +-
 gcc/graphite-flattening.c      |   11 +-
 gcc/graphite-interchange.c     |   12 +-
 gcc/graphite-poly.c            |   39 +++-
 gcc/graphite-poly.h            |   53 +++--
 gcc/graphite-ppl.c             |   11 +-
 gcc/graphite-scop-detection.c  |   11 +-
 gcc/graphite-sese-to-poly.c    |  552 +++++++++++++++++++++++++++++++++++++---
 gcc/graphite.c                 |   18 +-
 22 files changed, 938 insertions(+), 872 deletions(-)
 delete mode 100644 gcc/graphite-cloog-compat.h

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 05/11] Move to new Cloog interface.
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 04/11] Document CLooG-ISL requirement for Graphite Sebastian Pop
@ 2011-08-11 22:45                   ` Sebastian Pop
  2011-08-11 22:45                   ` [PATCH 10/11] add pbb->domain Sebastian Pop
                                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

  * graphite-clast-to-gimple.c (new_clast_name_index): Store a copy
  of the string, no just a reference.
  (clast_name_index): Add a new field, that specifies if we need to free the
  name.
  (free_clast_name_index): If necessary, free the name string.
  (clast_name_index_elt_info): Calculate the hash based on the string content,
  not the memory location it is stored in.
  (clast_name_to_level): Specify that we do not need to free the name.
  (clast_name_to_index): Dito.
  (clast_name_to_lb_ub): Dito.
  (eq_clast_name_indexes): Compare the strings, not their base pointers.
  (free_scattering): Removed.
  (initialize_cloog_names): Renamed to add_names_to_union_domain().
  (add_names_to_union_domain): Changed to work on a union_domain, instead of a
  CloogNames structure.
  (build_cloog_prog): Removed.
  (build_cloog_union_domain): New.
  (generate_cloog_input): New.
  (scop_to_clast): Use CloogInput instead of CloogProgram.
  (print_generated_program): Adapt to new scop_to_clast() and do not
  print the CloogProgram any more.
  (create_params_index): Removed, functionality integrated in
  add_names_to_union_domain().
  (gloog): Adapt to new scop_to_clast().
  * graphite-clast-to-gimple.h (scop_to_clast): Remove.

Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-clast-to-gimple.c |  334 +++++++++++++++-------------------------
 gcc/graphite-clast-to-gimple.h |    1 -
 2 files changed, 125 insertions(+), 210 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a76b01d..a7d0ddc 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -70,6 +70,9 @@ typedef struct clast_name_index {
   int level;
   mpz_t bound_one, bound_two;
   const char *name;
+  /* If free_name is set, the content of name was allocated by us and needs
+     to be freed.  */
+  char *free_name;
 } *clast_name_index_p;
 
 /* Returns a pointer to a new element of type clast_name_index_p built
@@ -80,8 +83,11 @@ new_clast_name_index (const char *name, int index, int level,
 		      mpz_t bound_one, mpz_t bound_two)
 {
   clast_name_index_p res = XNEW (struct clast_name_index);
+  char *new_name = XNEWVEC (char, strlen (name) + 1);
+  strcpy (new_name, name);
 
-  res->name = name;
+  res->name = new_name;
+  res->free_name = new_name;
   res->level = level;
   res->index = index;
   mpz_init (res->bound_one);
@@ -97,6 +103,8 @@ static void
 free_clast_name_index (void *ptr)
 {
   struct clast_name_index *c = (struct clast_name_index *) ptr;
+  if (c->free_name)
+    free (c->free_name);
   mpz_clear (c->bound_one);
   mpz_clear (c->bound_two);
   free (ptr);
@@ -115,6 +123,7 @@ clast_name_to_level (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -134,12 +143,9 @@ clast_name_to_index (clast_name_p name, htab_t index_table)
   struct clast_name_index tmp;
   PTR *slot;
 
-#ifdef CLOOG_ORG
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
-#else
-  tmp.name = name;
-#endif
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -160,12 +166,9 @@ clast_name_to_lb_ub (clast_name_p name, htab_t index_table, mpz_t bound_one,
   struct clast_name_index tmp;
   PTR *slot;
 
-#ifdef CLOOG_ORG
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
-#else
-  tmp.name = name;
-#endif
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -189,6 +192,7 @@ save_clast_name_index (htab_t index_table, const char *name,
   PTR *slot;
 
   tmp.name = name;
+  tmp.free_name = NULL;
   slot = htab_find_slot (index_table, &tmp, INSERT);
 
   if (slot)
@@ -204,7 +208,16 @@ save_clast_name_index (htab_t index_table, const char *name,
 static inline hashval_t
 clast_name_index_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
+  const struct clast_name_index *e = ((const struct clast_name_index *) elt);
+  hashval_t hash = 0;
+
+  int length = strlen (e->name);
+  int i;
+
+  for (i = 0; i < length; ++i)
+    hash = hash | (e->name[i] << (i % 4));
+
+  return hash;
 }
 
 /* Compares database elements E1 and E2.  */
@@ -215,7 +228,7 @@ 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);
+  return strcmp (elt1->name, elt2->name) == 0;
 }
 
 \f
@@ -1238,77 +1251,69 @@ translate_clast (loop_p context_loop, struct clast_stmt *stmt, edge next_e,
 			  level, ip);
 }
 
-/* Free the SCATTERING domain list.  */
-
-static void
-free_scattering (CloogScatteringList *scattering)
-{
-  while (scattering)
-    {
-      CloogScattering *dom = scattering->scatt;
-      CloogScatteringList *next = scattering->next;
-
-      cloog_scattering_free (dom);
-      free (scattering);
-      scattering = next;
-    }
-}
-
-/* Initialize Cloog's parameter names from the names used in GIMPLE.
-   Initialize Cloog's iterator names, using 'graphite_iterator_%d'
-   from 0 to scop_nb_loops (scop).  */
+/* Add parameter and iterator names to the CloogUnionDomain.  */
 
-static void
-initialize_cloog_names (scop_p scop, CloogProgram *prog)
+static CloogUnionDomain *
+add_names_to_union_domain (scop_p scop, CloogUnionDomain *union_domain,
+			   int nb_scattering_dims, htab_t params_index)
 {
   sese region = SCOP_REGION (scop);
   int i;
   int nb_iterators = scop_max_loop_depth (scop);
-  int nb_scattering = prog->nb_scattdims;
   int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
-  char **iterators = XNEWVEC (char *, nb_iterators * 2);
-  char **scattering = XNEWVEC (char *, nb_scattering);
-  char **parameters= XNEWVEC (char *, nb_parameters);
+  mpz_t bound_one, bound_two;
 
-  prog->names = cloog_names_malloc ();
+  mpz_init (bound_one);
+  mpz_init (bound_two);
 
   for (i = 0; i < nb_parameters; i++)
     {
       tree param = VEC_index (tree, SESE_PARAMS (region), i);
       const char *name = get_name (param);
       int len;
+      char *parameter;
 
       if (!name)
 	name = "T";
 
       len = strlen (name);
       len += 17;
-      parameters[i] = XNEWVEC (char, len + 1);
-      snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
+      parameter = XNEWVEC (char, len + 1);
+      snprintf (parameter, len, "%s_%d", name, SSA_NAME_VERSION (param));
+      save_clast_name_index (params_index, parameter, i, i, bound_one,
+			     bound_two);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_PARAM, i,
+						  parameter);
+      compute_bounds_for_param (scop, i, bound_one, bound_two);
+      free (parameter);
     }
 
-  prog->names->nb_parameters = nb_parameters;
-  prog->names->parameters = parameters;
+  mpz_clear (bound_one);
+  mpz_clear (bound_two);
 
   for (i = 0; i < nb_iterators; i++)
     {
       int len = 4 + 16;
-      iterators[i] = XNEWVEC (char, len);
-      snprintf (iterators[i], len, "git_%d", i);
+      char *iterator;
+      iterator = XNEWVEC (char, len);
+      snprintf (iterator, len, "git_%d", i);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_ITER, i,
+						  iterator);
+      free (iterator);
     }
 
-  prog->names->nb_iterators = nb_iterators;
-  prog->names->iterators = iterators;
-
-  for (i = 0; i < nb_scattering; i++)
+  for (i = 0; i < nb_scattering_dims; i++)
     {
       int len = 5 + 16;
-      scattering[i] = XNEWVEC (char, len);
-      snprintf (scattering[i], len, "scat_%d", i);
+      char *scattering;
+      scattering = XNEWVEC (char, len);
+      snprintf (scattering, len, "scat_%d", i);
+      union_domain = cloog_union_domain_set_name (union_domain, CLOOG_SCAT, i,
+						  scattering);
+      free (scattering);
     }
 
-  prog->names->nb_scattering = nb_scattering;
-  prog->names->scattering = scattering;
+  return union_domain;
 }
 
 /* Initialize a CLooG input file.  */
@@ -1336,129 +1341,40 @@ init_cloog_input_file (int scop_number)
   return graphite_out_file;
 }
 
-/* Build cloog program for SCoP.  */
+/* Build cloog union domain for SCoP.  */
 
-static void
-build_cloog_prog (scop_p scop, CloogProgram *prog,
-                  CloogOptions *options)
+static CloogUnionDomain *
+build_cloog_union_domain (scop_p scop)
 {
   int i;
-  int max_nb_loops = scop_max_loop_depth (scop);
   poly_bb_p pbb;
-  CloogLoop *loop_list = NULL;
-  CloogBlockList *block_list = NULL;
-  CloogScatteringList *scattering = NULL;
-  int nbs = 2 * max_nb_loops + 1;
-  int *scaldims;
-
-  prog->context =
-    new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop),
-						 scop_nb_params (scop),
-						 cloog_state);
-  nbs = unify_scattering_dimensions (scop);
-  scaldims = (int *) xmalloc (nbs * (sizeof (int)));
-  prog->nb_scattdims = nbs;
-  initialize_cloog_names (scop, prog);
+
+  CloogUnionDomain *union_domain =
+    cloog_union_domain_alloc (scop_nb_params (scop));
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
-      CloogStatement *stmt;
-      CloogBlock *block;
-      CloogDomain *dom;
+      CloogDomain *domain;
+      CloogScattering *scattering;
 
       /* Dead code elimination: when the domain of a PBB is empty,
 	 don't generate code for the PBB.  */
       if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PBB_DOMAIN (pbb)))
 	continue;
 
-      /* Build the new statement and its block.  */
-      stmt = cloog_statement_alloc (cloog_state, pbb_index (pbb));
-      dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
-                                                         scop_nb_params (scop),
-                                                         cloog_state);
-      block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
-      stmt->usr = pbb;
-
-      /* Build loop list.  */
-      {
-        CloogLoop *new_loop_list = cloog_loop_malloc (cloog_state);
-        new_loop_list->next = loop_list;
-        new_loop_list->domain = dom;
-        new_loop_list->block = block;
-        loop_list = new_loop_list;
-      }
-
-      /* Build block list.  */
-      {
-        CloogBlockList *new_block_list = cloog_block_list_malloc ();
-
-        new_block_list->next = block_list;
-        new_block_list->block = block;
-        block_list = new_block_list;
-      }
+      domain = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
+							    scop_nb_params (scop),
+							    cloog_state);
 
-      /* Build scattering list.  */
-      {
-        /* XXX: Replace with cloog_domain_list_alloc(), when available.  */
-        CloogScatteringList *new_scattering
-	  = (CloogScatteringList *) xmalloc (sizeof (CloogScatteringList));
-        ppl_Polyhedron_t scat;
-	CloogScattering *dom;
-
-	scat = PBB_TRANSFORMED_SCATTERING (pbb);
-        dom = new_Cloog_Scattering_from_ppl_Polyhedron
-          (scat, scop_nb_params (scop), pbb_nb_scattering_transform (pbb),
-           cloog_state);
-
-        new_scattering->next = scattering;
-        new_scattering->scatt = dom;
-        scattering = new_scattering;
-      }
-    }
-
-  prog->loop = loop_list;
-  prog->blocklist = block_list;
-
-  for (i = 0; i < nbs; i++)
-    scaldims[i] = 0 ;
-
-  prog->scaldims = scaldims;
-
-  /* Extract scalar dimensions to simplify the code generation problem.  */
-  cloog_program_extract_scalars (prog, scattering, options);
-
-  /* Dump a .cloog input file, if requested.  This feature is only
-     enabled in the Graphite branch.  */
-  if (0)
-    {
-      static size_t file_scop_number = 0;
-      FILE *cloog_file = init_cloog_input_file (file_scop_number);
+      scattering = new_Cloog_Scattering_from_ppl_Polyhedron
+	(PBB_TRANSFORMED_SCATTERING (pbb), scop_nb_params (scop),
+	 pbb_nb_scattering_transform (pbb), cloog_state);
 
-      cloog_program_dump_cloog (cloog_file, prog, scattering);
-      ++file_scop_number;
+      union_domain = cloog_union_domain_add_domain (union_domain, "", domain,
+						    scattering, pbb);
     }
 
-  /* Apply scattering.  */
-  cloog_program_scatter (prog, scattering, options);
-  free_scattering (scattering);
-
-  /* Iterators corresponding to scalar dimensions have to be extracted.  */
-  cloog_names_scalarize (prog->names, nbs, prog->scaldims);
-
-  /* Free blocklist.  */
-  {
-    CloogBlockList *next = prog->blocklist;
-
-    while (next)
-      {
-        CloogBlockList *toDelete = next;
-        next = next->next;
-        toDelete->next =  NULL;
-        toDelete->block = NULL;
-        cloog_block_list_free (toDelete);
-      }
-    prog->blocklist = NULL;
-  }
+  return union_domain;
 }
 
 /* Return the options that will be used in GLOOG.  */
@@ -1523,24 +1439,52 @@ debug_clast_stmt (struct clast_stmt *stmt)
   print_clast_stmt (stderr, stmt);
 }
 
+static CloogInput *
+generate_cloog_input (scop_p scop, htab_t params_index)
+{
+  CloogUnionDomain *union_domain;
+  CloogInput *cloog_input;
+  CloogDomain *context;
+
+  int nb_scattering_dims = unify_scattering_dimensions (scop);
+  union_domain = build_cloog_union_domain (scop);
+  union_domain = add_names_to_union_domain (scop, union_domain,
+					    nb_scattering_dims,
+					    params_index);
+  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
+    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
+
+  cloog_input = cloog_input_alloc (context, union_domain);
+
+  return cloog_input;
+}
+
 /* Translate SCOP to a CLooG program and clast.  These two
    representations should be freed together: a clast cannot be used
    without a program.  */
 
-cloog_prog_clast
-scop_to_clast (scop_p scop)
+static struct clast_stmt *
+scop_to_clast (scop_p scop, htab_t params_index)
 {
+  CloogInput *cloog_input;
+  struct clast_stmt *clast;
   CloogOptions *options = set_cloog_options ();
-  cloog_prog_clast pc;
 
-  /* Connect new cloog prog generation to graphite.  */
-  pc.prog = cloog_program_malloc ();
-  build_cloog_prog (scop, pc.prog, options);
-  pc.prog = cloog_program_generate (pc.prog, options);
-  pc.stmt = cloog_clast_create (pc.prog, options);
+  cloog_input = generate_cloog_input (scop, params_index);
+
+  /* Dump a .cloog input file, if requested.  This feature is only
+     enabled in the Graphite branch.  */
+  if (0)
+  {
+    static size_t file_scop_number = 0;
+    FILE *cloog_file = init_cloog_input_file (file_scop_number);
+    cloog_input_dump_cloog (cloog_file, cloog_input, options);
+  }
+
+  clast = cloog_clast_create_from_input (cloog_input, options);
 
   cloog_options_free (options);
-  return pc;
+  return clast;
 }
 
 /* Prints to FILE the code generated by CLooG for SCOP.  */
@@ -1549,20 +1493,20 @@ void
 print_generated_program (FILE *file, scop_p scop)
 {
   CloogOptions *options = set_cloog_options ();
+  htab_t params_index;
+  struct clast_stmt *clast;
 
-  cloog_prog_clast pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+            eq_clast_name_indexes, free_clast_name_index);
 
-  fprintf (file, "       (prog: \n");
-  cloog_program_print (file, pc.prog);
-  fprintf (file, "       )\n");
+  clast = scop_to_clast (scop, params_index);
 
   fprintf (file, "       (clast: \n");
-  clast_pprint (file, pc.stmt, 0, options);
+  clast_pprint (file, clast, 0, options);
   fprintf (file, "       )\n");
 
   cloog_options_free (options);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
 }
 
 /* Prints to STDERR the code generated by CLooG for SCOP.  */
@@ -1573,32 +1517,6 @@ debug_generated_program (scop_p scop)
   print_generated_program (stderr, scop);
 }
 
-/* Add CLooG names to parameter index.  The index is used to translate
-   back from CLooG names to GCC trees.  */
-
-static void
-create_params_index (scop_p scop, htab_t index_table, CloogProgram *prog)
-{
-  CloogNames *names = prog->names;
-  int nb_parameters = names->nb_parameters;
-  char **parameters = names->parameters;
-  int i;
-  mpz_t bound_one, bound_two;
-
-  mpz_init (bound_one);
-  mpz_init (bound_two);
-
-  for (i = 0; i < nb_parameters; i++)
-    {
-      compute_bounds_for_param (scop, i, bound_one, bound_two);
-      save_clast_name_index (index_table, parameters[i], i, i,
-			     bound_one, bound_two);
-    }
-
-  mpz_clear (bound_one);
-  mpz_clear (bound_two);
-}
-
 /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
    the given SCOP.  Return true if code generation succeeded.
    BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
@@ -1612,18 +1530,21 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   sese region = SCOP_REGION (scop);
   ifsese if_region = NULL;
   htab_t newivs_index, params_index;
-  cloog_prog_clast pc;
+  struct clast_stmt *clast;
   struct ivs_params ip;
 
   timevar_push (TV_GRAPHITE_CODE_GEN);
   gloog_error = false;
 
-  pc = scop_to_clast (scop);
+  params_index = htab_create (10, clast_name_index_elt_info,
+			      eq_clast_name_indexes, free_clast_name_index);
+
+  clast = scop_to_clast (scop, params_index);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "\nCLAST generated by CLooG: \n");
-      print_clast_stmt (dump_file, pc.stmt);
+      print_clast_stmt (dump_file, clast);
       fprintf (dump_file, "\n");
     }
 
@@ -1641,10 +1562,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   context_loop = SESE_ENTRY (region)->src->loop_father;
   newivs_index = htab_create (10, clast_name_index_elt_info,
 			      eq_clast_name_indexes, free_clast_name_index);
-  params_index = htab_create (10, clast_name_index_elt_info,
-			      eq_clast_name_indexes, free_clast_name_index);
-
-  create_params_index (scop, params_index, pc.prog);
 
   ip.newivs = &newivs;
   ip.newivs_index = newivs_index;
@@ -1652,7 +1569,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   ip.params_index = params_index;
   ip.region = region;
 
-  translate_clast (context_loop, pc.stmt, if_region->true_region->entry,
+  translate_clast (context_loop, clast, if_region->true_region->entry,
 		   bb_pbb_mapping, 0, &ip);
   graphite_verify ();
   scev_reset ();
@@ -1669,8 +1586,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
   htab_delete (newivs_index);
   htab_delete (params_index);
   VEC_free (tree, heap, newivs);
-  cloog_clast_free (pc.stmt);
-  cloog_program_free (pc.prog);
+  cloog_clast_free (clast);
   timevar_pop (TV_GRAPHITE_CODE_GEN);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h
index b5affd9..c82bb6a 100644
--- a/gcc/graphite-clast-to-gimple.h
+++ b/gcc/graphite-clast-to-gimple.h
@@ -41,7 +41,6 @@ typedef struct bb_pbb_def
 } bb_pbb_def;
 
 extern bool gloog (scop_p, htab_t);
-extern cloog_prog_clast scop_to_clast (scop_p);
 extern void debug_clast_stmt (struct clast_stmt *);
 extern void print_clast_stmt (FILE *, struct clast_stmt *);
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 20:54           ` Sebastian Pop
  2011-08-11 22:06             ` Sven Verdoolaege
@ 2011-08-11 22:45             ` Sebastian Pop
  2011-08-11 22:45               ` Sven Verdoolaege
  1 sibling, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 22:45 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Tobias Grosser, gcc-patches

>>> +  {
>>> +    isl_dim *dc = isl_set_get_dim (scop->context);
>>> +    int nb_in = isl_dim_size (dc, isl_dim_set);
>>> +    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
>>> +    int nbp = scop_nb_params (scop);
>>> +    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
>>> +    int i;
>>> +
>>> +    for (i = 0; i < nbp; i++)
>>> +      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
>>> +                             isl_dim_get_dim_id (dc, isl_dim_param, i));
>>> +    for (i = 0; i < nb_in; i++)
>>> +      dim = isl_dim_set_dim_id (dim, isl_dim_in, i,
>>> +                             isl_dim_get_dim_id (dc, isl_dim_set, i));
>>
>> This is dangerous too.  Why don't you derive dim directly from dc
>> instead of creating a fresh dim and then trying to copy some information?
>
> Yes, thanks for pointing this out.  I will fix this.

I am confused on this one:
which function should I use to create dim from dc?
I don't see how to specify the number of input and output dimensions
like the isl_dim_alloc would do.

What do you think about copying only the parameters from scop->context?

  {
    isl_dim *dc = isl_set_get_dim (scop->context);
    int nb_in = isl_dim_size (dc, isl_dim_set);
    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
    int nbp = scop_nb_params (scop);
    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
    int i;

    for (i = 0; i < nbp; i++)
      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
				isl_dim_get_dim_id (dc, isl_dim_param, i));

    acc = isl_map_universe (dim);
    acc = isl_map_set_tuple_id (acc, isl_dim_out, isl_id_for_dr (scop, dr));
    isl_dim_free (dc);
  }

Would this be ok?

Thanks,
Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [graphite] Move to cloog.org interface
  2011-08-11 22:45             ` Sebastian Pop
@ 2011-08-11 22:45               ` Sven Verdoolaege
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
  0 siblings, 1 reply; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-11 22:45 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Tobias Grosser, gcc-patches

On Thu, Aug 11, 2011 at 04:59:43PM -0500, Sebastian Pop wrote:
> >>> +  {
> >>> +    isl_dim *dc = isl_set_get_dim (scop->context);
> >>> +    int nb_in = isl_dim_size (dc, isl_dim_set);
> >>> +    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
> >>> +    int nbp = scop_nb_params (scop);
> >>> +    isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out);
> >>> +    int i;
> >>> +
> >>> +    for (i = 0; i < nbp; i++)
> >>> +      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
> >>> +                             isl_dim_get_dim_id (dc, isl_dim_param, i));
> >>> +    for (i = 0; i < nb_in; i++)
> >>> +      dim = isl_dim_set_dim_id (dim, isl_dim_in, i,
> >>> +                             isl_dim_get_dim_id (dc, isl_dim_set, i));
> >>
> >> This is dangerous too.  Why don't you derive dim directly from dc
> >> instead of creating a fresh dim and then trying to copy some information?
> >
> > Yes, thanks for pointing this out.  I will fix this.
> 
> I am confused on this one:
> which function should I use to create dim from dc?

It looks like you want to do

	dim = isl_dim_add(isl_dim_from_domain(dc), isl_dim_out, nb_out);

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 09/11] Add scop->context
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (5 preceding siblings ...)
  2011-08-11 22:45                   ` [PATCH 03/11] Remove code that supported legacy CLooG Sebastian Pop
@ 2011-08-11 23:18                   ` Sebastian Pop
  2011-08-12  2:41                     ` Jack Howarth
                                       ` (2 more replies)
  2011-08-11 23:27                   ` [PATCH 01/11] Make CLooG-ISL the only supported CLooG version Sebastian Pop
                                     ` (3 subsequent siblings)
  10 siblings, 3 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 23:18 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-clast-to-gimple.c |   55 ++++++--
 gcc/graphite-cloog-util.c      |    1 +
 gcc/graphite-poly.c            |    8 +
 gcc/graphite-poly.h            |    3 +
 gcc/graphite-sese-to-poly.c    |  301 +++++++++++++++++++++++++++++++++++++++-
 gcc/graphite.c                 |    4 +
 6 files changed, 356 insertions(+), 16 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index bb0f4c8..9a9effa 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -24,6 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/list.h>
+#include <isl/constraint.h>
+#include <isl/div.h>
+#include <isl/ilp.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
 #endif
@@ -768,16 +773,19 @@ graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt,
 static void
 compute_bounds_for_param (scop_p scop, int param, mpz_t low, mpz_t up)
 {
-  ppl_Linear_Expression_t le;
-
-  /* Prepare the linear expression corresponding to the parameter that
-     we want to maximize/minimize.  */
-  ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
-  ppl_set_coef (le, param, 1);
-
-  ppl_max_for_le_pointset (SCOP_CONTEXT (scop), le, up);
-  ppl_min_for_le_pointset (SCOP_CONTEXT (scop), le, low);
-  ppl_delete_Linear_Expression (le);
+  isl_int v;
+  isl_aff *aff = isl_aff_zero
+    (isl_local_space_from_dim (isl_set_get_dim (scop->context)));
+
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, param, 1);
+
+  isl_int_init (v);
+  isl_set_min (scop->context, aff, &v);
+  isl_int_get_gmp (v, low);
+  isl_set_max (scop->context, aff, &v);
+  isl_int_get_gmp (v, up);
+  isl_int_clear (v);
+  isl_aff_free (aff);
 }
 
 /* Compute the lower bound LOW and upper bound UP for the induction
@@ -1357,7 +1365,6 @@ build_cloog_union_domain (scop_p scop)
 {
   int i;
   poly_bb_p pbb;
-
   CloogUnionDomain *union_domain =
     cloog_union_domain_alloc (scop_nb_params (scop));
 
@@ -1460,8 +1467,30 @@ generate_cloog_input (scop_p scop, htab_t params_index)
   union_domain = add_names_to_union_domain (scop, union_domain,
 					    nb_scattering_dims,
 					    params_index);
-  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
-    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
+
+  if (1)
+    {
+      /* For now remove the isl_id's from the context before
+	 translating to CLooG: this code will be removed when the
+	 domain will also contain isl_id's.  */
+      isl_set *ct = isl_set_project_out (isl_set_copy (scop->context),
+					 isl_dim_set, 0, number_of_loops ());
+      isl_printer *p = isl_printer_to_str (scop->ctx);
+      char *str;
+
+      p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
+      p = isl_printer_print_set (p, ct);
+      isl_set_free (ct);
+
+      str = isl_printer_get_str (p);
+      ct = isl_set_read_from_str (scop->ctx, str,
+				  scop_nb_params (scop));
+      free (str);
+      isl_printer_free (p);
+      context = cloog_domain_from_isl_set (ct);
+    }
+  else
+    context = cloog_domain_from_isl_set (isl_set_copy (scop->context));
 
   cloog_input = cloog_input_alloc (context, union_domain);
 
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 82a49a1..6086864 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
 #endif
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index af40d20..fd2703b 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1012,6 +1012,7 @@ new_scop (void *region)
   scop_p scop = XNEW (struct scop);
 
   SCOP_CONTEXT (scop) = NULL;
+  scop->context = NULL;
   scop_set_region (scop, region);
   SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
   SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
@@ -1040,6 +1041,7 @@ free_scop (scop_p scop)
   if (SCOP_CONTEXT (scop))
     ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
 
+  isl_set_free (scop->context);
   htab_delete (SCOP_ORIGINAL_PDDRS (scop));
   free_lst (SCOP_ORIGINAL_SCHEDULE (scop));
   free_lst (SCOP_TRANSFORMED_SCHEDULE (scop));
@@ -1401,6 +1403,12 @@ print_scop_context (FILE *file, scop_p scop, int verbosity)
   else
     fprintf (file, "0 %d\n", (int) scop_nb_params (scop) + 2);
 
+  if (scop->context)
+    {
+      isl_printer *p = isl_printer_to_file (scop->ctx, file);
+      isl_printer_print_set (p, scop->context);
+    }
+
   if (verbosity > 0)
     fprintf (file, "# )\n");
 }
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 72e9530..bb8771d 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1409,6 +1409,9 @@ struct scop
   ppl_Pointset_Powerset_C_Polyhedron_t _context;
   isl_set *context;
 
+  /* The context used internally by ISL.  */
+  isl_ctx *ctx;
+
   /* A hashtable of the data dependence relations for the original
      scattering.  */
   htab_t original_pddrs;
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index b7efe41..69392a9 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <isl/aff.h>
 #include <cloog/cloog.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
@@ -595,6 +597,216 @@ build_scop_scattering (scop_p scop)
   ppl_delete_Linear_Expression (static_schedule);
 }
 
+static isl_pw_aff *extract_affine (scop_p, tree);
+
+/* Extract an affine expression from the chain of recurrence E.  */
+
+static isl_pw_aff *
+extract_affine_chrec (scop_p s, tree e)
+{
+  isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e));
+  isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e));
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
+  isl_local_space *ls = isl_local_space_from_dim (dim);
+  isl_aff *loop = isl_aff_set_coefficient_si
+    (isl_aff_zero (ls), isl_dim_set, CHREC_VARIABLE (e), 1);
+  isl_pw_aff *l = isl_pw_aff_from_aff (loop);
+
+  /* Before multiplying, make sure that the result is affine.  */
+  gcc_assert (isl_pw_aff_is_cst (rhs)
+	      || isl_pw_aff_is_cst (l));
+
+  return isl_pw_aff_add (lhs, isl_pw_aff_mul (rhs, l));
+}
+
+/* Extract an affine expression from the mult_expr E.  */
+
+static isl_pw_aff *
+extract_affine_mul (scop_p s, tree e)
+{
+  isl_pw_aff *lhs = extract_affine (s, TREE_OPERAND (e, 0));
+  isl_pw_aff *rhs = extract_affine (s, TREE_OPERAND (e, 1));
+
+  if (!isl_pw_aff_is_cst (lhs)
+      && !isl_pw_aff_is_cst (rhs))
+    {
+      isl_pw_aff_free (lhs);
+      isl_pw_aff_free (rhs);
+      return NULL;
+    }
+
+  return isl_pw_aff_mul (lhs, rhs);
+}
+
+/* Return an ISL identifier from the name of the ssa_name E.  */
+
+static isl_id *
+isl_id_for_ssa_name (scop_p s, tree e)
+{
+  const char *name = get_name (e);
+  isl_id *id;
+
+  if (name)
+    id = isl_id_alloc (s->ctx, name, e);
+  else
+    {
+      char name1[50];
+      snprintf (name1, sizeof (name1), "P_%d", SSA_NAME_VERSION (e));
+      id = isl_id_alloc (s->ctx, name1, e);
+    }
+
+  return id;
+}
+
+/* Return an ISL identifier from the loop L.  */
+
+static isl_id *
+isl_id_for_loop (scop_p s, loop_p l)
+{
+  isl_id *id;
+  char name[50];
+
+  snprintf (name, sizeof (name), "L_%d", l ? l->num : -1);
+  id = isl_id_alloc (s->ctx, name, l);
+
+  return id;
+}
+
+/* Extract an affine expression from the ssa_name E.  */
+
+static isl_pw_aff *
+extract_affine_name (scop_p s, tree e)
+{
+  isl_aff *aff;
+  isl_set *dom;
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 1, number_of_loops ());
+
+  dim = isl_dim_set_dim_id (dim, isl_dim_param, 0, isl_id_for_ssa_name (s, e));
+  dom = isl_set_universe (isl_dim_copy (dim));
+  aff = isl_aff_zero (isl_local_space_from_dim (dim));
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, 0, 1);
+  return isl_pw_aff_alloc (dom, aff);
+}
+
+/* Extract an affine expression from the gmp constant G.  */
+
+static isl_pw_aff *
+extract_affine_gmp (scop_p s, mpz_t g)
+{
+  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
+  isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (dim));
+  isl_aff *aff = isl_aff_zero (ls);
+  isl_set *dom = isl_set_universe (dim);
+  isl_int v;
+
+  isl_int_init (v);
+  isl_int_set_gmp (v, g);
+  aff = isl_aff_add_constant (aff, v);
+  isl_int_clear (v);
+
+  return isl_pw_aff_alloc (dom, aff);
+}
+
+/* Extract an affine expression from the integer_cst E.  */
+
+static isl_pw_aff *
+extract_affine_int (scop_p s, tree e)
+{
+  isl_pw_aff *res;
+  mpz_t g;
+
+  mpz_init (g);
+  tree_int_to_gmp (e, g);
+  res = extract_affine_gmp (s, g);
+  mpz_clear (g);
+
+  return res;
+}
+
+/* Compute pwaff mod 2^width.  */
+
+static isl_pw_aff *
+wrap (isl_pw_aff *pwaff, unsigned width)
+{
+  isl_int mod;
+
+  isl_int_init (mod);
+  isl_int_set_si (mod, 1);
+  isl_int_mul_2exp (mod, mod, width);
+
+  pwaff = isl_pw_aff_mod (pwaff, mod);
+
+  isl_int_clear (mod);
+
+  return pwaff;
+}
+
+/* Extract an affine expression from the tree E in the scop S.  */
+
+static isl_pw_aff *
+extract_affine (scop_p s, tree e)
+{
+  isl_pw_aff *lhs, *rhs, *res;
+  tree type;
+
+  if (e == chrec_dont_know)
+    return NULL;
+
+  switch (TREE_CODE (e))
+    {
+    case POLYNOMIAL_CHREC:
+      res = extract_affine_chrec (s, e);
+      break;
+
+    case MULT_EXPR:
+      res = extract_affine_mul (s, e);
+      break;
+
+    case PLUS_EXPR:
+    case POINTER_PLUS_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1));
+      res = isl_pw_aff_add (lhs, rhs);
+      break;
+
+    case MINUS_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1));
+      res = isl_pw_aff_sub (lhs, rhs);
+      break;
+
+    case NEGATE_EXPR:
+    case BIT_NOT_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0));
+      rhs = extract_affine (s, integer_minus_one_node);
+      res = isl_pw_aff_mul (lhs, rhs);
+      break;
+
+    case SSA_NAME:
+      res = extract_affine_name (s, e);
+      break;
+
+    case INTEGER_CST:
+      res = extract_affine_int (s, e);
+      break;
+
+    CASE_CONVERT:
+    case NON_LVALUE_EXPR:
+      res = extract_affine (s, TREE_OPERAND (e, 0));
+      break;
+
+    default:
+      gcc_unreachable ();
+      break;
+    }
+
+  type = TREE_TYPE (e);
+  if (TYPE_UNSIGNED (type))
+    res = wrap (res, TYPE_PRECISION (type));
+
+  return res;
+}
+
 /* Add the value K to the dimension D of the linear expression EXPR.  */
 
 static void
@@ -931,6 +1143,7 @@ find_scop_parameters (scop_p scop)
   sese region = SCOP_REGION (scop);
   struct loop *loop;
   mpz_t one;
+  int nbp;
 
   mpz_init (one);
   mpz_set_si (one, 1);
@@ -953,11 +1166,28 @@ find_scop_parameters (scop_p scop)
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     find_params_in_bb (region, PBB_BLACK_BOX (pbb));
 
-  scop_set_nb_params (scop, sese_nb_params (region));
+  nbp = sese_nb_params (region);
+  scop_set_nb_params (scop, nbp);
   SESE_ADD_PARAMS (region) = false;
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension
-    (&SCOP_CONTEXT (scop), scop_nb_params (scop), 0);
+    (&SCOP_CONTEXT (scop), nbp, 0);
+
+  {
+    tree e;
+    unsigned nbl = number_of_loops ();
+    isl_dim *dim = isl_dim_set_alloc (scop->ctx, nbp, nbl);
+
+    FOR_EACH_VEC_ELT (tree, SESE_PARAMS (region), i, e)
+      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
+				isl_id_for_ssa_name (scop, e));
+
+    for (i = 0; i < nbl; i++)
+      dim = isl_dim_set_dim_id (dim, isl_dim_set, i,
+				isl_id_for_loop (scop, get_loop (i)));
+
+    scop->context = isl_set_universe (dim);
+  }
 }
 
 /* Insert in the SCOP context constraints from the estimation of the
@@ -1094,6 +1324,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       ppl_Constraint_t ub;
       ppl_Linear_Expression_t ub_expr;
       double_int nit;
+      isl_pw_aff *aff;
 
       mpz_init (one);
       mpz_set_si (one, 1);
@@ -1102,8 +1333,33 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
       scan_tree_for_params (SCOP_REGION (scop), nb_iters, ub_expr, one);
       mpz_clear (one);
 
+      aff = extract_affine (scop, nb_iters);
+      scop->context = isl_set_intersect
+	(scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)));
+
       if (max_stmt_executions (loop, true, &nit))
-	add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
+	{
+	  add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
+
+	  {
+	    /* Insert in the context the constraints from the
+	       estimation of the number of iterations NIT and the
+	       symbolic number of iterations (involving parameter
+	       names) NB_ITERS.  First, build the affine expression
+	       "NIT - NB_ITERS" and then say that it is positive,
+	       i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS".  */
+	    isl_pw_aff *approx;
+	    mpz_t g;
+	    isl_set *x;
+
+	    mpz_init (g);
+	    mpz_set_double_int (g, nit, false);
+	    approx = extract_affine_gmp (scop, g);
+	    mpz_clear (g);
+	    x = isl_pw_aff_ge_set (approx, aff);
+	    scop->context = isl_set_intersect (scop->context, x);
+	  }
+	}
 
       /* loop_i <= expr_nb_iters */
       ppl_set_coef (ub_expr, nb, -1);
@@ -1463,6 +1719,26 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
       ppl_Polyhedron_add_constraint (context, cstr);
       ppl_delete_Linear_Expression (le);
       ppl_delete_Constraint (cstr);
+
+      {
+	isl_dim *dim = isl_set_get_dim (scop->context);
+	isl_constraint *c = isl_inequality_alloc (dim);
+	mpz_t g;
+	isl_int v;
+
+	mpz_init (g);
+	isl_int_init (v);
+	tree_int_to_gmp (lb, g);
+	isl_int_set_gmp (v, g);
+	isl_int_neg (v, v);
+	mpz_clear (g);
+	isl_constraint_set_constant (c, v);
+	isl_int_set_si (v, 1);
+	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
+	isl_int_clear (v);
+
+	scop->context = isl_set_add_constraint (scop->context, c);
+      }
     }
 
   if (ub)
@@ -1474,6 +1750,25 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
       ppl_Polyhedron_add_constraint (context, cstr);
       ppl_delete_Linear_Expression (le);
       ppl_delete_Constraint (cstr);
+
+      {
+	isl_dim *dim = isl_set_get_dim (scop->context);
+	isl_constraint *c = isl_inequality_alloc (dim);
+	mpz_t g;
+	isl_int v;
+
+	mpz_init (g);
+	isl_int_init (v);
+	tree_int_to_gmp (ub, g);
+	isl_int_set_gmp (v, g);
+	mpz_clear (g);
+	isl_constraint_set_constant (c, v);
+	isl_int_set_si (v, -1);
+	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
+	isl_int_clear (v);
+
+	scop->context = isl_set_add_constraint (scop->context, c);
+      }
     }
 }
 
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 8f6d8a1..b2cf7c6 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -260,10 +260,12 @@ graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
+  isl_ctx *ctx;
 
   if (!graphite_initialize ())
     return;
 
+  ctx = isl_ctx_alloc ();
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -277,6 +279,7 @@ graphite_transform_loops (void)
   FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
     if (dbg_cnt (graphite_scop))
       {
+	scop->ctx = ctx;
 	build_poly_scop (scop);
 
 	if (POLY_SCOP_P (scop)
@@ -288,6 +291,7 @@ graphite_transform_loops (void)
   htab_delete (bb_pbb_mapping);
   free_scops (scops);
   graphite_finalize (need_cfg_cleanup_p);
+  isl_ctx_free (ctx);
 }
 
 #else /* If Cloog is not available: #ifndef HAVE_cloog.  */
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/11] Make CLooG-ISL the only supported CLooG version.
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (6 preceding siblings ...)
  2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
@ 2011-08-11 23:27                   ` Sebastian Pop
  2011-08-12  0:02                   ` [PATCH 08/11] Add ISL data structures Sebastian Pop
                                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-11 23:27 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

2011-07-21  Tobias Grosser  <tobias@grosser.es>

	* configure: Regenerated.
	* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
	both cloog.org and legacy versions. The only supported version will
	be CLooG with the isl backend.

Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 ChangeLog       |    7 ++
 config/cloog.m4 |  107 +++-------------------------------
 configure       |  170 +++----------------------------------------------------
 3 files changed, 26 insertions(+), 258 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b062cc..aeb3f14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-07-21  Tobias Grosser  <tobias@grosser.es>
+
+	* configure: Regenerated.
+	* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
+	both cloog.org and legacy versions. The only supported version will
+	be CLooG with the isl backend.
+
 2011-07-26  Ian Lance Taylor  <iant@google.com>
 
 	* configure.ac: Set have_compiler based on whether gcc directory
diff --git a/config/cloog.m4 b/config/cloog.m4
index e95b98d..8662acd 100644
--- a/config/cloog.m4
+++ b/config/cloog.m4
@@ -37,17 +37,6 @@ AC_DEFUN([CLOOG_INIT_FLAGS],
       [--with-cloog-lib=PATH],
       [Specify the directory for the installed CLooG library])])
 
-  AC_ARG_ENABLE(cloog-backend,
-    [AS_HELP_STRING(
-      [--enable-cloog-backend[[=BACKEND]]],
-      [set the CLooG BACKEND used to either isl, ppl or ppl-legacy (default)])],
-    [ if   test "x${enableval}" = "xisl"; then
-	cloog_backend=isl
-      elif test "x${enableval}" = "xppl"; then
-	cloog_backend=ppl
-      else
-	cloog_backend=ppl-legacy
-      fi], cloog_backend=ppl-legacy)
   AC_ARG_ENABLE(cloog-version-check,
     [AS_HELP_STRING(
       [--disable-cloog-version-check],
@@ -107,23 +96,6 @@ m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
   [#include "cloog/cloog.h" ],
   [cloog_version ()])])
 
-# _CLOOG_ORG_PROG_PPL ()
-# ------------------
-# Helper for detecting CLooG.org's PPL backend.
-m4_define([_CLOOG_ORG_PROG_PPL],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"
-   #include "cloog/ppl/cloog.h"],
-  [cloog_version ()])])
-
-# _CLOOG_PPL_LEGACY_PROG ()
-# -------------------------
-# Helper for detecting CLooG-Legacy (CLooG-PPL).
-m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"],
-  [#ifndef CLOOG_PPL_BACKEND
-    choke me
-   #endif ])])
-
 # CLOOG_FIND_FLAGS ()
 # ------------------
 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
@@ -144,49 +116,17 @@ AC_DEFUN([CLOOG_FIND_FLAGS],
   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
   LDFLAGS="${LDFLAGS} ${clooglibs}"
 
-  case $cloog_backend in
-    "ppl-legacy")
-    CFLAGS="${CFLAGS} ${pplinc}"
-    LDFLAGS="${LDFLAGS} ${ppllibs}"
-    AC_CACHE_CHECK([for installed CLooG PPL Legacy], [gcc_cv_cloog_type],
-      [LIBS="-lcloog ${_cloog_saved_LIBS}"
-      AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG], [gcc_cv_cloog_type="PPL Legacy"],
-		     [gcc_cv_cloog_type=no])])
-    ;;
-    "isl")
-    AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
-      [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
-      AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
-		     [gcc_cv_cloog_type=no])])
-    ;;
-    "ppl")
-    CFLAGS="${CFLAGS} ${pplinc}"
-    LDFLAGS="${LDFLAGS} ${ppllibs}"
-    AC_CACHE_CHECK([for installed CLooG PPL], [gcc_cv_cloog_type],
-      [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
-      AC_LINK_IFELSE([_CLOOG_ORG_PROG_PPL], [gcc_cv_cloog_type="PPL"],
-		     [gcc_cv_cloog_type=no])])
-    ;;
-    *)
-      gcc_cv_cloog_type=""
-  esac
+  AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
+    [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
+    AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
+		   [gcc_cv_cloog_type=no])])
 
   case $gcc_cv_cloog_type in
-    "PPL Legacy")
-      clooginc="${clooginc}"
-      clooglibs="${clooglibs} -lcloog"
-      cloog_org=no
-      ;;
     "ISL")
       clooginc="${clooginc} ${_cloogorginc}"
       clooglibs="${clooglibs} -lcloog-isl -lisl"
       cloog_org=yes
       ;;
-    "PPL")
-      clooginc="${clooginc} ${_cloogorginc}"
-      clooglibs="${clooglibs} -lcloog-ppl"
-      cloog_org=yes
-      ;;
     *)
       clooglibs=
       clooginc=
@@ -212,25 +152,10 @@ m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
     choke me
    #endif])])
 
-# _CLOOG_CHECK_RT_PROG ()
-# -----------------------
-# Helper for verifying that CLooG's compile time version
-# matches the run time version.
-m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"],
-  [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
-    && (cloog_version_minor () != CLOOG_VERSION_MINOR)
-    && (cloog_version_revision () != CLOOG_VERSION_REVISION))
-    {
-      return 1;
-    }])])
-
 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
 # ----------------------------------------------------------------
 # Test the found CLooG to be exact of version MAJOR.MINOR and at least
 # REVISION.
-# If we're using the old CLooG-PPL (Legacy), the old version check will
-# be executed (Ignores the provided version information).
 AC_DEFUN([CLOOG_CHECK_VERSION],
 [
   AC_REQUIRE([CLOOG_FIND_FLAGS])
@@ -242,21 +167,11 @@ AC_DEFUN([CLOOG_CHECK_VERSION],
     CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
     LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
 
-    if test "${cloog_org}" = yes ; then
-      AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
-        [gcc_cv_cloog_ct_0_14_0],
-        [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
-          [gcc_cv_cloog_ct_0_14_0=yes],
-          [gcc_cv_cloog_ct_0_14_0=no])])
-    elif test "${cloog_org}" = no ; then
-      AC_CACHE_CHECK([for version 0.15.5 (or later revision) of CLooG],
-        [gcc_cv_cloog_ct_0_15_5],
-        [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,5)],
-          [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG(0,15,9)],
-           [gcc_cv_cloog_ct_0_15_5=yes],
-            [gcc_cv_cloog_ct_0_15_5="buggy but acceptable"])],
-          [gcc_cv_cloog_ct_0_15_5=no])])
-    fi
+    AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
+      [gcc_cv_cloog],
+      [AC_COMPILE_IFELSE([_CLOOG_CHECK_CT_PROG($1,$2,$3)],
+	[gcc_cv_cloog=yes],
+	[gcc_cv_cloog=no])])
 
     CFLAGS=$_cloog_saved_CFLAGS
     LDFLAGS=$_cloog_saved_LDFLAGS
@@ -272,9 +187,7 @@ AC_DEFUN([CLOOG_IF_FAILED],
 [
   CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
   
-  if test "${gcc_cv_cloog_ct_0_14_0}" = no \
-    || test "${gcc_cv_cloog_rt_0_14_0}" = no \
-    || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
+  if test "${gcc_cv_cloog}" = no ; then
     clooglibs=
     clooginc=
   fi
diff --git a/configure b/configure
index 5366d71..fbb29e0 100755
--- a/configure
+++ b/configure
@@ -775,7 +775,6 @@ enable_ppl_version_check
 with_cloog
 with_cloog_include
 with_cloog_lib
-enable_cloog_backend
 enable_cloog_version_check
 enable_lto
 enable_stage1_languages
@@ -1472,9 +1471,6 @@ Optional Features:
                           build stages 2 and 3 with C++, not C
   --disable-ppl-version-check
                           disable check for PPL version
-  --enable-cloog-backend[=BACKEND]
-                          set the CLooG BACKEND used to either isl, ppl or
-                          ppl-legacy (default)
   --disable-cloog-version-check
                           disable check for CLooG version
   --enable-lto            enable link time optimization support
@@ -5710,19 +5706,6 @@ if test "${with_cloog_lib+set}" = set; then :
 fi
 
 
-  # Check whether --enable-cloog-backend was given.
-if test "${enable_cloog_backend+set}" = set; then :
-  enableval=$enable_cloog_backend;  if   test "x${enableval}" = "xisl"; then
-	cloog_backend=isl
-      elif test "x${enableval}" = "xppl"; then
-	cloog_backend=ppl
-      else
-	cloog_backend=ppl-legacy
-      fi
-else
-  cloog_backend=ppl-legacy
-fi
-
   # Check whether --enable-cloog-version-check was given.
 if test "${enable_cloog_version_check+set}" = set; then :
   enableval=$enable_cloog_version_check; ENABLE_CLOOG_CHECK=$enableval
@@ -5795,48 +5778,13 @@ if test "x$with_cloog" != "xno"; then
   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
   LDFLAGS="${LDFLAGS} ${clooglibs}"
 
-  case $cloog_backend in
-    "ppl-legacy")
-    CFLAGS="${CFLAGS} ${pplinc}"
-    LDFLAGS="${LDFLAGS} ${ppllibs}"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG PPL Legacy" >&5
-$as_echo_n "checking for installed CLooG PPL Legacy... " >&6; }
-if test "${gcc_cv_cloog_type+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  LIBS="-lcloog ${_cloog_saved_LIBS}"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "cloog/cloog.h"
-int
-main ()
-{
-#ifndef CLOOG_PPL_BACKEND
-    choke me
-   #endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gcc_cv_cloog_type="PPL Legacy"
-else
-  gcc_cv_cloog_type=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_type" >&5
-$as_echo "$gcc_cv_cloog_type" >&6; }
-    ;;
-    "isl")
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG ISL" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG ISL" >&5
 $as_echo_n "checking for installed CLooG ISL... " >&6; }
 if test "${gcc_cv_cloog_type+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
   LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "cloog/cloog.h"
 int
@@ -5857,59 +5805,13 @@ rm -f core conftest.err conftest.$ac_objext \
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_type" >&5
 $as_echo "$gcc_cv_cloog_type" >&6; }
-    ;;
-    "ppl")
-    CFLAGS="${CFLAGS} ${pplinc}"
-    LDFLAGS="${LDFLAGS} ${ppllibs}"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for installed CLooG PPL" >&5
-$as_echo_n "checking for installed CLooG PPL... " >&6; }
-if test "${gcc_cv_cloog_type+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "cloog/cloog.h"
-   #include "cloog/ppl/cloog.h"
-int
-main ()
-{
-cloog_version ()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gcc_cv_cloog_type="PPL"
-else
-  gcc_cv_cloog_type=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_type" >&5
-$as_echo "$gcc_cv_cloog_type" >&6; }
-    ;;
-    *)
-      gcc_cv_cloog_type=""
-  esac
 
   case $gcc_cv_cloog_type in
-    "PPL Legacy")
-      clooginc="${clooginc}"
-      clooglibs="${clooglibs} -lcloog"
-      cloog_org=no
-      ;;
     "ISL")
       clooginc="${clooginc} ${_cloogorginc}"
       clooglibs="${clooglibs} -lcloog-isl -lisl"
       cloog_org=yes
       ;;
-    "PPL")
-      clooginc="${clooginc} ${_cloogorginc}"
-      clooglibs="${clooglibs} -lcloog-ppl"
-      cloog_org=yes
-      ;;
     *)
       clooglibs=
       clooginc=
@@ -5933,10 +5835,9 @@ $as_echo "$gcc_cv_cloog_type" >&6; }
     CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
     LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
 
-    if test "${cloog_org}" = yes ; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.1 of CLooG" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.1 of CLooG" >&5
 $as_echo_n "checking for version 0.16.1 of CLooG... " >&6; }
-if test "${gcc_cv_cloog_ct_0_14_0+set}" = set; then :
+if test "${gcc_cv_cloog+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5955,65 +5856,14 @@ main ()
 }
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
-  gcc_cv_cloog_ct_0_14_0=yes
-else
-  gcc_cv_cloog_ct_0_14_0=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_ct_0_14_0" >&5
-$as_echo "$gcc_cv_cloog_ct_0_14_0" >&6; }
-    elif test "${cloog_org}" = no ; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.15.5 (or later revision) of CLooG" >&5
-$as_echo_n "checking for version 0.15.5 (or later revision) of CLooG... " >&6; }
-if test "${gcc_cv_cloog_ct_0_15_5+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "cloog/cloog.h"
-int
-main ()
-{
-#if CLOOG_VERSION_MAJOR != 0 \
-    || CLOOG_VERSION_MINOR != 15 \
-    || CLOOG_VERSION_REVISION < 5
-    choke me
-   #endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "cloog/cloog.h"
-int
-main ()
-{
-#if CLOOG_VERSION_MAJOR != 0 \
-    || CLOOG_VERSION_MINOR != 15 \
-    || CLOOG_VERSION_REVISION < 9
-    choke me
-   #endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gcc_cv_cloog_ct_0_15_5=yes
-else
-  gcc_cv_cloog_ct_0_15_5="buggy but acceptable"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  gcc_cv_cloog=yes
 else
-  gcc_cv_cloog_ct_0_15_5=no
+  gcc_cv_cloog=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog_ct_0_15_5" >&5
-$as_echo "$gcc_cv_cloog_ct_0_15_5" >&6; }
-    fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_cloog" >&5
+$as_echo "$gcc_cv_cloog" >&6; }
 
     CFLAGS=$_cloog_saved_CFLAGS
     LDFLAGS=$_cloog_saved_LDFLAGS
@@ -6037,9 +5887,7 @@ $as_echo "$gcc_cv_cloog_ct_0_15_5" >&6; }
 
 
 
-  if test "${gcc_cv_cloog_ct_0_14_0}" = no \
-    || test "${gcc_cv_cloog_rt_0_14_0}" = no \
-    || test "${gcc_cv_cloog_ct_0_15_5}" = no; then
+  if test "${gcc_cv_cloog}" = no ; then
     clooglibs=
     clooginc=
   fi
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 08/11] Add ISL data structures
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (7 preceding siblings ...)
  2011-08-11 23:27                   ` [PATCH 01/11] Make CLooG-ISL the only supported CLooG version Sebastian Pop
@ 2011-08-12  0:02                   ` Sebastian Pop
  2011-08-12  8:42                     ` Sven Verdoolaege
  2011-08-12  0:07                   ` [PATCH 07/11] fix memory leak Sebastian Pop
  2011-08-12  0:07                   ` [PATCH 11/11] add pdr->accesses and pdr->extent Sebastian Pop
  10 siblings, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12  0:02 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-blocking.c        |   12 +++++++++++-
 gcc/graphite-clast-to-gimple.c |    9 +++++++++
 gcc/graphite-cloog-util.c      |   11 ++++++++++-
 gcc/graphite-cloog-util.h      |    2 --
 gcc/graphite-dependences.c     |   11 ++++++++++-
 gcc/graphite-flattening.c      |   11 ++++++++++-
 gcc/graphite-interchange.c     |   12 +++++++++++-
 gcc/graphite-poly.c            |   12 +++++++++++-
 gcc/graphite-poly.h            |   40 +++++++++++++++++++++++-----------------
 gcc/graphite-ppl.c             |   11 ++++++++++-
 gcc/graphite-scop-detection.c  |   11 ++++++++++-
 gcc/graphite-sese-to-poly.c    |   10 ++++++++++
 gcc/graphite.c                 |   12 +++++++++++-
 13 files changed, 136 insertions(+), 28 deletions(-)

diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 967de9d..429b405 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -1,7 +1,7 @@
 /* Heuristics and transform for loop blocking and strip mining on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Pranav Garg  <pranav.garg2107@gmail.com>.
 
@@ -20,7 +20,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a7d0ddc..bb0f4c8 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 83cfb54..82a49a1 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>
    and Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index da26ee9..07894ea 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -21,8 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GRAPHITE_CLOOG_UTIL_H
 #define GRAPHITE_CLOOG_UTIL_H
 
-#include "cloog/cloog.h"
-
 CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
 CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t,
 						   int, CloogState *);
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index fb49f16..9ba2731 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -1,5 +1,5 @@
 /* Data dependence analysis for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Konrad Trifunovic <konrad.trifunovic@inria.fr>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-flattening.c b/gcc/graphite-flattening.c
index ccd0f5f..c58d8a3 100644
--- a/gcc/graphite-flattening.c
+++ b/gcc/graphite-flattening.c
@@ -1,5 +1,5 @@
 /* Loop flattening for Graphite.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com>.
 
 This file is part of GCC.
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index cb4d32c..b819ece 100644
--- a/gcc/graphite-interchange.c
+++ b/gcc/graphite-interchange.c
@@ -1,7 +1,7 @@
 /* Interchange heuristics and transform for loop interchange on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Harsha Jagasia <harsha.jagasia@amd.com>.
 
@@ -20,7 +20,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index db5b0cb..af40d20 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1,5 +1,5 @@
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -18,7 +18,17 @@ 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 COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 417e99e..72e9530 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1,5 +1,5 @@
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -180,7 +180,8 @@ struct poly_dr
      - P: Number of parameters.
 
      In the example, the vector "R C O I L P" is "7 7 3 2 0 1".  */
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses;
+  ppl_Pointset_Powerset_C_Polyhedron_t _accesses;
+  isl_map *accesses;
 
   /* Data reference's base object set number, we must assure 2 pdrs are in the
      same base object set before dependency checking.  */
@@ -195,7 +196,7 @@ struct poly_dr
 #define PDR_CDR(PDR) (PDR->compiler_dr)
 #define PDR_PBB(PDR) (PDR->pbb)
 #define PDR_TYPE(PDR) (PDR->type)
-#define PDR_ACCESSES(PDR) (PDR->accesses)
+#define PDR_ACCESSES(PDR) (PDR->_accesses)
 #define PDR_BASE_OBJECT_SET(PDR) (PDR->dr_base_object_set)
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
@@ -353,19 +354,23 @@ struct poly_bb
 
      The number of variables in the DOMAIN may change and is not
      related to the number of loops in the original code.  */
-  ppl_Pointset_Powerset_C_Polyhedron_t domain;
+  ppl_Pointset_Powerset_C_Polyhedron_t _domain;
+  isl_set *domain;
 
   /* The data references we access.  */
   VEC (poly_dr_p, heap) *drs;
 
   /* The original scattering.  */
-  poly_scattering_p original;
+  poly_scattering_p _original;
+  isl_map *schedule;
 
   /* The transformed scattering.  */
-  poly_scattering_p transformed;
+  poly_scattering_p _transformed;
+  isl_map *transformed;
 
   /* A copy of the transformed scattering.  */
-  poly_scattering_p saved;
+  poly_scattering_p _saved;
+  isl_map *saved;
 
   /* True when the PDR duplicates have already been removed.  */
   bool pdr_duplicates_removed;
@@ -376,15 +381,15 @@ struct poly_bb
 
 #define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
 #define PBB_SCOP(PBB) (PBB->scop)
-#define PBB_DOMAIN(PBB) (PBB->domain)
+#define PBB_DOMAIN(PBB) (PBB->_domain)
 #define PBB_DRS(PBB) (PBB->drs)
-#define PBB_ORIGINAL(PBB) (PBB->original)
-#define PBB_ORIGINAL_SCATTERING(PBB) (PBB->original->scattering)
-#define PBB_TRANSFORMED(PBB) (PBB->transformed)
-#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB->transformed->scattering)
-#define PBB_SAVED(PBB) (PBB->saved)
-#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
-#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
+#define PBB_ORIGINAL(PBB) (PBB->_original)
+#define PBB_ORIGINAL_SCATTERING(PBB) (PBB_ORIGINAL (PBB)->scattering)
+#define PBB_TRANSFORMED(PBB) (PBB->_transformed)
+#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB_TRANSFORMED (PBB)->scattering)
+#define PBB_SAVED(PBB) (PBB->_saved)
+#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB_TRANSFORMED (PBB)->nb_local_variables)
+#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB_TRANSFORMED (PBB)->nb_scattering)
 #define PBB_PDR_DUPLICATES_REMOVED(PBB) (PBB->pdr_duplicates_removed)
 #define PBB_IS_REDUCTION(PBB) (PBB->is_reduction)
 
@@ -1401,7 +1406,8 @@ struct scop
   -128 >= a >= 127
      0 >= b >= 65,535
      c = 2a + b  */
-  ppl_Pointset_Powerset_C_Polyhedron_t context;
+  ppl_Pointset_Powerset_C_Polyhedron_t _context;
+  isl_set *context;
 
   /* A hashtable of the data dependence relations for the original
      scattering.  */
@@ -1414,7 +1420,7 @@ struct scop
 
 #define SCOP_BBS(S) (S->bbs)
 #define SCOP_REGION(S) ((sese) S->region)
-#define SCOP_CONTEXT(S) (S->context)
+#define SCOP_CONTEXT(S) (S->_context)
 #define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs)
 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule)
 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule)
diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c
index 9762ca4..d449237 100644
--- a/gcc/graphite-ppl.c
+++ b/gcc/graphite-ppl.c
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com>
    and Tobias Grosser <grosser@fim.uni-passau.de>
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 3460568..4cd1643 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1,5 +1,5 @@
 /* Detection of Static Control Parts (SCoP) for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 05280e7..b7efe41 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -19,6 +19,16 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite.c b/gcc/graphite.c
index e746c61..8f6d8a1 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -1,5 +1,6 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
 
 This file is part of GCC.
@@ -33,6 +34,15 @@ 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/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 07/11] fix memory leak
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (8 preceding siblings ...)
  2011-08-12  0:02                   ` [PATCH 08/11] Add ISL data structures Sebastian Pop
@ 2011-08-12  0:07                   ` Sebastian Pop
  2011-08-12  0:07                   ` [PATCH 11/11] add pdr->accesses and pdr->extent Sebastian Pop
  10 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12  0:07 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-sese-to-poly.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 7e23c9d..05280e7 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1996,6 +1996,7 @@ build_scop_drs (scop_p scop)
     if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb))))
       {
 	free_gimple_bb (PBB_BLACK_BOX (pbb));
+	free_poly_bb (pbb);
 	VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
 	i--;
       }
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 11/11] add pdr->accesses and pdr->extent
  2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
                                     ` (9 preceding siblings ...)
  2011-08-12  0:07                   ` [PATCH 07/11] fix memory leak Sebastian Pop
@ 2011-08-12  0:07                   ` Sebastian Pop
  2011-08-12 15:25                     ` [PATCH] add pbb->schedule Sebastian Pop
  10 siblings, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12  0:07 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop


Signed-off-by: Sebastian Pop <sebpop@gmail.com>
---
 gcc/graphite-poly.c         |    7 ++-
 gcc/graphite-poly.h         |    4 +-
 gcc/graphite-sese-to-poly.c |  146 ++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 145 insertions(+), 12 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index ce0649b..1828727 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -847,7 +847,8 @@ pbb_remove_duplicate_pdrs (poly_bb_p pbb)
 void
 new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
 	     ppl_Pointset_Powerset_C_Polyhedron_t accesses,
-	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts)
+	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts,
+	     isl_map *acc, isl_set *extent)
 {
   static int id = 0;
   poly_dr_p pdr = XNEW (struct poly_dr);
@@ -857,6 +858,8 @@ new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
   PDR_NB_REFS (pdr) = 1;
   PDR_PBB (pdr) = pbb;
   PDR_ACCESSES (pdr) = accesses;
+  pdr->accesses = acc;
+  pdr->extent = extent;
   PDR_TYPE (pdr) = type;
   PDR_CDR (pdr) = cdr;
   PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
@@ -869,6 +872,8 @@ void
 free_poly_dr (poly_dr_p pdr)
 {
   ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr));
+  isl_map_free (pdr->accesses);
+  isl_set_free (pdr->extent);
   XDELETE (pdr);
 }
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 3483ef0..809b7f0 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -182,6 +182,7 @@ struct poly_dr
      In the example, the vector "R C O I L P" is "7 7 3 2 0 1".  */
   ppl_Pointset_Powerset_C_Polyhedron_t _accesses;
   isl_map *accesses;
+  isl_set *extent;
 
   /* Data reference's base object set number, we must assure 2 pdrs are in the
      same base object set before dependency checking.  */
@@ -201,7 +202,8 @@ struct poly_dr
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
 void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t,
-		  enum poly_dr_type, void *, graphite_dim_t);
+		  enum poly_dr_type, void *, graphite_dim_t, isl_map *,
+		  isl_set *);
 void free_poly_dr (poly_dr_p);
 void debug_pdr (poly_dr_p, int);
 void print_pdr (FILE *, poly_dr_p, int);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 75355e9..28c5d98 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -658,6 +658,26 @@ isl_id_for_ssa_name (scop_p s, tree e)
   return id;
 }
 
+/* Return an ISL identifier for the data reference DR.  */
+
+static isl_id *
+isl_id_for_dr (scop_p s, data_reference_p dr)
+{
+  isl_id *id;
+  const char *name = get_name (DR_BASE_OBJECT (dr));
+
+  if (name)
+    id = isl_id_alloc (s->ctx, name, dr);
+  else
+    {
+      char name1[1];
+      snprintf (name1, sizeof (name1), "A");
+      id = isl_id_alloc (s->ctx, name1, dr);
+    }
+
+  return id;
+}
+
 /* Extract an affine expression from the ssa_name E.  */
 
 static isl_pw_aff *
@@ -1894,8 +1914,9 @@ build_scop_iteration_domain (scop_p scop)
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_alias_set (isl_map *acc,
+		   ppl_Polyhedron_t accesses, data_reference_p dr,
 		   ppl_dimension_type accessp_nb_dims,
 		   ppl_dimension_type dom_nb_dims)
 {
@@ -1916,6 +1937,34 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
 
   ppl_delete_Linear_Expression (alias);
   ppl_delete_Constraint (cstr);
+
+  {
+    isl_constraint *c = isl_equality_alloc (isl_map_get_dim (acc));
+    c = isl_constraint_set_constant_si (c, -alias_set_num);
+    c = isl_constraint_set_coefficient_si (c, isl_dim_out, 0, 1);
+
+    return isl_map_add_constraint (acc, c);
+  }
+}
+
+/* Assign the affine expression INDEX to the output dimension POS of
+   MAP and return the result.  */
+
+static isl_map *
+set_index (isl_map *map, int pos, isl_pw_aff *index)
+{
+  isl_map *index_map;
+  int len = isl_map_dim (map, isl_dim_out);
+  isl_id *id;
+
+  index_map = isl_map_from_pw_aff (index);
+  index_map = isl_map_insert_dims (index_map, isl_dim_out, 0, pos);
+  index_map = isl_map_add_dims (index_map, isl_dim_out, len - pos - 1);
+
+  id = isl_map_get_tuple_id (map, isl_dim_out);
+  index_map = isl_map_set_tuple_id (index_map, isl_dim_out, id);
+
+  return isl_map_intersect (map, index_map);
 }
 
 /* Add to ACCESSES polyhedron equalities defining the access functions
@@ -1923,8 +1972,9 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
    polyhedron, DOM_NB_DIMS is the dimension of the iteration domain.
    PBB is the poly_bb_p that contains the data reference DR.  */
 
-static void
-pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_memory_accesses (isl_map *acc,
+			 ppl_Polyhedron_t accesses, data_reference_p dr,
 			 ppl_dimension_type accessp_nb_dims,
 			 ppl_dimension_type dom_nb_dims,
 			 poly_bb_p pbb)
@@ -1957,9 +2007,13 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
       ppl_delete_Linear_Expression (fn);
       ppl_delete_Linear_Expression (access);
       ppl_delete_Constraint (cstr);
+
+      acc = set_index (acc, i + 1, extract_affine (scop, afn));
     }
 
   mpz_clear (v);
+
+  return acc;
 }
 
 /* Add constrains representing the size of the accessed data to the
@@ -1967,8 +2021,9 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_set *
+pdr_add_data_dimensions (isl_set *extent, scop_p scop,
+			 ppl_Polyhedron_t accesses, data_reference_p dr,
 			 ppl_dimension_type accessp_nb_dims,
 			 ppl_dimension_type dom_nb_dims)
 {
@@ -2006,6 +2061,52 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 
       high = array_ref_up_bound (ref);
 
+      if (host_integerp (low, 0)
+	  && high
+	  && host_integerp (high, 0)
+	  /* 1-element arrays at end of structures may extend over
+	     their declared size.  */
+	  && !(array_at_struct_end_p (ref)
+	       && operand_equal_p (low, high, 0)))
+	{
+	  isl_id *id;
+	  isl_aff *aff;
+	  isl_set *univ, *lbs, *ubs;
+	  isl_pw_aff *index;
+	  isl_dim *dim;
+	  isl_set *valid;
+	  int nbl = isl_set_dim (scop->context, isl_dim_set);
+	  int nbs = isl_set_dim (extent, isl_dim_set);
+	  isl_pw_aff *lb = extract_affine_int (scop, low);
+	  isl_pw_aff *ub = extract_affine_int (scop, high);
+
+	  /* high >= 0 */
+	  valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
+	  scop->context = isl_set_intersect (scop->context, valid);
+
+	  /* Make the dimension of LB and UB to be exactly NBS.  */
+	  lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1);
+	  ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1);
+	  lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1);
+	  ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1);
+
+	  dim = isl_set_get_dim (extent);
+	  aff = isl_aff_zero (isl_local_space_from_dim (dim));
+	  aff = isl_aff_add_coefficient_si (aff, isl_dim_set, i, 1);
+	  univ = isl_set_universe (isl_aff_get_dim (aff));
+	  index = isl_pw_aff_alloc (univ, aff);
+
+	  id = isl_set_get_tuple_id (extent);
+	  lb = isl_pw_aff_set_tuple_id (lb, isl_id_copy (id));
+	  ub = isl_pw_aff_set_tuple_id (ub, id);
+
+	  /* low <= sub_i <= high */
+	  lbs = isl_pw_aff_ge_set (isl_pw_aff_copy (index), lb);
+	  ubs = isl_pw_aff_le_set (index, ub);
+	  extent = isl_set_intersect (extent, lbs);
+	  extent = isl_set_intersect (extent, ubs);
+	}
+
       /* high - subscript >= 0 */
       if (high && host_integerp (high, 0)
 	  /* 1-element arrays at end of structures may extend over
@@ -2024,6 +2125,8 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 	  ppl_delete_Constraint (cstr);
 	}
     }
+
+  return extent;
 }
 
 /* Build data accesses for DR in PBB.  */
@@ -2036,6 +2139,9 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
   ppl_dimension_type dom_nb_dims;
   ppl_dimension_type accessp_nb_dims;
   int dr_base_object_set;
+  isl_map *acc;
+  isl_set *extent;
+  scop_p scop = PBB_SCOP (pbb);
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb),
 						      &dom_nb_dims);
@@ -2043,9 +2149,29 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 
   ppl_new_C_Polyhedron_from_space_dimension (&accesses, accessp_nb_dims, 0);
 
-  pdr_add_alias_set (accesses, dr, accessp_nb_dims, dom_nb_dims);
-  pdr_add_memory_accesses (accesses, dr, accessp_nb_dims, dom_nb_dims, pbb);
-  pdr_add_data_dimensions (accesses, dr, accessp_nb_dims, dom_nb_dims);
+  {
+    isl_dim *dc = isl_set_get_dim (scop->context);
+    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
+    isl_dim *dim = isl_dim_add (isl_dim_from_domain (dc), isl_dim_out, nb_out);
+
+    acc = isl_map_universe (dim);
+    acc = isl_map_set_tuple_id (acc, isl_dim_out, isl_id_for_dr (scop, dr));
+  }
+
+  acc = pdr_add_alias_set (acc, accesses, dr, accessp_nb_dims, dom_nb_dims);
+  acc = pdr_add_memory_accesses (acc, accesses, dr, accessp_nb_dims,
+				 dom_nb_dims, pbb);
+
+  {
+    isl_id *id = isl_id_for_dr (scop, dr);
+    int nb = 1 + DR_NUM_DIMENSIONS (dr);
+    isl_dim *dim = isl_dim_set_alloc (scop->ctx, 0, nb);
+
+    dim = isl_dim_set_tuple_id (dim, isl_dim_set, id);
+    extent = isl_set_nat_universe (dim);
+    extent = pdr_add_data_dimensions (extent, scop, accesses, dr,
+				      accessp_nb_dims, dom_nb_dims);
+  }
 
   ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&accesses_ps,
 							    accesses);
@@ -2056,7 +2182,7 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 
   new_poly_dr (pbb, dr_base_object_set, accesses_ps,
 	       DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
-	       dr, DR_NUM_DIMENSIONS (dr));
+	       dr, DR_NUM_DIMENSIONS (dr), acc, extent);
 }
 
 /* Write to FILE the alias graph of data references in DIMACS format.  */
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
@ 2011-08-12  2:41                     ` Jack Howarth
  2011-08-12  7:21                       ` Sebastian Pop
  2011-08-12  9:15                     ` Tobias Grosser
  2011-08-12  9:19                     ` Sven Verdoolaege
  2 siblings, 1 reply; 58+ messages in thread
From: Jack Howarth @ 2011-08-12  2:41 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: skimo, tobias, gcc-patches

On Thu, Aug 11, 2011 at 05:44:37PM -0500, Sebastian Pop wrote:
> 
> Signed-off-by: Sebastian Pop <sebpop@gmail.com>
> ---
>  gcc/graphite-clast-to-gimple.c |   55 ++++++--
>  gcc/graphite-cloog-util.c      |    1 +
>  gcc/graphite-poly.c            |    8 +
>  gcc/graphite-poly.h            |    3 +
>  gcc/graphite-sese-to-poly.c    |  301 +++++++++++++++++++++++++++++++++++++++-
>  gcc/graphite.c                 |    4 +
>  6 files changed, 356 insertions(+), 16 deletions(-)
> 
> diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
> index bb0f4c8..9a9effa 100644
> --- a/gcc/graphite-clast-to-gimple.c
> +++ b/gcc/graphite-clast-to-gimple.c
> @@ -24,6 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>  #include <isl/set.h>
>  #include <isl/map.h>
>  #include <isl/union_map.h>
> +#include <isl/list.h>
> +#include <isl/constraint.h>
> +#include <isl/div.h>
> +#include <isl/ilp.h>
> +#include <isl/aff.h>
>  #include <cloog/cloog.h>
>  #include <cloog/isl/domain.h>
>  #endif
> @@ -768,16 +773,19 @@ graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt,
>  static void
>  compute_bounds_for_param (scop_p scop, int param, mpz_t low, mpz_t up)
>  {
> -  ppl_Linear_Expression_t le;
> -
> -  /* Prepare the linear expression corresponding to the parameter that
> -     we want to maximize/minimize.  */
> -  ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
> -  ppl_set_coef (le, param, 1);
> -
> -  ppl_max_for_le_pointset (SCOP_CONTEXT (scop), le, up);
> -  ppl_min_for_le_pointset (SCOP_CONTEXT (scop), le, low);
> -  ppl_delete_Linear_Expression (le);
> +  isl_int v;
> +  isl_aff *aff = isl_aff_zero
> +    (isl_local_space_from_dim (isl_set_get_dim (scop->context)));
> +
> +  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, param, 1);
> +
> +  isl_int_init (v);
> +  isl_set_min (scop->context, aff, &v);
> +  isl_int_get_gmp (v, low);
> +  isl_set_max (scop->context, aff, &v);
> +  isl_int_get_gmp (v, up);
> +  isl_int_clear (v);
> +  isl_aff_free (aff);
>  }
>  
>  /* Compute the lower bound LOW and upper bound UP for the induction
> @@ -1357,7 +1365,6 @@ build_cloog_union_domain (scop_p scop)
>  {
>    int i;
>    poly_bb_p pbb;
> -
>    CloogUnionDomain *union_domain =
>      cloog_union_domain_alloc (scop_nb_params (scop));
>  
> @@ -1460,8 +1467,30 @@ generate_cloog_input (scop_p scop, htab_t params_index)
>    union_domain = add_names_to_union_domain (scop, union_domain,
>  					    nb_scattering_dims,
>  					    params_index);
> -  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
> -    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
> +
> +  if (1)
> +    {
> +      /* For now remove the isl_id's from the context before
> +	 translating to CLooG: this code will be removed when the
> +	 domain will also contain isl_id's.  */
> +      isl_set *ct = isl_set_project_out (isl_set_copy (scop->context),
> +					 isl_dim_set, 0, number_of_loops ());
> +      isl_printer *p = isl_printer_to_str (scop->ctx);
> +      char *str;
> +
> +      p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
> +      p = isl_printer_print_set (p, ct);
> +      isl_set_free (ct);
> +
> +      str = isl_printer_get_str (p);
> +      ct = isl_set_read_from_str (scop->ctx, str,
> +				  scop_nb_params (scop));
> +      free (str);
> +      isl_printer_free (p);
> +      context = cloog_domain_from_isl_set (ct);
> +    }
> +  else
> +    context = cloog_domain_from_isl_set (isl_set_copy (scop->context));
>  
>    cloog_input = cloog_input_alloc (context, union_domain);
>  
> diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
> index 82a49a1..6086864 100644
> --- a/gcc/graphite-cloog-util.c
> +++ b/gcc/graphite-cloog-util.c
> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include <isl/set.h>
>  #include <isl/map.h>
>  #include <isl/union_map.h>
> +#include <isl/aff.h>
>  #include <cloog/cloog.h>
>  #include <cloog/isl/domain.h>
>  #endif
> diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
> index af40d20..fd2703b 100644
> --- a/gcc/graphite-poly.c
> +++ b/gcc/graphite-poly.c
> @@ -1012,6 +1012,7 @@ new_scop (void *region)
>    scop_p scop = XNEW (struct scop);
>  
>    SCOP_CONTEXT (scop) = NULL;
> +  scop->context = NULL;
>    scop_set_region (scop, region);
>    SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
>    SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
> @@ -1040,6 +1041,7 @@ free_scop (scop_p scop)
>    if (SCOP_CONTEXT (scop))
>      ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
>  
> +  isl_set_free (scop->context);
>    htab_delete (SCOP_ORIGINAL_PDDRS (scop));
>    free_lst (SCOP_ORIGINAL_SCHEDULE (scop));
>    free_lst (SCOP_TRANSFORMED_SCHEDULE (scop));
> @@ -1401,6 +1403,12 @@ print_scop_context (FILE *file, scop_p scop, int verbosity)
>    else
>      fprintf (file, "0 %d\n", (int) scop_nb_params (scop) + 2);
>  
> +  if (scop->context)
> +    {
> +      isl_printer *p = isl_printer_to_file (scop->ctx, file);
> +      isl_printer_print_set (p, scop->context);
> +    }
> +
>    if (verbosity > 0)
>      fprintf (file, "# )\n");
>  }
> diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
> index 72e9530..bb8771d 100644
> --- a/gcc/graphite-poly.h
> +++ b/gcc/graphite-poly.h
> @@ -1409,6 +1409,9 @@ struct scop
>    ppl_Pointset_Powerset_C_Polyhedron_t _context;
>    isl_set *context;
>  
> +  /* The context used internally by ISL.  */
> +  isl_ctx *ctx;
> +
>    /* A hashtable of the data dependence relations for the original
>       scattering.  */
>    htab_t original_pddrs;
> diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
> index b7efe41..69392a9 100644
> --- a/gcc/graphite-sese-to-poly.c
> +++ b/gcc/graphite-sese-to-poly.c
> @@ -24,6 +24,8 @@ along with GCC; see the file COPYING3.  If not see
>  #include <isl/set.h>
>  #include <isl/map.h>
>  #include <isl/union_map.h>
> +#include <isl/constraint.h>
> +#include <isl/aff.h>
>  #include <cloog/cloog.h>
>  #include <cloog/cloog.h>
>  #include <cloog/isl/domain.h>
> @@ -595,6 +597,216 @@ build_scop_scattering (scop_p scop)
>    ppl_delete_Linear_Expression (static_schedule);
>  }
>  
> +static isl_pw_aff *extract_affine (scop_p, tree);
> +
> +/* Extract an affine expression from the chain of recurrence E.  */
> +
> +static isl_pw_aff *
> +extract_affine_chrec (scop_p s, tree e)
> +{
> +  isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e));
> +  isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e));
> +  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
> +  isl_local_space *ls = isl_local_space_from_dim (dim);
> +  isl_aff *loop = isl_aff_set_coefficient_si
> +    (isl_aff_zero (ls), isl_dim_set, CHREC_VARIABLE (e), 1);
> +  isl_pw_aff *l = isl_pw_aff_from_aff (loop);
> +
> +  /* Before multiplying, make sure that the result is affine.  */
> +  gcc_assert (isl_pw_aff_is_cst (rhs)
> +	      || isl_pw_aff_is_cst (l));
> +
> +  return isl_pw_aff_add (lhs, isl_pw_aff_mul (rhs, l));
> +}
> +
> +/* Extract an affine expression from the mult_expr E.  */
> +
> +static isl_pw_aff *
> +extract_affine_mul (scop_p s, tree e)
> +{
> +  isl_pw_aff *lhs = extract_affine (s, TREE_OPERAND (e, 0));
> +  isl_pw_aff *rhs = extract_affine (s, TREE_OPERAND (e, 1));
> +
> +  if (!isl_pw_aff_is_cst (lhs)
> +      && !isl_pw_aff_is_cst (rhs))
> +    {
> +      isl_pw_aff_free (lhs);
> +      isl_pw_aff_free (rhs);
> +      return NULL;
> +    }
> +
> +  return isl_pw_aff_mul (lhs, rhs);
> +}
> +
> +/* Return an ISL identifier from the name of the ssa_name E.  */
> +
> +static isl_id *
> +isl_id_for_ssa_name (scop_p s, tree e)
> +{
> +  const char *name = get_name (e);
> +  isl_id *id;
> +
> +  if (name)
> +    id = isl_id_alloc (s->ctx, name, e);
> +  else
> +    {
> +      char name1[50];
> +      snprintf (name1, sizeof (name1), "P_%d", SSA_NAME_VERSION (e));
> +      id = isl_id_alloc (s->ctx, name1, e);
> +    }
> +
> +  return id;
> +}
> +
> +/* Return an ISL identifier from the loop L.  */
> +
> +static isl_id *
> +isl_id_for_loop (scop_p s, loop_p l)
> +{
> +  isl_id *id;
> +  char name[50];
> +
> +  snprintf (name, sizeof (name), "L_%d", l ? l->num : -1);
> +  id = isl_id_alloc (s->ctx, name, l);
> +
> +  return id;
> +}
> +
> +/* Extract an affine expression from the ssa_name E.  */
> +
> +static isl_pw_aff *
> +extract_affine_name (scop_p s, tree e)
> +{
> +  isl_aff *aff;
> +  isl_set *dom;
> +  isl_dim *dim = isl_dim_set_alloc (s->ctx, 1, number_of_loops ());
> +
> +  dim = isl_dim_set_dim_id (dim, isl_dim_param, 0, isl_id_for_ssa_name (s, e));
> +  dom = isl_set_universe (isl_dim_copy (dim));
> +  aff = isl_aff_zero (isl_local_space_from_dim (dim));
> +  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, 0, 1);
> +  return isl_pw_aff_alloc (dom, aff);
> +}
> +
> +/* Extract an affine expression from the gmp constant G.  */
> +
> +static isl_pw_aff *
> +extract_affine_gmp (scop_p s, mpz_t g)
> +{
> +  isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ());
> +  isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (dim));
> +  isl_aff *aff = isl_aff_zero (ls);
> +  isl_set *dom = isl_set_universe (dim);
> +  isl_int v;
> +
> +  isl_int_init (v);
> +  isl_int_set_gmp (v, g);
> +  aff = isl_aff_add_constant (aff, v);
> +  isl_int_clear (v);
> +
> +  return isl_pw_aff_alloc (dom, aff);
> +}
> +
> +/* Extract an affine expression from the integer_cst E.  */
> +
> +static isl_pw_aff *
> +extract_affine_int (scop_p s, tree e)
> +{
> +  isl_pw_aff *res;
> +  mpz_t g;
> +
> +  mpz_init (g);
> +  tree_int_to_gmp (e, g);
> +  res = extract_affine_gmp (s, g);
> +  mpz_clear (g);
> +
> +  return res;
> +}
> +
> +/* Compute pwaff mod 2^width.  */
> +
> +static isl_pw_aff *
> +wrap (isl_pw_aff *pwaff, unsigned width)
> +{
> +  isl_int mod;
> +
> +  isl_int_init (mod);
> +  isl_int_set_si (mod, 1);
> +  isl_int_mul_2exp (mod, mod, width);
> +
> +  pwaff = isl_pw_aff_mod (pwaff, mod);
> +
> +  isl_int_clear (mod);
> +
> +  return pwaff;
> +}
> +
> +/* Extract an affine expression from the tree E in the scop S.  */
> +
> +static isl_pw_aff *
> +extract_affine (scop_p s, tree e)
> +{
> +  isl_pw_aff *lhs, *rhs, *res;
> +  tree type;
> +
> +  if (e == chrec_dont_know)
> +    return NULL;
> +
> +  switch (TREE_CODE (e))
> +    {
> +    case POLYNOMIAL_CHREC:
> +      res = extract_affine_chrec (s, e);
> +      break;
> +
> +    case MULT_EXPR:
> +      res = extract_affine_mul (s, e);
> +      break;
> +
> +    case PLUS_EXPR:
> +    case POINTER_PLUS_EXPR:
> +      lhs = extract_affine (s, TREE_OPERAND (e, 0));
> +      rhs = extract_affine (s, TREE_OPERAND (e, 1));
> +      res = isl_pw_aff_add (lhs, rhs);
> +      break;
> +
> +    case MINUS_EXPR:
> +      lhs = extract_affine (s, TREE_OPERAND (e, 0));
> +      rhs = extract_affine (s, TREE_OPERAND (e, 1));
> +      res = isl_pw_aff_sub (lhs, rhs);
> +      break;
> +
> +    case NEGATE_EXPR:
> +    case BIT_NOT_EXPR:
> +      lhs = extract_affine (s, TREE_OPERAND (e, 0));
> +      rhs = extract_affine (s, integer_minus_one_node);
> +      res = isl_pw_aff_mul (lhs, rhs);
> +      break;
> +
> +    case SSA_NAME:
> +      res = extract_affine_name (s, e);
> +      break;
> +
> +    case INTEGER_CST:
> +      res = extract_affine_int (s, e);
> +      break;
> +
> +    CASE_CONVERT:
> +    case NON_LVALUE_EXPR:
> +      res = extract_affine (s, TREE_OPERAND (e, 0));
> +      break;
> +
> +    default:
> +      gcc_unreachable ();
> +      break;
> +    }
> +
> +  type = TREE_TYPE (e);
> +  if (TYPE_UNSIGNED (type))
> +    res = wrap (res, TYPE_PRECISION (type));
> +
> +  return res;
> +}
> +
>  /* Add the value K to the dimension D of the linear expression EXPR.  */
>  
>  static void
> @@ -931,6 +1143,7 @@ find_scop_parameters (scop_p scop)
>    sese region = SCOP_REGION (scop);
>    struct loop *loop;
>    mpz_t one;
> +  int nbp;
>  
>    mpz_init (one);
>    mpz_set_si (one, 1);
> @@ -953,11 +1166,28 @@ find_scop_parameters (scop_p scop)
>    FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
>      find_params_in_bb (region, PBB_BLACK_BOX (pbb));
>  
> -  scop_set_nb_params (scop, sese_nb_params (region));
> +  nbp = sese_nb_params (region);
> +  scop_set_nb_params (scop, nbp);
>    SESE_ADD_PARAMS (region) = false;
>  
>    ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension
> -    (&SCOP_CONTEXT (scop), scop_nb_params (scop), 0);
> +    (&SCOP_CONTEXT (scop), nbp, 0);
> +
> +  {
> +    tree e;
> +    unsigned nbl = number_of_loops ();
> +    isl_dim *dim = isl_dim_set_alloc (scop->ctx, nbp, nbl);
> +
> +    FOR_EACH_VEC_ELT (tree, SESE_PARAMS (region), i, e)
> +      dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
> +				isl_id_for_ssa_name (scop, e));
> +
> +    for (i = 0; i < nbl; i++)
> +      dim = isl_dim_set_dim_id (dim, isl_dim_set, i,
> +				isl_id_for_loop (scop, get_loop (i)));
> +
> +    scop->context = isl_set_universe (dim);
> +  }
>  }
>  
>  /* Insert in the SCOP context constraints from the estimation of the
> @@ -1094,6 +1324,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
>        ppl_Constraint_t ub;
>        ppl_Linear_Expression_t ub_expr;
>        double_int nit;
> +      isl_pw_aff *aff;
>  
>        mpz_init (one);
>        mpz_set_si (one, 1);
> @@ -1102,8 +1333,33 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
>        scan_tree_for_params (SCOP_REGION (scop), nb_iters, ub_expr, one);
>        mpz_clear (one);
>  
> +      aff = extract_affine (scop, nb_iters);
> +      scop->context = isl_set_intersect
> +	(scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff)));
> +
>        if (max_stmt_executions (loop, true, &nit))
> -	add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
> +	{
> +	  add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
> +
> +	  {
> +	    /* Insert in the context the constraints from the
> +	       estimation of the number of iterations NIT and the
> +	       symbolic number of iterations (involving parameter
> +	       names) NB_ITERS.  First, build the affine expression
> +	       "NIT - NB_ITERS" and then say that it is positive,
> +	       i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS".  */
> +	    isl_pw_aff *approx;
> +	    mpz_t g;
> +	    isl_set *x;
> +
> +	    mpz_init (g);
> +	    mpz_set_double_int (g, nit, false);
> +	    approx = extract_affine_gmp (scop, g);
> +	    mpz_clear (g);
> +	    x = isl_pw_aff_ge_set (approx, aff);
> +	    scop->context = isl_set_intersect (scop->context, x);
> +	  }
> +	}
>  
>        /* loop_i <= expr_nb_iters */
>        ppl_set_coef (ub_expr, nb, -1);
> @@ -1463,6 +1719,26 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
>        ppl_Polyhedron_add_constraint (context, cstr);
>        ppl_delete_Linear_Expression (le);
>        ppl_delete_Constraint (cstr);
> +
> +      {
> +	isl_dim *dim = isl_set_get_dim (scop->context);
> +	isl_constraint *c = isl_inequality_alloc (dim);
> +	mpz_t g;
> +	isl_int v;
> +
> +	mpz_init (g);
> +	isl_int_init (v);
> +	tree_int_to_gmp (lb, g);
> +	isl_int_set_gmp (v, g);
> +	isl_int_neg (v, v);
> +	mpz_clear (g);
> +	isl_constraint_set_constant (c, v);
> +	isl_int_set_si (v, 1);
> +	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
> +	isl_int_clear (v);
> +
> +	scop->context = isl_set_add_constraint (scop->context, c);
> +      }
>      }
>  
>    if (ub)
> @@ -1474,6 +1750,25 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
>        ppl_Polyhedron_add_constraint (context, cstr);
>        ppl_delete_Linear_Expression (le);
>        ppl_delete_Constraint (cstr);
> +
> +      {
> +	isl_dim *dim = isl_set_get_dim (scop->context);
> +	isl_constraint *c = isl_inequality_alloc (dim);
> +	mpz_t g;
> +	isl_int v;
> +
> +	mpz_init (g);
> +	isl_int_init (v);
> +	tree_int_to_gmp (ub, g);
> +	isl_int_set_gmp (v, g);
> +	mpz_clear (g);
> +	isl_constraint_set_constant (c, v);
> +	isl_int_set_si (v, -1);
> +	isl_constraint_set_coefficient (c, isl_dim_param, p, v);
> +	isl_int_clear (v);
> +
> +	scop->context = isl_set_add_constraint (scop->context, c);
> +      }
>      }
>  }
>  
> diff --git a/gcc/graphite.c b/gcc/graphite.c
> index 8f6d8a1..b2cf7c6 100644
> --- a/gcc/graphite.c
> +++ b/gcc/graphite.c
> @@ -260,10 +260,12 @@ graphite_transform_loops (void)
>    bool need_cfg_cleanup_p = false;
>    VEC (scop_p, heap) *scops = NULL;
>    htab_t bb_pbb_mapping;
> +  isl_ctx *ctx;
>  
>    if (!graphite_initialize ())
>      return;
>  
> +  ctx = isl_ctx_alloc ();
>    build_scops (&scops);
>  
>    if (dump_file && (dump_flags & TDF_DETAILS))
> @@ -277,6 +279,7 @@ graphite_transform_loops (void)
>    FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
>      if (dbg_cnt (graphite_scop))
>        {
> +	scop->ctx = ctx;
>  	build_poly_scop (scop);
>  
>  	if (POLY_SCOP_P (scop)
> @@ -288,6 +291,7 @@ graphite_transform_loops (void)
>    htab_delete (bb_pbb_mapping);
>    free_scops (scops);
>    graphite_finalize (need_cfg_cleanup_p);
> +  isl_ctx_free (ctx);
>  }
>  
>  #else /* If Cloog is not available: #ifndef HAVE_cloog.  */
> -- 
> 1.7.4.1

Sebastian,
    This patch falls to compile under clang3.0svn with the error...

../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:643:8: error: unknown type name 'isl_id'
static isl_id *
       ^
../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:647:3: error: use of undeclared identifier 'isl_id'
  isl_id *id;

Did you omit some of the patch?
               Jack

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-12  2:41                     ` Jack Howarth
@ 2011-08-12  7:21                       ` Sebastian Pop
  2011-08-12  7:22                         ` Jack Howarth
  0 siblings, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12  7:21 UTC (permalink / raw)
  To: Jack Howarth; +Cc: skimo, tobias, gcc-patches

>    This patch falls to compile under clang3.0svn with the error...
>
> ../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:643:8: error: unknown type name 'isl_id'
> static isl_id *
>       ^
> ../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:647:3: error: use of undeclared identifier 'isl_id'
>  isl_id *id;
>
> Did you omit some of the patch?
>               Jack
>

You should use the latest isl from git to compile gcc with these patches.

commit 1303fcc500dabe1e1afe1fe521ff285093d7cc13
Author: Sven Verdoolaege <skimo@kotnet.org>
Date:   Thu Aug 11 10:21:27 2011 +0200

    rename isl_map_insert to isl_set_insert_dims and add it to the docs

    The new name is more consistent with other functions, especially
    isl_map_add_dims.

I am using the isl_set_insert_dims function so you would need at least
this revision.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-12  7:21                       ` Sebastian Pop
@ 2011-08-12  7:22                         ` Jack Howarth
  0 siblings, 0 replies; 58+ messages in thread
From: Jack Howarth @ 2011-08-12  7:22 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: skimo, tobias, gcc-patches

On Thu, Aug 11, 2011 at 09:08:41PM -0500, Sebastian Pop wrote:
> >    This patch falls to compile under clang3.0svn with the error...
> >
> > ../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:643:8: error: unknown type name 'isl_id'
> > static isl_id *
> >       ^
> > ../../gcc-4.7-20110811/gcc/graphite-sese-to-poly.c:647:3: error: use of undeclared identifier 'isl_id'
> >  isl_id *id;
> >
> > Did you omit some of the patch?
> >               Jack
> >
> 
> You should use the latest isl from git to compile gcc with these patches.

Sebastian,
    Do you mean the latest cloog.org fit release? If so, this means the patch that [PATCH 02/11] Require cloog 0.16.3
is now insufficient and whould be requiring an unreleased 0.16.4. Certainly cloog 0.16.4 should be released before
these patches are committed, no?
               Jack

> 
> commit 1303fcc500dabe1e1afe1fe521ff285093d7cc13
> Author: Sven Verdoolaege <skimo@kotnet.org>
> Date:   Thu Aug 11 10:21:27 2011 +0200
> 
>     rename isl_map_insert to isl_set_insert_dims and add it to the docs
> 
>     The new name is more consistent with other functions, especially
>     isl_map_add_dims.
> 
> I am using the isl_set_insert_dims function so you would need at least
> this revision.
> 
> Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/11] Add ISL data structures
  2011-08-12  0:02                   ` [PATCH 08/11] Add ISL data structures Sebastian Pop
@ 2011-08-12  8:42                     ` Sven Verdoolaege
  0 siblings, 0 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12  8:42 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: tobias, gcc-patches

Shouldn't you document that you need isl now?

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
  2011-08-12  2:41                     ` Jack Howarth
@ 2011-08-12  9:15                     ` Tobias Grosser
  2011-08-12  9:19                     ` Sven Verdoolaege
  2 siblings, 0 replies; 58+ messages in thread
From: Tobias Grosser @ 2011-08-12  9:15 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: skimo, gcc-patches

> diff --git a/gcc/graphite.c b/gcc/graphite.c
> index 8f6d8a1..b2cf7c6 100644
> --- a/gcc/graphite.c
> +++ b/gcc/graphite.c
> @@ -260,10 +260,12 @@ graphite_transform_loops (void)
>     bool need_cfg_cleanup_p = false;
>     VEC (scop_p, heap) *scops = NULL;
>     htab_t bb_pbb_mapping;
> +  isl_ctx *ctx;
>
>     if (!graphite_initialize ())
>       return;
>
> +  ctx = isl_ctx_alloc ();
>     build_scops (&scops);
>
>     if (dump_file&&  (dump_flags&  TDF_DETAILS))
> @@ -277,6 +279,7 @@ graphite_transform_loops (void)
>     FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
>       if (dbg_cnt (graphite_scop))
>         {
> +	scop->ctx = ctx;
>   	build_poly_scop (scop);
>
>   	if (POLY_SCOP_P (scop)
> @@ -288,6 +291,7 @@ graphite_transform_loops (void)
>     htab_delete (bb_pbb_mapping);
>     free_scops (scops);
>     graphite_finalize (need_cfg_cleanup_p);
> +  isl_ctx_free (ctx);
>   }

You should pass context to graphite_initialize() and use
CloogState *cloog_isl_state_malloc(struct isl_ctx *ctx);
to allocate the CloogState. It is defined in
cloog/isl/cloog.h

Tobi

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
  2011-08-12  2:41                     ` Jack Howarth
  2011-08-12  9:15                     ` Tobias Grosser
@ 2011-08-12  9:19                     ` Sven Verdoolaege
  2011-08-12 15:18                       ` Sebastian Pop
  2011-08-12 15:42                       ` [PATCH 1/2] use cloog_isl_state_malloc Sebastian Pop
  2 siblings, 2 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12  9:19 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: tobias, gcc-patches

On Thu, Aug 11, 2011 at 05:44:37PM -0500, Sebastian Pop wrote:
> +  ctx = isl_ctx_alloc ();

I can't find the call to cloog_isl_state_malloc in this patch
that Tobi correctly requested.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/11] Add scop->context
  2011-08-12  9:19                     ` Sven Verdoolaege
@ 2011-08-12 15:18                       ` Sebastian Pop
  2011-08-12 15:42                       ` [PATCH 1/2] use cloog_isl_state_malloc Sebastian Pop
  1 sibling, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12 15:18 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: tobias, gcc-patches

On Fri, Aug 12, 2011 at 02:22, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Thu, Aug 11, 2011 at 05:44:37PM -0500, Sebastian Pop wrote:
>> +  ctx = isl_ctx_alloc ();
>
> I can't find the call to cloog_isl_state_malloc in this patch
> that Tobi correctly requested.

Yes, sorry, I forgot about this one after I merged my patches
on top of Tobi's changes.  I will do this and document the new
ISL requrements.

Thanks.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH] add pbb->schedule
  2011-08-12  0:07                   ` [PATCH 11/11] add pdr->accesses and pdr->extent Sebastian Pop
@ 2011-08-12 15:25                     ` Sebastian Pop
  0 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12 15:25 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

---
 gcc/graphite-poly.c         |    6 ++++
 gcc/graphite-sese-to-poly.c |   54 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 1828727..2835311 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -886,6 +886,9 @@ new_poly_bb (scop_p scop, void *black_box)
 
   PBB_DOMAIN (pbb) = NULL;
   pbb->domain = NULL;
+  pbb->schedule = NULL;
+  pbb->transformed = NULL;
+  pbb->saved = NULL;
   PBB_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
   PBB_TRANSFORMED (pbb) = NULL;
@@ -911,6 +914,9 @@ free_poly_bb (poly_bb_p pbb)
     ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
 
   isl_set_free (pbb->domain);
+  isl_map_free (pbb->schedule);
+  isl_map_free (pbb->transformed);
+  isl_map_free (pbb->saved);
 
   if (PBB_TRANSFORMED (pbb))
     poly_scattering_free (PBB_TRANSFORMED (pbb));
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 28c5d98..aec637b 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -407,6 +407,16 @@ build_scop_bbs (scop_p scop)
   sbitmap_free (visited);
 }
 
+/* Return an ISL identifier for the polyhedral basic block PBB.  */
+
+static isl_id *
+isl_id_for_pbb (scop_p s, poly_bb_p pbb)
+{
+  char name[50];
+  snprintf (name, sizeof (name), "S_%d", pbb_index (pbb));
+  return isl_id_alloc (s->ctx, name, pbb);
+}
+
 /* Converts the STATIC_SCHEDULE of PBB into a scattering polyhedron.
    We generate SCATTERING_DIMENSIONS scattering dimensions.
 
@@ -441,7 +451,8 @@ build_scop_bbs (scop_p scop)
    | 0   0   1   0   0   0   0   0  -5  = 0  */
 
 static void
-build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
+build_pbb_scattering_polyhedrons (isl_aff *static_sched,
+				  ppl_Linear_Expression_t static_schedule,
 				  poly_bb_p pbb, int scattering_dimensions)
 {
   int i;
@@ -452,9 +463,11 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
   ppl_Coefficient_t c;
   ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params;
   mpz_t v;
+  isl_int val;
 
   gcc_assert (scattering_dimensions >= used_scattering_dimensions);
 
+  isl_int_init (val);
   mpz_init (v);
   ppl_new_Coefficient (&c);
   PBB_TRANSFORMED (pbb) = poly_scattering_new ();
@@ -463,6 +476,15 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
 
   PBB_NB_SCATTERING_TRANSFORM (pbb) = scattering_dimensions;
 
+  {
+    isl_dim *dc = isl_set_get_dim (scop->context);
+    isl_dim *dm = isl_dim_add (isl_dim_from_domain (dc),
+			       isl_dim_out, scattering_dimensions);
+    pbb->schedule = isl_map_universe (dm);
+    pbb->schedule = isl_map_set_tuple_id (pbb->schedule, isl_dim_out,
+					  isl_id_for_pbb (scop, pbb));
+  }
+
   for (i = 0; i < scattering_dimensions; i++)
     {
       ppl_Constraint_t cstr;
@@ -481,6 +503,20 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
 	  mpz_neg (v, v);
 	  ppl_assign_Coefficient_from_mpz_t (c, v);
 	  ppl_Linear_Expression_add_to_inhomogeneous (expr, c);
+
+	  {
+	    isl_constraint *c = isl_equality_alloc
+	      (isl_map_get_dim (pbb->schedule));
+
+	    if (0 != isl_aff_get_coefficient (static_sched, isl_dim_set,
+					      i / 2, &val))
+	      gcc_unreachable ();
+
+	    isl_int_neg (val, val);
+	    c = isl_constraint_set_constant (c, val);
+	    c = isl_constraint_set_coefficient_si (c, isl_dim_out, i, 1);
+	    pbb->schedule = isl_map_add_constraint (pbb->schedule, c);
+	  }
 	}
 
       /* Iterations of this loop.  */
@@ -492,6 +528,9 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
 	  ppl_assign_Coefficient_from_mpz_t (c, v);
 	  ppl_Linear_Expression_add_to_coefficient
 	    (expr, scattering_dimensions + loop, c);
+
+	  pbb->schedule = isl_map_equate (pbb->schedule, isl_dim_in, loop,
+					  isl_dim_out, i);
 	}
 
       ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
@@ -500,10 +539,12 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
       ppl_delete_Constraint (cstr);
     }
 
+  isl_int_clear (val);
   mpz_clear (v);
   ppl_delete_Coefficient (c);
 
   PBB_ORIGINAL (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
+  pbb->transformed = isl_map_copy (pbb->schedule);
 }
 
 /* Build for BB the static schedule.
@@ -551,6 +592,8 @@ build_scop_scattering (scop_p scop)
   ppl_Linear_Expression_t static_schedule;
   ppl_Coefficient_t c;
   mpz_t v;
+  isl_dim *dc = isl_set_get_dim (scop->context);
+  isl_aff *static_sched = isl_aff_zero (isl_local_space_from_dim (dc));
 
   mpz_init (v);
   ppl_new_Coefficient (&c);
@@ -564,6 +607,8 @@ build_scop_scattering (scop_p scop)
   ppl_assign_Coefficient_from_mpz_t (c, v);
   ppl_Linear_Expression_add_to_coefficient (static_schedule, 0, c);
 
+  static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set, 0, -1);
+
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
       gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
@@ -587,11 +632,14 @@ build_scop_scattering (scop_p scop)
       ppl_assign_Linear_Expression_from_Linear_Expression (static_schedule,
 							   common);
 
-      build_pbb_scattering_polyhedrons (common, pbb, nb_scat_dims);
-
+      static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set,
+						 prefix, 1);
+      build_pbb_scattering_polyhedrons (static_sched, common, pbb,
+					nb_scat_dims);
       ppl_delete_Linear_Expression (common);
     }
 
+  isl_aff_free (static_sched);
   mpz_clear (v);
   ppl_delete_Coefficient (c);
   ppl_delete_Linear_Expression (static_schedule);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 1/2] use cloog_isl_state_malloc
  2011-08-12  9:19                     ` Sven Verdoolaege
  2011-08-12 15:18                       ` Sebastian Pop
@ 2011-08-12 15:42                       ` Sebastian Pop
  2011-08-12 15:50                         ` [PATCH 2/2] document ISL requirement for GCC installation Sebastian Pop
  1 sibling, 1 reply; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12 15:42 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

---
 gcc/graphite.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/graphite.c b/gcc/graphite.c
index b2cf7c6..7d124c7 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/union_map.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
+#include <cloog/isl/cloog.h>
 #endif
 
 #include "system.h"
@@ -196,7 +197,7 @@ print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops)
 /* Initialize graphite: when there are no loops returns false.  */
 
 static bool
-graphite_initialize (void)
+graphite_initialize (isl_ctx *ctx)
 {
   int ppl_initialized;
 
@@ -208,6 +209,7 @@ graphite_initialize (void)
       if (dump_file && (dump_flags & TDF_DETAILS))
 	print_global_statistics (dump_file);
 
+      isl_ctx_free (ctx);
       return false;
     }
 
@@ -218,7 +220,7 @@ graphite_initialize (void)
   ppl_initialized = ppl_initialize ();
   gcc_assert (ppl_initialized == 0);
 
-  cloog_state = cloog_state_malloc ();
+  cloog_state = cloog_isl_state_malloc (ctx);
 
   if (dump_file && dump_flags)
     dump_function_to_file (current_function_decl, dump_file, dump_flags);
@@ -260,12 +262,11 @@ graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
-  isl_ctx *ctx;
+  isl_ctx *ctx = isl_ctx_alloc ();
 
-  if (!graphite_initialize ())
+  if (!graphite_initialize (ctx))
     return;
 
-  ctx = isl_ctx_alloc ();
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 15:42                       ` [PATCH 1/2] use cloog_isl_state_malloc Sebastian Pop
@ 2011-08-12 15:50                         ` Sebastian Pop
  2011-08-12 16:04                           ` Sven Verdoolaege
  2011-08-12 17:32                           ` Joseph S. Myers
  0 siblings, 2 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12 15:50 UTC (permalink / raw)
  To: skimo, tobias; +Cc: gcc-patches, Sebastian Pop

---
 gcc/doc/install.texi |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 368221f..f2b2fd9 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -368,6 +368,11 @@ It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
 The configure option @option{--with-ppl} should be used if PPL is not
 installed in your default library search path.
 
+@item Integer Set Library (ISL) version 0.08
+
+Necessary to build GCC with the Graphite loop optimizations.
+It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
+
 @item CLooG-ISL 0.16
 
 Necessary to build GCC with the Graphite loop optimizations.  It is
@@ -1620,7 +1625,8 @@ a cross compiler, they will not be used to configure target libraries.
 @itemx --with-cloog=@var{pathname}
 @itemx --with-cloog-include=@var{pathname}
 @itemx --with-cloog-lib=@var{pathname}
-If you do not have PPL (the Parma Polyhedra Library) and the CLooG
+If you do not have ISL (the Integer Set Library),
+PPL (the Parma Polyhedra Library), and the CLooG (the Chunky Loop Generator)
 libraries installed in a standard location and you want to build GCC,
 you can explicitly specify the directory where they are installed
 (@samp{--with-ppl=@/@var{pplinstalldir}},
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 15:50                         ` [PATCH 2/2] document ISL requirement for GCC installation Sebastian Pop
@ 2011-08-12 16:04                           ` Sven Verdoolaege
  2011-08-12 17:32                           ` Joseph S. Myers
  1 sibling, 0 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 16:04 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: tobias, gcc-patches

On Fri, Aug 12, 2011 at 10:16:05AM -0500, Sebastian Pop wrote:
> ---
>  gcc/doc/install.texi |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 368221f..f2b2fd9 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -368,6 +368,11 @@ It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
>  The configure option @option{--with-ppl} should be used if PPL is not
>  installed in your default library search path.
>  
> +@item Integer Set Library (ISL) version 0.08

Are you going to wait until 0.08 is available before
applying these patches?

> +Necessary to build GCC with the Graphite loop optimizations.
> +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.

Please use http://freshmeat.net/projects/isl/ instead.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 15:50                         ` [PATCH 2/2] document ISL requirement for GCC installation Sebastian Pop
  2011-08-12 16:04                           ` Sven Verdoolaege
@ 2011-08-12 17:32                           ` Joseph S. Myers
  2011-08-12 19:18                             ` Sven Verdoolaege
  1 sibling, 1 reply; 58+ messages in thread
From: Joseph S. Myers @ 2011-08-12 17:32 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: skimo, tobias, gcc-patches

On Fri, 12 Aug 2011, Sebastian Pop wrote:

> ---
>  gcc/doc/install.texi |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 368221f..f2b2fd9 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -368,6 +368,11 @@ It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
>  The configure option @option{--with-ppl} should be used if PPL is not
>  installed in your default library search path.
>  
> +@item Integer Set Library (ISL) version 0.08
> +
> +Necessary to build GCC with the Graphite loop optimizations.
> +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.

So have things changed relative to what was said in 
<http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00873.html> about ISL being 
included in CLooG-ISL?

Please propose all changes to libraries for building GCC in separate 
threads on the gcc@ list rather than just in patches on gcc-patches - the 
principle of what would be needed should be clearly understood before 
things get to the point of patch posting.  Make very clear what different 
configurations have been tested, including both static and shared 
libraries, different hosts (as many as possible among the primary and 
secondary platforms) and Canadian cross configurations, and solicit 
assistance to test other platforms as needed.  See what was done for the 
original inclusion of Graphite and the associated use of PPL.  Make clear 
whether versions of the libraries in question might affect the code 
generated, and if so then default to version checks tight enough to avoid 
such dependence.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 17:32                           ` Joseph S. Myers
@ 2011-08-12 19:18                             ` Sven Verdoolaege
  2011-08-12 19:22                               ` Jack Howarth
  2011-08-12 19:27                               ` Joseph S. Myers
  0 siblings, 2 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 19:18 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 05:02:18PM +0000, Joseph S. Myers wrote:
> On Fri, 12 Aug 2011, Sebastian Pop wrote:
> > +@item Integer Set Library (ISL) version 0.08
> > +
> > +Necessary to build GCC with the Graphite loop optimizations.
> > +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
> 
> So have things changed relative to what was said in 
> <http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00873.html> about ISL being 
> included in CLooG-ISL?

isl is still included in CLooG, but Sebastian now wants to use isl
itself in graphite.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:18                             ` Sven Verdoolaege
@ 2011-08-12 19:22                               ` Jack Howarth
  2011-08-12 19:54                                 ` Sebastian Pop
  2011-08-12 19:27                               ` Joseph S. Myers
  1 sibling, 1 reply; 58+ messages in thread
From: Jack Howarth @ 2011-08-12 19:22 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Joseph S. Myers, Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 07:35:24PM +0200, Sven Verdoolaege wrote:
> On Fri, Aug 12, 2011 at 05:02:18PM +0000, Joseph S. Myers wrote:
> > On Fri, 12 Aug 2011, Sebastian Pop wrote:
> > > +@item Integer Set Library (ISL) version 0.08
> > > +
> > > +Necessary to build GCC with the Graphite loop optimizations.
> > > +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
> > 
> > So have things changed relative to what was said in 
> > <http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00873.html> about ISL being 
> > included in CLooG-ISL?
> 
> isl is still included in CLooG, but Sebastian now wants to use isl
> itself in graphite.
> 
> skimo

   Will graphite be totally converted to isl such that ppl can be deprecated
in time for the gcc 4.7 release?
                  Jack

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:18                             ` Sven Verdoolaege
  2011-08-12 19:22                               ` Jack Howarth
@ 2011-08-12 19:27                               ` Joseph S. Myers
  2011-08-12 19:29                                 ` Sven Verdoolaege
  1 sibling, 1 reply; 58+ messages in thread
From: Joseph S. Myers @ 2011-08-12 19:27 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, 12 Aug 2011, Sven Verdoolaege wrote:

> On Fri, Aug 12, 2011 at 05:02:18PM +0000, Joseph S. Myers wrote:
> > On Fri, 12 Aug 2011, Sebastian Pop wrote:
> > > +@item Integer Set Library (ISL) version 0.08
> > > +
> > > +Necessary to build GCC with the Graphite loop optimizations.
> > > +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
> > 
> > So have things changed relative to what was said in 
> > <http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00873.html> about ISL being 
> > included in CLooG-ISL?
> 
> isl is still included in CLooG, but Sebastian now wants to use isl
> itself in graphite.

I don't see why that should make any difference to the build requirements.  
If CLooG-ISL builds and installs a library libisl.a as well as 
libcloog-isl.a (as config/cloog.m4 thinks it does at present), why should 
someone need to download and install a separate ISL package rather than 
getting libisl.a from CLooG-ISL?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:27                               ` Joseph S. Myers
@ 2011-08-12 19:29                                 ` Sven Verdoolaege
  2011-08-12 19:30                                   ` Joseph S. Myers
  0 siblings, 1 reply; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 19:29 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 06:56:38PM +0000, Joseph S. Myers wrote:
> I don't see why that should make any difference to the build requirements.  
> If CLooG-ISL builds and installs a library libisl.a as well as 
> libcloog-isl.a (as config/cloog.m4 thinks it does at present), why should 
> someone need to download and install a separate ISL package rather than 
> getting libisl.a from CLooG-ISL?

The one that comes with CLooG may not be recent enough.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:29                                 ` Sven Verdoolaege
@ 2011-08-12 19:30                                   ` Joseph S. Myers
  2011-08-12 19:40                                     ` Sven Verdoolaege
  0 siblings, 1 reply; 58+ messages in thread
From: Joseph S. Myers @ 2011-08-12 19:30 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, 12 Aug 2011, Sven Verdoolaege wrote:

> On Fri, Aug 12, 2011 at 06:56:38PM +0000, Joseph S. Myers wrote:
> > I don't see why that should make any difference to the build requirements.  
> > If CLooG-ISL builds and installs a library libisl.a as well as 
> > libcloog-isl.a (as config/cloog.m4 thinks it does at present), why should 
> > someone need to download and install a separate ISL package rather than 
> > getting libisl.a from CLooG-ISL?
> 
> The one that comes with CLooG may not be recent enough.

Do you mean there is not only a requirement to build both libraries, but 
there is a requirement to build CLooG *first*, then ISL, so that ISL's 
libisl.a overwrites CLooG's rather than the other way round (supposing 
that they are installed in the same prefix)?  That's clearly not a 
sensible approach.  If you can't make the version included in CLooG the 
right one for GCC, then stop including it in CLooG altogether (like GMP 
stopped including MPFR some years ago).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:30                                   ` Joseph S. Myers
@ 2011-08-12 19:40                                     ` Sven Verdoolaege
  2011-08-12 20:29                                       ` Joseph S. Myers
  2011-08-12 21:02                                       ` Jack Howarth
  0 siblings, 2 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 19:40 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 07:16:55PM +0000, Joseph S. Myers wrote:
> Do you mean there is not only a requirement to build both libraries, but 
> there is a requirement to build CLooG *first*, then ISL, so that ISL's 
> libisl.a overwrites CLooG's rather than the other way round (supposing 
> that they are installed in the same prefix)?

No.  You build isl first and configure CLooG to use that isl.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:22                               ` Jack Howarth
@ 2011-08-12 19:54                                 ` Sebastian Pop
  0 siblings, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-12 19:54 UTC (permalink / raw)
  To: Jack Howarth, gcc; +Cc: Sven Verdoolaege, Joseph S. Myers, tobias, gcc-patches

On Fri, Aug 12, 2011 at 12:50, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> On Fri, Aug 12, 2011 at 07:35:24PM +0200, Sven Verdoolaege wrote:
>> On Fri, Aug 12, 2011 at 05:02:18PM +0000, Joseph S. Myers wrote:
>> > On Fri, 12 Aug 2011, Sebastian Pop wrote:
>> > > +@item Integer Set Library (ISL) version 0.08
>> > > +
>> > > +Necessary to build GCC with the Graphite loop optimizations.
>> > > +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
>> >
>> > So have things changed relative to what was said in
>> > <http://gcc.gnu.org/ml/gcc-patches/2010-08/msg00873.html> about ISL being
>> > included in CLooG-ISL?
>>
>> isl is still included in CLooG, but Sebastian now wants to use isl
>> itself in graphite.
>>
>> skimo
>
>   Will graphite be totally converted to isl such that ppl can be deprecated
> in time for the gcc 4.7 release?
>                  Jack

Yes, having GCC only depend on ISL and CLooG-ISL (and not depend
anymore on PPL) is our plan for 4.7.

The rationale behind this is that with PPL it would be very difficult to fix
bugs due to wrap around unsigned types, like this one:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47594
With ISL it is possible to represent the wrapping types and fix this bug.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:40                                     ` Sven Verdoolaege
@ 2011-08-12 20:29                                       ` Joseph S. Myers
  2011-08-12 21:15                                         ` Sven Verdoolaege
  2011-08-12 21:02                                       ` Jack Howarth
  1 sibling, 1 reply; 58+ messages in thread
From: Joseph S. Myers @ 2011-08-12 20:29 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, 12 Aug 2011, Sven Verdoolaege wrote:

> On Fri, Aug 12, 2011 at 07:16:55PM +0000, Joseph S. Myers wrote:
> > Do you mean there is not only a requirement to build both libraries, but 
> > there is a requirement to build CLooG *first*, then ISL, so that ISL's 
> > libisl.a overwrites CLooG's rather than the other way round (supposing 
> > that they are installed in the same prefix)?
> 
> No.  You build isl first and configure CLooG to use that isl.

Will CLooG give an error if you configure it in such a way that its isl 
would overwrite one previously installed?  If not, this seems too 
error-prone - there's no obvious way for CLooG to know whether a 
previously installed isl comes from a previous installation of CLooG 
(should be overwritten) or was installed on its own (so CLooG should be 
built to use it).

The requirements for how CLooG is configured need to be clearly documented 
in GCC's documentation.  But, first, all these proposals (starting with 
the one to use CLooG-ISL instead of CLooG-PPL) need to be raised in their 
own threads on the gcc list, making clear exactly what is proposed, how it 
has been tested on different hosts and how many versions the requirements 
are expected to be stable for - patch submission should be the very last 
stage after sufficient discussion (and notice to the many GCC builders who 
may not follow gcc-patches) on the gcc list.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 19:40                                     ` Sven Verdoolaege
  2011-08-12 20:29                                       ` Joseph S. Myers
@ 2011-08-12 21:02                                       ` Jack Howarth
  2011-08-12 21:35                                         ` Sven Verdoolaege
  1 sibling, 1 reply; 58+ messages in thread
From: Jack Howarth @ 2011-08-12 21:02 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Joseph S. Myers, Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 09:22:04PM +0200, Sven Verdoolaege wrote:
> On Fri, Aug 12, 2011 at 07:16:55PM +0000, Joseph S. Myers wrote:
> > Do you mean there is not only a requirement to build both libraries, but 
> > there is a requirement to build CLooG *first*, then ISL, so that ISL's 
> > libisl.a overwrites CLooG's rather than the other way round (supposing 
> > that they are installed in the same prefix)?
> 
> No.  You build isl first and configure CLooG to use that isl.
> 
> skimo

Skimo,
   Currently we don't have any checks for the minimal isl version required.
Since the proposed patches only include a requirement for cloog 0.16.3, this
clearly is insufficent to force the use of the correct isl version. Will isl
continue to be bundled with cloog such that the required version of both isl
and cloog will be determined from the cloog version numbering?
         Jack

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 20:29                                       ` Joseph S. Myers
@ 2011-08-12 21:15                                         ` Sven Verdoolaege
  2011-08-13 20:12                                           ` Joseph S. Myers
  0 siblings, 1 reply; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 21:15 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 07:28:52PM +0000, Joseph S. Myers wrote:
> On Fri, 12 Aug 2011, Sven Verdoolaege wrote:
> 
> > On Fri, Aug 12, 2011 at 07:16:55PM +0000, Joseph S. Myers wrote:
> > > Do you mean there is not only a requirement to build both libraries, but 
> > > there is a requirement to build CLooG *first*, then ISL, so that ISL's 
> > > libisl.a overwrites CLooG's rather than the other way round (supposing 
> > > that they are installed in the same prefix)?
> > 
> > No.  You build isl first and configure CLooG to use that isl.
> 
> Will CLooG give an error if you configure it in such a way that its isl 
> would overwrite one previously installed?  If not, this seems too 
> error-prone - there's no obvious way for CLooG to know whether a 
> previously installed isl comes from a previous installation of CLooG 
> (should be overwritten) or was installed on its own (so CLooG should be 
> built to use it).

If CLooG is told to use a previously built isl, it won't even compile
the bundled isl.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 21:02                                       ` Jack Howarth
@ 2011-08-12 21:35                                         ` Sven Verdoolaege
  0 siblings, 0 replies; 58+ messages in thread
From: Sven Verdoolaege @ 2011-08-12 21:35 UTC (permalink / raw)
  To: Jack Howarth; +Cc: Joseph S. Myers, Sebastian Pop, tobias, gcc-patches

On Fri, Aug 12, 2011 at 03:30:25PM -0400, Jack Howarth wrote:
> Skimo,
>    Currently we don't have any checks for the minimal isl version required.

I assume they will be added at some point.
AFAIU, Sebastian just started working on this.
It will take some time for him to finish the transition.

Anyway, I'm not involved in graphite development.
I was just asked to review some patches on their use of isl.

skimo

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-12 21:15                                         ` Sven Verdoolaege
@ 2011-08-13 20:12                                           ` Joseph S. Myers
  2011-08-14  2:27                                             ` Sebastian Pop
  0 siblings, 1 reply; 58+ messages in thread
From: Joseph S. Myers @ 2011-08-13 20:12 UTC (permalink / raw)
  To: Sven Verdoolaege; +Cc: Sebastian Pop, tobias, gcc-patches

On Fri, 12 Aug 2011, Sven Verdoolaege wrote:

> On Fri, Aug 12, 2011 at 07:28:52PM +0000, Joseph S. Myers wrote:
> > On Fri, 12 Aug 2011, Sven Verdoolaege wrote:
> > 
> > > On Fri, Aug 12, 2011 at 07:16:55PM +0000, Joseph S. Myers wrote:
> > > > Do you mean there is not only a requirement to build both libraries, but 
> > > > there is a requirement to build CLooG *first*, then ISL, so that ISL's 
> > > > libisl.a overwrites CLooG's rather than the other way round (supposing 
> > > > that they are installed in the same prefix)?
> > > 
> > > No.  You build isl first and configure CLooG to use that isl.
> > 
> > Will CLooG give an error if you configure it in such a way that its isl 
> > would overwrite one previously installed?  If not, this seems too 
> > error-prone - there's no obvious way for CLooG to know whether a 
> > previously installed isl comes from a previous installation of CLooG 
> > (should be overwritten) or was installed on its own (so CLooG should be 
> > built to use it).
> 
> If CLooG is told to use a previously built isl, it won't even compile
> the bundled isl.

I advise either removing the option for CLooG to use bundled ISL, or 
making the bundled version the recommended version for GCC.  Having too 
many ways to configure things is bad.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-13 20:12                                           ` Joseph S. Myers
@ 2011-08-14  2:27                                             ` Sebastian Pop
  2011-08-14  8:09                                               ` Jack Howarth
  2011-08-14  8:15                                               ` Matthias Klose
  0 siblings, 2 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-14  2:27 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Sven Verdoolaege, tobias, gcc-patches

On Sat, Aug 13, 2011 at 10:32, Joseph S. Myers <joseph@codesourcery.com> wrote:
> I advise either removing the option for CLooG to use bundled ISL, or
> making the bundled version the recommended version for GCC.  Having too
> many ways to configure things is bad.

I would prefer using the ISL bundled with CLooG and not have
to provide a way to configure GCC with ISL.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-14  2:27                                             ` Sebastian Pop
@ 2011-08-14  8:09                                               ` Jack Howarth
  2011-08-14  8:15                                               ` Matthias Klose
  1 sibling, 0 replies; 58+ messages in thread
From: Jack Howarth @ 2011-08-14  8:09 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Joseph S. Myers, Sven Verdoolaege, tobias, gcc-patches

On Sat, Aug 13, 2011 at 11:02:40AM -0500, Sebastian Pop wrote:
> On Sat, Aug 13, 2011 at 10:32, Joseph S. Myers <joseph@codesourcery.com> wrote:
> > I advise either removing the option for CLooG to use bundled ISL, or
> > making the bundled version the recommended version for GCC.  Having too
> > many ways to configure things is bad.
> 
> I would prefer using the ISL bundled with CLooG and not have
> to provide a way to configure GCC with ISL.

Sebastian,
   On a related issue, only isl git...

http://repo.or.cz/w/isl.git

seems to have these newer changes. These changes need to be synchronized
with cloog.org git in order to test your proposed patches.
             Jack

> 
> Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-14  2:27                                             ` Sebastian Pop
  2011-08-14  8:09                                               ` Jack Howarth
@ 2011-08-14  8:15                                               ` Matthias Klose
  2011-08-14  8:27                                                 ` Sebastian Pop
  2011-08-14 16:23                                                 ` Richard Guenther
  1 sibling, 2 replies; 58+ messages in thread
From: Matthias Klose @ 2011-08-14  8:15 UTC (permalink / raw)
  To: Sebastian Pop; +Cc: Joseph S. Myers, Sven Verdoolaege, tobias, gcc-patches

On 08/13/2011 06:02 PM, Sebastian Pop wrote:
> On Sat, Aug 13, 2011 at 10:32, Joseph S. Myers <joseph@codesourcery.com> wrote:
>> I advise either removing the option for CLooG to use bundled ISL, or
>> making the bundled version the recommended version for GCC.  Having too
>> many ways to configure things is bad.
> 
> I would prefer using the ISL bundled with CLooG and not have
> to provide a way to configure GCC with ISL.

which would be exactly the way no distribution would use it. So please just
don't bundle ISL with CLoog.

  Matthias

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-14  8:15                                               ` Matthias Klose
@ 2011-08-14  8:27                                                 ` Sebastian Pop
  2011-08-14 16:23                                                 ` Richard Guenther
  1 sibling, 0 replies; 58+ messages in thread
From: Sebastian Pop @ 2011-08-14  8:27 UTC (permalink / raw)
  To: Matthias Klose; +Cc: Joseph S. Myers, Sven Verdoolaege, tobias, gcc-patches

On Sat, Aug 13, 2011 at 11:26, Matthias Klose <doko@debian.org> wrote:
> On 08/13/2011 06:02 PM, Sebastian Pop wrote:
>> On Sat, Aug 13, 2011 at 10:32, Joseph S. Myers <joseph@codesourcery.com> wrote:
>>> I advise either removing the option for CLooG to use bundled ISL, or
>>> making the bundled version the recommended version for GCC.  Having too
>>> many ways to configure things is bad.
>>
>> I would prefer using the ISL bundled with CLooG and not have
>> to provide a way to configure GCC with ISL.
>
> which would be exactly the way no distribution would use it. So please just
> don't bundle ISL with CLoog.

Sven also pointed out that it would be a mistake to use the ISL
bundled with CLooG.
So, I will prepare a patch for GCC to use a configure option --with-isl.

Sebastian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-14  8:15                                               ` Matthias Klose
  2011-08-14  8:27                                                 ` Sebastian Pop
@ 2011-08-14 16:23                                                 ` Richard Guenther
  2011-08-15 15:20                                                   ` Michael Matz
  1 sibling, 1 reply; 58+ messages in thread
From: Richard Guenther @ 2011-08-14 16:23 UTC (permalink / raw)
  To: Matthias Klose
  Cc: Sebastian Pop, Joseph S. Myers, Sven Verdoolaege, tobias, gcc-patches

On Sat, Aug 13, 2011 at 6:26 PM, Matthias Klose <doko@debian.org> wrote:
> On 08/13/2011 06:02 PM, Sebastian Pop wrote:
>> On Sat, Aug 13, 2011 at 10:32, Joseph S. Myers <joseph@codesourcery.com> wrote:
>>> I advise either removing the option for CLooG to use bundled ISL, or
>>> making the bundled version the recommended version for GCC.  Having too
>>> many ways to configure things is bad.
>>
>> I would prefer using the ISL bundled with CLooG and not have
>> to provide a way to configure GCC with ISL.
>
> which would be exactly the way no distribution would use it. So please just
> don't bundle ISL with CLoog.

Well, I would simply have linked the bundled ISL statically into libcloog.

Richard.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/2] document ISL requirement for GCC installation
  2011-08-14 16:23                                                 ` Richard Guenther
@ 2011-08-15 15:20                                                   ` Michael Matz
  0 siblings, 0 replies; 58+ messages in thread
From: Michael Matz @ 2011-08-15 15:20 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Matthias Klose, Sebastian Pop, Joseph S. Myers, Sven Verdoolaege,
	tobias, gcc-patches

Hi,

On Sun, 14 Aug 2011, Richard Guenther wrote:

> > which would be exactly the way no distribution would use it. So please 
> > just don't bundle ISL with CLoog.
> 
> Well, I would simply have linked the bundled ISL statically into 
> libcloog.

Which would still require not exporting the (bundled) libisl symbols from 
libcloog.  Looking at the cloog git repo it doesn't seem that it knows 
anything about symbol versions (and it wouldn't help static libs anyway).

No, the only even barely sane way is for the cloog version GCC should use 
to not include a builtin copy of some stale version of isl at all.


Ciao,
Michael.

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2011-08-15 14:17 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-10 23:09 [graphite] Move to cloog.org interface Tobias Grosser
2011-08-11  5:44 ` Sebastian Pop
2011-08-11 18:13   ` Tobias Grosser
2011-08-11 18:24     ` Sebastian Pop
2011-08-11 18:29       ` Tobias Grosser
2011-08-11 19:02       ` Sebastian Pop
2011-08-11 20:11         ` Tobias Grosser
2011-08-11 20:56           ` Sebastian Pop
2011-08-11 22:45             ` Sven Verdoolaege
2011-08-11 22:00           ` Sven Verdoolaege
2011-08-11 20:24         ` Sven Verdoolaege
2011-08-11 20:54           ` Sebastian Pop
2011-08-11 22:06             ` Sven Verdoolaege
2011-08-11 22:45               ` Sebastian Pop
2011-08-11 22:45             ` Sebastian Pop
2011-08-11 22:45               ` Sven Verdoolaege
2011-08-11 22:45                 ` [PATCH 00/11] Partial conversion of Graphite to ISL Sebastian Pop
2011-08-11 22:45                   ` [PATCH 04/11] Document CLooG-ISL requirement for Graphite Sebastian Pop
2011-08-11 22:45                   ` [PATCH 05/11] Move to new Cloog interface Sebastian Pop
2011-08-11 22:45                   ` [PATCH 10/11] add pbb->domain Sebastian Pop
2011-08-11 22:45                   ` [PATCH 06/11] Remove ATTRIBUTE_UNUSED Sebastian Pop
2011-08-11 22:45                   ` [PATCH 02/11] Require cloog 0.16.3 Sebastian Pop
2011-08-11 22:45                   ` [PATCH 03/11] Remove code that supported legacy CLooG Sebastian Pop
2011-08-11 23:18                   ` [PATCH 09/11] Add scop->context Sebastian Pop
2011-08-12  2:41                     ` Jack Howarth
2011-08-12  7:21                       ` Sebastian Pop
2011-08-12  7:22                         ` Jack Howarth
2011-08-12  9:15                     ` Tobias Grosser
2011-08-12  9:19                     ` Sven Verdoolaege
2011-08-12 15:18                       ` Sebastian Pop
2011-08-12 15:42                       ` [PATCH 1/2] use cloog_isl_state_malloc Sebastian Pop
2011-08-12 15:50                         ` [PATCH 2/2] document ISL requirement for GCC installation Sebastian Pop
2011-08-12 16:04                           ` Sven Verdoolaege
2011-08-12 17:32                           ` Joseph S. Myers
2011-08-12 19:18                             ` Sven Verdoolaege
2011-08-12 19:22                               ` Jack Howarth
2011-08-12 19:54                                 ` Sebastian Pop
2011-08-12 19:27                               ` Joseph S. Myers
2011-08-12 19:29                                 ` Sven Verdoolaege
2011-08-12 19:30                                   ` Joseph S. Myers
2011-08-12 19:40                                     ` Sven Verdoolaege
2011-08-12 20:29                                       ` Joseph S. Myers
2011-08-12 21:15                                         ` Sven Verdoolaege
2011-08-13 20:12                                           ` Joseph S. Myers
2011-08-14  2:27                                             ` Sebastian Pop
2011-08-14  8:09                                               ` Jack Howarth
2011-08-14  8:15                                               ` Matthias Klose
2011-08-14  8:27                                                 ` Sebastian Pop
2011-08-14 16:23                                                 ` Richard Guenther
2011-08-15 15:20                                                   ` Michael Matz
2011-08-12 21:02                                       ` Jack Howarth
2011-08-12 21:35                                         ` Sven Verdoolaege
2011-08-11 23:27                   ` [PATCH 01/11] Make CLooG-ISL the only supported CLooG version Sebastian Pop
2011-08-12  0:02                   ` [PATCH 08/11] Add ISL data structures Sebastian Pop
2011-08-12  8:42                     ` Sven Verdoolaege
2011-08-12  0:07                   ` [PATCH 07/11] fix memory leak Sebastian Pop
2011-08-12  0:07                   ` [PATCH 11/11] add pdr->accesses and pdr->extent Sebastian Pop
2011-08-12 15:25                     ` [PATCH] add pbb->schedule Sebastian Pop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).