add isl_id_to_ast_expr
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 5 Jun 2013 12:36:36 +0000 (5 14:36 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 27 Jul 2013 09:04:01 +0000 (27 11:04 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
Makefile.am
doc/user.pod
include/isl/id_to_ast_expr.h [new file with mode: 0644]
isl_id_to_ast_expr.c [new file with mode: 0644]

index 2c6de70..96b09ee 100644 (file)
@@ -66,6 +66,7 @@ libisl_la_SOURCES = \
        isl_fold.c \
        isl_gmp.c \
        isl_hash.c \
+       isl_id_to_ast_expr.c \
        isl_ilp.c \
        isl_ilp_private.h \
        isl_input.c \
@@ -217,6 +218,7 @@ pkginclude_HEADERS = \
        include/isl/dim.h \
        include/isl/flow.h \
        include/isl/id.h \
+       include/isl/id_to_ast_expr.h \
        include/isl/ilp.h \
        include/isl/hash.h \
        include/isl/hmap.h \
index c4601ee..6b25151 100644 (file)
@@ -3287,6 +3287,62 @@ Lists can be printed using
                __isl_take isl_printer *p,
                __isl_keep isl_set_list *list);
 
+=head2 Associative arrays
+
+Associative arrays map isl objects of a specific type to isl objects
+of some (other) specific type.  They are defined for several pairs
+of types, including (C<isl_map>, C<isl_basic_set>) and
+(C<isl_id>, C<isl_ast_expr>).
+Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
+as an example.
+
+Associative arrays can be created, copied and freed using
+the following functions.
+
+       #include <isl/id_to_ast_expr.h>
+       __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
+               isl_ctx *ctx, int min_size);
+       __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
+               __isl_keep id_to_ast_expr *id2expr);
+       void *isl_id_to_ast_expr_free(
+               __isl_take id_to_ast_expr *id2expr);
+
+The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
+to specify the expected size of the associative array.
+The associative array will be grown automatically as needed.
+
+Associative arrays can be inspected using the following functions.
+
+       #include <isl/id_to_ast_expr.h>
+       isl_ctx *isl_id_to_ast_expr_get_ctx(
+               __isl_keep id_to_ast_expr *id2expr);
+       int isl_id_to_ast_expr_has(
+               __isl_keep id_to_ast_expr *id2expr,
+               __isl_keep isl_id *key);
+       __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
+               __isl_keep id_to_ast_expr *id2expr,
+               __isl_take isl_id *key);
+       int isl_id_to_ast_expr_foreach(
+               __isl_keep id_to_ast_expr *id2expr,
+               int (*fn)(__isl_take isl_id *key,
+                       __isl_take isl_ast_expr *val, void *user),
+               void *user);
+
+They can be modified using the following function.
+
+       #include <isl/id_to_ast_expr.h>
+       __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
+               __isl_take id_to_ast_expr *id2expr,
+               __isl_take isl_id *key,
+               __isl_take isl_ast_expr *val);
+
+Associative arrays can be printed using the following function.
+
+       #include <isl/id_to_ast_expr.h>
+       __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
+               __isl_take isl_printer *p,
+               __isl_keep id_to_ast_expr *id2expr);
+
 =head2 Multiple Values
 
 An C<isl_multi_val> object represents a sequence of zero or more values,
diff --git a/include/isl/id_to_ast_expr.h b/include/isl/id_to_ast_expr.h
new file mode 100644 (file)
index 0000000..0ced87a
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef ISL_ID_TO_AST_EXPR_H
+#define ISL_ID_TO_AST_EXPR_H
+
+#include <isl/id.h>
+#include <isl/ast.h>
+
+#define ISL_KEY_BASE   id
+#define ISL_VAL_BASE   ast_expr
+#include <isl/hmap.h>
+#undef ISL_KEY_BASE
+#undef ISL_VAL_BASE
+
+#endif
diff --git a/isl_id_to_ast_expr.c b/isl_id_to_ast_expr.c
new file mode 100644 (file)
index 0000000..a0f6080
--- /dev/null
@@ -0,0 +1,10 @@
+#include <isl/id_to_ast_expr.h>
+
+#define isl_id_is_equal(id1,id2)       id1 == id2
+
+#define KEY_BASE       id
+#define KEY_EQUAL      isl_id_is_equal
+#define VAL_BASE       ast_expr
+#define VAL_EQUAL      isl_ast_expr_is_equal
+
+#include <isl_hmap_templ.c>