add isl_dim_get_hash
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 25 Jul 2010 09:04:53 +0000 (11:04 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 31 Jul 2010 09:16:51 +0000 (11:16 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_dim.c
isl_dim_private.h

index 5142292..9599bca 100644 (file)
--- a/isl_dim.c
+++ b/isl_dim.c
@@ -8,7 +8,7 @@
  */
 
 #include <stdlib.h>
-#include <isl_dim.h>
+#include <isl_dim_private.h>
 #include "isl_name.h"
 
 struct isl_dim *isl_dim_alloc(struct isl_ctx *ctx,
@@ -905,3 +905,30 @@ int isl_dim_compatible(struct isl_dim *dim1, struct isl_dim *dim2)
        return dim1->nparam == dim2->nparam &&
               dim1->n_in + dim1->n_out == dim2->n_in + dim2->n_out;
 }
+
+uint32_t isl_dim_get_hash(__isl_keep isl_dim *dim)
+{
+       int i;
+       uint32_t hash;
+       struct isl_name *name;
+
+       if (!dim)
+               return 0;
+       hash = isl_hash_init();
+
+       hash = isl_hash_builtin(hash, dim->nparam);
+       hash = isl_hash_builtin(hash, dim->n_in);
+       hash = isl_hash_builtin(hash, dim->n_out);
+
+       for (i = 0; i < dim->nparam; ++i) {
+               name = get_name(dim, isl_dim_param, i);
+               hash = isl_hash_builtin(hash, name);
+       }
+
+       name = tuple_name(dim, isl_dim_in);
+       hash = isl_hash_builtin(hash, name);
+       name = tuple_name(dim, isl_dim_out);
+       hash = isl_hash_builtin(hash, name);
+
+       return hash;
+}
index 3f1f94f..f98651e 100644 (file)
@@ -1,4 +1,7 @@
 #include <isl_dim.h>
+#include <isl_hash.h>
+
+uint32_t isl_dim_get_hash(__isl_keep isl_dim *dim);
 
 __isl_give isl_dim *isl_dim_as_set_dim(__isl_take isl_dim *dim);