From 7f1168695c3eb674348128b3f7c465d3d977f0b9 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 1 Sep 2011 12:46:39 +0200 Subject: [PATCH] pip: optionally use isl_basic_set_partial_lexmin_pw_multi_aff Signed-off-by: Sven Verdoolaege --- pip.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++----------- pip_test.sh.in | 6 ++++-- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/pip.c b/pip.c index 6ee1c749..9cbdf934 100644 --- a/pip.c +++ b/pip.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include "isl_tab.h" #include "isl_sample.h" #include "isl_scan.h" #include #include +#include #include /* The input of this program is the same as that of the "example" program @@ -38,11 +40,23 @@ struct options { struct isl_options *isl; unsigned verify; + unsigned format; +}; + +#define FORMAT_SET 0 +#define FORMAT_AFF 1 + +struct isl_arg_choice pip_format[] = { + {"set", FORMAT_SET}, + {"affine", FORMAT_AFF}, + {0} }; struct isl_arg options_arg[] = { ISL_ARG_CHILD(struct options, isl, "isl", isl_options_arg, "isl options") ISL_ARG_BOOL(struct options, verify, 'T', "verify", 0, NULL) +ISL_ARG_CHOICE(struct options, format, 0, "format", + pip_format, FORMAT_SET, "output format") ISL_ARG_END }; @@ -265,8 +279,9 @@ int main(int argc, char **argv) { struct isl_ctx *ctx; struct isl_basic_set *context, *bset, *copy, *context_copy; - struct isl_set *set; + struct isl_set *set = NULL; struct isl_set *empty; + isl_pw_multi_aff *pma = NULL; int neg_one; char s[1024]; int urs_parms = 0; @@ -321,23 +336,44 @@ int main(int argc, char **argv) context_copy = isl_basic_set_copy(context); } - if (max) - set = isl_basic_set_partial_lexmax(bset, context, &empty); - else - set = isl_basic_set_partial_lexmin(bset, context, &empty); + if (options->format == FORMAT_AFF) { + if (max) + pma = isl_basic_set_partial_lexmax_pw_multi_aff(bset, + context, &empty); + else + pma = isl_basic_set_partial_lexmin_pw_multi_aff(bset, + context, &empty); + } else { + if (max) + set = isl_basic_set_partial_lexmax(bset, + context, &empty); + else + set = isl_basic_set_partial_lexmin(bset, + context, &empty); + } if (options->verify) { assert(!rational); + if (options->format == FORMAT_AFF) + set = isl_set_from_pw_multi_aff(pma); check_solution(copy, context_copy, set, empty, max); + isl_set_free(set); } else { - isl_set_print(set, stdout, 0, ISL_FORMAT_ISL); - fprintf(stdout, "\n"); - fprintf(stdout, "no solution: "); - isl_set_print(empty, stdout, 0, ISL_FORMAT_ISL); - fprintf(stdout, "\n"); + isl_printer *p; + p = isl_printer_to_file(ctx, stdout); + if (options->format == FORMAT_AFF) + p = isl_printer_print_pw_multi_aff(p, pma); + else + p = isl_printer_print_set(p, set); + p = isl_printer_end_line(p); + p = isl_printer_print_str(p, "no solution: "); + p = isl_printer_print_set(p, empty); + p = isl_printer_end_line(p); + isl_printer_free(p); + isl_set_free(set); + isl_pw_multi_aff_free(pma); } - isl_set_free(set); isl_set_free(empty); isl_ctx_free(ctx); diff --git a/pip_test.sh.in b/pip_test.sh.in index cdc5fb97..28ad1ef4 100755 --- a/pip_test.sh.in +++ b/pip_test.sh.in @@ -21,6 +21,8 @@ PIP_TESTS="\ for i in $PIP_TESTS; do echo $i; - ./isl_pip$EXEEXT --context=gbr -T < $srcdir/test_inputs/$i || exit - ./isl_pip$EXEEXT --context=lexmin -T < $srcdir/test_inputs/$i || exit + ./isl_pip$EXEEXT --format=set --context=gbr -T < $srcdir/test_inputs/$i || exit + ./isl_pip$EXEEXT --format=set --context=lexmin -T < $srcdir/test_inputs/$i || exit + ./isl_pip$EXEEXT --format=affine --context=gbr -T < $srcdir/test_inputs/$i || exit + ./isl_pip$EXEEXT --format=affine --context=lexmin -T < $srcdir/test_inputs/$i || exit done -- 2.11.4.GIT