From d8031a99244cac4100f54dfb0f25283518d66055 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 28 Aug 2011 14:18:46 +0200 Subject: [PATCH] add isl_pw_multi_aff_read_from_str Signed-off-by: Sven Verdoolaege --- doc/user.pod | 6 ++++++ include/isl/aff.h | 2 ++ isl_input.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 9e54f966..11cf6a28 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3053,6 +3053,12 @@ Operations include __isl_take isl_multi_aff *maff, __isl_take isl_set *context); +An expression can be read from input using + + #include + __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str( + isl_ctx *ctx, const char *str); + An expression can be printed using #include diff --git a/include/isl/aff.h b/include/isl/aff.h index 8815cafb..107e57a4 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -308,6 +308,8 @@ __isl_give isl_printer *isl_printer_print_pw_multi_aff(__isl_take isl_printer *p __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(__isl_take isl_set *set); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(__isl_take isl_map *map); +__isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(isl_ctx *ctx, + const char *str); void isl_pw_multi_aff_dump(__isl_keep isl_pw_multi_aff *pma); #if defined(__cplusplus) diff --git a/isl_input.c b/isl_input.c index 4436459c..acc3662c 100644 --- a/isl_input.c +++ b/isl_input.c @@ -2334,3 +2334,39 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_file(isl_ctx *ctx, isl_stream_free(s); return pwqp; } + +/* Read an isl_pw_multi_aff from "s". + * We currently read a generic object and if it turns out to be a set or + * a map, we convert that to an isl_pw_multi_aff. + * It would be more efficient if we were to construct the isl_pw_multi_aff + * directly. + */ +__isl_give isl_pw_multi_aff *isl_stream_read_pw_multi_aff(struct isl_stream *s) +{ + struct isl_obj obj; + + obj = obj_read(s); + if (!obj.v) + return NULL; + + if (obj.type == isl_obj_map) + return isl_pw_multi_aff_from_map(obj.v); + if (obj.type == isl_obj_set) + return isl_pw_multi_aff_from_set(obj.v); + + obj.type->free(obj.v); + isl_die(s->ctx, isl_error_invalid, "unexpected object type", + return NULL); +} + +__isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(isl_ctx *ctx, + const char *str) +{ + isl_pw_multi_aff *pma; + struct isl_stream *s = isl_stream_new_str(ctx, str); + if (!s) + return NULL; + pma = isl_stream_read_pw_multi_aff(s); + isl_stream_free(s); + return pma; +} -- 2.11.4.GIT