From 409470b6c4cb8f63c276781e1ed2ed9762672090 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 26 Jan 2013 18:40:59 +0100 Subject: [PATCH] add isl_union_pw_multi_aff_read_from_str Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/aff.h | 3 +++ isl_input.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 999e2f4a..a183d3f2 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4008,6 +4008,9 @@ An expression can be read from input using isl_ctx *ctx, const char *str); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str( isl_ctx *ctx, const char *str); + __isl_give isl_union_pw_multi_aff * + isl_union_pw_multi_aff_read_from_str( + isl_ctx *ctx, const char *str); An expression can be printed using diff --git a/include/isl/aff.h b/include/isl/aff.h index 87d27bd9..af8233f0 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -514,6 +514,9 @@ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_union_set( __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_union_map( __isl_take isl_union_map *umap); +__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_read_from_str( + isl_ctx *ctx, const char *str); + __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(__isl_take isl_space *space); __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity( __isl_take isl_space *space); diff --git a/isl_input.c b/isl_input.c index bd3b7746..ba3d8f26 100644 --- a/isl_input.c +++ b/isl_input.c @@ -2751,6 +2751,47 @@ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(isl_ctx *ctx, return pma; } +/* Read an isl_union_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_union_pw_multi_aff. + * It would be more efficient if we were to construct + * the isl_union_pw_multi_aff directly. + */ +__isl_give isl_union_pw_multi_aff *isl_stream_read_union_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 || obj.type == isl_obj_set) + obj = to_union(s->ctx, obj); + if (obj.type == isl_obj_union_map) + return isl_union_pw_multi_aff_from_union_map(obj.v); + if (obj.type == isl_obj_union_set) + return isl_union_pw_multi_aff_from_union_set(obj.v); + + obj.type->free(obj.v); + isl_die(s->ctx, isl_error_invalid, "unexpected object type", + return NULL); +} + +/* Read an isl_union_pw_multi_aff from "str". + */ +__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_read_from_str( + isl_ctx *ctx, const char *str) +{ + isl_union_pw_multi_aff *upma; + struct isl_stream *s = isl_stream_new_str(ctx, str); + if (!s) + return NULL; + upma = isl_stream_read_union_pw_multi_aff(s); + isl_stream_free(s); + return upma; +} + /* Assuming "pa" represents a single affine expression defined on a universe * domain, extract this affine expression. */ -- 2.11.4.GIT