diff mbox

[cxx-conversion] graphite-related hash tables

Message ID CAGqM8fYVqTrxxURqPdTBerCt8CETm--W86nc0J18okxv8MpTWw@mail.gmail.com
State New
Headers show

Commit Message

Lawrence Crowl Dec. 2, 2012, 1:42 a.m. UTC
Change graphite-related hash tables from htab_t to hash_table:

graphite-clast-to-gimple.c ivs_params::newivs_index
graphite-clast-to-gimple.c ivs_params::params_index
graphite-clast-to-gimple.c print_generated_program::params_index
graphite-clast-to-gimple.c gloog::newivs_index
graphite-clast-to-gimple.c gloog::params_index
graphite.c graphite_transform_loops::bb_pbb_mapping
sese.c copy_bb_and_scalar_dependences::rename_map

Move hash table declarations to a new graphite-htab.h, because they
are used in few places.

Remove unused:

htab_t scop::original_pddrs
SCOP_ORIGINAL_PDDRS

Remove unused:

insert_loop_close_phis
insert_guard_phis
debug_ivtype_map
ivtype_map_elt_info
new_ivtype_map_elt


Tested on x86-64.

Okay for branch?


    sese.h graphite-poly.h

Comments

Tobias Grosser Dec. 2, 2012, 9:58 a.m. UTC | #1
On Sun, Dec 2, 2012, at 02:42 AM, Lawrence Crowl wrote:
> Change graphite-related hash tables from htab_t to hash_table:
> 
> graphite-clast-to-gimple.c ivs_params::newivs_index
> graphite-clast-to-gimple.c ivs_params::params_index
> graphite-clast-to-gimple.c print_generated_program::params_index
> graphite-clast-to-gimple.c gloog::newivs_index
> graphite-clast-to-gimple.c gloog::params_index
> graphite.c graphite_transform_loops::bb_pbb_mapping
> sese.c copy_bb_and_scalar_dependences::rename_map
> 
> Move hash table declarations to a new graphite-htab.h, because they
> are used in few places.
> 
> Remove unused:
> 
> htab_t scop::original_pddrs
> SCOP_ORIGINAL_PDDRS
> 
> Remove unused:
> 
> insert_loop_close_phis
> insert_guard_phis
> debug_ivtype_map
> ivtype_map_elt_info
> new_ivtype_map_elt
> 
> 
> Tested on x86-64.
> 
> Okay for branch?

Hi Lawrance,

from the point of graphite, the update looks very good. Thanks  lot for
getting the new hash table implementation in.
Also, thanks for the dead code removal.

Assuming the test suite passes and this is just a no-behavior change
intended commit, I am fine with this. No idea, who needs to sign off
branch commits, though.

Cheers
Tobi
Diego Novillo Dec. 3, 2012, 1:45 p.m. UTC | #2
On Sun, Dec 2, 2012 at 4:58 AM, Tobias Grosser <tobias@grosser.es> wrote:

> Assuming the test suite passes and this is just a no-behavior change
> intended commit, I am fine with this. No idea, who needs to sign off
> branch commits, though.

The branch is under the usual maintainer rules (it's a regular
development branch).  If you think the patch is OK, then it certainly
is.


Diego.
diff mbox

Patch

Index: gcc/ChangeLog

2012-11-30  Lawrence Crowl  <crowl@google.com>

	* graphite-htab.h: New.
	(typedef hash_table <bb_pbb_hasher> bb_pbb_htab_type): New.
	(extern find_pbb_via_hash): Move from graphite-poly.h.
	(extern loop_is_parallel_p): Move from graphite-poly.h.
	(extern get_loop_body_pbbs): Move from graphite-poly.h.

	* graphite-clast-to-gimple.h: (extern gloog) Move to graphite-htab.h.
	(bb_pbb_map_hash): Fold into bb_pbb_htab_type in graphite-htab.h.
	(eq_bb_pbb_map): Fold into bb_pbb_htab_type in graphite-htab.h.

	* graphite-clast-to-gimple.c: Include graphite-htab.h.
	(htab_t ivs_params::newivs_index):
	Change type to hash_table.  Update dependent calls and types.
	(htab_t ivs_params::params_index): Likewise.
	(htab_t print_generated_program::params_index): Likewise.
	(htab_t gloog::newivs_index): Likewise.
	(htab_t gloog::params_index): Likewise.

	* graphite-dependences.c: Include graphite-htab.h.
	(loop_is_parallel_p): Change hash table type of parameter.

	* graphite-poly.h (htab_t scop::original_pddrs): Remove unused.
	(SCOP_ORIGINAL_PDDRS): Remove unused.
	(extern find_pbb_via_hash): Move to graphite-htab.h.
	(extern loop_is_parallel_p): Move to graphite-htab.h.
	(extern get_loop_body_pbbs): Move to graphite-htab.h.

	* graphite.c: Include graphite-htab.h.
	(htab_t graphite_transform_loops::bb_pbb_mapping):
	Change type to hash_table.  Update dependent calls and types.

	* sese.h (extern insert_loop_close_phis): Remove unused.
	(extern insert_guard_phis): Remove unused.
	(extern debug_ivtype_map): Remove unused.
	(extern ivtype_map_elt_info): Remove unused.
	(inline new_ivtype_map_elt): Remove unused.
	(extern debug_rename_map): Move to .c file.

	* sese.c (debug_rename_map_1): Make extern.
	(debug_ivtype_elt): Remove unused.
	(debug_ivtype_map_1): Remove unused.
	(debug_ivtype_map): Remove unused.
	(ivtype_map_elt_info): Remove unused.
	(eq_ivtype_map_elts): Remove unused.
	(htab_t copy_bb_and_scalar_dependences::rename_map):
	Change type to hash_table.  Update dependent calls and types.

	* Makefile.in: Update to changes above.

Index: gcc/graphite-htab.h
===================================================================
--- gcc/graphite-htab.h	(revision 0)
+++ gcc/graphite-htab.h	(revision 0)
@@ -0,0 +1,60 @@ 
+/* Translation of CLAST (CLooG AST) to Gimple.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Sebastian Pop <sebastian.pop@amd.com>.
+
+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 GCC_GRAPHITE_HTAB_H
+#define GCC_GRAPHITE_HTAB_H
+
+#include "hash-table.h"
+#include "graphite-clast-to-gimple.h"
+
+/* Hashtable helpers.  */
+
+struct bb_pbb_hasher : typed_free_remove <bb_pbb_def>
+{
+  typedef bb_pbb_def value_type;
+  typedef bb_pbb_def compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};
+
+/* Hash function for data base element BB_PBB.  */
+
+inline hashval_t
+bb_pbb_hasher::hash (const value_type *bb_pbb)
+{
+  return (hashval_t)(bb_pbb->bb->index);
+}
+
+/* Compare data base element PB1 and PB2.  */
+
+inline bool
+bb_pbb_hasher::equal (const value_type *bp1, const compare_type *bp2)
+{
+  return (bp1->bb->index == bp2->bb->index);
+}
+
+typedef hash_table <bb_pbb_hasher> bb_pbb_htab_type;
+
+extern bool gloog (scop_p, bb_pbb_htab_type);
+poly_bb_p find_pbb_via_hash (bb_pbb_htab_type, basic_block);
+bool loop_is_parallel_p (loop_p, bb_pbb_htab_type, int);
+scop_p get_loop_body_pbbs (loop_p, bb_pbb_htab_type, VEC (poly_bb_p, heap) **);
+
+#endif
Index: gcc/graphite.c
===================================================================
--- gcc/graphite.c	(revision 193902)
+++ gcc/graphite.c	(working copy)
@@ -63,6 +63,7 @@  along with GCC; see the file COPYING3.
 #include "graphite-scop-detection.h"
 #include "graphite-clast-to-gimple.h"
 #include "graphite-sese-to-poly.h"
+#include "graphite-htab.h"

 CloogState *cloog_state;

@@ -256,7 +257,7 @@  graphite_transform_loops (void)
   scop_p scop;
   bool need_cfg_cleanup_p = false;
   vec<scop_p> scops = vNULL;
-  htab_t bb_pbb_mapping;
+  bb_pbb_htab_type bb_pbb_mapping;
   isl_ctx *ctx;

   /* If a function is parallel it was most probably already run
through graphite
@@ -278,7 +279,7 @@  graphite_transform_loops (void)
       print_global_statistics (dump_file);
     }

-  bb_pbb_mapping = htab_create (10, bb_pbb_map_hash, eq_bb_pbb_map, free);
+  bb_pbb_mapping.create (10);

   FOR_EACH_VEC_ELT (scops, i, scop)
     if (dbg_cnt (graphite_scop))
@@ -292,7 +293,7 @@  graphite_transform_loops (void)
 	  need_cfg_cleanup_p = true;
       }

-  htab_delete (bb_pbb_mapping);
+  bb_pbb_mapping.dispose ();
   free_scops (scops);
   graphite_finalize (need_cfg_cleanup_p);
   the_isl_ctx = NULL;
Index: gcc/sese.c
===================================================================
--- gcc/sese.c	(revision 193902)
+++ gcc/sese.c	(working copy)
@@ -23,6 +23,7 @@  along with GCC; see the file COPYING3.
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "hash-table.h"
 #include "tree-pretty-print.h"
 #include "tree-flow.h"
 #include "cfgloop.h"
@@ -47,90 +48,51 @@  debug_rename_elt (rename_map_elt elt)

 /* Helper function for debug_rename_map.  */

-static int
-debug_rename_map_1 (void **slot, void *s ATTRIBUTE_UNUSED)
+int
+debug_rename_map_1 (rename_map_elt_s **slot, void *s ATTRIBUTE_UNUSED)
 {
-  struct rename_map_elt_s *entry = (struct rename_map_elt_s *) *slot;
+  struct rename_map_elt_s *entry = *slot;
   debug_rename_elt (entry);
   return 1;
 }
+

-/* Print to stderr all the elements of RENAME_MAP.  */
+/* Hashtable helpers.  */

-DEBUG_FUNCTION void
-debug_rename_map (htab_t rename_map)
+struct rename_map_hasher : typed_free_remove <rename_map_elt_s>
 {
-  htab_traverse (rename_map, debug_rename_map_1, NULL);
-}
+  typedef rename_map_elt_s value_type;
+  typedef rename_map_elt_s compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};

 /* Computes a hash function for database element ELT.  */

-hashval_t
-rename_map_elt_info (const void *elt)
+inline hashval_t
+rename_map_hasher::hash (const value_type *elt)
 {
-  return SSA_NAME_VERSION (((const struct rename_map_elt_s *) elt)->old_name);
+  return SSA_NAME_VERSION (elt->old_name);
 }

 /* Compares database elements E1 and E2.  */

-int
-eq_rename_map_elts (const void *e1, const void *e2)
+inline bool
+rename_map_hasher::equal (const value_type *elt1, const compare_type *elt2)
 {
-  const struct rename_map_elt_s *elt1 = (const struct rename_map_elt_s *) e1;
-  const struct rename_map_elt_s *elt2 = (const struct rename_map_elt_s *) e2;
-
   return (elt1->old_name == elt2->old_name);
 }

+typedef hash_table <rename_map_hasher> rename_map_type;
 

-/* Print to stderr the element ELT.  */
-
-static void
-debug_ivtype_elt (ivtype_map_elt elt)
-{
-  fprintf (stderr, "(%s, ", elt->cloog_iv);
-  print_generic_expr (stderr, elt->type, 0);
-  fprintf (stderr, ")\n");
-}
-
-/* Helper function for debug_ivtype_map.  */
-
-static int
-debug_ivtype_map_1 (void **slot, void *s ATTRIBUTE_UNUSED)
-{
-  struct ivtype_map_elt_s *entry = (struct ivtype_map_elt_s *) *slot;
-  debug_ivtype_elt (entry);
-  return 1;
-}
-
-/* Print to stderr all the elements of MAP.  */
+/* Print to stderr all the elements of RENAME_MAP.  */

 DEBUG_FUNCTION void
-debug_ivtype_map (htab_t map)
-{
-  htab_traverse (map, debug_ivtype_map_1, NULL);
-}
-
-/* Computes a hash function for database element ELT.  */
-
-hashval_t
-ivtype_map_elt_info (const void *elt)
-{
-  return htab_hash_pointer (((const struct ivtype_map_elt_s *) elt)->cloog_iv);
-}
-
-/* Compares database elements E1 and E2.  */
-
-int
-eq_ivtype_map_elts (const void *e1, const void *e2)
+debug_rename_map (rename_map_type rename_map)
 {
-  const struct ivtype_map_elt_s *elt1 = (const struct ivtype_map_elt_s *) e1;
-  const struct ivtype_map_elt_s *elt2 = (const struct ivtype_map_elt_s *) e2;
-
-  return (elt1->cloog_iv == elt2->cloog_iv);
+  rename_map.traverse <void *, debug_rename_map_1> (NULL);
 }
-
 

 /* Record LOOP as occurring in REGION.  */
@@ -415,17 +377,17 @@  get_false_edge_from_guard_bb (basic_bloc
 /* Returns the expression associated to OLD_NAME in RENAME_MAP.  */

 static tree
-get_rename (htab_t rename_map, tree old_name)
+get_rename (rename_map_type rename_map, tree old_name)
 {
   struct rename_map_elt_s tmp;
-  PTR *slot;
+  rename_map_elt_s **slot;

   gcc_assert (TREE_CODE (old_name) == SSA_NAME);
   tmp.old_name = old_name;
-  slot = htab_find_slot (rename_map, &tmp, NO_INSERT);
+  slot = rename_map.find_slot (&tmp, NO_INSERT);

   if (slot && *slot)
-    return ((rename_map_elt) *slot)->expr;
+    return (*slot)->expr;

   return NULL_TREE;
 }
@@ -433,16 +395,16 @@  get_rename (htab_t rename_map, tree old_
 /* Register in RENAME_MAP the rename tuple (OLD_NAME, EXPR).  */

 static void
-set_rename (htab_t rename_map, tree old_name, tree expr)
+set_rename (rename_map_type rename_map, tree old_name, tree expr)
 {
   struct rename_map_elt_s tmp;
-  PTR *slot;
+  rename_map_elt_s **slot;

   if (old_name == expr)
     return;

   tmp.old_name = old_name;
-  slot = htab_find_slot (rename_map, &tmp, INSERT);
+  slot = rename_map.find_slot (&tmp, INSERT);

   if (!slot)
     return;
@@ -460,7 +422,8 @@  set_rename (htab_t rename_map, tree old_
    is set when the code generation cannot continue.  */

 static bool
-rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
+rename_uses (gimple copy, rename_map_type rename_map,
+	     gimple_stmt_iterator *gsi_tgt,
 	     sese region, loop_p loop, vec<tree> iv_map,
 	     bool *gloog_error)
 {
@@ -566,7 +529,7 @@  rename_uses (gimple copy, htab_t rename_

 static void
 graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
-				htab_t rename_map,
+				rename_map_type rename_map,
 				vec<tree> iv_map, sese region,
 				bool *gloog_error)
 {
@@ -634,14 +597,14 @@  copy_bb_and_scalar_dependences (basic_bl
 				bool *gloog_error)
 {
   basic_block new_bb = split_edge (next_e);
-  htab_t rename_map = htab_create (10, rename_map_elt_info,
-				   eq_rename_map_elts, free);
+  rename_map_type rename_map;
+  rename_map.create (10);

   next_e = single_succ_edge (new_bb);
   graphite_copy_stmts_from_block (bb, new_bb, rename_map, iv_map, region,
 				  gloog_error);
   remove_phi_nodes (new_bb);
-  htab_delete (rename_map);
+  rename_map.dispose ();

   return next_e;
 }
Index: gcc/sese.h
===================================================================
--- gcc/sese.h	(revision 193902)
+++ gcc/sese.h	(working copy)
@@ -59,8 +59,6 @@  extern void build_sese_loop_nests (sese)
 extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge,
 					    vec<tree> , bool *);
 extern struct loop *outermost_loop_in_sese (sese, basic_block);
-extern void insert_loop_close_phis (htab_t, loop_p);
-extern void insert_guard_phis (basic_block, edge, edge, htab_t, htab_t);
 extern tree scalar_evolution_in_region (sese, loop_p, tree);

 /* Check that SESE contains LOOP.  */
@@ -260,7 +258,6 @@  typedef struct rename_map_elt_s
 } *rename_map_elt;


-extern void debug_rename_map (htab_t);
 extern hashval_t rename_map_elt_info (const void *);
 extern int eq_rename_map_elts (const void *, const void *);

@@ -286,24 +283,6 @@  typedef struct ivtype_map_elt_s
   const char *cloog_iv;
 } *ivtype_map_elt;

-extern void debug_ivtype_map (htab_t);
-extern hashval_t ivtype_map_elt_info (const void *);
-extern int eq_ivtype_map_elts (const void *, const void *);
-
-/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW.  */
-
-static inline ivtype_map_elt
-new_ivtype_map_elt (const char *cloog_iv, tree type)
-{
-  ivtype_map_elt res;
-
-  res = XNEW (struct ivtype_map_elt_s);
-  res->cloog_iv = cloog_iv;
-  res->type = type;
-
-  return res;
-}
-
 /* Free and compute again all the dominators information.  */

 static inline void
Index: gcc/graphite-clast-to-gimple.c
===================================================================
--- gcc/graphite-clast-to-gimple.c	(revision 193902)
+++ gcc/graphite-clast-to-gimple.c	(working copy)
@@ -47,6 +47,7 @@  along with GCC; see the file COPYING3.
 #include "cloog/cloog.h"
 #include "graphite-poly.h"
 #include "graphite-clast-to-gimple.h"
+#include "graphite-htab.h"

 typedef const struct clast_expr *clast_name_p;

@@ -124,6 +125,55 @@  typedef struct clast_name_index {
   char *free_name;
 } *clast_name_index_p;

+/* Helper for hashing clast_name_index.  */
+
+struct clast_index_hasher
+{
+  typedef clast_name_index value_type;
+  typedef clast_name_index compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+  static inline void remove (value_type *);
+};
+
+/* Computes a hash function for database element E.  */
+
+inline hashval_t
+clast_index_hasher::hash (const value_type *e)
+{
+  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 ELT1 and ELT2.  */
+
+inline bool
+clast_index_hasher::equal (const value_type *elt1, const compare_type *elt2)
+{
+  return strcmp (elt1->name, elt2->name) == 0;
+}
+
+/* Free the memory taken by a clast_name_index struct.  */
+
+inline void
+clast_index_hasher::remove (value_type *c)
+{
+  if (c->free_name)
+    free (c->free_name);
+  mpz_clear (c->bound_one);
+  mpz_clear (c->bound_two);
+  free (c);
+}
+
+typedef hash_table <clast_index_hasher> clast_index_htab_type;
+
 /* Returns a pointer to a new element of type clast_name_index_p built
    from NAME, INDEX, LEVEL, BOUND_ONE, and BOUND_TWO.  */

@@ -146,35 +196,22 @@  new_clast_name_index (const char *name,
   return res;
 }

-/* Free the memory taken by a clast_name_index struct.  */
-
-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);
-}
-
 /* For a given clast NAME, returns -1 if NAME is not in the
    INDEX_TABLE, otherwise returns the loop level for the induction
    variable NAME, or if it is a parameter, the parameter number in the
    vector of parameters.  */

 static inline int
-clast_name_to_level (clast_name_p name, htab_t index_table)
+clast_name_to_level (clast_name_p name, clast_index_htab_type index_table)
 {
   struct clast_name_index tmp;
-  PTR *slot;
+  clast_name_index **slot;

   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);
+  slot = index_table.find_slot (&tmp, NO_INSERT);

   if (slot && *slot)
     return ((struct clast_name_index *) *slot)->level;
@@ -187,18 +224,18 @@  clast_name_to_level (clast_name_p name,
    SCATTERING_DIMENSIONS vector.  */

 static inline int
-clast_name_to_index (struct clast_name *name, htab_t index_table)
+clast_name_to_index (struct clast_name *name, clast_index_htab_type
index_table)
 {
   struct clast_name_index tmp;
-  PTR *slot;
+  clast_name_index **slot;

   tmp.name = ((const struct clast_name *) name)->name;
   tmp.free_name = NULL;

-  slot = htab_find_slot (index_table, &tmp, NO_INSERT);
+  slot = index_table.find_slot (&tmp, NO_INSERT);

   if (slot && *slot)
-    return ((struct clast_name_index *) *slot)->index;
+    return (*slot)->index;

   return -1;
 }
@@ -208,16 +245,16 @@  clast_name_to_index (struct clast_name *
    found in the INDEX_TABLE, false otherwise.  */

 static inline bool
-clast_name_to_lb_ub (struct clast_name *name, htab_t index_table,
+clast_name_to_lb_ub (struct clast_name *name, clast_index_htab_type
index_table,
 		     mpz_t bound_one, mpz_t bound_two)
 {
   struct clast_name_index tmp;
-  PTR *slot;
+  clast_name_index **slot;

   tmp.name = name->name;
   tmp.free_name = NULL;

-  slot = htab_find_slot (index_table, &tmp, NO_INSERT);
+  slot = index_table.find_slot (&tmp, NO_INSERT);

   if (slot && *slot)
     {
@@ -232,15 +269,15 @@  clast_name_to_lb_ub (struct clast_name *
 /* Records in INDEX_TABLE the INDEX and LEVEL for NAME.  */

 static inline void
-save_clast_name_index (htab_t index_table, const char *name,
+save_clast_name_index (clast_index_htab_type index_table, const char *name,
 		       int index, int level, mpz_t bound_one, mpz_t bound_two)
 {
   struct clast_name_index tmp;
-  PTR *slot;
+  clast_name_index **slot;

   tmp.name = name;
   tmp.free_name = NULL;
-  slot = htab_find_slot (index_table, &tmp, INSERT);
+  slot = index_table.find_slot (&tmp, INSERT);

   if (slot)
     {
@@ -249,35 +286,6 @@  save_clast_name_index (htab_t index_tabl
       *slot = new_clast_name_index (name, index, level, bound_one, bound_two);
     }
 }
-
-/* Computes a hash function for database element ELT.  */
-
-static inline hashval_t
-clast_name_index_elt_info (const void *elt)
-{
-  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.  */
-
-static inline int
-eq_clast_name_indexes (const void *e1, const void *e2)
-{
-  const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
-  const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
-
-  return strcmp (elt1->name, elt2->name) == 0;
-}
-
 

 /* NEWIVS_INDEX binds CLooG's scattering name to the index of the tree
@@ -288,7 +296,7 @@  eq_clast_name_indexes (const void *e1, c

 typedef struct ivs_params {
   vec<tree> params, *newivs;
-  htab_t newivs_index, params_index;
+  clast_index_htab_type newivs_index, params_index;
   sese region;
 } *ivs_params_p;

@@ -300,7 +308,7 @@  clast_name_to_gcc (struct clast_name *na
 {
   int index;

-  if (ip->params.exists () && ip->params_index)
+  if (ip->params.exists () && ip->params_index.is_created ())
     {
       index = clast_name_to_index (name, ip->params_index);

@@ -308,7 +316,7 @@  clast_name_to_gcc (struct clast_name *na
 	return ip->params[index];
     }

-  gcc_assert (ip->newivs && ip->newivs_index);
+  gcc_assert (ip->newivs && ip->newivs_index.is_created ());
   index = clast_name_to_index (name, ip->newivs_index);
   gcc_assert (index >= 0);

@@ -699,12 +707,12 @@  type_for_clast_name (struct clast_name *
 {
   bool found = false;

-  if (ip->params.exists () && ip->params_index)
+  if (ip->params.exists () && ip->params_index.is_created ())
     found = clast_name_to_lb_ub (name, ip->params_index, bound_one, bound_two);

   if (!found)
     {
-      gcc_assert (ip->newivs && ip->newivs_index);
+      gcc_assert (ip->newivs && ip->newivs_index.is_created ());
       found = clast_name_to_lb_ub (name, ip->newivs_index, bound_one,
 				   bound_two);
       gcc_assert (found);
@@ -1009,13 +1017,14 @@  new_bb_pbb_def (basic_block bb, poly_bb_
 /* Mark BB with it's relevant PBB via hashing table BB_PBB_MAPPING.  */

 static void
-mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, htab_t bb_pbb_mapping)
+mark_bb_with_pbb (poly_bb_p pbb, basic_block bb,
+		  bb_pbb_htab_type bb_pbb_mapping)
 {
   bb_pbb_def tmp;
-  PTR *x;
+  bb_pbb_def **x;

   tmp.bb = bb;
-  x = htab_find_slot (bb_pbb_mapping, &tmp, INSERT);
+  x = bb_pbb_mapping.find_slot (&tmp, INSERT);

   if (x && !*x)
     *x = new_bb_pbb_def (bb, pbb);
@@ -1024,13 +1033,13 @@  mark_bb_with_pbb (poly_bb_p pbb, basic_b
 /* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING.  */

 poly_bb_p
-find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
+find_pbb_via_hash (bb_pbb_htab_type bb_pbb_mapping, basic_block bb)
 {
   bb_pbb_def tmp;
-  PTR *slot;
+  bb_pbb_def **slot;

   tmp.bb = bb;
-  slot = htab_find_slot (bb_pbb_mapping, &tmp, NO_INSERT);
+  slot = bb_pbb_mapping.find_slot (&tmp, NO_INSERT);

   if (slot && *slot)
     return ((bb_pbb_def *) *slot)->pbb;
@@ -1044,7 +1053,7 @@  find_pbb_via_hash (htab_t bb_pbb_mapping
    related poly_bb_p.  */

 scop_p
-get_loop_body_pbbs (loop_p loop, htab_t bb_pbb_mapping,
+get_loop_body_pbbs (loop_p loop, bb_pbb_htab_type bb_pbb_mapping,
 		    vec<poly_bb_p> *pbbs)
 {
   unsigned i;
@@ -1074,7 +1083,7 @@  get_loop_body_pbbs (loop_p loop, htab_t

 static edge
 translate_clast_user (struct clast_user_stmt *stmt, edge next_e,
-		      htab_t bb_pbb_mapping, ivs_params_p ip)
+		      bb_pbb_htab_type bb_pbb_mapping, ivs_params_p ip)
 {
   int i, nb_loops;
   basic_block new_bb;
@@ -1143,7 +1152,8 @@  graphite_create_new_loop_guard (edge ent
 }

 static edge
-translate_clast (loop_p, struct clast_stmt *, edge, htab_t, int, ivs_params_p);
+translate_clast (loop_p, struct clast_stmt *, edge, bb_pbb_htab_type,
+		 int, ivs_params_p);

 /* Create the loop for a clast for statement.

@@ -1152,8 +1162,9 @@  translate_clast (loop_p, struct clast_st

 static edge
 translate_clast_for_loop (loop_p context_loop, struct clast_for *stmt,
-			  edge next_e, htab_t bb_pbb_mapping, int level,
-			  tree type, tree lb, tree ub, ivs_params_p ip)
+			  edge next_e, bb_pbb_htab_type bb_pbb_mapping,
+			  int level, tree type, tree lb, tree ub,
+			  ivs_params_p ip)
 {
   struct loop *loop = graphite_create_new_loop (next_e, stmt, context_loop,
 						type, lb, ub, level, ip);
@@ -1186,7 +1197,8 @@  translate_clast_for_loop (loop_p context

 static edge
 translate_clast_for (loop_p context_loop, struct clast_for *stmt, edge next_e,
-		     htab_t bb_pbb_mapping, int level, ivs_params_p ip)
+		     bb_pbb_htab_type bb_pbb_mapping, int level,
+		     ivs_params_p ip)
 {
   tree type, lb, ub;
   edge last_e = graphite_create_new_loop_guard (next_e, stmt, &type,
@@ -1244,7 +1256,7 @@  translate_clast_assignment (struct clast

 static edge
 translate_clast_guard (loop_p context_loop, struct clast_guard *stmt,
-		       edge next_e, htab_t bb_pbb_mapping, int level,
+		       edge next_e, bb_pbb_htab_type bb_pbb_mapping, int level,
 		       ivs_params_p ip)
 {
   edge last_e = graphite_create_new_guard (next_e, stmt, ip);
@@ -1263,7 +1275,7 @@  translate_clast_guard (loop_p context_lo

 static edge
 translate_clast (loop_p context_loop, struct clast_stmt *stmt, edge next_e,
-		 htab_t bb_pbb_mapping, int level, ivs_params_p ip)
+		 bb_pbb_htab_type bb_pbb_mapping, int level, ivs_params_p ip)
 {
   if (!stmt)
     return next_e;
@@ -1304,7 +1316,8 @@  translate_clast (loop_p context_loop, st

 static CloogUnionDomain *
 add_names_to_union_domain (scop_p scop, CloogUnionDomain *union_domain,
-			   int nb_scattering_dims, htab_t params_index)
+			   int nb_scattering_dims,
+			   clast_index_htab_type params_index)
 {
   sese region = SCOP_REGION (scop);
   int i;
@@ -1547,7 +1560,7 @@  int get_max_scattering_dimensions (scop_
 }

 static CloogInput *
-generate_cloog_input (scop_p scop, htab_t params_index)
+generate_cloog_input (scop_p scop, clast_index_htab_type params_index)
 {
   CloogUnionDomain *union_domain;
   CloogInput *cloog_input;
@@ -1570,7 +1583,7 @@  generate_cloog_input (scop_p scop, htab_
    without a program.  */

 static struct clast_stmt *
-scop_to_clast (scop_p scop, htab_t params_index)
+scop_to_clast (scop_p scop, clast_index_htab_type params_index)
 {
   CloogInput *cloog_input;
   struct clast_stmt *clast;
@@ -1599,11 +1612,10 @@  void
 print_generated_program (FILE *file, scop_p scop)
 {
   CloogOptions *options = set_cloog_options ();
-  htab_t params_index;
+  clast_index_htab_type params_index;
   struct clast_stmt *clast;

-  params_index = htab_create (10, clast_name_index_elt_info,
-            eq_clast_name_indexes, free_clast_name_index);
+  params_index.create (10);

   clast = scop_to_clast (scop, params_index);

@@ -1629,22 +1641,21 @@  debug_generated_program (scop_p scop)
 */

 bool
-gloog (scop_p scop, htab_t bb_pbb_mapping)
+gloog (scop_p scop, bb_pbb_htab_type bb_pbb_mapping)
 {
   vec<tree> newivs;
   newivs.create (10);
   loop_p context_loop;
   sese region = SCOP_REGION (scop);
   ifsese if_region = NULL;
-  htab_t newivs_index, params_index;
+  clast_index_htab_type newivs_index, params_index;
   struct clast_stmt *clast;
   struct ivs_params ip;

   timevar_push (TV_GRAPHITE_CODE_GEN);
   gloog_error = false;

-  params_index = htab_create (10, clast_name_index_elt_info,
-			      eq_clast_name_indexes, free_clast_name_index);
+  params_index.create (10);

   clast = scop_to_clast (scop, params_index);

@@ -1667,8 +1678,7 @@  gloog (scop_p scop, htab_t bb_pbb_mappin
   graphite_verify ();

   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);
+  newivs_index.create (10);

   ip.newivs = &newivs;
   ip.newivs_index = newivs_index;
@@ -1690,8 +1700,8 @@  gloog (scop_p scop, htab_t bb_pbb_mappin
   free (if_region->region);
   free (if_region);

-  htab_delete (newivs_index);
-  htab_delete (params_index);
+  newivs_index.dispose ();
+  params_index.dispose ();
   newivs.release ();
   cloog_clast_free (clast);
   timevar_pop (TV_GRAPHITE_CODE_GEN);
Index: gcc/graphite-clast-to-gimple.h
===================================================================
--- gcc/graphite-clast-to-gimple.h	(revision 193902)
+++ gcc/graphite-clast-to-gimple.h	(working copy)
@@ -38,26 +38,7 @@  typedef struct bb_pbb_def
   poly_bb_p pbb;
 } bb_pbb_def;

-extern bool gloog (scop_p, htab_t);
 extern void debug_clast_stmt (struct clast_stmt *);
 extern void print_clast_stmt (FILE *, struct clast_stmt *);

-/* Hash function for data base element BB_PBB.  */
-
-static inline hashval_t
-bb_pbb_map_hash (const void *bb_pbb)
-{
-  return (hashval_t)(((const bb_pbb_def *)bb_pbb)->bb->index);
-}
-
-/* Compare data base element BB_PBB1 and BB_PBB2.  */
-
-static inline int
-eq_bb_pbb_map (const void *bb_pbb1, const void *bb_pbb2)
-{
-  const bb_pbb_def *bp1 = (const bb_pbb_def *) bb_pbb1;
-  const bb_pbb_def *bp2 = (const bb_pbb_def *) bb_pbb2;
-  return (bp1->bb->index == bp2->bb->index);
-}
-
 #endif
Index: gcc/graphite-dependences.c
===================================================================
--- gcc/graphite-dependences.c	(revision 193902)
+++ gcc/graphite-dependences.c	(working copy)
@@ -43,6 +43,7 @@  along with GCC; see the file COPYING3.

 #ifdef HAVE_cloog
 #include "graphite-poly.h"
+#include "graphite-htab.h"

 /* Add the constraints from the set S to the domain of MAP.  */

@@ -579,7 +580,7 @@  loop_level_carries_dependences (scop_p s
    poly_bb_p.  */

 bool
-loop_is_parallel_p (loop_p loop, htab_t bb_pbb_mapping, int depth)
+loop_is_parallel_p (loop_p loop, bb_pbb_htab_type bb_pbb_mapping, int depth)
 {
   bool dependences;
   scop_p scop;
Index: gcc/graphite-poly.h
===================================================================
--- gcc/graphite-poly.h	(revision 193902)
+++ gcc/graphite-poly.h	(working copy)
@@ -1376,10 +1376,6 @@  struct scop
     *must_war, *may_war, *must_war_no_source, *may_war_no_source,
     *must_waw, *may_waw, *must_waw_no_source, *may_waw_no_source;

-  /* A hashtable of the data dependence relations for the original
-     scattering.  */
-  htab_t original_pddrs;
-
   /* True when the scop has been converted to its polyhedral
      representation.  */
   bool poly_scop_p;
@@ -1388,7 +1384,6 @@  struct scop
 #define SCOP_BBS(S) (S->bbs)
 #define SCOP_REGION(S) ((sese) S->region)
 #define SCOP_CONTEXT(S) (NULL)
-#define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs)
 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule)
 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule)
 #define SCOP_SAVED_SCHEDULE(S) (S->saved_schedule)
@@ -1536,9 +1531,6 @@  restore_scattering (scop_p scop)
 }

 bool graphite_legal_transform (scop_p);
-poly_bb_p find_pbb_via_hash (htab_t, basic_block);
-bool loop_is_parallel_p (loop_p, htab_t, int);
-scop_p get_loop_body_pbbs (loop_p, htab_t, vec<poly_bb_p> *);
 isl_map *reverse_loop_at_level (poly_bb_p, int);
 isl_union_map *reverse_loop_for_pbbs (scop_p, vec<poly_bb_p> , int);
 __isl_give isl_union_map *extend_schedule (__isl_take isl_union_map *);
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 193902)
+++ gcc/Makefile.in	(working copy)
@@ -976,6 +976,7 @@  GCC_PLUGIN_H = gcc-plugin.h highlev-plug
 PLUGIN_H = plugin.h $(GCC_PLUGIN_H)
 PLUGIN_VERSION_H = plugin-version.h configargs.h
 LIBFUNCS_H = libfuncs.h $(HASHTAB_H)
+GRAPHITE_HTAB_H = graphite-htab.h graphite-clast-to-gimple.h $(HASH_TABLE_H)

 #
 # Now figure out from those variables how to compile and link.
@@ -2550,18 +2551,18 @@  sese.o : sese.c sese.h $(CONFIG_H) $(SYS
    $(TREE_FLOW_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) $(TREE_PASS_H) value-prof.h
 graphite.o : graphite.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
$(DIAGNOSTIC_CORE_H) \
    $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h \
-   $(DBGCNT_H) graphite-poly.h graphite-scop-detection.h \
+   $(DBGCNT_H) $(GRAPHITE_HTAB_H) graphite-poly.h graphite-scop-detection.h \
    graphite-clast-to-gimple.h graphite-sese-to-poly.h
 graphite-blocking.o : graphite-blocking.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h dumpfile.h $(TREE_FLOW_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
    sese.h graphite-poly.h
 graphite-clast-to-gimple.o : graphite-clast-to-gimple.c $(CONFIG_H) \
    $(SYSTEM_H) coretypes.h $(DIAGNOSTIC_CORE_H) $(TREE_FLOW_H) $(TREE_PASS_H) \
-   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h \
+   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h $(GRAPHITE_HTAB_H) \
    graphite-poly.h graphite-clast-to-gimple.h
 graphite-dependences.o : graphite-dependences.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(TREE_PASS_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
-   sese.h graphite-poly.h
+   sese.h $(GRAPHITE_HTAB_H) graphite-poly.h
 graphite-interchange.o : graphite-interchange.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h dumpfile.h $(TREE_FLOW_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \