From 665c6cf62965b09509fc0922227f432bbb1bc37b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 5 Jun 2013 14:36:36 +0200 Subject: [PATCH] add isl_id_to_ast_expr Signed-off-by: Sven Verdoolaege --- Makefile.am | 2 ++ doc/user.pod | 56 ++++++++++++++++++++++++++++++++++++++++++++ include/isl/id_to_ast_expr.h | 13 ++++++++++ isl_id_to_ast_expr.c | 10 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 include/isl/id_to_ast_expr.h create mode 100644 isl_id_to_ast_expr.c diff --git a/Makefile.am b/Makefile.am index 2c6de702..96b09eea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/doc/user.pod b/doc/user.pod index c4601ee2..6b251510 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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, C) and +(C, C). +Here, we take associative arrays that map Cs to Cs +as an example. + +Associative arrays can be created, copied and freed using +the following functions. + + #include + __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 argument to C 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_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_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_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 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 index 00000000..0ced87af --- /dev/null +++ b/include/isl/id_to_ast_expr.h @@ -0,0 +1,13 @@ +#ifndef ISL_ID_TO_AST_EXPR_H +#define ISL_ID_TO_AST_EXPR_H + +#include +#include + +#define ISL_KEY_BASE id +#define ISL_VAL_BASE ast_expr +#include +#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 index 00000000..a0f6080e --- /dev/null +++ b/isl_id_to_ast_expr.c @@ -0,0 +1,10 @@ +#include + +#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 -- 2.11.4.GIT