generalize and export isl_map_to_basic_set
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 5 Jun 2013 11:08:25 +0000 (5 13:08 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 27 Jul 2013 09:04:00 +0000 (27 11:04 +0200)
The user level documentation will be added when we introduce isl_id_to_ast_expr.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
Makefile.am
include/isl/hmap.h [new file with mode: 0644]
include/isl/map_to_basic_set.h [new file with mode: 0644]
isl_hmap_templ.c [new file with mode: 0644]
isl_map_to_basic_set.c
isl_map_to_basic_set.h [deleted file]
isl_schedule.c

index b0fca50..2c6de70 100644 (file)
@@ -79,7 +79,6 @@ libisl_la_SOURCES = \
        isl_map_subtract.c \
        isl_map_private.h \
        isl_map_to_basic_set.c \
-       isl_map_to_basic_set.h \
        isl_mat.c \
        isl_mat_private.h \
        isl_morph.c \
@@ -220,11 +219,13 @@ pkginclude_HEADERS = \
        include/isl/id.h \
        include/isl/ilp.h \
        include/isl/hash.h \
+       include/isl/hmap.h \
        include/isl/list.h \
        include/isl/local_space.h \
        include/isl/lp.h \
        include/isl/mat.h \
        include/isl/map.h \
+       include/isl/map_to_basic_set.h \
        include/isl/map_type.h \
        include/isl/multi.h \
        include/isl/obj.h \
@@ -252,6 +253,7 @@ EXTRA_DIST = \
        LICENSE \
        isl_config_post.h \
        basis_reduction_templ.c \
+       isl_hmap_templ.c \
        isl_list_templ.c \
        isl_list_templ.h \
        isl_map_lexopt_templ.c \
diff --git a/include/isl/hmap.h b/include/isl/hmap.h
new file mode 100644 (file)
index 0000000..54140e6
--- /dev/null
@@ -0,0 +1,54 @@
+#include <isl/ctx.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define ISL_xCAT(A,B) A ## B
+#define ISL_CAT(A,B) ISL_xCAT(A,B)
+#define ISL_KEY ISL_CAT(isl_,ISL_KEY_BASE)
+#define ISL_VAL ISL_CAT(isl_,ISL_VAL_BASE)
+#define ISL_xFN(TYPE,NAME) TYPE ## _ ## NAME
+#define ISL_FN(TYPE,NAME) ISL_xFN(TYPE,NAME)
+#define ISL_xHMAP(KEY,VAL_BASE) KEY ## _to_ ## VAL_BASE
+#define ISL_yHMAP(KEY,VAL_BASE) ISL_xHMAP(KEY,VAL_BASE)
+#define ISL_HMAP ISL_yHMAP(ISL_KEY,ISL_VAL_BASE)
+#define ISL_HMAP_BASE ISL_yHMAP(ISL_KEY_BASE,ISL_VAL_BASE)
+
+struct ISL_HMAP;
+typedef struct ISL_HMAP        ISL_HMAP;
+
+__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,alloc)(isl_ctx *ctx, int min_size);
+__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,copy)(__isl_keep ISL_HMAP *hmap);
+void *ISL_FN(ISL_HMAP,free)(__isl_take ISL_HMAP *hmap);
+
+isl_ctx *ISL_FN(ISL_HMAP,get_ctx)(__isl_keep ISL_HMAP *hmap);
+
+int ISL_FN(ISL_HMAP,has)(__isl_keep ISL_HMAP *hmap, __isl_keep ISL_KEY *key);
+__isl_give ISL_VAL *ISL_FN(ISL_HMAP,get)(__isl_keep ISL_HMAP *hmap,
+       __isl_take ISL_KEY *key);
+__isl_give ISL_HMAP *ISL_FN(ISL_HMAP,set)(__isl_take ISL_HMAP *hmap,
+       __isl_take ISL_KEY *key, __isl_take ISL_VAL *val);
+
+int ISL_FN(ISL_HMAP,foreach)(__isl_keep ISL_HMAP *hmap,
+       int (*fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user),
+       void *user);
+
+__isl_give isl_printer *ISL_FN(isl_printer_print,ISL_HMAP_BASE)(
+       __isl_take isl_printer *p, __isl_keep ISL_HMAP *hmap);
+void ISL_FN(ISL_HMAP,dump)(__isl_keep ISL_HMAP *hmap);
+
+#undef ISL_xCAT
+#undef ISL_CAT
+#undef ISL_KEY
+#undef ISL_VAL
+#undef ISL_xFN
+#undef ISL_FN
+#undef ISL_xHMAP
+#undef ISL_yHMAP
+#undef ISL_HMAP
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/include/isl/map_to_basic_set.h b/include/isl/map_to_basic_set.h
new file mode 100644 (file)
index 0000000..7df8ee3
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef ISL_MAP_TO_BASIC_SET_H
+#define ISL_MAP_TO_BASIC_SET_H
+
+#include <isl/set_type.h>
+#include <isl/map_type.h>
+
+#define ISL_KEY_BASE   map
+#define ISL_VAL_BASE   basic_set
+#include <isl/hmap.h>
+#undef ISL_KEY_BASE
+#undef ISL_VAL_BASE
+
+#endif
diff --git a/isl_hmap_templ.c b/isl_hmap_templ.c
new file mode 100644 (file)
index 0000000..07f72a4
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2011      INRIA Saclay
+ * Copyright 2013      Ecole Normale Superieure
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
+ * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
+ * 91893 Orsay, France
+ * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
+ */
+
+#include <isl/ctx.h>
+#include <isl/hash.h>
+
+#define xCAT(A,B) A ## B
+#define CAT(A,B) xCAT(A,B)
+#define KEY CAT(isl_,KEY_BASE)
+#define VAL CAT(isl_,VAL_BASE)
+#define xFN(TYPE,NAME) TYPE ## _ ## NAME
+#define FN(TYPE,NAME) xFN(TYPE,NAME)
+#define xHMAP(KEY,VAL_BASE) KEY ## _to_ ## VAL_BASE
+#define yHMAP(KEY,VAL_BASE) xHMAP(KEY,VAL_BASE)
+#define HMAP yHMAP(KEY,VAL_BASE)
+#define HMAP_BASE yHMAP(KEY_BASE,VAL_BASE)
+#define xS(TYPE1,TYPE2,NAME) struct isl_ ## TYPE1 ## _ ## TYPE2 ## _ ## NAME
+#define yS(TYPE1,TYPE2,NAME) xS(TYPE1,TYPE2,NAME)
+#define S(NAME) yS(KEY_BASE,VAL_BASE,NAME)
+
+struct HMAP {
+       int ref;
+       isl_ctx *ctx;
+       struct isl_hash_table table;
+};
+
+S(pair) {
+       KEY *key;
+       VAL *val;
+};
+
+__isl_give HMAP *FN(HMAP,alloc)(isl_ctx *ctx, int min_size)
+{
+       HMAP *hmap;
+
+       hmap = isl_calloc_type(ctx, HMAP);
+       if (!hmap)
+               return NULL;
+
+       hmap->ctx = ctx;
+       isl_ctx_ref(ctx);
+       hmap->ref = 1;
+
+       if (isl_hash_table_init(ctx, &hmap->table, min_size) < 0)
+               return FN(HMAP,free)(hmap);
+
+       return hmap;
+}
+
+static int free_pair(void **entry, void *user)
+{
+       S(pair) *pair = *entry;
+       FN(KEY,free)(pair->key);
+       FN(VAL,free)(pair->val);
+       free(pair);
+       *entry = NULL;
+       return 0;
+}
+
+void *FN(HMAP,free)(__isl_take HMAP *hmap)
+{
+       if (!hmap)
+               return NULL;
+       if (--hmap->ref > 0)
+               return NULL;
+       isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
+       isl_hash_table_clear(&hmap->table);
+       isl_ctx_deref(hmap->ctx);
+       free(hmap);
+       return NULL;
+}
+
+isl_ctx *FN(HMAP,get_ctx)(__isl_keep HMAP *hmap)
+{
+       return hmap ? hmap->ctx : NULL;
+}
+
+/* Add a mapping from "key" to "val" to the associative array
+ * pointed to by user.
+ */
+static int add_key_val(__isl_take KEY *key, __isl_take VAL *val, void *user)
+{
+       HMAP **hmap = (HMAP **) user;
+
+       *hmap = FN(HMAP,set)(*hmap, key, val);
+
+       if (!*hmap)
+               return -1;
+
+       return 0;
+}
+
+__isl_give HMAP *FN(HMAP,dup)(__isl_keep HMAP *hmap)
+{
+       HMAP *dup;
+
+       if (!hmap)
+               return NULL;
+
+       dup = FN(HMAP,alloc)(hmap->ctx, hmap->table.n);
+       if (FN(HMAP,foreach)(hmap, &add_key_val, &dup) < 0)
+               return FN(HMAP,free)(dup);
+
+       return dup;
+}
+
+__isl_give HMAP *FN(HMAP,cow)(__isl_take HMAP *hmap)
+{
+       if (!hmap)
+               return NULL;
+
+       if (hmap->ref == 1)
+               return hmap;
+       hmap->ref--;
+       return FN(HMAP,dup)(hmap);
+}
+
+__isl_give HMAP *FN(HMAP,copy)(__isl_keep HMAP *hmap)
+{
+       if (!hmap)
+               return NULL;
+
+       hmap->ref++;
+       return hmap;
+}
+
+static int has_key(const void *entry, const void *c_key)
+{
+       const S(pair) *pair = entry;
+       KEY *key = (KEY *) c_key;
+
+       return KEY_EQUAL(pair->key, key);
+}
+
+int FN(HMAP,has)(__isl_keep HMAP *hmap, __isl_keep KEY *key)
+{
+       uint32_t hash;
+
+       if (!hmap)
+               return -1;
+
+       hash = FN(KEY,get_hash)(key);
+       return !!isl_hash_table_find(hmap->ctx, &hmap->table, hash,
+                                       &has_key, key, 0);
+}
+
+__isl_give VAL *FN(HMAP,get)(__isl_keep HMAP *hmap, __isl_take KEY *key)
+{
+       struct isl_hash_table_entry *entry;
+       S(pair) *pair;
+       uint32_t hash;
+
+       if (!hmap || !key)
+               goto error;
+
+       hash = FN(KEY,get_hash)(key);
+       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
+                                       &has_key, key, 0);
+       FN(KEY,free)(key);
+
+       if (!entry)
+               return NULL;
+
+       pair = entry->data;
+
+       return FN(VAL,copy)(pair->val);
+error:
+       FN(KEY,free)(key);
+       return NULL;
+}
+
+/* Add a mapping from "key" to "val" to "hmap".
+ * If "key" was already mapped to something else, then that mapping
+ * is replaced.
+ * If key happened to be mapped to "val" already, then we leave
+ * "hmap" untouched.
+ */
+__isl_give HMAP *FN(HMAP,set)(__isl_take HMAP *hmap,
+       __isl_take KEY *key, __isl_take VAL *val)
+{
+       struct isl_hash_table_entry *entry;
+       S(pair) *pair;
+       uint32_t hash;
+
+       if (!hmap)
+               goto error;
+
+       hash = FN(KEY,get_hash)(key);
+       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
+                                       &has_key, key, 0);
+       if (entry) {
+               int equal;
+               pair = entry->data;
+               equal = VAL_EQUAL(pair->val, val);
+               if (equal < 0)
+                       goto error;
+               if (equal) {
+                       FN(KEY,free)(key);
+                       FN(VAL,free)(val);
+                       return hmap;
+               }
+       }
+
+       hmap = FN(HMAP,cow)(hmap);
+       if (!hmap)
+               goto error;
+
+       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
+                                       &has_key, key, 1);
+
+       if (!entry)
+               goto error;
+
+       if (entry->data) {
+               pair = entry->data;
+               FN(VAL,free)(pair->val);
+               pair->val = val;
+               FN(KEY,free)(key);
+               return hmap;
+       }
+
+       pair = isl_alloc_type(hmap->ctx, S(pair));
+       if (!pair)
+               goto error;
+
+       entry->data = pair;
+       pair->key = key;
+       pair->val = val;
+       return hmap;
+error:
+       FN(KEY,free)(key);
+       FN(VAL,free)(val);
+       return FN(HMAP,free)(hmap);
+}
+
+/* Internal data structure for isl_map_to_basic_set_foreach.
+ *
+ * fn is the function that should be called on each entry.
+ * user is the user-specified final argument to fn.
+ */
+S(foreach_data) {
+       int (*fn)(__isl_take KEY *key, __isl_take VAL *val, void *user);
+       void *user;
+};
+
+/* Call data->fn on a copy of the key and value in *entry.
+ */
+static int call_on_copy(void **entry, void *user)
+{
+       S(pair) *pair = *entry;
+       S(foreach_data) *data = (S(foreach_data) *) user;
+
+       return data->fn(FN(KEY,copy)(pair->key), FN(VAL,copy)(pair->val),
+                       data->user);
+}
+
+/* Call "fn" on each pair of key and value in "hmap".
+ */
+int FN(HMAP,foreach)(__isl_keep HMAP *hmap,
+       int (*fn)(__isl_take KEY *key, __isl_take VAL *val, void *user),
+       void *user)
+{
+       S(foreach_data) data = { fn, user };
+
+       if (!hmap)
+               return -1;
+
+       return isl_hash_table_foreach(hmap->ctx, &hmap->table,
+                                     &call_on_copy, &data);
+}
+
+/* Internal data structure for print_pair.
+ *
+ * p is the printer on which the associative array is being printed.
+ * first is set if the current key-value pair is the first to be printed.
+ */
+S(print_data) {
+       isl_printer *p;
+       int first;
+};
+
+/* Print the given key-value pair to data->p.
+ */
+static int print_pair(__isl_take KEY *key, __isl_take VAL *val, void *user)
+{
+       S(print_data) *data = user;
+
+       if (!data->first)
+               data->p = isl_printer_print_str(data->p, ", ");
+       data->p = FN(isl_printer_print,KEY_BASE)(data->p, key);
+       data->p = isl_printer_print_str(data->p, ": ");
+       data->p = FN(isl_printer_print,VAL_BASE)(data->p, val);
+       data->first = 0;
+
+       FN(KEY,free)(key);
+       FN(VAL,free)(val);
+       return 0;
+}
+
+/* Print the associative array to "p".
+ */
+__isl_give isl_printer *FN(isl_printer_print,HMAP_BASE)(
+       __isl_take isl_printer *p, __isl_keep HMAP *hmap)
+{
+       S(print_data) data;
+
+       if (!p || !hmap)
+               return isl_printer_free(p);
+
+       p = isl_printer_print_str(p, "{");
+       data.p = p;
+       data.first = 1;
+       if (FN(HMAP,foreach)(hmap, &print_pair, &data) < 0)
+               data.p = isl_printer_free(data.p);
+       p = data.p;
+       p = isl_printer_print_str(p, "}");
+
+       return p;
+}
+
+void FN(HMAP,dump)(__isl_keep HMAP *hmap)
+{
+       isl_printer *printer;
+
+       if (!hmap)
+               return;
+
+       printer = isl_printer_to_file(FN(HMAP,get_ctx)(hmap), stderr);
+       printer = FN(isl_printer_print,HMAP_BASE)(printer, hmap);
+       printer = isl_printer_end_line(printer);
+
+       isl_printer_free(printer);
+}
dissimilarity index 99%
index 0386656..6755d52 100644 (file)
-/*
- * Copyright 2011      INRIA Saclay
- * Copyright 2013      Ecole Normale Superieure
- *
- * Use of this software is governed by the MIT license
- *
- * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
- * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
- * 91893 Orsay, France
- * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
- */
-
-#include <isl_map_to_basic_set.h>
-
-struct isl_map_basic_set_pair {
-       isl_map         *key;
-       isl_basic_set   *val;
-};
-
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_alloc(isl_ctx *ctx,
-       int min_size)
-{
-       isl_map_to_basic_set *hmap;
-
-       hmap = isl_calloc_type(ctx, isl_map_to_basic_set);
-       if (!hmap)
-               return NULL;
-
-       hmap->ctx = ctx;
-       isl_ctx_ref(ctx);
-       hmap->ref = 1;
-
-       if (isl_hash_table_init(ctx, &hmap->table, min_size) < 0)
-               return isl_map_to_basic_set_free(hmap);
-
-       return hmap;
-}
-
-static int free_pair(void **entry, void *user)
-{
-       struct isl_map_basic_set_pair *pair = *entry;
-       isl_map_free(pair->key);
-       isl_basic_set_free(pair->val);
-       free(pair);
-       *entry = NULL;
-       return 0;
-}
-
-void *isl_map_to_basic_set_free(__isl_take isl_map_to_basic_set *hmap)
-{
-       if (!hmap)
-               return NULL;
-       if (--hmap->ref > 0)
-               return NULL;
-       isl_hash_table_foreach(hmap->ctx, &hmap->table, &free_pair, NULL);
-       isl_hash_table_clear(&hmap->table);
-       isl_ctx_deref(hmap->ctx);
-       free(hmap);
-       return NULL;
-}
-
-isl_ctx *isl_map_to_basic_set_get_ctx(__isl_keep isl_map_to_basic_set *hmap)
-{
-       return hmap ? hmap->ctx : NULL;
-}
-
-/* Add a mapping from "key" to "val" to the associative array
- * pointed to by user.
- */
-static int add_key_val(__isl_take isl_map *key, __isl_take isl_basic_set *val,
-       void *user)
-{
-       isl_map_to_basic_set **hmap = (isl_map_to_basic_set **) user;
-
-       *hmap = isl_map_to_basic_set_set(*hmap, key, val);
-
-       if (!*hmap)
-               return -1;
-
-       return 0;
-}
-
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_dup(
-       __isl_keep isl_map_to_basic_set *hmap)
-{
-       isl_map_to_basic_set *dup;
-
-       if (!hmap)
-               return NULL;
-
-       dup = isl_map_to_basic_set_alloc(hmap->ctx, hmap->table.n);
-       if (isl_map_to_basic_set_foreach(hmap, &add_key_val, &dup) < 0)
-               return isl_map_to_basic_set_free(dup);
-
-       return dup;
-}
-
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_cow(
-       __isl_take isl_map_to_basic_set *hmap)
-{
-       if (!hmap)
-               return NULL;
-
-       if (hmap->ref == 1)
-               return hmap;
-       hmap->ref--;
-       return isl_map_to_basic_set_dup(hmap);
-}
-
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_copy(
-       __isl_keep isl_map_to_basic_set *hmap)
-{
-       if (!hmap)
-               return NULL;
-
-       hmap->ref++;
-       return hmap;
-}
-
-static int has_key(const void *entry, const void *key)
-{
-       const struct isl_map_basic_set_pair *pair = entry;
-       isl_map *map = (isl_map *)key;
-
-       return isl_map_plain_is_equal(pair->key, map);
-}
-
-int isl_map_to_basic_set_has(__isl_keep isl_map_to_basic_set *hmap,
-       __isl_keep isl_map *key)
-{
-       uint32_t hash;
-
-       if (!hmap)
-               return -1;
-
-       hash = isl_map_get_hash(key);
-       return !!isl_hash_table_find(hmap->ctx, &hmap->table, hash,
-                                       &has_key, key, 0);
-}
-
-__isl_give isl_basic_set *isl_map_to_basic_set_get(
-       __isl_keep isl_map_to_basic_set *hmap, __isl_take isl_map *key)
-{
-       struct isl_hash_table_entry *entry;
-       struct isl_map_basic_set_pair *pair;
-       uint32_t hash;
-
-       if (!hmap || !key)
-               goto error;
-
-       hash = isl_map_get_hash(key);
-       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
-                                       &has_key, key, 0);
-       isl_map_free(key);
-
-       if (!entry)
-               return NULL;
-
-       pair = entry->data;
-
-       return isl_basic_set_copy(pair->val);
-error:
-       isl_map_free(key);
-       return NULL;
-}
-
-/* Add a mapping from "key" to "val" to "hmap".
- * If "key" was already mapped to something else, then that mapping
- * is replaced.
- * If key happened to be mapped to "val" already, then we leave
- * "hmap" untouched.
- */
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_set(
-       __isl_take isl_map_to_basic_set *hmap,
-       __isl_take isl_map *key, __isl_take isl_basic_set *val)
-{
-       struct isl_hash_table_entry *entry;
-       struct isl_map_basic_set_pair *pair;
-       uint32_t hash;
-
-       if (!hmap)
-               goto error;
-
-       hash = isl_map_get_hash(key);
-       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
-                                       &has_key, key, 0);
-       if (entry) {
-               int equal;
-               pair = entry->data;
-               equal = isl_basic_set_plain_is_equal(pair->val, val);
-               if (equal < 0)
-                       goto error;
-               if (equal) {
-                       isl_map_free(key);
-                       isl_basic_set_free(val);
-                       return hmap;
-               }
-       }
-
-       hmap = isl_map_to_basic_set_cow(hmap);
-       if (!hmap)
-               goto error;
-
-       entry = isl_hash_table_find(hmap->ctx, &hmap->table, hash,
-                                       &has_key, key, 1);
-
-       if (!entry)
-               goto error;
-
-       if (entry->data) {
-               pair = entry->data;
-               isl_basic_set_free(pair->val);
-               pair->val = val;
-               isl_map_free(key);
-               return hmap;
-       }
-
-       pair = isl_alloc_type(hmap->ctx, struct isl_map_basic_set_pair);
-       if (!pair)
-               goto error;
-
-       entry->data = pair;
-       pair->key = key;
-       pair->val = val;
-       return hmap;
-error:
-       isl_map_free(key);
-       isl_basic_set_free(val);
-       return isl_map_to_basic_set_free(hmap);
-}
-
-/* Internal data structure for isl_map_to_basic_set_foreach.
- *
- * fn is the function that should be called on each entry.
- * user is the user-specified final argument to fn.
- */
-struct isl_map_to_basic_set_foreach_data {
-       int (*fn)(__isl_take isl_map *key, __isl_take isl_basic_set *val,
-                   void *user);
-       void *user;
-};
-
-/* Call data->fn on a copy of the key and value in *entry.
- */
-static int call_on_copy(void **entry, void *user)
-{
-       struct isl_map_basic_set_pair *pair = *entry;
-       struct isl_map_to_basic_set_foreach_data *data;
-       data = (struct isl_map_to_basic_set_foreach_data *) user;
-
-       return data->fn(isl_map_copy(pair->key), isl_basic_set_copy(pair->val),
-                       data->user);
-}
-
-/* Call "fn" on each pair of key and value in "hmap".
- */
-int isl_map_to_basic_set_foreach(__isl_keep isl_map_to_basic_set *hmap,
-       int (*fn)(__isl_take isl_map *key, __isl_take isl_basic_set *val,
-                   void *user), void *user)
-{
-       struct isl_map_to_basic_set_foreach_data data = { fn, user };
-
-       if (!hmap)
-               return -1;
-
-       return isl_hash_table_foreach(hmap->ctx, &hmap->table,
-                                     &call_on_copy, &data);
-}
-
-/* Internal data structure for print_pair.
- *
- * p is the printer on which the associative array is being printed.
- * first is set if the current key-value pair is the first to be printed.
- */
-struct isl_map_to_basic_set_print_data {
-       isl_printer *p;
-       int first;
-};
-
-/* Print the given key-value pair to data->p.
- */
-static int print_pair(__isl_take isl_map *key, __isl_take isl_basic_set *val,
-       void *user)
-{
-       struct isl_map_to_basic_set_print_data *data = user;
-
-       if (!data->first)
-               data->p = isl_printer_print_str(data->p, ", ");
-       data->p = isl_printer_print_map(data->p, key);
-       data->p = isl_printer_print_str(data->p, ": ");
-       data->p = isl_printer_print_basic_set(data->p, val);
-       data->first = 0;
-
-       isl_map_free(key);
-       isl_basic_set_free(val);
-       return 0;
-}
-
-/* Print the associative array to "p".
- */
-__isl_give isl_printer *isl_printer_print_map_to_basic_set(
-       __isl_take isl_printer *p, __isl_keep isl_map_to_basic_set *hmap)
-{
-       struct isl_map_to_basic_set_print_data data;
-
-       if (!p || !hmap)
-               return isl_printer_free(p);
-
-       p = isl_printer_print_str(p, "{");
-       data.p = p;
-       data.first = 1;
-       if (isl_map_to_basic_set_foreach(hmap, &print_pair, &data) < 0)
-               data.p = isl_printer_free(data.p);
-       p = data.p;
-       p = isl_printer_print_str(p, "}");
-
-       return p;
-}
-
-void isl_map_to_basic_set_dump(__isl_keep isl_map_to_basic_set *hmap)
-{
-       isl_printer *printer;
-
-       if (!hmap)
-               return;
-
-       printer = isl_printer_to_file(isl_map_to_basic_set_get_ctx(hmap),
-                                       stderr);
-       printer = isl_printer_print_map_to_basic_set(printer, hmap);
-       printer = isl_printer_end_line(printer);
-
-       isl_printer_free(printer);
-}
+#include <isl/map_to_basic_set.h>
+#include <isl/map.h>
+#include <isl/set.h>
+
+#define KEY_BASE       map
+#define KEY_EQUAL      isl_map_plain_is_equal
+#define VAL_BASE       basic_set
+#define VAL_EQUAL      isl_basic_set_plain_is_equal
+
+#include <isl_hmap_templ.c>
diff --git a/isl_map_to_basic_set.h b/isl_map_to_basic_set.h
deleted file mode 100644 (file)
index cbf0423..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef ISL_HMAP_MAP_BASIC_SET_H
-#define ISL_HMAP_MAP_BASIC_SET_H
-
-#include <isl/ctx.h>
-#include <isl/hash.h>
-#include <isl/map.h>
-#include <isl/set.h>
-#include <isl/printer.h>
-
-struct isl_map_to_basic_set {
-       int ref;
-       isl_ctx *ctx;
-       struct isl_hash_table table;
-};
-typedef struct isl_map_to_basic_set    isl_map_to_basic_set;
-
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_alloc( isl_ctx *ctx,
-       int min_size);
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_copy(
-       __isl_keep isl_map_to_basic_set *hmap);
-void *isl_map_to_basic_set_free(__isl_take isl_map_to_basic_set *map2bset);
-
-isl_ctx *isl_map_to_basic_set_get_ctx(__isl_keep isl_map_to_basic_set *hmap);
-
-int isl_map_to_basic_set_has(__isl_keep isl_map_to_basic_set *map2bset,
-       __isl_keep isl_map *key);
-__isl_give isl_basic_set *isl_map_to_basic_set_get(
-       __isl_keep isl_map_to_basic_set *map2bset, __isl_take isl_map *key);
-__isl_give isl_map_to_basic_set *isl_map_to_basic_set_set(
-       __isl_take isl_map_to_basic_set *map2bset,
-       __isl_take isl_map *key, __isl_take isl_basic_set *val);
-
-int isl_map_to_basic_set_foreach(__isl_keep isl_map_to_basic_set *hmap,
-       int (*fn)(__isl_take isl_map *key, __isl_take isl_basic_set *val,
-                   void *user), void *user);
-
-__isl_give isl_printer *isl_printer_print_map_to_basic_set(
-       __isl_take isl_printer *p, __isl_keep isl_map_to_basic_set *hmap);
-void isl_map_to_basic_set_dump(__isl_keep isl_map_to_basic_set *hmap);
-
-#endif
index 534d94f..c3205ef 100644 (file)
@@ -23,7 +23,7 @@
 #include <isl_seq.h>
 #include <isl_tab.h>
 #include <isl_dim_map.h>
-#include <isl_map_to_basic_set.h>
+#include <isl/map_to_basic_set.h>
 #include <isl_sort.h>
 #include <isl_schedule_private.h>
 #include <isl_band_private.h>