From 130549b3b873681a5788398b32fd0afaceb961df Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 25 Jul 2010 11:04:53 +0200 Subject: [PATCH] add isl_dim_get_hash Signed-off-by: Sven Verdoolaege --- isl_dim.c | 29 ++++++++++++++++++++++++++++- isl_dim_private.h | 3 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/isl_dim.c b/isl_dim.c index 5142292..9599bca 100644 --- a/isl_dim.c +++ b/isl_dim.c @@ -8,7 +8,7 @@ */ #include -#include +#include #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; +} diff --git a/isl_dim_private.h b/isl_dim_private.h index 3f1f94f..f98651e 100644 --- a/isl_dim_private.h +++ b/isl_dim_private.h @@ -1,4 +1,7 @@ #include +#include + +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); -- 2.7.4