From c8db99d32321c886e018c85e336e67768eb68d1c Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Wed, 22 Jul 2020 10:06:56 +0200 Subject: [PATCH] Redo Update to ISL 0.22.1 GCC had a horrible .gitignore, untracked files were not applied --- gcc/isl/all.h | 14 ++++++++++++++ gcc/isl/check_reparse_templ.c | 32 ++++++++++++++++++++++++++++++++ gcc/isl/check_reparse_test_templ.c | 28 ++++++++++++++++++++++++++++ gcc/isl/check_type_range_templ.c | 20 ++++++++++++++++++++ gcc/isl/dep.c | 1 + gcc/isl/has_single_reference_templ.c | 12 ++++++++++++ gcc/isl/isl_aff_map.c | 517 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_bind_domain_templ.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_box.c | 407 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_domain_factor_templ.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_list_macro.h | 8 ++++++++ gcc/isl/isl_local_private.h | 8 ++++++++ gcc/isl/isl_maybe_ast_graft_list.h | 10 ++++++++++ gcc/isl/isl_multi_align_set.c | 7 +++++++ gcc/isl/isl_multi_align_templ.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_align_union_set.c | 7 +++++++ gcc/isl/isl_multi_arith_templ.c | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_bind_domain_templ.c | 14 ++++++++++++++ gcc/isl/isl_multi_bind_templ.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_dim_id_templ.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_domain_templ.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_explicit_domain.c | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_from_base_templ.c | 37 +++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_identity_templ.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_locals_templ.c | 17 +++++++++++++++++ gcc/isl/isl_multi_move_dims_templ.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_nan_templ.c | 17 +++++++++++++++++ gcc/isl/isl_multi_no_domain_templ.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_no_explicit_domain.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_param_templ.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_product_templ.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_pw_aff_explicit_domain.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_read_no_explicit_domain_templ.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_splice_templ.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_tuple_id_templ.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_union_pw_aff_explicit_domain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_multi_zero_templ.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_project_out_all_params_templ.c | 21 +++++++++++++++++++++ gcc/isl/isl_pw_bind_domain_templ.c | 14 ++++++++++++++ gcc/isl/isl_pw_eval.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_pw_templ.h | 5 +++++ gcc/isl/isl_set_to_ast_graft_list.c | 17 +++++++++++++++++ gcc/isl/isl_set_to_ast_graft_list.h | 18 ++++++++++++++++++ gcc/isl/isl_test_cpp-checked-conversion.cc | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_test_cpp-checked.cc | 311 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_test_cpp-generic.cc | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_test_cpp.cc | 321 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_test_list_templ.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/isl_test_python.py | 449 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/opt_type.h | 16 ++++++++++++++++ gcc/isl/print_yaml_field_templ.c | 22 ++++++++++++++++++++++ gcc/isl/py-compile | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/set_list_from_map_list_inl.c | 9 +++++++++ gcc/isl/uset_from_umap.c | 8 ++++++++ gcc/isl/cpp/cpp-checked-conversion.h.bot | 2 ++ gcc/isl/cpp/cpp-checked-conversion.h.top | 14 ++++++++++++++ gcc/isl/cpp/cpp-checked.h.bot | 2 ++ gcc/isl/cpp/cpp-checked.h.pre | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/cpp/cpp-checked.h.top | 10 ++++++++++ gcc/isl/cpp/cpp.h.bot | 2 ++ gcc/isl/cpp/cpp.h.pre | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/cpp/cpp.h.top | 10 ++++++++++ gcc/isl/interface/cpp.cc | 2589 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/interface/cpp.h | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/interface/cpp_conversion.cc | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/interface/cpp_conversion.h | 15 +++++++++++++++ gcc/isl/m4/ax_cxx_compile_stdcxx.m4 | 982 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/m4/ax_cxx_compile_stdcxx_11.m4 | 39 +++++++++++++++++++++++++++++++++++++++ gcc/isl/python/isl.py.top | 37 +++++++++++++++++++++++++++++++++++++ gcc/isl/include/isl/cpp-checked-conversion.h | 675 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/include/isl/cpp-checked.h | 12532 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/include/isl/cpp.h | 18118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/include/isl/fixed_box.h | 43 +++++++++++++++++++++++++++++++++++++++++++ gcc/isl/include/isl/id_type.h | 22 ++++++++++++++++++++++ gcc/isl/include/isl/space_type.h | 27 +++++++++++++++++++++++++++ gcc/isl/include/isl/stride_info.h | 30 ++++++++++++++++++++++++++++++ gcc/isl/include/isl/val_type.h | 22 ++++++++++++++++++++++ gcc/isl/test_inputs/codegen/bilinear.c | 9 +++++++++ gcc/isl/test_inputs/codegen/bilinear.st | 9 +++++++++ gcc/isl/test_inputs/codegen/component7.c | 6 ++++++ gcc/isl/test_inputs/codegen/component7.st | 11 +++++++++++ gcc/isl/test_inputs/codegen/group.c | 7 +++++++ gcc/isl/test_inputs/codegen/group.st | 2 ++ gcc/isl/test_inputs/schedule/bounded_coefficients.sc | 12 ++++++++++++ gcc/isl/test_inputs/schedule/bounded_coefficients.st | 5 +++++ gcc/isl/test_inputs/schedule/carry_bounded_coefficients.sc | 19 +++++++++++++++++++ gcc/isl/test_inputs/schedule/carry_bounded_coefficients.st | 5 +++++ gcc/isl/test_inputs/schedule/flat1.sc | 3 +++ gcc/isl/test_inputs/schedule/flat1.st | 5 +++++ gcc/isl/test_inputs/schedule/flat2.sc | 3 +++ gcc/isl/test_inputs/schedule/flat2.st | 5 +++++ gcc/isl/test_inputs/schedule/flat3.sc | 3 +++ gcc/isl/test_inputs/schedule/flat3.st | 5 +++++ gcc/isl/test_inputs/schedule/flat4.sc | 3 +++ gcc/isl/test_inputs/schedule/flat4.st | 5 +++++ gcc/isl/test_inputs/schedule/flat5.sc | 3 +++ gcc/isl/test_inputs/schedule/flat5.st | 5 +++++ gcc/isl/test_inputs/schedule/flat6.sc | 3 +++ gcc/isl/test_inputs/schedule/flat6.st | 5 +++++ gcc/isl/test_inputs/schedule/max_coincidence.sc | 7 +++++++ gcc/isl/test_inputs/schedule/max_coincidence.st | 13 +++++++++++++ gcc/isl/test_inputs/schedule/nomax_coincidence.sc | 7 +++++++ gcc/isl/test_inputs/schedule/nomax_coincidence.st | 9 +++++++++ gcc/isl/test_inputs/schedule/poliwoda.sc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ gcc/isl/test_inputs/schedule/poliwoda.st | 5 +++++ 105 files changed, 41233 insertions(+) diff --git a/gcc/isl/all.h b/gcc/isl/all.h new file mode 100644 index 0000000..dea77dd 100644 --- /dev/null +++ a/gcc/isl/all.h @@ -1,0 +1,14 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/isl/check_reparse_templ.c b/gcc/isl/check_reparse_templ.c new file mode 100644 index 0000000..333c44c 100644 --- /dev/null +++ a/gcc/isl/check_reparse_templ.c @@ -1,0 +1,32 @@ +#define xCAT(A,B) A ## B +#define CAT(A,B) xCAT(A,B) +#undef TYPE +#define TYPE CAT(isl_,BASE) +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Check that printing "obj" and parsing the output results + * in the same expression. + */ +static isl_stat FN(check_reparse,BASE)(isl_ctx *ctx, + __isl_take TYPE *obj) +{ + char *str; + isl_bool equal; + TYPE *obj2; + + str = FN(TYPE,to_str)(obj); + obj2 = FN(TYPE,read_from_str)(ctx, str); + free(str); + equal = FN(TYPE,plain_is_equal)(obj, obj2); + FN(TYPE,free)(obj); + FN(TYPE,free)(obj2); + if (equal < 0) + return isl_stat_error; + if (!equal) + isl_die(ctx, isl_error_unknown, + "parsed function not equal to original", + return isl_stat_error); + + return isl_stat_ok; +} diff --git a/gcc/isl/check_reparse_test_templ.c b/gcc/isl/check_reparse_test_templ.c new file mode 100644 index 0000000..58c194c 100644 --- /dev/null +++ a/gcc/isl/check_reparse_test_templ.c @@ -1,0 +1,28 @@ +#define xCAT(A,B) A ## B +#define CAT(A,B) xCAT(A,B) +#undef TYPE +#define TYPE CAT(isl_,BASE) +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +#define TESTS CAT(reparse_,CAT(BASE,_tests)) + +/* Test parsing of objects of type TYPE by printing + * the expressions and checking that parsing the output results + * in the same expression. + * Do this for a set of expressions parsed from strings. + */ +static isl_stat FN(check,TESTS)(isl_ctx *ctx) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(TESTS); ++i) { + TYPE *obj; + + obj = FN(TYPE,read_from_str)(ctx, TESTS[i]); + if (FN(check_reparse,BASE)(ctx, obj) < 0) + return isl_stat_error; + } + + return isl_stat_ok; +} diff --git a/gcc/isl/check_type_range_templ.c b/gcc/isl/check_type_range_templ.c new file mode 100644 index 0000000..4e4c1e2 100644 --- /dev/null +++ a/gcc/isl/check_type_range_templ.c @@ -1,0 +1,20 @@ +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Check that there are "n" dimensions of type "type" starting at "first" + * in "obj". + */ +isl_stat FN(TYPE,check_range)(__isl_keep TYPE *obj, + enum isl_dim_type type, unsigned first, unsigned n) +{ + isl_size dim; + + dim = FN(TYPE,dim)(obj, type); + if (dim < 0) + return isl_stat_error; + if (first + n > dim || first + n < first) + isl_die(FN(TYPE,get_ctx)(obj), isl_error_invalid, + "position or range out of bounds", + return isl_stat_error); + return isl_stat_ok; +} diff --git a/gcc/isl/dep.c b/gcc/isl/dep.c new file mode 100644 index 0000000..3344a3c 100644 --- /dev/null +++ a/gcc/isl/dep.c @@ -1,0 +1,1 @@ +#include "all.h" diff --git a/gcc/isl/has_single_reference_templ.c b/gcc/isl/has_single_reference_templ.c new file mode 100644 index 0000000..332f6b2 100644 --- /dev/null +++ a/gcc/isl/has_single_reference_templ.c @@ -1,0 +1,12 @@ +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Does "obj" have a single reference? + * That is, can "obj" be changed inplace? + */ +isl_bool FN(TYPE,has_single_reference)(__isl_keep TYPE *obj) +{ + if (!obj) + return isl_bool_error; + return obj->ref == 1; +} diff --git a/gcc/isl/isl_aff_map.c b/gcc/isl/isl_aff_map.c new file mode 100644 index 0000000..0228bd3 100644 --- /dev/null +++ a/gcc/isl/isl_aff_map.c @@ -1,0 +1,517 @@ +/* + * Copyright 2011 INRIA Saclay + * Copyright 2012-2013 Ecole Normale Superieure + * Copyright 2016 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* Check that the input living in "space" lives in a map space. + * That is, check that "space" is a map space. + */ +static isl_stat check_input_is_map(__isl_keep isl_space *space) +{ + isl_bool is_set; + + is_set = isl_space_is_set(space); + if (is_set < 0) + return isl_stat_error; + if (is_set) + isl_die(isl_space_get_ctx(space), isl_error_invalid, + "space of input is not a map", return isl_stat_error); + return isl_stat_ok; +} + +/* Check that the input living in "space" lives in a set space. + * That is, check that "space" is a set space. + */ +static isl_stat check_input_is_set(__isl_keep isl_space *space) +{ + isl_bool is_set; + + is_set = isl_space_is_set(space); + if (is_set < 0) + return isl_stat_error; + if (!is_set) + isl_die(isl_space_get_ctx(space), isl_error_invalid, + "space of input is not a set", return isl_stat_error); + return isl_stat_ok; +} + +/* Construct a basic map mapping the domain of the affine expression + * to a one-dimensional range prescribed by the affine expression. + * If "rational" is set, then construct a rational basic map. + * + * A NaN affine expression cannot be converted to a basic map. + */ +static __isl_give isl_basic_map *isl_basic_map_from_aff2( + __isl_take isl_aff *aff, int rational) +{ + int k; + int pos; + isl_bool is_nan; + isl_local_space *ls; + isl_basic_map *bmap = NULL; + + if (!aff) + return NULL; + is_nan = isl_aff_is_nan(aff); + if (is_nan < 0) + goto error; + if (is_nan) + isl_die(isl_aff_get_ctx(aff), isl_error_invalid, + "cannot convert NaN", goto error); + + ls = isl_aff_get_local_space(aff); + bmap = isl_basic_map_from_local_space(ls); + bmap = isl_basic_map_extend_constraints(bmap, 1, 0); + k = isl_basic_map_alloc_equality(bmap); + if (k < 0) + goto error; + + pos = isl_basic_map_offset(bmap, isl_dim_out); + isl_seq_cpy(bmap->eq[k], aff->v->el + 1, pos); + isl_int_neg(bmap->eq[k][pos], aff->v->el[0]); + isl_seq_cpy(bmap->eq[k] + pos + 1, aff->v->el + 1 + pos, + aff->v->size - (pos + 1)); + + isl_aff_free(aff); + if (rational) + bmap = isl_basic_map_set_rational(bmap); + bmap = isl_basic_map_gauss(bmap, NULL); + bmap = isl_basic_map_finalize(bmap); + return bmap; +error: + isl_aff_free(aff); + isl_basic_map_free(bmap); + return NULL; +} + +/* Construct a basic map mapping the domain of the affine expression + * to a one-dimensional range prescribed by the affine expression. + */ +__isl_give isl_basic_map *isl_basic_map_from_aff(__isl_take isl_aff *aff) +{ + return isl_basic_map_from_aff2(aff, 0); +} + +/* Construct a map mapping the domain of the affine expression + * to a one-dimensional range prescribed by the affine expression. + */ +__isl_give isl_map *isl_map_from_aff(__isl_take isl_aff *aff) +{ + isl_basic_map *bmap; + + bmap = isl_basic_map_from_aff(aff); + return isl_map_from_basic_map(bmap); +} + +/* Construct a basic map mapping the domain of the multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression. + * If "rational" is set, then construct a rational basic map. + */ +__isl_give isl_basic_map *isl_basic_map_from_multi_aff2( + __isl_take isl_multi_aff *maff, int rational) +{ + int i; + isl_size dim; + isl_space *space; + isl_basic_map *bmap; + + dim = isl_multi_aff_dim(maff, isl_dim_out); + if (dim < 0) + goto error; + + if (dim != maff->n) + isl_die(isl_multi_aff_get_ctx(maff), isl_error_internal, + "invalid space", goto error); + + space = isl_space_domain(isl_multi_aff_get_space(maff)); + bmap = isl_basic_map_universe(isl_space_from_domain(space)); + if (rational) + bmap = isl_basic_map_set_rational(bmap); + + for (i = 0; i < maff->n; ++i) { + isl_aff *aff; + isl_basic_map *bmap_i; + + aff = isl_aff_copy(maff->u.p[i]); + bmap_i = isl_basic_map_from_aff2(aff, rational); + + bmap = isl_basic_map_flat_range_product(bmap, bmap_i); + } + + bmap = isl_basic_map_reset_space(bmap, isl_multi_aff_get_space(maff)); + + isl_multi_aff_free(maff); + return bmap; +error: + isl_multi_aff_free(maff); + return NULL; +} + +/* Construct a basic map mapping the domain of the multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression. + * If "ma" lives in a set space, then the result is actually a set. + */ +static __isl_give isl_basic_map *basic_map_from_multi_aff( + __isl_take isl_multi_aff *ma) +{ + return isl_basic_map_from_multi_aff2(ma, 0); +} + +/* Construct a basic map mapping the domain of the multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression. + */ +__isl_give isl_basic_map *isl_basic_map_from_multi_aff( + __isl_take isl_multi_aff *ma) +{ + if (check_input_is_map(isl_multi_aff_peek_space(ma)) < 0) + ma = isl_multi_aff_free(ma); + return basic_map_from_multi_aff(ma); +} + +/* Construct a basic set mapping the parameter domain + * of the multi-affine expression to its space, with each dimension + * in the space equated to the corresponding affine expression. + */ +__isl_give isl_basic_set *isl_basic_set_from_multi_aff( + __isl_take isl_multi_aff *ma) +{ + if (check_input_is_set(isl_multi_aff_peek_space(ma)) < 0) + ma = isl_multi_aff_free(ma); + return bset_from_bmap(basic_map_from_multi_aff(ma)); +} + +/* Construct a map mapping the domain of the multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression. + * If "maff" lives in a set space, then the result is actually a set. + */ +__isl_give isl_map *isl_map_from_multi_aff_internal( + __isl_take isl_multi_aff *maff) +{ + isl_basic_map *bmap; + + bmap = basic_map_from_multi_aff(maff); + return isl_map_from_basic_map(bmap); +} + +/* Construct a map mapping the domain the multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression. + */ +__isl_give isl_map *isl_map_from_multi_aff(__isl_take isl_multi_aff *ma) +{ + if (check_input_is_map(isl_multi_aff_peek_space(ma)) < 0) + ma = isl_multi_aff_free(ma); + return isl_map_from_multi_aff_internal(ma); +} + +/* Construct a set mapping the parameter domain the multi-affine expression + * to its space, with each dimension in the space equated to the + * corresponding affine expression. + */ +__isl_give isl_set *isl_set_from_multi_aff(__isl_take isl_multi_aff *ma) +{ + if (check_input_is_set(isl_multi_aff_peek_space(ma)) < 0) + ma = isl_multi_aff_free(ma); + return isl_map_from_multi_aff_internal(ma); +} + +/* Construct a basic map mapping a domain in the given space to + * to an n-dimensional range, with n the number of elements in the list, + * where each coordinate in the range is prescribed by the + * corresponding affine expression. + * The domains of all affine expressions in the list are assumed to match + * domain_space. + */ +__isl_give isl_basic_map *isl_basic_map_from_aff_list( + __isl_take isl_space *domain_space, __isl_take isl_aff_list *list) +{ + int i; + isl_space *space; + isl_basic_map *bmap; + + if (!list) + return NULL; + + space = isl_space_from_domain(domain_space); + bmap = isl_basic_map_universe(space); + + for (i = 0; i < list->n; ++i) { + isl_aff *aff; + isl_basic_map *bmap_i; + + aff = isl_aff_copy(list->p[i]); + bmap_i = isl_basic_map_from_aff(aff); + + bmap = isl_basic_map_flat_range_product(bmap, bmap_i); + } + + isl_aff_list_free(list); + return bmap; +} + +/* Construct a map with as domain the domain of pwaff and + * one-dimensional range corresponding to the affine expressions. + * If "pwaff" lives in a set space, then the result is actually a set. + */ +__isl_give isl_map *isl_map_from_pw_aff_internal(__isl_take isl_pw_aff *pwaff) +{ + int i; + isl_space *space; + isl_map *map; + + if (!pwaff) + return NULL; + + space = isl_pw_aff_get_space(pwaff); + map = isl_map_empty(space); + + for (i = 0; i < pwaff->n; ++i) { + isl_basic_map *bmap; + isl_map *map_i; + + bmap = isl_basic_map_from_aff(isl_aff_copy(pwaff->p[i].aff)); + map_i = isl_map_from_basic_map(bmap); + map_i = isl_map_intersect_domain(map_i, + isl_set_copy(pwaff->p[i].set)); + map = isl_map_union_disjoint(map, map_i); + } + + isl_pw_aff_free(pwaff); + + return map; +} + +/* Construct a map with as domain the domain of pwaff and + * one-dimensional range corresponding to the affine expressions. + */ +__isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff) +{ + if (check_input_is_map(isl_pw_aff_peek_space(pwaff)) < 0) + pwaff = isl_pw_aff_free(pwaff); + return isl_map_from_pw_aff_internal(pwaff); +} + +/* Construct a one-dimensional set with as parameter domain + * the domain of pwaff and the single set dimension + * corresponding to the affine expressions. + */ +__isl_give isl_set *isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff) +{ + if (check_input_is_set(isl_pw_aff_peek_space(pwaff)) < 0) + pwaff = isl_pw_aff_free(pwaff); + return set_from_map(isl_map_from_pw_aff_internal(pwaff)); +} + +/* Construct a map mapping the domain of the piecewise multi-affine expression + * to its range, with each dimension in the range equated to the + * corresponding affine expression on its cell. + * + * If the domain of "pma" is rational, then so is the constructed "map". + */ +__isl_give isl_map *isl_map_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma) +{ + int i; + isl_map *map; + + if (!pma) + return NULL; + + map = isl_map_empty(isl_pw_multi_aff_get_space(pma)); + + for (i = 0; i < pma->n; ++i) { + isl_bool rational; + isl_multi_aff *maff; + isl_basic_map *bmap; + isl_map *map_i; + + rational = isl_set_is_rational(pma->p[i].set); + if (rational < 0) + map = isl_map_free(map); + maff = isl_multi_aff_copy(pma->p[i].maff); + bmap = isl_basic_map_from_multi_aff2(maff, rational); + map_i = isl_map_from_basic_map(bmap); + map_i = isl_map_intersect_domain(map_i, + isl_set_copy(pma->p[i].set)); + map = isl_map_union_disjoint(map, map_i); + } + + isl_pw_multi_aff_free(pma); + return map; +} + +__isl_give isl_set *isl_set_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma) +{ + if (check_input_is_set(isl_pw_multi_aff_peek_space(pma)) < 0) + pma = isl_pw_multi_aff_free(pma); + return set_from_map(isl_map_from_pw_multi_aff(pma)); +} + +/* Construct a set or map mapping the shared (parameter) domain + * of the piecewise affine expressions to the range of "mpa" + * with each dimension in the range equated to the + * corresponding piecewise affine expression. + */ +static __isl_give isl_map *map_from_multi_pw_aff( + __isl_take isl_multi_pw_aff *mpa) +{ + int i; + isl_size dim; + isl_space *space; + isl_map *map; + + dim = isl_multi_pw_aff_dim(mpa, isl_dim_out); + if (dim < 0) + goto error; + + if (isl_space_dim(mpa->space, isl_dim_out) != mpa->n) + isl_die(isl_multi_pw_aff_get_ctx(mpa), isl_error_internal, + "invalid space", goto error); + + space = isl_multi_pw_aff_get_domain_space(mpa); + map = isl_map_universe(isl_space_from_domain(space)); + + for (i = 0; i < mpa->n; ++i) { + isl_pw_aff *pa; + isl_map *map_i; + + pa = isl_pw_aff_copy(mpa->u.p[i]); + map_i = isl_map_from_pw_aff_internal(pa); + + map = isl_map_flat_range_product(map, map_i); + } + + map = isl_map_reset_space(map, isl_multi_pw_aff_get_space(mpa)); + + isl_multi_pw_aff_free(mpa); + return map; +error: + isl_multi_pw_aff_free(mpa); + return NULL; +} + +/* Construct a map mapping the shared domain + * of the piecewise affine expressions to the range of "mpa" + * with each dimension in the range equated to the + * corresponding piecewise affine expression. + */ +__isl_give isl_map *isl_map_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa) +{ + if (check_input_is_map(isl_multi_pw_aff_peek_space(mpa)) < 0) + mpa = isl_multi_pw_aff_free(mpa); + return map_from_multi_pw_aff(mpa); +} + +/* Construct a set mapping the shared parameter domain + * of the piecewise affine expressions to the space of "mpa" + * with each dimension in the range equated to the + * corresponding piecewise affine expression. + */ +__isl_give isl_set *isl_set_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa) +{ + if (check_input_is_set(isl_multi_pw_aff_peek_space(mpa)) < 0) + mpa = isl_multi_pw_aff_free(mpa); + return set_from_map(map_from_multi_pw_aff(mpa)); +} + +/* Convert "pa" to an isl_map and add it to *umap. + */ +static isl_stat map_from_pw_aff_entry(__isl_take isl_pw_aff *pa, void *user) +{ + isl_union_map **umap = user; + isl_map *map; + + map = isl_map_from_pw_aff(pa); + *umap = isl_union_map_add_map(*umap, map); + + return *umap ? isl_stat_ok : isl_stat_error; +} + +/* Construct a union map mapping the domain of the union + * piecewise affine expression to its range, with the single output dimension + * equated to the corresponding affine expressions on their cells. + */ +__isl_give isl_union_map *isl_union_map_from_union_pw_aff( + __isl_take isl_union_pw_aff *upa) +{ + isl_space *space; + isl_union_map *umap; + + if (!upa) + return NULL; + + space = isl_union_pw_aff_get_space(upa); + umap = isl_union_map_empty(space); + + if (isl_union_pw_aff_foreach_pw_aff(upa, &map_from_pw_aff_entry, + &umap) < 0) + umap = isl_union_map_free(umap); + + isl_union_pw_aff_free(upa); + return umap; +} + +/* Convert "pma" to an isl_map and add it to *umap. + */ +static isl_stat map_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma, + void *user) +{ + isl_union_map **umap = user; + isl_map *map; + + map = isl_map_from_pw_multi_aff(pma); + *umap = isl_union_map_add_map(*umap, map); + + return isl_stat_ok; +} + +/* Construct a union map mapping the domain of the union + * piecewise multi-affine expression to its range, with each dimension + * in the range equated to the corresponding affine expression on its cell. + */ +__isl_give isl_union_map *isl_union_map_from_union_pw_multi_aff( + __isl_take isl_union_pw_multi_aff *upma) +{ + isl_space *space; + isl_union_map *umap; + + if (!upma) + return NULL; + + space = isl_union_pw_multi_aff_get_space(upma); + umap = isl_union_map_empty(space); + + if (isl_union_pw_multi_aff_foreach_pw_multi_aff(upma, + &map_from_pw_multi_aff, &umap) < 0) + goto error; + + isl_union_pw_multi_aff_free(upma); + return umap; +error: + isl_union_pw_multi_aff_free(upma); + isl_union_map_free(umap); + return NULL; +} diff --git a/gcc/isl/isl_bind_domain_templ.c b/gcc/isl/isl_bind_domain_templ.c new file mode 100644 index 0000000..06cbf07 100644 --- /dev/null +++ a/gcc/isl/isl_bind_domain_templ.c @@ -1,0 +1,168 @@ +/* + * Copyright 2018 Cerebras Systems + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA + */ + +#include + +/* Merge parameter "param" into the input dimension "i" of "obj". + * + * First plug in the parameter for the input dimension in "obj". + * The drop the (now defunct) input dimension and + * move the parameter in its original position. + * Since dimension manipulations destroy spaces, modify the space + * separately by only dropping the parameter. + */ +static __isl_give TYPE *FN(TYPE,merge_param)(__isl_take TYPE *obj, int i, + int param) +{ + isl_id *id; + isl_aff *aff; + isl_space *space; + isl_multi_aff *ma; + + space = FN(TYPE,get_domain_space)(obj); + id = isl_space_get_dim_id(space, isl_dim_param, param); + aff = isl_aff_param_on_domain_space_id(isl_space_copy(space), id); + space = isl_space_map_from_set(space); + ma = isl_multi_aff_identity(space); + ma = isl_multi_aff_set_aff(ma, i, aff); + obj = FN(TYPE,pullback_multi_aff)(obj, ma); + space = FN(TYPE,get_domain_space)(obj); + obj = FN(TYPE,drop_dims)(obj, isl_dim_in, i, 1); + obj = FN(TYPE,move_dims)(obj, isl_dim_in, i, isl_dim_param, param, 1); + space = isl_space_drop_dims(space, isl_dim_param, param, 1); + obj = FN(TYPE,reset_domain_space)(obj, space); + + return obj; +} + +/* Given a tuple of identifiers "tuple" that correspond + * to the initial input dimensions of "obj", + * if any of those identifiers appear as parameters + * in "obj", then equate those parameters with the corresponding + * input dimensions and project out the parameters. + * The result therefore has no such parameters. + */ +static __isl_give TYPE *FN(TYPE,equate_initial_params)(__isl_take TYPE *obj, + __isl_keep isl_multi_id *tuple) +{ + int i; + isl_size n; + + n = isl_multi_id_size(tuple); + if (n < 0) + return FN(TYPE,free)(obj); + for (i = 0; i < n; ++i) { + isl_id *id; + int pos; + + id = isl_multi_id_get_at(tuple, i); + if (!id) + return FN(TYPE,free)(obj); + pos = FN(TYPE,find_dim_by_id)(obj, isl_dim_param, id); + isl_id_free(id); + if (pos < 0) + continue; + obj = FN(TYPE,merge_param)(obj, i, pos); + } + + return obj; +} + +/* Given a tuple of identifiers "tuple" in a space that corresponds + * to the domain of "obj", if any of those identifiers appear as parameters + * in "obj", then equate those parameters with the corresponding + * input dimensions and project out the parameters. + * The result therefore has no such parameters. + */ +static __isl_give TYPE *FN(TYPE,equate_domain_params)(__isl_take TYPE *obj, + __isl_keep isl_multi_id *tuple) +{ + isl_stat r; + isl_space *obj_space, *tuple_space; + + obj_space = FN(TYPE,get_space)(obj); + tuple_space = isl_multi_id_peek_space(tuple); + r = isl_space_check_domain_tuples(tuple_space, obj_space); + isl_space_free(obj_space); + if (r < 0) + return FN(TYPE,free)(obj); + + return FN(TYPE,equate_initial_params)(obj, tuple); +} + +/* Bind the domain dimensions of the function "obj" to parameters + * with identifiers specified by "tuple", living in the same space + * as the domain of "obj". + * + * If no parameters with these identifiers appear in "obj" already, + * then the domain dimensions are simply reinterpreted as parameters. + * Otherwise, the parameters are first equated to the corresponding + * domain dimensions. + */ +__isl_give TYPE *FN(TYPE,bind_domain)(__isl_take TYPE *obj, + __isl_take isl_multi_id *tuple) +{ + isl_space *space; + + obj = FN(TYPE,equate_domain_params)(obj, tuple); + space = FN(TYPE,get_space)(obj); + space = isl_space_bind_map_domain(space, tuple); + isl_multi_id_free(tuple); + obj = FN(TYPE,reset_space)(obj, space); + + return obj; +} + +/* Given a tuple of identifiers "tuple" in a space that corresponds + * to the domain of the wrapped relation in the domain of "obj", + * if any of those identifiers appear as parameters + * in "obj", then equate those parameters with the corresponding + * input dimensions and project out the parameters. + * The result therefore has no such parameters. + */ +static __isl_give TYPE *FN(TYPE,equate_domain_wrapped_domain_params)( + __isl_take TYPE *obj, __isl_keep isl_multi_id *tuple) +{ + isl_stat r; + isl_space *obj_space, *tuple_space; + + obj_space = FN(TYPE,get_space)(obj); + tuple_space = isl_multi_id_peek_space(tuple); + r = isl_space_check_domain_wrapped_domain_tuples(tuple_space, + obj_space); + isl_space_free(obj_space); + if (r < 0) + return FN(TYPE,free)(obj); + + return FN(TYPE,equate_initial_params)(obj, tuple); +} + +/* Given a function living in a space of the form [A -> B] -> C and + * a tuple of identifiers in A, bind the domain dimensions of the relation + * wrapped in the domain of "obj" with identifiers specified by "tuple", + * returning a function in the space B -> C. + * + * If no parameters with these identifiers appear in "obj" already, + * then the domain dimensions are simply reinterpreted as parameters. + * Otherwise, the parameters are first equated to the corresponding + * domain dimensions. + */ +__isl_give TYPE *FN(TYPE,bind_domain_wrapped_domain)(__isl_take TYPE *obj, + __isl_take isl_multi_id *tuple) +{ + isl_space *space; + + obj = FN(TYPE,equate_domain_wrapped_domain_params)(obj, tuple); + space = FN(TYPE,get_space)(obj); + space = isl_space_bind_domain_wrapped_domain(space, tuple); + isl_multi_id_free(tuple); + obj = FN(TYPE,reset_space)(obj, space); + + return obj; +} diff --git a/gcc/isl/isl_box.c b/gcc/isl/isl_box.c new file mode 100644 index 0000000..189dc22 100644 --- /dev/null +++ a/gcc/isl/isl_box.c @@ -1,0 +1,407 @@ +/* + * Copyright 2010-2011 INRIA Saclay + * Copyright 2012-2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Representation of a box of fixed size containing the elements + * [offset, offset + size). + * "size" lives in the target space of "offset". + * + * If any of the "offsets" is NaN, then the object represents + * the failure of finding a fixed-size box. + */ +struct isl_fixed_box { + isl_multi_aff *offset; + isl_multi_val *size; +}; + +/* Free "box" and return NULL. + */ +__isl_null isl_fixed_box *isl_fixed_box_free(__isl_take isl_fixed_box *box) +{ + if (!box) + return NULL; + isl_multi_aff_free(box->offset); + isl_multi_val_free(box->size); + free(box); + return NULL; +} + +/* Construct an isl_fixed_box with the given offset and size. + */ +static __isl_give isl_fixed_box *isl_fixed_box_alloc( + __isl_take isl_multi_aff *offset, __isl_take isl_multi_val *size) +{ + isl_ctx *ctx; + isl_fixed_box *box; + + if (!offset || !size) + goto error; + ctx = isl_multi_aff_get_ctx(offset); + box = isl_alloc_type(ctx, struct isl_fixed_box); + if (!box) + goto error; + box->offset = offset; + box->size = size; + + return box; +error: + isl_multi_aff_free(offset); + isl_multi_val_free(size); + return NULL; +} + +/* Construct an initial isl_fixed_box with zero offsets + * in the given space and zero corresponding sizes. + */ +static __isl_give isl_fixed_box *isl_fixed_box_init( + __isl_take isl_space *space) +{ + isl_multi_aff *offset; + isl_multi_val *size; + + offset = isl_multi_aff_zero(isl_space_copy(space)); + size = isl_multi_val_zero(isl_space_range(space)); + return isl_fixed_box_alloc(offset, size); +} + +/* Return a copy of "box". + */ +__isl_give isl_fixed_box *isl_fixed_box_copy(__isl_keep isl_fixed_box *box) +{ + isl_multi_aff *offset; + isl_multi_val *size; + + offset = isl_fixed_box_get_offset(box); + size = isl_fixed_box_get_size(box); + return isl_fixed_box_alloc(offset, size); +} + +/* Replace the offset and size in direction "pos" by "offset" and "size" + * (without checking whether "box" is a valid box). + */ +static __isl_give isl_fixed_box *isl_fixed_box_set_extent( + __isl_take isl_fixed_box *box, int pos, __isl_keep isl_aff *offset, + __isl_keep isl_val *size) +{ + if (!box) + return NULL; + box->offset = isl_multi_aff_set_aff(box->offset, pos, + isl_aff_copy(offset)); + box->size = isl_multi_val_set_val(box->size, pos, isl_val_copy(size)); + if (!box->offset || !box->size) + return isl_fixed_box_free(box); + return box; +} + +/* Replace the offset and size in direction "pos" by "offset" and "size", + * if "box" is a valid box. + */ +static __isl_give isl_fixed_box *isl_fixed_box_set_valid_extent( + __isl_take isl_fixed_box *box, int pos, __isl_keep isl_aff *offset, + __isl_keep isl_val *size) +{ + isl_bool valid; + + valid = isl_fixed_box_is_valid(box); + if (valid < 0 || !valid) + return box; + return isl_fixed_box_set_extent(box, pos, offset, size); +} + +/* Replace "box" by an invalid box, by setting all offsets to NaN + * (and all sizes to infinity). + */ +static __isl_give isl_fixed_box *isl_fixed_box_invalidate( + __isl_take isl_fixed_box *box) +{ + int i; + isl_size n; + isl_space *space; + isl_val *infty; + isl_aff *nan; + + if (!box) + return NULL; + n = isl_multi_val_dim(box->size, isl_dim_set); + if (n < 0) + return isl_fixed_box_free(box); + + infty = isl_val_infty(isl_fixed_box_get_ctx(box)); + space = isl_space_domain(isl_fixed_box_get_space(box)); + nan = isl_aff_nan_on_domain(isl_local_space_from_space(space)); + for (i = 0; i < n; ++i) + box = isl_fixed_box_set_extent(box, i, nan, infty); + isl_aff_free(nan); + isl_val_free(infty); + + if (!box->offset || !box->size) + return isl_fixed_box_free(box); + return box; +} + +/* Return the isl_ctx to which "box" belongs. + */ +isl_ctx *isl_fixed_box_get_ctx(__isl_keep isl_fixed_box *box) +{ + if (!box) + return NULL; + return isl_multi_aff_get_ctx(box->offset); +} + +/* Return the space in which "box" lives. + */ +__isl_give isl_space *isl_fixed_box_get_space(__isl_keep isl_fixed_box *box) +{ + if (!box) + return NULL; + return isl_multi_aff_get_space(box->offset); +} + +/* Does "box" contain valid information? + */ +isl_bool isl_fixed_box_is_valid(__isl_keep isl_fixed_box *box) +{ + if (!box) + return isl_bool_error; + return isl_bool_not(isl_multi_aff_involves_nan(box->offset)); +} + +/* Return the offsets of the box "box". + */ +__isl_give isl_multi_aff *isl_fixed_box_get_offset( + __isl_keep isl_fixed_box *box) +{ + if (!box) + return NULL; + return isl_multi_aff_copy(box->offset); +} + +/* Return the sizes of the box "box". + */ +__isl_give isl_multi_val *isl_fixed_box_get_size(__isl_keep isl_fixed_box *box) +{ + if (!box) + return NULL; + return isl_multi_val_copy(box->size); +} + +/* Data used in set_dim_extent and compute_size_in_direction. + * + * "bset" is a wrapped copy of the basic map that has the selected + * output dimension as range. + * "pos" is the position of the variable representing the output dimension, + * i.e., the variable for which the size should be computed. This variable + * is also the last variable in "bset". + * "size" is the best size found so far + * (infinity if no offset was found so far). + * "offset" is the offset corresponding to the best size + * (NULL if no offset was found so far). + */ +struct isl_size_info { + isl_basic_set *bset; + isl_size pos; + isl_val *size; + isl_aff *offset; +}; + +/* Is "c" a suitable bound on dimension "pos" for use as a lower bound + * of a fixed-size range. + * In particular, it needs to be a lower bound on "pos". + * In order for the final offset not to be too complicated, + * the constraint itself should also not involve any integer divisions. + */ +static isl_bool is_suitable_bound(__isl_keep isl_constraint *c, unsigned pos) +{ + isl_size n_div; + isl_bool is_bound, any_divs; + + is_bound = isl_constraint_is_lower_bound(c, isl_dim_set, pos); + if (is_bound < 0 || !is_bound) + return is_bound; + + n_div = isl_constraint_dim(c, isl_dim_div); + if (n_div < 0) + return isl_bool_error; + any_divs = isl_constraint_involves_dims(c, isl_dim_div, 0, n_div); + return isl_bool_not(any_divs); +} + +/* Given a constraint from the basic set describing the bounds on + * an array index, check if it is a lower bound, say m i >= b(x), and, + * if so, check whether the expression "i - ceil(b(x)/m) + 1" has a constant + * upper bound. If so, and if this bound is smaller than any bound + * derived from earlier constraints, set the size to this bound on + * the expression and the lower bound to ceil(b(x)/m). + */ +static isl_stat compute_size_in_direction(__isl_take isl_constraint *c, + void *user) +{ + struct isl_size_info *info = user; + isl_val *v; + isl_aff *aff; + isl_aff *lb; + isl_bool is_bound, better; + + is_bound = is_suitable_bound(c, info->pos); + if (is_bound < 0 || !is_bound) { + isl_constraint_free(c); + return is_bound < 0 ? isl_stat_error : isl_stat_ok; + } + + aff = isl_constraint_get_bound(c, isl_dim_set, info->pos); + aff = isl_aff_ceil(aff); + + lb = isl_aff_copy(aff); + + aff = isl_aff_neg(aff); + aff = isl_aff_add_coefficient_si(aff, isl_dim_in, info->pos, 1); + + v = isl_basic_set_max_val(info->bset, aff); + isl_aff_free(aff); + + v = isl_val_add_ui(v, 1); + better = isl_val_lt(v, info->size); + if (better >= 0 && better) { + isl_val_free(info->size); + info->size = isl_val_copy(v); + lb = isl_aff_domain_factor_domain(lb); + isl_aff_free(info->offset); + info->offset = isl_aff_copy(lb); + } + isl_val_free(v); + isl_aff_free(lb); + + isl_constraint_free(c); + + return better < 0 ? isl_stat_error : isl_stat_ok; +} + +/* Look for a fixed-size range of values for the output dimension "pos" + * of "map", by looking for a lower-bound expression in the parameters + * and input dimensions such that the range of the output dimension + * is a constant shifted by this expression. + * + * In particular, look through the explicit lower bounds on the output dimension + * for candidate expressions and pick the one that results in the smallest size. + * Initialize the size with infinity and if no better size is found + * then invalidate the box. Otherwise, set the offset and size + * in the given direction by those that correspond to the smallest size. + */ +static __isl_give isl_fixed_box *set_dim_extent(__isl_take isl_fixed_box *box, + __isl_keep isl_map *map, int pos) +{ + struct isl_size_info info; + isl_bool valid; + isl_ctx *ctx; + + if (!box || !map) + return isl_fixed_box_free(box); + + ctx = isl_map_get_ctx(map); + map = isl_map_copy(map); + map = isl_map_project_onto(map, isl_dim_out, pos, 1); + map = isl_map_compute_divs(map); + info.size = isl_val_infty(ctx); + info.offset = NULL; + info.pos = isl_map_dim(map, isl_dim_in); + info.bset = isl_basic_map_wrap(isl_map_simple_hull(map)); + if (info.pos < 0) + info.bset = isl_basic_set_free(info.bset); + if (isl_basic_set_foreach_constraint(info.bset, + &compute_size_in_direction, &info) < 0) + box = isl_fixed_box_free(box); + valid = isl_val_is_int(info.size); + if (valid < 0) + box = isl_fixed_box_free(box); + else if (valid) + box = isl_fixed_box_set_valid_extent(box, pos, + info.offset, info.size); + else + box = isl_fixed_box_invalidate(box); + isl_val_free(info.size); + isl_aff_free(info.offset); + isl_basic_set_free(info.bset); + + return box; +} + +/* Try and construct a fixed-size rectangular box with an offset + * in terms of the domain of "map" that contains the range of "map". + * If no such box can be constructed, then return an invalidated box, + * i.e., one where isl_fixed_box_is_valid returns false. + * + * Iterate over the dimensions in the range + * setting the corresponding offset and extent. + */ +__isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull( + __isl_keep isl_map *map) +{ + int i; + isl_size n; + isl_space *space; + isl_fixed_box *box; + + n = isl_map_dim(map, isl_dim_out); + if (n < 0) + return NULL; + space = isl_map_get_space(map); + box = isl_fixed_box_init(space); + + map = isl_map_detect_equalities(isl_map_copy(map)); + for (i = 0; i < n; ++i) { + isl_bool valid; + + box = set_dim_extent(box, map, i); + valid = isl_fixed_box_is_valid(box); + if (valid < 0 || !valid) + break; + } + isl_map_free(map); + + return box; +} + +#undef BASE +#define BASE multi_val +#include "print_yaml_field_templ.c" + +#undef BASE +#define BASE multi_aff +#include "print_yaml_field_templ.c" + +/* Print the information contained in "box" to "p". + * The information is printed as a YAML document. + */ +__isl_give isl_printer *isl_printer_print_fixed_box( + __isl_take isl_printer *p, __isl_keep isl_fixed_box *box) +{ + if (!box) + return isl_printer_free(p); + + p = isl_printer_yaml_start_mapping(p); + p = print_yaml_field_multi_aff(p, "offset", box->offset); + p = print_yaml_field_multi_val(p, "size", box->size); + p = isl_printer_yaml_end_mapping(p); + + return p; +} + +#undef BASE +#define BASE fixed_box +#include diff --git a/gcc/isl/isl_domain_factor_templ.c b/gcc/isl/isl_domain_factor_templ.c new file mode 100644 index 0000000..c64e9a2 100644 --- /dev/null +++ a/gcc/isl/isl_domain_factor_templ.c @@ -1,0 +1,67 @@ +/* + * Copyright 2012 Ecole Normale Superieure + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Drop the "n" domain dimensions starting at "first" from "obj", + * after checking that they do not appear in the affine expression. + */ +static __isl_give TYPE *FN(TYPE,drop_domain)(__isl_take TYPE *obj, + unsigned first, unsigned n) +{ + isl_bool involves; + + involves = FN(TYPE,involves_dims)(obj, isl_dim_in, first, n); + if (involves < 0) + return FN(TYPE,free)(obj); + if (involves) + isl_die(FN(TYPE,get_ctx)(obj), isl_error_invalid, + "affine expression involves some of the domain dimensions", + return FN(TYPE,free)(obj)); + return FN(TYPE,drop_dims)(obj, isl_dim_in, first, n); +} + +/* Check that the domain of "obj" is a product. + */ +static isl_stat FN(TYPE,check_domain_product)(__isl_keep TYPE *obj) +{ + isl_bool is_product; + + is_product = FN(TYPE,domain_is_product)(obj); + if (is_product < 0) + return isl_stat_error; + if (!is_product) + isl_die(FN(TYPE,get_ctx)(obj), isl_error_invalid, + "domain is not a product", return isl_stat_error); + return isl_stat_ok; +} + +/* Given an affine function with a domain of the form [A -> B] that + * does not depend on B, return the same function on domain A. + */ +__isl_give TYPE *FN(TYPE,domain_factor_domain)(__isl_take TYPE *obj) +{ + isl_space *space; + isl_size n, n_in; + + if (FN(TYPE,check_domain_product)(obj) < 0) + return FN(TYPE,free)(obj); + space = FN(TYPE,get_domain_space)(obj); + n = isl_space_dim(space, isl_dim_set); + space = isl_space_factor_domain(space); + n_in = isl_space_dim(space, isl_dim_set); + if (n < 0 || n_in < 0) + obj = FN(TYPE,free)(obj); + else + obj = FN(TYPE,drop_domain)(obj, n_in, n - n_in); + obj = FN(TYPE,reset_domain_space)(obj, space); + return obj; +} diff --git a/gcc/isl/isl_list_macro.h b/gcc/isl/isl_list_macro.h new file mode 100644 index 0000000..72f258a 100644 --- /dev/null +++ a/gcc/isl/isl_list_macro.h @@ -1,0 +1,8 @@ +#define xCAT(A,B) A ## B +#define CAT(A,B) xCAT(A,B) +#undef EL +#define EL CAT(isl_,EL_BASE) +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) +#define xLIST(EL) EL ## _list +#define LIST(EL) xLIST(EL) diff --git a/gcc/isl/isl_local_private.h b/gcc/isl/isl_local_private.h new file mode 100644 index 0000000..bb44d36 100644 --- /dev/null +++ a/gcc/isl/isl_local_private.h @@ -1,0 +1,8 @@ +#ifndef ISL_LOCAL_PRIVATE_H +#define ISL_LOCAL_PRIVATE_H + +#include + +__isl_give isl_local *isl_local_alloc_from_mat(__isl_take isl_mat *mat); + +#endif diff --git a/gcc/isl/isl_maybe_ast_graft_list.h b/gcc/isl/isl_maybe_ast_graft_list.h new file mode 100644 index 0000000..1446691 100644 --- /dev/null +++ a/gcc/isl/isl_maybe_ast_graft_list.h @@ -1,0 +1,10 @@ +#ifndef ISL_MAYBE_AST_GRAFT_LIST_H +#define ISL_MAYBE_AST_GRAFT_LIST_H + +#include "isl_ast_graft_private.h" + +#define ISL_TYPE isl_ast_graft_list +#include +#undef ISL_TYPE + +#endif diff --git a/gcc/isl/isl_multi_align_set.c b/gcc/isl/isl_multi_align_set.c new file mode 100644 index 0000000..d7ef608 100644 --- /dev/null +++ a/gcc/isl/isl_multi_align_set.c @@ -1,0 +1,7 @@ +#define ALIGN_DOMBASE set +#define ALIGN_DOM isl_set + +#include + +#undef ALIGN_DOMBASE +#undef ALIGN_DOM diff --git a/gcc/isl/isl_multi_align_templ.c b/gcc/isl/isl_multi_align_templ.c new file mode 100644 index 0000000..f4604f0 100644 --- /dev/null +++ a/gcc/isl/isl_multi_align_templ.c @@ -1,0 +1,45 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + */ + +/* Align the parameters of "multi" and "domain" (if needed) and + * call "fn". + */ +static __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),align_params),ALIGN_DOMBASE)( + __isl_take MULTI(BASE) *multi, __isl_take ALIGN_DOM *domain, + __isl_give MULTI(BASE) *fn(__isl_take MULTI(BASE) *multi, + __isl_take ALIGN_DOM *domain)) +{ + isl_bool aligned; + isl_bool named; + isl_space *dom_space; + + aligned = FN(ALIGN_DOM,space_has_equal_params)(domain, multi->space); + if (aligned < 0) + goto error; + if (aligned) + return fn(multi, domain); + + dom_space = FN(ALIGN_DOM,peek_space)(domain); + named = isl_space_has_named_params(multi->space); + if (named >= 0 && named) + named = isl_space_has_named_params(dom_space); + if (named < 0) + goto error; + if (!named) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid, + "unaligned unnamed parameters", goto error); + multi = FN(MULTI(BASE),align_params)(multi, + FN(ALIGN_DOM,get_space)(domain)); + domain = FN(ALIGN_DOM,align_params)(domain, + FN(MULTI(BASE),get_space)(multi)); + return fn(multi, domain); +error: + FN(MULTI(BASE),free)(multi); + FN(ALIGN_DOM,free)(domain); + return NULL; +} diff --git a/gcc/isl/isl_multi_align_union_set.c b/gcc/isl/isl_multi_align_union_set.c new file mode 100644 index 0000000..545a887 100644 --- /dev/null +++ a/gcc/isl/isl_multi_align_union_set.c @@ -1,0 +1,7 @@ +#define ALIGN_DOMBASE union_set +#define ALIGN_DOM isl_union_set + +#include + +#undef ALIGN_DOMBASE +#undef ALIGN_DOM diff --git a/gcc/isl/isl_multi_arith_templ.c b/gcc/isl/isl_multi_arith_templ.c new file mode 100644 index 0000000..2cef5df 100644 --- /dev/null +++ a/gcc/isl/isl_multi_arith_templ.c @@ -1,0 +1,256 @@ +/* + * Copyright 2011 Sven Verdoolaege + * Copyright 2012-2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include + +#include + +/* Add "multi2" to "multi1" and return the result. + * + * The parameters of "multi1" and "multi2" are assumed to have been aligned. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),add_aligned)( + __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2) +{ + return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,add)); +} + +/* Add "multi2" to "multi1" and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),add)(__isl_take MULTI(BASE) *multi1, + __isl_take MULTI(BASE) *multi2) +{ + return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2, + &FN(MULTI(BASE),add_aligned)); +} + +/* Subtract "multi2" from "multi1" and return the result. + * + * The parameters of "multi1" and "multi2" are assumed to have been aligned. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),sub_aligned)( + __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2) +{ + return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,sub)); +} + +/* Subtract "multi2" from "multi1" and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),sub)(__isl_take MULTI(BASE) *multi1, + __isl_take MULTI(BASE) *multi2) +{ + return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2, + &FN(MULTI(BASE),sub_aligned)); +} + +/* Multiply the elements of "multi" by "v" and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),scale_val)(__isl_take MULTI(BASE) *multi, + __isl_take isl_val *v) +{ + int i; + + if (!multi || !v) + goto error; + + if (isl_val_is_one(v)) { + isl_val_free(v); + return multi; + } + + if (!isl_val_is_rat(v)) + isl_die(isl_val_get_ctx(v), isl_error_invalid, + "expecting rational factor", goto error); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + for (i = 0; i < multi->n; ++i) { + multi->u.p[i] = FN(EL,scale_val)(multi->u.p[i], + isl_val_copy(v)); + if (!multi->u.p[i]) + goto error; + } + + isl_val_free(v); + return multi; +error: + isl_val_free(v); + return FN(MULTI(BASE),free)(multi); +} + +/* Divide the elements of "multi" by "v" and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),scale_down_val)( + __isl_take MULTI(BASE) *multi, __isl_take isl_val *v) +{ + int i; + + if (!multi || !v) + goto error; + + if (isl_val_is_one(v)) { + isl_val_free(v); + return multi; + } + + if (!isl_val_is_rat(v)) + isl_die(isl_val_get_ctx(v), isl_error_invalid, + "expecting rational factor", goto error); + if (isl_val_is_zero(v)) + isl_die(isl_val_get_ctx(v), isl_error_invalid, + "cannot scale down by zero", goto error); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + for (i = 0; i < multi->n; ++i) { + multi->u.p[i] = FN(EL,scale_down_val)(multi->u.p[i], + isl_val_copy(v)); + if (!multi->u.p[i]) + goto error; + } + + isl_val_free(v); + return multi; +error: + isl_val_free(v); + return FN(MULTI(BASE),free)(multi); +} + +/* Multiply the elements of "multi" by the corresponding element of "mv" + * and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),scale_multi_val)( + __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv) +{ + int i; + + if (!multi || !mv) + goto error; + + if (!isl_space_tuple_is_equal(multi->space, isl_dim_out, + mv->space, isl_dim_set)) + isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid, + "spaces don't match", goto error); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + goto error; + + for (i = 0; i < multi->n; ++i) { + isl_val *v; + + v = isl_multi_val_get_val(mv, i); + multi->u.p[i] = FN(EL,scale_val)(multi->u.p[i], v); + if (!multi->u.p[i]) + goto error; + } + + isl_multi_val_free(mv); + return multi; +error: + isl_multi_val_free(mv); + return FN(MULTI(BASE),free)(multi); +} + +/* Divide the elements of "multi" by the corresponding element of "mv" + * and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),scale_down_multi_val)( + __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv) +{ + int i; + + if (!multi || !mv) + goto error; + + if (!isl_space_tuple_is_equal(multi->space, isl_dim_out, + mv->space, isl_dim_set)) + isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid, + "spaces don't match", goto error); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + for (i = 0; i < multi->n; ++i) { + isl_val *v; + + v = isl_multi_val_get_val(mv, i); + multi->u.p[i] = FN(EL,scale_down_val)(multi->u.p[i], v); + if (!multi->u.p[i]) + goto error; + } + + isl_multi_val_free(mv); + return multi; +error: + isl_multi_val_free(mv); + return FN(MULTI(BASE),free)(multi); +} + +/* Compute the residues of the elements of "multi" modulo + * the corresponding element of "mv" and return the result. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),mod_multi_val)( + __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv) +{ + int i; + + if (!multi || !mv) + goto error; + + if (!isl_space_tuple_is_equal(multi->space, isl_dim_out, + mv->space, isl_dim_set)) + isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid, + "spaces don't match", goto error); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + goto error; + + for (i = 0; i < multi->n; ++i) { + isl_val *v; + + v = isl_multi_val_get_val(mv, i); + multi->u.p[i] = FN(EL,mod_val)(multi->u.p[i], v); + if (!multi->u.p[i]) + goto error; + } + + isl_multi_val_free(mv); + return multi; +error: + isl_multi_val_free(mv); + return FN(MULTI(BASE),free)(multi); +} + +/* Return the opposite of "multi". + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),neg)(__isl_take MULTI(BASE) *multi) +{ + int i; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + for (i = 0; i < multi->n; ++i) { + multi->u.p[i] = FN(EL,neg)(multi->u.p[i]); + if (!multi->u.p[i]) + return FN(MULTI(BASE),free)(multi); + } + + return multi; +} diff --git a/gcc/isl/isl_multi_bind_domain_templ.c b/gcc/isl/isl_multi_bind_domain_templ.c new file mode 100644 index 0000000..d7eec37 100644 --- /dev/null +++ a/gcc/isl/isl_multi_bind_domain_templ.c @@ -1,0 +1,14 @@ +/* + * Copyright 2018 Cerebras Systems + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA + */ + +#include + +#undef TYPE +#define TYPE MULTI(BASE) +#include diff --git a/gcc/isl/isl_multi_bind_templ.c b/gcc/isl/isl_multi_bind_templ.c new file mode 100644 index 0000000..ce2508c 100644 --- /dev/null +++ a/gcc/isl/isl_multi_bind_templ.c @@ -1,0 +1,65 @@ +/* + * Copyright 2018 Cerebras Systems + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA + */ + +/* Bind the expressions of "multi" to parameters with identifiers + * specified by "tuple", living in the same space as + * (the target space of) "multi", + * returning the elements in the domain where the expressions + * are equal to the parameters. + */ +__isl_give DOM *FN(MULTI(BASE),bind)(__isl_take MULTI(BASE) *multi, + __isl_take isl_multi_id *tuple) +{ + int i; + isl_id *id; + isl_stat r; + isl_size n; + isl_space *multi_space, *tuple_space; + EL *el; + DOM *bnd; + + multi_space = isl_space_range(FN(MULTI(BASE),get_space)(multi)); + tuple_space = isl_multi_id_peek_space(tuple); + r = isl_space_check_equal_tuples(multi_space, tuple_space); + isl_space_free(multi_space); + if (r < 0) + goto error; + n = FN(MULTI(BASE),dim)(multi, isl_dim_set); + if (n < 0) + goto error; + + if (n == 0) { + isl_multi_id_free(tuple); + return FN(MULTI(BASE),domain)(multi); + } + + el = FN(MULTI(BASE),get_at)(multi, 0); + id = isl_multi_id_get_at(tuple, 0); + bnd = FN(EL,bind_id)(el, id); + + for (i = 1; i < n; ++i) { + DOM *bnd_i; + + el = FN(MULTI(BASE),get_at)(multi, i); + id = isl_multi_id_get_at(tuple, i); + bnd_i = FN(EL,bind_id)(el, id); + + bnd_i = FN(DOM,align_params)(bnd_i, FN(DOM,get_space)(bnd)); + bnd = FN(DOM,align_params)(bnd, FN(DOM,get_space)(bnd_i)); + bnd = FN(DOM,intersect)(bnd, bnd_i); + } + + FN(MULTI(BASE),free)(multi); + isl_multi_id_free(tuple); + return bnd; +error: + FN(MULTI(BASE),free)(multi); + isl_multi_id_free(tuple); + return NULL; +} diff --git a/gcc/isl/isl_multi_dim_id_templ.c b/gcc/isl/isl_multi_dim_id_templ.c new file mode 100644 index 0000000..80dd7db 100644 --- /dev/null +++ a/gcc/isl/isl_multi_dim_id_templ.c @@ -1,0 +1,92 @@ +/* + * Copyright 2011 Sven Verdoolaege + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +/* Return the position of the dimension of the given type and name + * in "multi". + * Return -1 if no such dimension can be found. + */ +int FN(MULTI(BASE),find_dim_by_name)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type, const char *name) +{ + if (!multi) + return -1; + return isl_space_find_dim_by_name(multi->space, type, name); +} + +/* Return the position of the first dimension of "type" with id "id". + * Return -1 if there is no such dimension. + */ +int FN(MULTI(BASE),find_dim_by_id)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type, __isl_keep isl_id *id) +{ + if (!multi) + return -1; + return isl_space_find_dim_by_id(multi->space, type, id); +} + +/* Return the id of the given dimension. + */ +__isl_give isl_id *FN(MULTI(BASE),get_dim_id)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos) +{ + return multi ? isl_space_get_dim_id(multi->space, type, pos) : NULL; +} + +__isl_give MULTI(BASE) *FN(MULTI(BASE),set_dim_name)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos, const char *s) +{ + int i; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + multi->space = isl_space_set_dim_name(multi->space, type, pos, s); + if (!multi->space) + return FN(MULTI(BASE),free)(multi); + + if (type == isl_dim_out) + return multi; + for (i = 0; i < multi->n; ++i) { + multi->u.p[i] = FN(EL,set_dim_name)(multi->u.p[i], + type, pos, s); + if (!multi->u.p[i]) + return FN(MULTI(BASE),free)(multi); + } + + return multi; +} + +/* Set the id of the given dimension of "multi" to "id". + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),set_dim_id)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos, __isl_take isl_id *id) +{ + isl_space *space; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi || !id) + goto error; + + space = FN(MULTI(BASE),get_space)(multi); + space = isl_space_set_dim_id(space, type, pos, id); + + return FN(MULTI(BASE),reset_space)(multi, space); +error: + isl_id_free(id); + FN(MULTI(BASE),free)(multi); + return NULL; +} diff --git a/gcc/isl/isl_multi_domain_templ.c b/gcc/isl/isl_multi_domain_templ.c new file mode 100644 index 0000000..6aa97fe 100644 --- /dev/null +++ a/gcc/isl/isl_multi_domain_templ.c @@ -1,0 +1,42 @@ +/* + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +/* Return the shared domain of the elements of "multi". + * + * If "multi" has an explicit domain, then return this domain. + */ +__isl_give isl_set *FN(MULTI(BASE),domain)(__isl_take MULTI(BASE) *multi) +{ + int i; + isl_set *dom; + + if (!multi) + return NULL; + + if (FN(MULTI(BASE),has_explicit_domain)(multi)) { + dom = FN(MULTI(BASE),get_explicit_domain)(multi); + FN(MULTI(BASE),free)(multi); + return dom; + } + + dom = isl_set_universe(FN(MULTI(BASE),get_domain_space)(multi)); + for (i = 0; i < multi->n; ++i) { + isl_set *dom_i; + + dom_i = FN(EL,domain)(FN(FN(MULTI(BASE),get),BASE)(multi, i)); + dom = isl_set_intersect(dom, dom_i); + } + + FN(MULTI(BASE),free)(multi); + return dom; +} diff --git a/gcc/isl/isl_multi_explicit_domain.c b/gcc/isl/isl_multi_explicit_domain.c new file mode 100644 index 0000000..bb65823 100644 --- /dev/null +++ a/gcc/isl/isl_multi_explicit_domain.c @@ -1,0 +1,205 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +/* These versions of the explicit domain functions are used + * when the multi expression may have an explicit domain. + */ + +#include + +__isl_give MULTI(BASE) *FN(MULTI(BASE),cow)(__isl_take MULTI(BASE) *multi); + +/* Does "multi" have an explicit domain? + * + * An explicit domain is only available if "multi" is zero-dimensional. + */ +static int FN(MULTI(BASE),has_explicit_domain)(__isl_keep MULTI(BASE) *multi) +{ + return multi && multi->n == 0; +} + +/* Check that "multi" has an explicit domain. + */ +static isl_stat FN(MULTI(BASE),check_has_explicit_domain)( + __isl_keep MULTI(BASE) *multi) +{ + if (!multi) + return isl_stat_error; + if (!FN(MULTI(BASE),has_explicit_domain)(multi)) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_internal, + "expression does not have an explicit domain", + return isl_stat_error); + return isl_stat_ok; +} + +/* Return the explicit domain of "multi", assuming it has one. + */ +static __isl_keep DOM *FN(MULTI(BASE),peek_explicit_domain)( + __isl_keep MULTI(BASE) *multi) +{ + if (FN(MULTI(BASE),check_has_explicit_domain)(multi) < 0) + return NULL; + return multi->u.dom; +} + +/* Return a copy of the explicit domain of "multi", assuming it has one. + */ +static __isl_give DOM *FN(MULTI(BASE),get_explicit_domain)( + __isl_keep MULTI(BASE) *multi) +{ + return FN(DOM,copy)(FN(MULTI(BASE),peek_explicit_domain)(multi)); +} + +/* Replace the explicit domain of "multi" by "dom", assuming it has one. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),set_explicit_domain)( + __isl_take MULTI(BASE) *multi, __isl_take DOM *dom) +{ + if (FN(MULTI(BASE),check_has_explicit_domain)(multi) < 0) + goto error; + multi = FN(MULTI(BASE),cow)(multi); + if (!multi || !dom) + goto error; + FN(DOM,free)(multi->u.dom); + multi->u.dom = dom; + if (!multi->u.dom) + return FN(MULTI(BASE),free)(multi); + return multi; +error: + FN(MULTI(BASE),free)(multi); + FN(DOM,free)(dom); + return NULL; +} + +/* Intersect the domain of "dst" with the explicit domain of "src". + * + * In the case of isl_multi_union_pw_aff objects, the explicit domain + * of "src" is allowed to have only constraints on the parameters, even + * if the domain of "dst" contains actual domain elements. In this case, + * the domain of "dst" is intersected with those parameter constraints. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_explicit_domain)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src) +{ + isl_bool is_params; + DOM *dom; + + dom = FN(MULTI(BASE),peek_explicit_domain)(src); + is_params = FN(DOM,is_params)(dom); + if (is_params < 0) + return FN(MULTI(BASE),free)(dst); + + dom = FN(DOM,copy)(dom); + if (!is_params) { + dst = FN(MULTI(BASE),intersect_domain)(dst, dom); + } else { + isl_set *params; + + params = FN(DOM,params)(dom); + dst = FN(MULTI(BASE),intersect_params)(dst, params); + } + + return dst; +} + +/* Set the explicit domain of "dst" to that of "src". + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),copy_explicit_domain)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src) +{ + DOM *dom; + + dom = FN(MULTI(BASE),get_explicit_domain)(src); + dst = FN(MULTI(BASE),set_explicit_domain)(dst, dom); + + return dst; +} + +/* Align the parameters of the explicit domain of "multi" to those of "space". + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_explicit_domain_params)( + __isl_take MULTI(BASE) *multi, __isl_take isl_space *space) +{ + DOM *dom; + + dom = FN(MULTI(BASE),get_explicit_domain)(multi); + dom = FN(DOM,align_params)(dom, space); + multi = FN(MULTI(BASE),set_explicit_domain)(multi, dom); + + return multi; +} + +/* Replace the space of the explicit domain of "multi" by "space", + * without modifying its dimension. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_explicit_domain_space)( + __isl_take MULTI(BASE) *multi, __isl_take isl_space *space) +{ + DOM *dom; + + dom = FN(MULTI(BASE),get_explicit_domain)(multi); + dom = FN(DOM,reset_equal_dim_space)(dom, space); + multi = FN(MULTI(BASE),set_explicit_domain)(multi, dom); + + return multi; +} + +/* Free the explicit domain of "multi". + */ +static void FN(MULTI(BASE),free_explicit_domain)(__isl_keep MULTI(BASE) *multi) +{ + if (FN(MULTI(BASE),check_has_explicit_domain)(multi) < 0) + return; + FN(DOM,free)(multi->u.dom); +} + +/* Do "multi1" and "multi2" have the same explicit domain? + */ +static isl_bool FN(MULTI(BASE),equal_explicit_domain)( + __isl_keep MULTI(BASE) *multi1, __isl_keep MULTI(BASE) *multi2) +{ + DOM *dom1, *dom2; + isl_bool equal; + + if (FN(MULTI(BASE),check_has_explicit_domain)(multi1) < 0 || + FN(MULTI(BASE),check_has_explicit_domain)(multi2) < 0) + return isl_bool_error; + dom1 = FN(MULTI(BASE),get_explicit_domain)(multi1); + dom2 = FN(MULTI(BASE),get_explicit_domain)(multi2); + equal = FN(DOM,is_equal)(dom1, dom2); + FN(DOM,free)(dom1); + FN(DOM,free)(dom2); + + return equal; +} + +static isl_stat FN(MULTI(BASE),check_explicit_domain)( + __isl_keep MULTI(BASE) *multi) __attribute__ ((unused)); + +/* Debugging function to check that the explicit domain of "multi" + * has the correct space. + */ +isl_stat FN(MULTI(BASE),check_explicit_domain)(__isl_keep MULTI(BASE) *multi) +{ + isl_space *space1, *space2; + isl_bool equal; + + if (FN(MULTI(BASE),check_has_explicit_domain)(multi) < 0) + return isl_stat_error; + space1 = isl_space_domain(isl_space_copy(multi->space)); + space2 = FN(DOM,get_space)(multi->u.dom); + equal = isl_space_is_equal(space1, space2); + isl_space_free(space1); + isl_space_free(space2); + if (equal < 0) + return isl_stat_error; + if (!equal) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_internal, + "check failed", return isl_stat_error); + return isl_stat_ok; +} diff --git a/gcc/isl/isl_multi_from_base_templ.c b/gcc/isl/isl_multi_from_base_templ.c new file mode 100644 index 0000000..2a2a6b1 100644 --- /dev/null +++ a/gcc/isl/isl_multi_from_base_templ.c @@ -1,0 +1,37 @@ +/* + * Copyright 2012,2014 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +/* Create a multiple expression with a single output/set dimension + * equal to "el". + * For most multiple expression types, the base type has a single + * output/set dimension and the space of the result is therefore + * the same as the space of the input. + * In the case of isl_multi_union_pw_aff, however, the base type + * lives in a parameter space and we therefore need to add + * a single set dimension. + */ +__isl_give MULTI(BASE) *FN(FN(MULTI(BASE),from),BASE)(__isl_take EL *el) +{ + isl_space *space; + MULTI(BASE) *multi; + + space = FN(EL,get_space(el)); + if (isl_space_is_params(space)) { + space = isl_space_set_from_params(space); + space = isl_space_add_dims(space, isl_dim_set, 1); + } + multi = FN(MULTI(BASE),alloc)(space); + multi = FN(FN(MULTI(BASE),set),BASE)(multi, 0, el); + + return multi; +} diff --git a/gcc/isl/isl_multi_identity_templ.c b/gcc/isl/isl_multi_identity_templ.c new file mode 100644 index 0000000..d598d11 100644 --- /dev/null +++ a/gcc/isl/isl_multi_identity_templ.c @@ -1,0 +1,86 @@ +/* + * Copyright 2012 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include + +#include + +/* Create a multi expression in the given space that maps each + * input dimension to the corresponding output dimension. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),identity)(__isl_take isl_space *space) +{ + int i; + isl_size n_in, n_out; + isl_local_space *ls; + MULTI(BASE) *multi; + + if (!space) + return NULL; + + if (isl_space_is_set(space)) + isl_die(isl_space_get_ctx(space), isl_error_invalid, + "expecting map space", goto error); + + n_in = isl_space_dim(space, isl_dim_in); + n_out = isl_space_dim(space, isl_dim_out); + if (n_in < 0 || n_out < 0) + goto error; + if (n_in != n_out) + isl_die(isl_space_get_ctx(space), isl_error_invalid, + "number of input and output dimensions needs to be " + "the same", goto error); + + multi = FN(MULTI(BASE),alloc)(isl_space_copy(space)); + + if (!n_out) { + isl_space_free(space); + return multi; + } + + space = isl_space_domain(space); + ls = isl_local_space_from_space(space); + + for (i = 0; i < n_out; ++i) { + EL *el; + el = FN(EL,var_on_domain)(isl_local_space_copy(ls), + isl_dim_set, i); + multi = FN(FN(MULTI(BASE),set),BASE)(multi, i, el); + } + + isl_local_space_free(ls); + + return multi; +error: + isl_space_free(space); + return NULL; +} + +/* Create a multi expression that maps elements in the given space + * to themselves. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),identity_on_domain_space)( + __isl_take isl_space *space) +{ + return FN(MULTI(BASE),identity)(isl_space_map_from_set(space)); +} + +/* Create a multi expression in the same space as "multi" that maps each + * input dimension to the corresponding output dimension. + */ +__isl_give MULTI(BASE) *FN(FN(MULTI(BASE),identity_multi),BASE)( + __isl_take MULTI(BASE) *multi) +{ + isl_space *space; + + space = FN(MULTI(BASE),get_space)(multi); + FN(MULTI(BASE),free)(multi); + return FN(MULTI(BASE),identity)(space); +} diff --git a/gcc/isl/isl_multi_locals_templ.c b/gcc/isl/isl_multi_locals_templ.c new file mode 100644 index 0000000..3cfb0a3 100644 --- /dev/null +++ a/gcc/isl/isl_multi_locals_templ.c @@ -1,0 +1,17 @@ +/* + * Copyright 2019 Cerebras Systems + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA + */ + +#include + +/* Does "multi" involve any local variables? + */ +isl_bool FN(MULTI(BASE),involves_locals)(__isl_keep MULTI(BASE) *multi) +{ + return FN(MULTI(BASE),any)(multi, FN(EL,involves_locals)); +} diff --git a/gcc/isl/isl_multi_move_dims_templ.c b/gcc/isl/isl_multi_move_dims_templ.c new file mode 100644 index 0000000..9c88085 100644 --- /dev/null +++ a/gcc/isl/isl_multi_move_dims_templ.c @@ -1,0 +1,71 @@ +/* + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +/* Move the "n" dimensions of "src_type" starting at "src_pos" of "multi" + * to dimensions of "dst_type" at "dst_pos". + * + * We only support moving input dimensions to parameters and vice versa. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),move_dims)(__isl_take MULTI(BASE) *multi, + enum isl_dim_type dst_type, unsigned dst_pos, + enum isl_dim_type src_type, unsigned src_pos, unsigned n) +{ + int i; + + if (!multi) + return NULL; + + if (n == 0 && + !isl_space_is_named_or_nested(multi->space, src_type) && + !isl_space_is_named_or_nested(multi->space, dst_type)) + return multi; + + if (dst_type == isl_dim_out || src_type == isl_dim_out) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid, + "cannot move output/set dimension", + return FN(MULTI(BASE),free)(multi)); + if (dst_type == isl_dim_div || src_type == isl_dim_div) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid, + "cannot move divs", + return FN(MULTI(BASE),free)(multi)); + if (FN(MULTI(BASE),check_range)(multi, src_type, src_pos, n) < 0) + return FN(MULTI(BASE),free)(multi); + if (dst_type == src_type) + isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_unsupported, + "moving dims within the same type not supported", + return FN(MULTI(BASE),free)(multi)); + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + multi->space = isl_space_move_dims(multi->space, dst_type, dst_pos, + src_type, src_pos, n); + if (!multi->space) + return FN(MULTI(BASE),free)(multi); + if (FN(MULTI(BASE),has_explicit_domain)(multi)) + multi = FN(MULTI(BASE),move_explicit_domain_dims)(multi, + dst_type, dst_pos, src_type, src_pos, n); + if (!multi) + return NULL; + + for (i = 0; i < multi->n; ++i) { + multi->u.p[i] = FN(EL,move_dims)(multi->u.p[i], + dst_type, dst_pos, + src_type, src_pos, n); + if (!multi->u.p[i]) + return FN(MULTI(BASE),free)(multi); + } + + return multi; +} diff --git a/gcc/isl/isl_multi_nan_templ.c b/gcc/isl/isl_multi_nan_templ.c new file mode 100644 index 0000000..2ea73a8 100644 --- /dev/null +++ a/gcc/isl/isl_multi_nan_templ.c @@ -1,0 +1,17 @@ +/* + * Copyright 2014 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +/* Does "multi" involve any NaNs? + */ +isl_bool FN(MULTI(BASE),involves_nan)(__isl_keep MULTI(BASE) *multi) +{ + return FN(MULTI(BASE),any)(multi, &FN(EL,involves_nan)); +} diff --git a/gcc/isl/isl_multi_no_domain_templ.c b/gcc/isl/isl_multi_no_domain_templ.c new file mode 100644 index 0000000..1c98ac4 100644 --- /dev/null +++ a/gcc/isl/isl_multi_no_domain_templ.c @@ -1,0 +1,118 @@ +/* + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include +#include + +#include + +/* The functions in this file are meant for base object types + * that do not have any associated space. They are only meant to be used + * in the generic isl_multi_* functions which have to deal with base objects + * that do have an associated space. + */ + + +/* Drop the "n" first dimensions of type "type" at position "first". + * + * For a base expression without an associated space, this function + * does not do anything. + */ +static __isl_give EL *FN(EL,drop_dims)(__isl_take EL *el, + enum isl_dim_type type, unsigned first, unsigned n) +{ + return el; +} + +/* Return the space of "el". + * + * For a base expression without an associated space, + * the conditions surrounding the call to this function make sure + * that this function will never actually get called. We return a valid + * space anyway, just in case. + */ +static __isl_give isl_space *FN(EL,get_space)(__isl_keep EL *el) +{ + if (!el) + return NULL; + + return isl_space_params_alloc(FN(EL,get_ctx)(el), 0); +} + +/* Reset the domain space of "el" to "space". + * + * For a base expression without an associated space, this function + * does not do anything, apart from error handling and cleaning up memory. + */ +static __isl_give EL *FN(EL,reset_domain_space)(__isl_take EL *el, + __isl_take isl_space *space) +{ + if (!space) + return FN(EL,free)(el); + isl_space_free(space); + return el; +} + +/* Align the parameters of "el" to those of "space". + * + * For a base expression without an associated space, this function + * does not do anything, apart from error handling and cleaning up memory. + * Note that the conditions surrounding the call to this function make sure + * that this function will never actually get called. + */ +static __isl_give EL *FN(EL,align_params)(__isl_take EL *el, + __isl_take isl_space *space) +{ + if (!space) + return FN(EL,free)(el); + isl_space_free(space); + return el; +} + +/* Reorder the dimensions of the domain of "el" according + * to the given reordering. + * + * For a base expression without an associated space, this function + * does not do anything, apart from error handling and cleaning up memory. + */ +static __isl_give EL *FN(EL,realign_domain)(__isl_take EL *el, + __isl_take isl_reordering *r) +{ + if (!r) + return FN(EL,free)(el); + isl_reordering_free(r); + return el; +} + +/* Do the parameters of "el" match those of "space"? + * + * For a base expression without an associated space, this function + * simply returns true, except if "el" or "space" are NULL. + */ +static isl_bool FN(EL,matching_params)(__isl_keep EL *el, + __isl_keep isl_space *space) +{ + if (!el || !space) + return isl_bool_error; + return isl_bool_true; +} + +/* Check that the domain space of "el" matches "space". + * + * For a base expression without an associated space, this function + * simply returns isl_stat_ok, except if "el" or "space" are NULL. + */ +static isl_stat FN(EL,check_match_domain_space)(__isl_keep EL *el, + __isl_keep isl_space *space) +{ + if (!el || !space) + return isl_stat_error; + return isl_stat_ok; +} diff --git a/gcc/isl/isl_multi_no_explicit_domain.c b/gcc/isl/isl_multi_no_explicit_domain.c new file mode 100644 index 0000000..cba4387 100644 --- /dev/null +++ a/gcc/isl/isl_multi_no_explicit_domain.c @@ -1,0 +1,172 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +/* These versions of the explicit domain functions are used + * when the multi expression cannot have an explicit domain. + */ + +#include + +#include + +/* Does "multi" have an explicit domain? + * + * No. + */ +static int FN(MULTI(BASE),has_explicit_domain)(__isl_keep MULTI(BASE) *multi) +{ + return 0; +} + +/* Initialize the explicit domain of "multi". + * "multi" cannot have an explicit domain, so this function is never called. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),init_explicit_domain)( + __isl_take MULTI(BASE) *multi) +{ + return multi; +} + +/* Intersect the domain of "dst" with the explicit domain of "src". + * "src" cannot have an explicit domain, so this function is never called. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_explicit_domain)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src) +{ + return dst; +} + +/* Set the explicit domain of "dst" to that of "src". + * "src" and "dst" cannot have an explicit domain, + * so this function is never called. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),copy_explicit_domain)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src) +{ + return dst; +} + +/* Only used by multi-expressions that include "isl_multi_product_templ.c". + */ +static __isl_give MULTI(BASE) * +FN(MULTI(BASE),intersect_explicit_domain_product)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src1, + __isl_keep MULTI(BASE) *src2) __attribute__ ((unused)); + +/* Intersect the domain of "dst" with the domain product + * of the explicit domains of "src1" and "src2". + * This function is only called if at least one of "src1" or "src2" + * has an explicit domain. + * "src1", "src2" and "dst" cannot have an explicit domain, + * so this function is never called. + */ +static __isl_give MULTI(BASE) * +FN(MULTI(BASE),intersect_explicit_domain_product)( + __isl_take MULTI(BASE) *dst, __isl_keep MULTI(BASE) *src1, + __isl_keep MULTI(BASE) *src2) +{ + return dst; +} + +/* Align the parameters of the explicit domain of "multi" to those of "space". + * "multi" cannot have an explicit domain, so this function is never called. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_explicit_domain_params)( + __isl_take MULTI(BASE) *multi, __isl_take isl_space *space) +{ + isl_space_free(space); + return multi; +} + +/* Replace the space of the explicit domain of "multi" by "space", + * without modifying its dimension. + * "multi" cannot have an explicit domain, so this function is never called. + */ +static __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_explicit_domain_space)( + __isl_take MULTI(BASE) *multi, __isl_take isl_space *space) +{ + isl_space_free(space); + return multi; +} + +/* Check whether the explicit domain of "multi" has non-zero coefficients + * for any dimension in the given range or if any of these dimensions appear + * with non-zero coefficients in any of the integer divisions involved. + * "multi" cannot have an explicit domain, so this function is never called. + */ +isl_bool FN(MULTI(BASE),involves_explicit_domain_dims)( + __isl_keep MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + return isl_bool_false; +} + +/* Insert "n" dimensions of type "type" at position "pos" + * of the explicit domain of "multi". + * "multi" cannot have an explicit domain, so this function is never called. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),insert_explicit_domain_dims)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + return multi; +} + +/* Drop the "n" dimensions of type "type" starting at position "pos" + * of the explicit domain of "multi". + * "multi" cannot have an explicit domain, so this function is never called. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),drop_explicit_domain_dims)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + return multi; +} + +/* Move the "n" dimensions of "src_type" starting at "src_pos" of + * of the explicit domain of "multi" to dimensions of "dst_type" at "dst_pos". + * "multi" cannot have an explicit domain, so this function is never called. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),move_explicit_domain_dims)( + __isl_take MULTI(BASE) *multi, + enum isl_dim_type dst_type, unsigned dst_pos, + enum isl_dim_type src_type, unsigned src_pos, unsigned n) +{ + return multi; +} + +/* Free the explicit domain of "multi". + * "multi" cannot have an explicit domain, so this function is never called. + */ +static void FN(MULTI(BASE),free_explicit_domain)(__isl_keep MULTI(BASE) *multi) +{ +} + +/* Do "multi1" and "multi2" have the same explicit domain? + * "multi1" and "multi2" cannot have an explicit domain, + * so this function is never called. + */ +static isl_bool FN(MULTI(BASE),equal_explicit_domain)( + __isl_keep MULTI(BASE) *multi1, __isl_keep MULTI(BASE) *multi2) +{ + return isl_bool_true; +} + +static isl_stat FN(MULTI(BASE),check_explicit_domain)( + __isl_keep MULTI(BASE) *multi) __attribute__ ((unused)); + +/* Debugging function to check that the explicit domain of "multi" + * has the correct space. + * "multi" cannot have an explicit domain, + * so this function should never be called. + */ +static isl_stat FN(MULTI(BASE),check_explicit_domain)( + __isl_keep MULTI(BASE) *multi) +{ + return isl_stat_ok; +} diff --git a/gcc/isl/isl_multi_param_templ.c b/gcc/isl/isl_multi_param_templ.c new file mode 100644 index 0000000..eab9354 100644 --- /dev/null +++ a/gcc/isl/isl_multi_param_templ.c @@ -1,0 +1,60 @@ +/* + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege + */ + +#include + +/* Does the multiple expression "multi" depend in any way + * on the parameter with identifier "id"? + */ +isl_bool FN(MULTI(BASE),involves_param_id)(__isl_keep MULTI(BASE) *multi, + __isl_keep isl_id *id) +{ + int i; + int pos; + + if (!multi || !id) + return isl_bool_error; + if (multi->n == 0) + return isl_bool_false; + pos = FN(MULTI(BASE),find_dim_by_id)(multi, isl_dim_param, id); + if (pos < 0) + return isl_bool_false; + + for (i = 0; i < multi->n; ++i) { + isl_bool involved = FN(EL,involves_param_id)(multi->u.p[i], id); + if (involved < 0 || involved) + return involved; + } + + return isl_bool_false; +} + +/* Does the multiple expression "multi" depend in any way + * on any of the parameters with identifiers in "list"? + */ +isl_bool FN(MULTI(BASE),involves_param_id_list)(__isl_keep MULTI(BASE) *multi, + __isl_keep isl_id_list *list) +{ + int i; + isl_size n; + + n = isl_id_list_size(list); + if (n < 0) + return isl_bool_error; + for (i = 0; i < n; ++i) { + isl_bool involves; + isl_id *id; + + id = isl_id_list_get_at(list, i); + involves = FN(MULTI(BASE),involves_param_id)(multi, id); + isl_id_free(id); + + if (involves < 0 || involves) + return involves; + } + + return isl_bool_false; +} diff --git a/gcc/isl/isl_multi_product_templ.c b/gcc/isl/isl_multi_product_templ.c new file mode 100644 index 0000000..216357c 100644 --- /dev/null +++ a/gcc/isl/isl_multi_product_templ.c @@ -1,0 +1,79 @@ +/* + * Copyright 2012 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +/* Given two MULTI(BASE)s A -> B and C -> D, + * construct a MULTI(BASE) [A -> C] -> [B -> D]. + * + * The parameters are assumed to have been aligned. + * + * If "multi1" and/or "multi2" has an explicit domain, then + * intersect the domain of the result with these explicit domains. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),product_aligned)( + __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2) +{ + int i; + EL *el; + isl_space *space; + MULTI(BASE) *res; + isl_size in1, in2, out1, out2; + + in1 = FN(MULTI(BASE),dim)(multi1, isl_dim_in); + in2 = FN(MULTI(BASE),dim)(multi2, isl_dim_in); + out1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out); + out2 = FN(MULTI(BASE),dim)(multi2, isl_dim_out); + if (in1 < 0 || in2 < 0 || out1 < 0 || out2 < 0) + goto error; + space = isl_space_product(FN(MULTI(BASE),get_space)(multi1), + FN(MULTI(BASE),get_space)(multi2)); + res = FN(MULTI(BASE),alloc)(isl_space_copy(space)); + space = isl_space_domain(space); + + for (i = 0; i < out1; ++i) { + el = FN(FN(MULTI(BASE),get),BASE)(multi1, i); + el = FN(EL,insert_dims)(el, isl_dim_in, in1, in2); + el = FN(EL,reset_domain_space)(el, isl_space_copy(space)); + res = FN(FN(MULTI(BASE),set),BASE)(res, i, el); + } + + for (i = 0; i < out2; ++i) { + el = FN(FN(MULTI(BASE),get),BASE)(multi2, i); + el = FN(EL,insert_dims)(el, isl_dim_in, 0, in1); + el = FN(EL,reset_domain_space)(el, isl_space_copy(space)); + res = FN(FN(MULTI(BASE),set),BASE)(res, out1 + i, el); + } + + if (FN(MULTI(BASE),has_explicit_domain)(multi1) || + FN(MULTI(BASE),has_explicit_domain)(multi2)) + res = FN(MULTI(BASE),intersect_explicit_domain_product)(res, + multi1, multi2); + + isl_space_free(space); + FN(MULTI(BASE),free)(multi1); + FN(MULTI(BASE),free)(multi2); + return res; +error: + FN(MULTI(BASE),free)(multi1); + FN(MULTI(BASE),free)(multi2); + return NULL; +} + +/* Given two MULTI(BASE)s A -> B and C -> D, + * construct a MULTI(BASE) [A -> C] -> [B -> D]. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),product)( + __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2) +{ + return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2, + &FN(MULTI(BASE),product_aligned)); +} diff --git a/gcc/isl/isl_multi_pw_aff_explicit_domain.c b/gcc/isl/isl_multi_pw_aff_explicit_domain.c new file mode 100644 index 0000000..e9efea0 100644 --- /dev/null +++ a/gcc/isl/isl_multi_pw_aff_explicit_domain.c @@ -1,0 +1,134 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +/* Initialize the explicit domain of "mpa". + * + * The explicit domain is initialized to a universe set + * in the domain space. + */ +static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_init_explicit_domain( + __isl_take isl_multi_pw_aff *mpa) +{ + if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) + return isl_multi_pw_aff_free(mpa); + mpa->u.dom = isl_set_universe(isl_multi_pw_aff_get_domain_space(mpa)); + if (!mpa->u.dom) + return isl_multi_pw_aff_free(mpa); + return mpa; +} + +/* Intersect the domain of "dst" with the domain product + * of the explicit domains of "src1" and "src2". + * This function is only called if at least one of "src1" or "src2" + * has an explicit domain. + */ +static __isl_give isl_multi_pw_aff * +isl_multi_pw_aff_intersect_explicit_domain_product( + __isl_take isl_multi_pw_aff *dst, __isl_keep isl_multi_pw_aff *src1, + __isl_keep isl_multi_pw_aff *src2) +{ + isl_space *space; + isl_set *dom; + isl_map *map; + + if (!src1 || !src2) + return FN(isl_multi_pw_aff,free)(dst); + space = isl_multi_pw_aff_get_domain_space(dst); + dom = isl_set_universe(space); + map = isl_set_unwrap(dom); + if (isl_multi_pw_aff_has_explicit_domain(src1)) { + dom = isl_set_copy(src1->u.dom); + map = isl_map_intersect_domain(map, dom); + } + if (isl_multi_pw_aff_has_explicit_domain(src2)) { + dom = isl_set_copy(src2->u.dom); + map = isl_map_intersect_range(map, dom); + } + dom = isl_map_wrap(map); + dst = isl_multi_pw_aff_intersect_domain(dst, dom); + return dst; +} + +/* Check whether the explicit domain of "mpa" has non-zero coefficients + * for any dimension in the given range or if any of these dimensions appear + * with non-zero coefficients in any of the integer divisions involved. + */ +isl_bool isl_multi_pw_aff_involves_explicit_domain_dims( + __isl_keep isl_multi_pw_aff *mpa, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) + return isl_bool_error; + if (type == isl_dim_in) + type = isl_dim_set; + return isl_set_involves_dims(mpa->u.dom, type, pos, n); +} + +/* Insert "n" dimensions of type "type" at position "pos" + * of the explicit domain of "mpa". + */ +static __isl_give isl_multi_pw_aff * +isl_multi_pw_aff_insert_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) + return isl_multi_pw_aff_free(mpa); + mpa = isl_multi_pw_aff_cow(mpa); + if (!mpa) + return NULL; + if (type == isl_dim_in) + type = isl_dim_set; + mpa->u.dom = isl_set_insert_dims(mpa->u.dom, type, pos, n); + if (!mpa->u.dom) + return isl_multi_pw_aff_free(mpa); + return mpa; +} + +/* Drop the "n" dimensions of type "type" starting at position "pos" + * of the explicit domain of "mpa". + */ +static __isl_give isl_multi_pw_aff * +isl_multi_pw_aff_drop_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) + return isl_multi_pw_aff_free(mpa); + mpa = isl_multi_pw_aff_cow(mpa); + if (!mpa) + return NULL; + if (type == isl_dim_in) + type = isl_dim_set; + mpa->u.dom = isl_set_drop(mpa->u.dom, type, pos, n); + if (!mpa->u.dom) + return isl_multi_pw_aff_free(mpa); + return mpa; +} + +/* Move the "n" dimensions of "src_type" starting at "src_pos" of + * of the explicit domain of "mpa" to dimensions of "dst_type" at "dst_pos". + */ +static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_explicit_domain_dims( + __isl_take isl_multi_pw_aff *mpa, + enum isl_dim_type dst_type, unsigned dst_pos, + enum isl_dim_type src_type, unsigned src_pos, unsigned n) +{ + if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) + return isl_multi_pw_aff_free(mpa); + mpa = isl_multi_pw_aff_cow(mpa); + if (!mpa) + return NULL; + if (dst_type == isl_dim_in) + dst_type = isl_dim_set; + if (src_type == isl_dim_in) + src_type = isl_dim_set; + mpa->u.dom = isl_set_move_dims(mpa->u.dom, dst_type, dst_pos, + src_type, src_pos, n); + if (!mpa->u.dom) + return isl_multi_pw_aff_free(mpa); + return mpa; +} diff --git a/gcc/isl/isl_multi_read_no_explicit_domain_templ.c b/gcc/isl/isl_multi_read_no_explicit_domain_templ.c new file mode 100644 index 0000000..b8a6ec5 100644 --- /dev/null +++ a/gcc/isl/isl_multi_read_no_explicit_domain_templ.c @@ -1,0 +1,94 @@ +/* + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include + +#include + +/* This function is called for each element in a tuple inside + * isl_stream_read_multi_*. + * Read an EL from "s" and add it to *list. + */ +static __isl_give isl_space *FN(read_el,BASE)(__isl_keep isl_stream *s, + struct vars *v, __isl_take isl_space *space, int rational, void *user) +{ + LIST(EL) **list = (LIST(EL) **) user; + EL *el; + + el = FN(isl_stream_read,BASE)(s); + *list = FN(LIST(EL),add)(*list, el); + if (!*list) + return isl_space_free(space); + + return space; +} + +/* Read a multi expression from "s". + * + * We first read a tuple space, collecting the element values in a list. + * Then we create an isl_multi_* from the space and the isl_*_list. + */ +__isl_give MULTI(BASE) *FN(isl_stream_read_multi,BASE)( + __isl_keep isl_stream *s) +{ + struct vars *v; + isl_set *dom = NULL; + isl_space *space; + MULTI(BASE) *multi = NULL; + LIST(EL) *list; + + v = vars_new(s->ctx); + if (!v) + return NULL; + + dom = isl_set_universe(isl_space_params_alloc(s->ctx, 0)); + if (next_is_tuple(s)) { + dom = read_map_tuple(s, dom, isl_dim_param, v, 1, 0); + if (isl_stream_eat(s, ISL_TOKEN_TO)) + goto error; + } + if (!isl_set_plain_is_universe(dom)) + isl_die(s->ctx, isl_error_invalid, + "expecting universe parameter domain", goto error); + if (isl_stream_eat(s, '{')) + goto error; + + space = isl_set_get_space(dom); + + list = FN(LIST(EL),alloc)(s->ctx, 0); + space = read_tuple_space(s, v, space, 1, 0, &FN(read_el,BASE), &list); + multi = FN(FN(MULTI(BASE),from),LIST(BASE))(space, list); + + if (isl_stream_eat(s, '}')) + goto error; + + vars_free(v); + isl_set_free(dom); + return multi; +error: + vars_free(v); + isl_set_free(dom); + FN(MULTI(BASE),free)(multi); + return NULL; +} + +/* Read a multi expression from "str". + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),read_from_str)(isl_ctx *ctx, + const char *str) +{ + MULTI(BASE) *multi; + isl_stream *s = isl_stream_new_str(ctx, str); + if (!s) + return NULL; + multi = FN(isl_stream_read_multi,BASE)(s); + isl_stream_free(s); + return multi; +} diff --git a/gcc/isl/isl_multi_splice_templ.c b/gcc/isl/isl_multi_splice_templ.c new file mode 100644 index 0000000..8dca620 100644 --- /dev/null +++ a/gcc/isl/isl_multi_splice_templ.c @@ -1,0 +1,63 @@ +/* + * Copyright 2012 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include + +#include + +/* Given two multi expressions, "multi1" + * + * [A1 A2] -> [B1 B2] + * + * where A2 starts at position "in_pos" and B2 starts at position "out_pos", + * and "multi2" + * + * [C] -> [D] + * + * return the multi expression + * + * [A1 C A2] -> [B1 D B2] + * + * We first insert input dimensions to obtain + * + * [A1 C A2] -> [B1 B2] + * + * and + * + * [A1 C A2] -> [D] + * + * and then apply range_splice. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),splice)( + __isl_take MULTI(BASE) *multi1, unsigned in_pos, unsigned out_pos, + __isl_take MULTI(BASE) *multi2) +{ + isl_size n_in1; + isl_size n_in2; + + n_in1 = FN(MULTI(BASE),dim)(multi1, isl_dim_in); + n_in2 = FN(MULTI(BASE),dim)(multi2, isl_dim_in); + if (n_in1 < 0 || n_in2 < 0) + goto error; + + if (FN(MULTI(BASE),check_range)(multi1, isl_dim_in, in_pos, 0) < 0) + goto error; + + multi1 = FN(MULTI(BASE),insert_dims)(multi1, isl_dim_in, in_pos, n_in2); + multi2 = FN(MULTI(BASE),insert_dims)(multi2, isl_dim_in, n_in2, + n_in1 - in_pos); + multi2 = FN(MULTI(BASE),insert_dims)(multi2, isl_dim_in, 0, in_pos); + + return FN(MULTI(BASE),range_splice)(multi1, out_pos, multi2); +error: + FN(MULTI(BASE),free)(multi1); + FN(MULTI(BASE),free)(multi2); + return NULL; +} diff --git a/gcc/isl/isl_multi_tuple_id_templ.c b/gcc/isl/isl_multi_tuple_id_templ.c new file mode 100644 index 0000000..03f74d4 100644 --- /dev/null +++ a/gcc/isl/isl_multi_tuple_id_templ.c @@ -1,0 +1,94 @@ +/* + * Copyright 2011 Sven Verdoolaege + * Copyright 2012-2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include + +#include + +const char *FN(MULTI(BASE),get_tuple_name)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type) +{ + return multi ? isl_space_get_tuple_name(multi->space, type) : NULL; +} + +/* Does the specified tuple have an id? + */ +isl_bool FN(MULTI(BASE),has_tuple_id)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type) +{ + if (!multi) + return isl_bool_error; + return isl_space_has_tuple_id(multi->space, type); +} + +/* Return the id of the specified tuple. + */ +__isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi, + enum isl_dim_type type) +{ + return multi ? isl_space_get_tuple_id(multi->space, type) : NULL; +} + +__isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)( + __isl_keep MULTI(BASE) *multi, enum isl_dim_type type, + const char *s) +{ + isl_space *space; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + space = FN(MULTI(BASE),get_space)(multi); + space = isl_space_set_tuple_name(space, type, s); + + return FN(MULTI(BASE),reset_space)(multi, space); +} + +__isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)( + __isl_take MULTI(BASE) *multi, enum isl_dim_type type, + __isl_take isl_id *id) +{ + isl_space *space; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + goto error; + + space = FN(MULTI(BASE),get_space)(multi); + space = isl_space_set_tuple_id(space, type, id); + + return FN(MULTI(BASE),reset_space)(multi, space); +error: + isl_id_free(id); + return NULL; +} + +/* Drop the id on the specified tuple. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)( + __isl_take MULTI(BASE) *multi, enum isl_dim_type type) +{ + isl_space *space; + + if (!multi) + return NULL; + if (!FN(MULTI(BASE),has_tuple_id)(multi, type)) + return multi; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi) + return NULL; + + space = FN(MULTI(BASE),get_space)(multi); + space = isl_space_reset_tuple_id(space, type); + + return FN(MULTI(BASE),reset_space)(multi, space); +} diff --git a/gcc/isl/isl_multi_union_pw_aff_explicit_domain.c b/gcc/isl/isl_multi_union_pw_aff_explicit_domain.c new file mode 100644 index 0000000..7ff9b12 100644 --- /dev/null +++ a/gcc/isl/isl_multi_union_pw_aff_explicit_domain.c @@ -1,0 +1,51 @@ +/* + * Copyright 2017 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +/* Initialize the explicit domain of "mupa". + * + * The explicit domain is initialized to a universe parameter set. + * It may later be specialized with constraints on the parameter or + * specific domain instances. + */ +static __isl_give isl_multi_union_pw_aff * +isl_multi_union_pw_aff_init_explicit_domain( + __isl_take isl_multi_union_pw_aff *mupa) +{ + isl_space *space; + + if (isl_multi_union_pw_aff_check_has_explicit_domain(mupa) < 0) + return isl_multi_union_pw_aff_free(mupa); + space = isl_space_params(isl_multi_union_pw_aff_get_space(mupa)); + mupa->u.dom = isl_union_set_from_set(isl_set_universe(space)); + if (!mupa->u.dom) + return isl_multi_union_pw_aff_free(mupa); + return mupa; +} + +/* Drop the "n" dimensions of type "type" starting at position "pos" + * of the explicit domain of "mupa". + */ +static __isl_give isl_multi_union_pw_aff * +isl_multi_union_pw_aff_drop_explicit_domain_dims( + __isl_take isl_multi_union_pw_aff *mupa, + enum isl_dim_type type, unsigned pos, unsigned n) +{ + if (isl_multi_union_pw_aff_check_has_explicit_domain(mupa) < 0) + return isl_multi_union_pw_aff_free(mupa); + if (type != isl_dim_param) + isl_die(isl_multi_union_pw_aff_get_ctx(mupa), isl_error_invalid, + "can only drop parameters", + return isl_multi_union_pw_aff_free(mupa)); + mupa = isl_multi_union_pw_aff_cow(mupa); + if (!mupa) + return NULL; + mupa->u.dom = isl_union_set_project_out(mupa->u.dom, type, pos, n); + if (!mupa->u.dom) + return isl_multi_union_pw_aff_free(mupa); + return mupa; +} diff --git a/gcc/isl/isl_multi_zero_templ.c b/gcc/isl/isl_multi_zero_templ.c new file mode 100644 index 0000000..2dbc582 100644 --- /dev/null +++ a/gcc/isl/isl_multi_zero_templ.c @@ -1,0 +1,51 @@ +/* + * Copyright 2012 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include + +#include + +/* Construct a multi expression in the given space with value zero in + * each of the output dimensions. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),zero)(__isl_take isl_space *space) +{ + isl_size n; + MULTI(BASE) *multi; + + n = isl_space_dim(space , isl_dim_out); + if (n < 0) + goto error; + + multi = FN(MULTI(BASE),alloc)(isl_space_copy(space)); + + if (!n) + isl_space_free(space); + else { + int i; + isl_local_space *ls; + EL *el; + + space = isl_space_domain(space); + ls = isl_local_space_from_space(space); + el = FN(EL,zero_on_domain)(ls); + + for (i = 0; i < n; ++i) + multi = FN(FN(MULTI(BASE),set),BASE)(multi, i, + FN(EL,copy)(el)); + + FN(EL,free)(el); + } + + return multi; +error: + isl_space_free(space); + return NULL; +} diff --git a/gcc/isl/isl_project_out_all_params_templ.c b/gcc/isl/isl_project_out_all_params_templ.c new file mode 100644 index 0000000..73f9a8f 100644 --- /dev/null +++ a/gcc/isl/isl_project_out_all_params_templ.c @@ -1,0 +1,21 @@ +/* + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege + */ + +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Project out all parameters from "obj" by existentially quantifying + * over them. + */ +__isl_give TYPE *FN(TYPE,project_out_all_params)(__isl_take TYPE *obj) +{ + isl_size n; + + n = FN(TYPE,dim)(obj, isl_dim_param); + if (n < 0) + return FN(TYPE,free)(obj); + return FN(TYPE,project_out)(obj, isl_dim_param, 0, n); +} diff --git a/gcc/isl/isl_pw_bind_domain_templ.c b/gcc/isl/isl_pw_bind_domain_templ.c new file mode 100644 index 0000000..2a01495 100644 --- /dev/null +++ a/gcc/isl/isl_pw_bind_domain_templ.c @@ -1,0 +1,14 @@ +/* + * Copyright 2018 Cerebras Systems + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, + * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA + */ + +#include + +#undef TYPE +#define TYPE PW +#include diff --git a/gcc/isl/isl_pw_eval.c b/gcc/isl/isl_pw_eval.c new file mode 100644 index 0000000..f59b787 100644 --- /dev/null +++ a/gcc/isl/isl_pw_eval.c @@ -1,0 +1,86 @@ +/* + * Copyright 2010 INRIA Saclay + * Copyright 2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France + */ + +#include +#include +#include + +#include + +/* Evaluate "pw" in the void point "pnt". + * In particular, return the value NaN. + */ +static __isl_give isl_val *FN(PW,eval_void)(__isl_take PW *pw, + __isl_take isl_point *pnt) +{ + isl_ctx *ctx; + + ctx = isl_point_get_ctx(pnt); + FN(PW,free)(pw); + isl_point_free(pnt); + return isl_val_nan(ctx); +} + +/* Evaluate the piecewise function "pw" in "pnt". + * If the point is void, then return NaN. + * If the point lies outside the domain of "pw", then return 0 or NaN + * depending on whether 0 is the default value for this type of function. + */ +__isl_give isl_val *FN(PW,eval)(__isl_take PW *pw, __isl_take isl_point *pnt) +{ + int i; + isl_bool is_void; + isl_bool found; + isl_ctx *ctx; + isl_bool ok; + isl_space *pnt_space, *pw_space; + isl_val *v; + + pnt_space = isl_point_peek_space(pnt); + pw_space = FN(PW,peek_space)(pw); + ok = isl_space_is_domain_internal(pnt_space, pw_space); + if (ok < 0) + goto error; + ctx = isl_point_get_ctx(pnt); + if (!ok) + isl_die(ctx, isl_error_invalid, + "incompatible spaces", goto error); + is_void = isl_point_is_void(pnt); + if (is_void < 0) + goto error; + if (is_void) + return FN(PW,eval_void)(pw, pnt); + + found = isl_bool_false; + for (i = 0; i < pw->n; ++i) { + found = isl_set_contains_point(pw->p[i].set, pnt); + if (found < 0) + goto error; + if (found) + break; + } + if (found) { + v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD), + isl_point_copy(pnt)); + } else if (DEFAULT_IS_ZERO) { + v = isl_val_zero(ctx); + } else { + v = isl_val_nan(ctx); + } + FN(PW,free)(pw); + isl_point_free(pnt); + return v; +error: + FN(PW,free)(pw); + isl_point_free(pnt); + return NULL; +} diff --git a/gcc/isl/isl_pw_templ.h b/gcc/isl/isl_pw_templ.h new file mode 100644 index 0000000..98db44a 100644 --- /dev/null +++ a/gcc/isl/isl_pw_templ.h @@ -1,0 +1,5 @@ +#include + +#include + +__isl_keep isl_space *FN(PW,peek_space)(__isl_keep PW *pw); diff --git a/gcc/isl/isl_set_to_ast_graft_list.c b/gcc/isl/isl_set_to_ast_graft_list.c new file mode 100644 index 0000000..86206d0 100644 --- /dev/null +++ a/gcc/isl/isl_set_to_ast_graft_list.c @@ -1,0 +1,17 @@ +#include +#include +#include "isl_ast_graft_private.h" +#include "isl_set_to_ast_graft_list.h" + +#define isl_ast_graft_list_is_identical(a, b) isl_bool_ok(a == b) + +#define ISL_KEY isl_set +#define ISL_VAL isl_ast_graft_list +#define ISL_HMAP_SUFFIX set_to_ast_graft_list +#define ISL_HMAP isl_set_to_ast_graft_list +#define ISL_KEY_IS_EQUAL isl_set_plain_is_equal +#define ISL_VAL_IS_EQUAL isl_ast_graft_list_is_identical +#define ISL_KEY_PRINT isl_printer_print_set +#define ISL_VAL_PRINT isl_printer_print_ast_graft_list + +#include diff --git a/gcc/isl/isl_set_to_ast_graft_list.h b/gcc/isl/isl_set_to_ast_graft_list.h new file mode 100644 index 0000000..862afaa 100644 --- /dev/null +++ a/gcc/isl/isl_set_to_ast_graft_list.h @@ -1,0 +1,18 @@ +#ifndef ISL_SET_TO_GRAFT_LIST_H +#define ISL_SET_TO_GRAFT_LIST_H + +#include +#include "isl_ast_graft_private.h" +#include "isl_maybe_ast_graft_list.h" + +#define ISL_KEY isl_set +#define ISL_VAL isl_ast_graft_list +#define ISL_HMAP_SUFFIX set_to_ast_graft_list +#define ISL_HMAP isl_set_to_ast_graft_list +#include +#undef ISL_KEY +#undef ISL_VAL +#undef ISL_HMAP_SUFFIX +#undef ISL_HMAP + +#endif diff --git a/gcc/isl/isl_test_cpp-checked-conversion.cc b/gcc/isl/isl_test_cpp-checked-conversion.cc new file mode 100644 index 0000000..a4aeaf5 100644 --- /dev/null +++ a/gcc/isl/isl_test_cpp-checked-conversion.cc @@ -1,0 +1,99 @@ +/* + * Copyright 2018 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +#include + +#include +#include +#include + +/* Check that converting a NULL object from the checked C++ bindings + * (where the user is expected to check for NULL return values) + * to the default C++ bindings (where exceptions are raised + * instead of returning a NULL object) raises an exception. + */ +static void check_conversion_null(isl_ctx *ctx) +{ + isl::checked::set checked_set; + isl::set set; + + bool caught = false; + try { + set = isl::uncheck(checked_set); + isl_die(ctx, isl_error_unknown, "no exception raised", return); + } catch (const isl::exception &e) { + caught = true; + } + if (!caught) + isl_die(ctx, isl_error_unknown, "no exception raised", return); +} + +/* Dummy function on a set in the checked C++ bindings. + */ +static void f_checked(isl::checked::set set) +{ +} + +/* Dummy function on a set in the default C++ bindings. + */ +static void f_unchecked(isl::set set) +{ +} + +/* Check the conversion between C++ bindings in function calls. + * An incorrect call will result in a compiler error. + */ +static void check_conversion_call(isl_ctx *ctx) +{ + isl::set set(ctx, "{ S[i] : 0 <= i < 10 }"); + isl::checked::set checked_set(ctx, "{ S[i] : 0 <= i < 10 }"); + + f_unchecked(set); + f_checked(isl::check(set)); + f_unchecked(isl::uncheck(checked_set)); + f_checked(checked_set); +} + +/* Check that a double conversion results in the original set, + * or at least something that is equal to the original set. + */ +static void check_conversion_equal(isl_ctx *ctx) +{ + isl::set set(ctx, "{ S[i] : 0 <= i < 10 }"); + isl::set set2; + isl::checked::set checked_set; + + checked_set = isl::check(set); + set2 = isl::uncheck(checked_set); + + if (!set.is_equal(set2)) + isl_die(ctx, isl_error_unknown, "bad conversion", return); +} + +/* Perform some tests on the conversion between the default C++ bindings and + * the checked C++ bindings. + */ +static void check_conversion(isl_ctx *ctx) +{ + check_conversion_null(ctx); + check_conversion_call(ctx); + check_conversion_equal(ctx); +} + +int main() +{ + isl_ctx *ctx = isl_ctx_alloc(); + + isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); + + check_conversion(ctx); + + isl_ctx_free(ctx); + + return EXIT_SUCCESS; +} diff --git a/gcc/isl/isl_test_cpp-checked.cc b/gcc/isl/isl_test_cpp-checked.cc new file mode 100644 index 0000000..1f74e7f 100644 --- /dev/null +++ a/gcc/isl/isl_test_cpp-checked.cc @@ -1,0 +1,311 @@ +/* Copyright 2016-2017 Tobias Grosser + * + * Use of this software is governed by the MIT license + * + * Written by Tobias Grosser, Weststrasse 47, CH-8003, Zurich + */ + +#include +#include +#include +#include +#include + +#include +#include + +namespace isl { using namespace checked; } + +static void assert_impl(bool condition, const char *file, int line, + const char *message) +{ + if (condition) + return; + + fprintf(stderr, "Assertion failed in %s:%d %s\n", file, line, message); + exit(EXIT_FAILURE); +} + +static void assert_impl(isl::boolean condition, const char *file, int line, + const char *message) +{ + assert_impl(bool(condition), file, line, message); +} + +/* Return the value encapsulated by "s". + */ +static int size_val(isl::size s) +{ + return s.is_error() ? -1 : unsigned(s); +} + +#define assert(exp) assert_impl(exp, __FILE__, __LINE__, #exp) +#define IS_TRUE(b) (b).is_true() +#define SIZE_VAL(s) size_val(s) + +#include "isl_test_cpp-generic.cc" + +/* Test that isl_bool values are returned correctly. + * + * We check in detail the following parts of the isl::boolean class: + * - The is_true, is_false, and is_error functions return true in case they + * are called on a true, false, or error instance of isl::boolean, + * respectively + * - Explicit conversion to 'bool' + * - Implicit conversion to 'bool' + * - The complement operator + * - Explicit construction from 'true' and 'false' + * - Explicit construction form isl_bool + */ +void test_return_bool(isl::ctx ctx) +{ + isl::set empty(ctx, "{ : false }"); + isl::set univ(ctx, "{ : }"); + isl::set null; + + isl::boolean b_true = empty.is_empty(); + isl::boolean b_false = univ.is_empty(); + isl::boolean b_error = null.is_empty(); + + assert(b_true.is_true()); + assert(!b_true.is_false()); + assert(!b_true.is_error()); + + assert(!b_false.is_true()); + assert(b_false.is_false()); + assert(!b_false.is_error()); + + assert(!b_error.is_true()); + assert(!b_error.is_false()); + assert(b_error.is_error()); + + assert(bool(b_true) == true); + assert(bool(b_false) == false); + + assert(b_true); + + assert((!b_false).is_true()); + assert((!b_true).is_false()); + assert((!b_error).is_error()); + + assert(isl::boolean(true).is_true()); + assert(!isl::boolean(true).is_false()); + assert(!isl::boolean(true).is_error()); + + assert(isl::boolean(false).is_false()); + assert(!isl::boolean(false).is_true()); + assert(!isl::boolean(false).is_error()); + + assert(isl::manage(isl_bool_true).is_true()); + assert(!isl::manage(isl_bool_true).is_false()); + assert(!isl::manage(isl_bool_true).is_error()); + + assert(isl::manage(isl_bool_false).is_false()); + assert(!isl::manage(isl_bool_false).is_true()); + assert(!isl::manage(isl_bool_false).is_error()); + + assert(isl::manage(isl_bool_error).is_error()); + assert(!isl::manage(isl_bool_error).is_true()); + assert(!isl::manage(isl_bool_error).is_false()); +} + +/* Test that return values are handled correctly. + * + * Test that isl C++ objects, integers, boolean values, and strings are + * returned correctly. + */ +void test_return(isl::ctx ctx) +{ + test_return_obj(ctx); + test_return_int(ctx); + test_return_bool(ctx); + test_return_string(ctx); +} + +/* Test that foreach functions are modeled correctly. + * + * Verify that lambdas are correctly called as callback of a 'foreach' + * function and that variables captured by the lambda work correctly. Also + * check that the foreach function takes account of the return value of the + * lambda and aborts in case isl::stat::error is returned and then returns + * isl::stat::error itself. + */ +void test_foreach(isl::ctx ctx) +{ + isl::set s(ctx, "{ [0]; [1]; [2] }"); + + std::vector basic_sets; + + auto add_to_vector = [&] (isl::basic_set bs) { + basic_sets.push_back(bs); + return isl::stat::ok(); + }; + + isl::stat ret1 = s.foreach_basic_set(add_to_vector); + + assert(ret1.is_ok()); + assert(basic_sets.size() == 3); + assert(isl::set(basic_sets[0]).is_subset(s).is_true()); + assert(isl::set(basic_sets[1]).is_subset(s).is_true()); + assert(isl::set(basic_sets[2]).is_subset(s).is_true()); + assert(!basic_sets[0].is_equal(basic_sets[1]).is_true()); + + auto fail = [&] (isl::basic_set bs) { + return isl::stat::error(); + }; + + isl::stat ret2 = s.foreach_basic_set(fail); + + assert(ret2.is_error()); +} + +/* Test the functionality of "every" functions. + * + * In particular, test the generic functionality and + * test that error conditions are properly propagated. + */ +static void test_every(isl::ctx ctx) +{ + isl::union_set us(ctx, "{ A[i]; B[j] }"); + + test_every_generic(ctx); + + auto fail = [] (isl::set s){ + return isl::boolean::error(); + }; + assert(us.every_set(fail).is_error()); +} + +/* Test basic schedule tree functionality. + * + * In particular, create a simple schedule tree and + * - perform some generic tests + * - test map_descendant_bottom_up in the failing case + * - test foreach_descendant_top_down + * - test every_descendant + */ +static void test_schedule_tree(isl::ctx ctx) +{ + auto root = test_schedule_tree_generic(ctx); + + auto fail_map = [](isl::schedule_node node) { + return isl::schedule_node(); + }; + assert(root.map_descendant_bottom_up(fail_map).is_null()); + + int count = 0; + auto inc_count = [&count](isl::schedule_node node) { + count++; + return isl::boolean(true); + }; + assert(root.foreach_descendant_top_down(inc_count).is_ok()); + assert(count == 8); + + count = 0; + auto inc_count_once = [&count](isl::schedule_node node) { + count++; + return isl::boolean(false); + }; + assert(root.foreach_descendant_top_down(inc_count_once).is_ok()); + assert(count == 1); + + auto is_not_domain = [](isl::schedule_node node) { + return !node.isa(); + }; + assert(root.child(0).every_descendant(is_not_domain).is_true()); + assert(root.every_descendant(is_not_domain).is_false()); + + auto fail = [](isl::schedule_node node) { + return isl::boolean(); + }; + assert(root.every_descendant(fail).is_error()); + + auto domain = root.as().domain(); + auto filters = isl::union_set(ctx, "{}"); + auto collect_filters = [&filters](isl::schedule_node node) { + if (node.isa().is_true()) { + auto filter = node.as(); + filters = filters.unite(filter.filter()); + } + return isl::boolean(true); + }; + assert(!root.every_descendant(collect_filters).is_error()); + assert(domain.is_equal(filters).is_true()); +} + +/* Test basic AST generation from a schedule tree. + * + * In particular, create a simple schedule tree and + * - perform some generic tests + * - test at_each_domain in the failing case + */ +static void test_ast_build(isl::ctx ctx) +{ + auto schedule = test_ast_build_generic(ctx); + + bool do_fail = true; + int count_ast_fail = 0; + auto fail_inc_count_ast = + [&count_ast_fail, &do_fail](isl::ast_node node, + isl::ast_build build) { + count_ast_fail++; + return do_fail ? isl::ast_node() : node; + }; + auto build = isl::ast_build(ctx); + build = build.set_at_each_domain(fail_inc_count_ast); + auto ast = build.node_from(schedule); + assert(ast.is_null()); + assert(count_ast_fail > 0); + auto build_copy = build; + int count_ast = 0; + auto inc_count_ast = + [&count_ast](isl::ast_node node, isl::ast_build build) { + count_ast++; + return node; + }; + build_copy = build_copy.set_at_each_domain(inc_count_ast); + ast = build_copy.node_from(schedule); + assert(!ast.is_null()); + assert(count_ast == 2); + count_ast_fail = 0; + do_fail = false; + ast = build.node_from(schedule); + assert(!ast.is_null()); + assert(count_ast_fail == 2); +} + +/* Test the isl checked C++ interface + * + * This includes: + * - The isl C <-> C++ pointer interface + * - Object construction + * - Different parameter types + * - Different return types + * - Foreach functions + * - Every functions + * - Spaces + * - Schedule trees + * - AST generation + * - AST expression generation + */ +int main() +{ + isl_ctx *ctx = isl_ctx_alloc(); + + isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); + + test_pointer(ctx); + test_constructors(ctx); + test_parameters(ctx); + test_return(ctx); + test_foreach(ctx); + test_every(ctx); + test_space(ctx); + test_schedule_tree(ctx); + test_ast_build(ctx); + test_ast_build_expr(ctx); + + isl_ctx_free(ctx); + + return EXIT_SUCCESS; +} diff --git a/gcc/isl/isl_test_cpp-generic.cc b/gcc/isl/isl_test_cpp-generic.cc new file mode 100644 index 0000000..e225a71 100644 --- /dev/null +++ a/gcc/isl/isl_test_cpp-generic.cc @@ -1,0 +1,374 @@ +/* Copyright 2016-2017 Tobias Grosser + * + * Use of this software is governed by the MIT license + * + * Written by Tobias Grosser, Weststrasse 47, CH-8003, Zurich + */ + +#ifndef IS_TRUE +#define IS_TRUE(b) (b) +#endif +#ifndef SIZE_VAL +#define SIZE_VAL(s) (s) +#endif + +/* Test the pointer interface for interaction between isl C and C++ types. + * + * This tests: + * - construction from an isl C object + * - check that constructed objects are non-null + * - get a non-owned C pointer from an isl C++ object usable in __isl_keep + * methods + * - use copy to get an owned C pointer from an isl C++ object which is usable + * in __isl_take methods. Verify that the original C++ object retains a valid + * pointer. + * - use release to get an owned C pointer from an isl C++ object which is + * usable in __isl_take methods. Verify that the original C++ object gave up + * its pointer and now is null. + */ +void test_pointer(isl::ctx ctx) +{ + isl_set *c_empty = isl_set_read_from_str(ctx.get(), "{ : false }"); + isl::set empty = isl::manage(c_empty); + assert(IS_TRUE(empty.is_empty())); + assert(isl_set_is_empty(empty.get())); + + assert(!empty.is_null()); + isl_set_free(empty.copy()); + assert(!empty.is_null()); + isl_set_free(empty.release()); + assert(empty.is_null()); +} + +/* Test that isl objects can be constructed. + * + * This tests: + * - construction of a null object + * - construction from a string + * - construction from an integer + * - static constructor without a parameter + * - conversion construction (implicit) + * - conversion construction (explicit) + * - construction of empty union set + * + * The tests to construct from integers and strings cover functionality that + * is also tested in the parameter type tests, but here we verify that + * multiple overloaded constructors are available and that overload resolution + * works as expected. + * + * Construction from an isl C pointer is tested in test_pointer. + */ +void test_constructors(isl::ctx ctx) +{ + isl::val null; + assert(null.is_null()); + + isl::val zero_from_str = isl::val(ctx, "0"); + assert(IS_TRUE(zero_from_str.is_zero())); + + isl::val zero_int_con = isl::val(ctx, 0); + assert(IS_TRUE(zero_int_con.is_zero())); + + isl::val zero_static_con = isl::val::zero(ctx); + assert(IS_TRUE(zero_static_con.is_zero())); + + isl::basic_set bs(ctx, "{ [1] }"); + isl::set result(ctx, "{ [1] }"); + isl::set s = bs; + assert(IS_TRUE(s.is_equal(result))); + isl::set s2(bs); + assert(IS_TRUE(s.unite(s2).is_equal(result))); + + isl::union_set us(ctx, "{ A[1]; B[2, 3] }"); + isl::union_set empty = isl::union_set::empty(ctx); + assert(IS_TRUE(us.is_equal(us.unite(empty)))); +} + +/* Test integer function parameters. + * + * Verify that extreme values and zero work. + */ +void test_parameters_int(isl::ctx ctx) +{ + isl::val long_max_str(ctx, std::to_string(LONG_MAX)); + isl::val long_max_int(ctx, LONG_MAX); + assert(IS_TRUE(long_max_str.eq(long_max_int))); + + isl::val long_min_str(ctx, std::to_string(LONG_MIN)); + isl::val long_min_int(ctx, LONG_MIN); + assert(IS_TRUE(long_min_str.eq(long_min_int))); + + isl::val long_zero_str = isl::val(ctx, std::to_string(0)); + isl::val long_zero_int = isl::val(ctx, 0); + assert(IS_TRUE(long_zero_str.eq(long_zero_int))); +} + +/* Test isl objects parameters. + * + * Verify that isl objects can be passed as lvalue and rvalue parameters. + * Also verify that isl object parameters are automatically type converted if + * there is an inheritance relation. Finally, test function calls without + * any additional parameters, apart from the isl object on which + * the method is called. + */ +void test_parameters_obj(isl::ctx ctx) +{ + isl::set a(ctx, "{ [0] }"); + isl::set b(ctx, "{ [1] }"); + isl::set c(ctx, "{ [2] }"); + isl::set expected(ctx, "{ [i] : 0 <= i <= 2 }"); + + isl::set tmp = a.unite(b); + isl::set res_lvalue_param = tmp.unite(c); + assert(IS_TRUE(res_lvalue_param.is_equal(expected))); + + isl::set res_rvalue_param = a.unite(b).unite(c); + assert(IS_TRUE(res_rvalue_param.is_equal(expected))); + + isl::basic_set a2(ctx, "{ [0] }"); + assert(IS_TRUE(a.is_equal(a2))); + + isl::val two(ctx, 2); + isl::val half(ctx, "1/2"); + isl::val res_only_this_param = two.inv(); + assert(IS_TRUE(res_only_this_param.eq(half))); +} + +/* Test different kinds of parameters to be passed to functions. + * + * This includes integer and isl C++ object parameters. + */ +void test_parameters(isl::ctx ctx) +{ + test_parameters_int(ctx); + test_parameters_obj(ctx); +} + +/* Test that isl objects are returned correctly. + * + * This only tests that after combining two objects, the result is successfully + * returned. + */ +void test_return_obj(isl::ctx ctx) +{ + isl::val one(ctx, "1"); + isl::val two(ctx, "2"); + isl::val three(ctx, "3"); + + isl::val res = one.add(two); + + assert(IS_TRUE(res.eq(three))); +} + +/* Test that integer values are returned correctly. + */ +void test_return_int(isl::ctx ctx) +{ + isl::val one(ctx, "1"); + isl::val neg_one(ctx, "-1"); + isl::val zero(ctx, "0"); + + assert(one.sgn() > 0); + assert(neg_one.sgn() < 0); + assert(zero.sgn() == 0); +} + +/* Test that strings are returned correctly. + * Do so by calling overloaded isl::ast_build::from_expr methods. + */ +void test_return_string(isl::ctx ctx) +{ + isl::set context(ctx, "[n] -> { : }"); + isl::ast_build build = isl::ast_build::from_context(context); + isl::pw_aff pw_aff(ctx, "[n] -> { [n] }"); + isl::set set(ctx, "[n] -> { : n >= 0 }"); + + isl::ast_expr expr = build.expr_from(pw_aff); + const char *expected_string = "n"; + assert(expected_string == expr.to_C_str()); + + expr = build.expr_from(set); + expected_string = "n >= 0"; + assert(expected_string == expr.to_C_str()); +} + +/* Test the functionality of "every" functions + * that does not depend on the type of C++ bindings. + */ +static void test_every_generic(isl::ctx ctx) +{ + isl::union_set us(ctx, "{ A[i]; B[j] }"); + + auto is_empty = [] (isl::set s) { + return s.is_empty(); + }; + assert(!IS_TRUE(us.every_set(is_empty))); + + auto is_non_empty = [] (isl::set s) { + return !s.is_empty(); + }; + assert(IS_TRUE(us.every_set(is_non_empty))); + + auto in_A = [] (isl::set s) { + return s.is_subset(isl::set(s.ctx(), "{ A[x] }")); + }; + assert(!IS_TRUE(us.every_set(in_A))); + + auto not_in_A = [] (isl::set s) { + return !s.is_subset(isl::set(s.ctx(), "{ A[x] }")); + }; + assert(!IS_TRUE(us.every_set(not_in_A))); +} + +/* Check basic construction of spaces. + */ +static void test_space(isl::ctx ctx) +{ + isl::space unit = isl::space::unit(ctx); + isl::space set_space = unit.add_named_tuple("A", 3); + isl::space map_space = set_space.add_named_tuple("B", 2); + + isl::set set = isl::set::universe(set_space); + isl::map map = isl::map::universe(map_space); + assert(IS_TRUE(set.is_equal(isl::set(ctx, "{ A[*,*,*] }")))); + assert(IS_TRUE(map.is_equal(isl::map(ctx, "{ A[*,*,*] -> B[*,*] }")))); +} + +/* Construct a simple schedule tree with an outer sequence node and + * a single-dimensional band node in each branch, with one of them + * marked coincident. + */ +static isl::schedule construct_schedule_tree(isl::ctx ctx) +{ + isl::union_set A(ctx, "{ A[i] : 0 <= i < 10 }"); + isl::union_set B(ctx, "{ B[i] : 0 <= i < 20 }"); + + auto node = isl::schedule_node::from_domain(A.unite(B)); + node = node.child(0); + + isl::union_set_list filters(ctx, 0); + filters = filters.add(A).add(B); + node = node.insert_sequence(filters); + + isl::multi_union_pw_aff f_A(ctx, "[ { A[i] -> [i] } ]"); + node = node.child(0); + node = node.child(0); + node = node.insert_partial_schedule(f_A); + auto band = node.as(); + band = band.member_set_coincident(0, true); + node = band.ancestor(2); + + isl::multi_union_pw_aff f_B(ctx, "[ { B[i] -> [i] } ]"); + node = node.child(1); + node = node.child(0); + node = node.insert_partial_schedule(f_B); + node = node.ancestor(2); + + return node.schedule(); +} + +/* Test basic schedule tree functionality that is independent + * of the type of bindings. + * + * In particular, create a simple schedule tree and + * - check that the root node is a domain node + * - check that an object of a subclass can be used as one of the superclass + * - test map_descendant_bottom_up in the successful case + */ +static isl::schedule_node test_schedule_tree_generic(isl::ctx ctx) +{ + auto schedule = construct_schedule_tree(ctx); + auto root = schedule.root(); + + assert(IS_TRUE(root.isa())); + root = root.as().child(0).parent(); + + int count = 0; + auto inc_count = [&count](isl::schedule_node node) { + count++; + return node; + }; + root = root.map_descendant_bottom_up(inc_count); + assert(count == 8); + + return root; +} + +/* Test marking band members for unrolling. + * "schedule" is the schedule created by construct_schedule_tree. + * It schedules two statements, with 10 and 20 instances, respectively. + * Unrolling all band members therefore results in 30 at-domain calls + * by the AST generator. + */ +static void test_ast_build_unroll(isl::schedule schedule) +{ + auto root = schedule.root(); + auto mark_unroll = [](isl::schedule_node node) { + if (IS_TRUE(node.isa())) { + auto band = node.as(); + node = band.member_set_ast_loop_unroll(0); + } + return node; + }; + root = root.map_descendant_bottom_up(mark_unroll); + schedule = root.schedule(); + + int count_ast = 0; + auto inc_count_ast = + [&count_ast](isl::ast_node node, isl::ast_build build) { + count_ast++; + return node; + }; + auto build = isl::ast_build(schedule.ctx()); + build = build.set_at_each_domain(inc_count_ast); + auto ast = build.node_from(schedule); + assert(count_ast == 30); +} + +/* Test basic AST generation from a schedule tree that is independent + * of the type of bindings. + * + * In particular, create a simple schedule tree and + * - generate an AST from the schedule tree + * - test at_each_domain in the successful case + * - test unrolling + */ +static isl::schedule test_ast_build_generic(isl::ctx ctx) +{ + auto schedule = construct_schedule_tree(ctx); + + int count_ast = 0; + auto inc_count_ast = + [&count_ast](isl::ast_node node, isl::ast_build build) { + count_ast++; + return node; + }; + auto build = isl::ast_build(ctx); + auto build_copy = build.set_at_each_domain(inc_count_ast); + auto ast = build.node_from(schedule); + assert(count_ast == 0); + count_ast = 0; + ast = build_copy.node_from(schedule); + assert(count_ast == 2); + build = build_copy; + count_ast = 0; + ast = build.node_from(schedule); + assert(count_ast == 2); + + test_ast_build_unroll(schedule); + + return schedule; +} + +/* Test basic AST expression generation from an affine expression. + */ +static void test_ast_build_expr(isl::ctx ctx) +{ + isl::pw_aff pa(ctx, "[n] -> { [n + 1] }"); + isl::ast_build build = isl::ast_build::from_context(pa.domain()); + + auto expr = build.expr_from(pa); + auto op = expr.as(); + assert(IS_TRUE(op.isa())); + assert(SIZE_VAL(op.n_arg()) == 2); +} diff --git a/gcc/isl/isl_test_cpp.cc b/gcc/isl/isl_test_cpp.cc new file mode 100644 index 0000000..2183ad4 100644 --- /dev/null +++ a/gcc/isl/isl_test_cpp.cc @@ -1,0 +1,321 @@ +/* Copyright 2016-2017 Tobias Grosser + * + * Use of this software is governed by the MIT license + * + * Written by Tobias Grosser, Weststrasse 47, CH-8003, Zurich + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +static void die_impl(const char *file, int line, const char *message) +{ + fprintf(stderr, "Assertion failed in %s:%d %s\n", file, line, message); + exit(EXIT_FAILURE); +} + +static void assert_impl(bool condition, const char *file, int line, + const char *message) +{ + if (condition) + return; + + return die_impl(file, line, message); +} + +#define die(msg) die_impl(__FILE__, __LINE__, msg) +#define assert(exp) assert_impl(exp, __FILE__, __LINE__, #exp) + +#include "isl_test_cpp-generic.cc" + +/* Test that isl_bool values are returned correctly. + * + * In particular, check the conversion to bool in case of true and false, and + * exception throwing in case of error. + */ +static void test_return_bool(isl::ctx ctx) +{ + isl::set empty(ctx, "{ : false }"); + isl::set univ(ctx, "{ : }"); + isl::set null; + + bool b_true = empty.is_empty(); + bool b_false = univ.is_empty(); + bool caught = false; + try { + null.is_empty(); + die("no exception raised"); + } catch (const isl::exception_invalid &e) { + caught = true; + } + + assert(b_true); + assert(!b_false); + assert(caught); +} + +/* Test that return values are handled correctly. + * + * Test that isl C++ objects, integers, boolean values, and strings are + * returned correctly. + */ +static void test_return(isl::ctx ctx) +{ + test_return_obj(ctx); + test_return_int(ctx); + test_return_bool(ctx); + test_return_string(ctx); +} + +/* Test that foreach functions are modeled correctly. + * + * Verify that lambdas are correctly called as callback of a 'foreach' + * function and that variables captured by the lambda work correctly. Also + * check that the foreach function handles exceptions thrown from + * the lambda and that it propagates the exception. + */ +static void test_foreach(isl::ctx ctx) +{ + isl::set s(ctx, "{ [0]; [1]; [2] }"); + + std::vector basic_sets; + + auto add_to_vector = [&] (isl::basic_set bs) { + basic_sets.push_back(bs); + }; + + s.foreach_basic_set(add_to_vector); + + assert(basic_sets.size() == 3); + assert(isl::set(basic_sets[0]).is_subset(s)); + assert(isl::set(basic_sets[1]).is_subset(s)); + assert(isl::set(basic_sets[2]).is_subset(s)); + assert(!basic_sets[0].is_equal(basic_sets[1])); + + auto fail = [&] (isl::basic_set bs) { + throw "fail"; + }; + + bool caught = false; + try { + s.foreach_basic_set(fail); + die("no exception raised"); + } catch (char const *s) { + caught = true; + } + assert(caught); +} + +/* Test the functionality of "every" functions. + * + * In particular, test the generic functionality and + * test that exceptions are properly propagated. + */ +static void test_every(isl::ctx ctx) +{ + isl::union_set us(ctx, "{ A[i]; B[j] }"); + + test_every_generic(ctx); + + auto fail = [] (isl::set s) -> bool { + throw "fail"; + }; + bool caught = false; + try { + us.every_set(fail); + die("no exception raised"); + } catch (char const *s) { + caught = true; + } + assert(caught); +} + +/* Test that an exception is generated for an isl error and + * that the error message is captured by the exception. + * Also check that the exception can be copied and that copying + * does not throw any exceptions. + */ +static void test_exception(isl::ctx ctx) +{ + isl::multi_union_pw_aff mupa(ctx, "[]"); + isl::exception copy; + + static_assert(std::is_nothrow_copy_constructible::value, + "exceptions must be nothrow-copy-constructible"); + static_assert(std::is_nothrow_assignable::value, + "exceptions must be nothrow-assignable"); + + try { + auto umap = isl::union_map::from(mupa); + } catch (const isl::exception_unsupported &error) { + die("caught wrong exception"); + } catch (const isl::exception &error) { + assert(strstr(error.what(), "without explicit domain")); + copy = error; + } + assert(strstr(copy.what(), "without explicit domain")); +} + +/* Test basic schedule tree functionality. + * + * In particular, create a simple schedule tree and + * - perform some generic tests + * - test map_descendant_bottom_up in the failing case + * - test foreach_descendant_top_down + * - test every_descendant + */ +static void test_schedule_tree(isl::ctx ctx) +{ + auto root = test_schedule_tree_generic(ctx); + + auto fail_map = [](isl::schedule_node node) { + throw "fail"; + return node; + }; + auto caught = false; + try { + root.map_descendant_bottom_up(fail_map); + die("no exception raised"); + } catch (char const *s) { + caught = true; + } + assert(caught); + + int count = 0; + auto inc_count = [&count](isl::schedule_node node) { + count++; + return true; + }; + root.foreach_descendant_top_down(inc_count); + assert(count == 8); + + count = 0; + auto inc_count_once = [&count](isl::schedule_node node) { + count++; + return false; + }; + root.foreach_descendant_top_down(inc_count_once); + assert(count == 1); + + auto is_not_domain = [](isl::schedule_node node) { + return !node.isa(); + }; + assert(root.child(0).every_descendant(is_not_domain)); + assert(!root.every_descendant(is_not_domain)); + + auto fail = [](isl::schedule_node node) { + throw "fail"; + return true; + }; + caught = false; + try { + root.every_descendant(fail); + die("no exception raised"); + } catch (char const *s) { + caught = true; + } + assert(caught); + + auto domain = root.as().domain(); + auto filters = isl::union_set(ctx, "{}"); + auto collect_filters = [&filters](isl::schedule_node node) { + if (node.isa()) { + auto filter = node.as(); + filters = filters.unite(filter.filter()); + } + return true; + }; + root.every_descendant(collect_filters); + assert(domain.is_equal(filters)); +} + +/* Test basic AST generation from a schedule tree. + * + * In particular, create a simple schedule tree and + * - perform some generic tests + * - test at_each_domain in the failing case + */ +static void test_ast_build(isl::ctx ctx) +{ + auto schedule = test_ast_build_generic(ctx); + + bool do_fail = true; + int count_ast_fail = 0; + auto fail_inc_count_ast = + [&count_ast_fail, &do_fail](isl::ast_node node, + isl::ast_build build) { + count_ast_fail++; + if (do_fail) + throw "fail"; + return node; + }; + auto build = isl::ast_build(ctx); + build = build.set_at_each_domain(fail_inc_count_ast); + auto caught = false; + try { + auto ast = build.node_from(schedule); + } catch (char const *s) { + caught = true; + } + assert(caught); + assert(count_ast_fail > 0); + auto build_copy = build; + int count_ast = 0; + auto inc_count_ast = + [&count_ast](isl::ast_node node, isl::ast_build build) { + count_ast++; + return node; + }; + build_copy = build_copy.set_at_each_domain(inc_count_ast); + auto ast = build_copy.node_from(schedule); + assert(count_ast == 2); + count_ast_fail = 0; + do_fail = false; + ast = build.node_from(schedule); + assert(count_ast_fail == 2); +} + +/* Test the (unchecked) isl C++ interface + * + * This includes: + * - The isl C <-> C++ pointer interface + * - Object construction + * - Different parameter types + * - Different return types + * - Foreach functions + * - Exceptions + * - Spaces + * - Schedule trees + * - AST generation + * - AST expression generation + */ +int main() +{ + isl_ctx *ctx = isl_ctx_alloc(); + + isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); + + test_pointer(ctx); + test_constructors(ctx); + test_parameters(ctx); + test_return(ctx); + test_foreach(ctx); + test_every(ctx); + test_exception(ctx); + test_space(ctx); + test_schedule_tree(ctx); + test_ast_build(ctx); + test_ast_build_expr(ctx); + + isl_ctx_free(ctx); + + return EXIT_SUCCESS; +} diff --git a/gcc/isl/isl_test_list_templ.c b/gcc/isl/isl_test_list_templ.c new file mode 100644 index 0000000..fa5cb32 100644 --- /dev/null +++ a/gcc/isl/isl_test_list_templ.c @@ -1,0 +1,51 @@ +#define xCAT(A,B) A ## B +#define CAT(A,B) xCAT(A,B) +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) +#define xLIST(EL) EL ## _list +#define LIST(EL) xLIST(EL) + +#undef SET +#define SET CAT(isl_,SET_BASE) +#undef EL +#define EL CAT(isl_,EL_BASE) + +/* Check that the conversion from SET to list of EL works as expected, + * using input described by "str". + */ +static isl_stat FN(FN(FN(test_get_list,EL_BASE),from),SET_BASE)(isl_ctx *ctx, + const char *str) +{ + int i; + isl_size n; + isl_bool equal; + SET *set, *set2; + LIST(EL) *list; + + set = FN(SET,read_from_str)(ctx, str); + list = FN(FN(SET,get),LIST(EL_BASE))(set); + + set2 = FN(SET,empty)(FN(SET,get_space)(set)); + + n = FN(LIST(EL),size)(list); + for (i = 0; i < n; i++) { + EL *el; + el = FN(LIST(EL),get_at)(list, i); + set2 = FN(SET,union)(set2, FN(FN(SET,from),EL_BASE)(el)); + } + + equal = FN(SET,is_equal)(set, set2); + + FN(SET,free)(set); + FN(SET,free)(set2); + FN(LIST(EL),free)(list); + + if (n < 0 || equal < 0) + return isl_stat_error; + + if (!equal) + isl_die(ctx, isl_error_unknown, "collections are not equal", + return isl_stat_error); + + return isl_stat_ok; +} diff --git a/gcc/isl/isl_test_python.py b/gcc/isl/isl_test_python.py new file mode 100755 index 0000000..5373f96 100755 --- /dev/null +++ a/gcc/isl/isl_test_python.py @@ -1,0 +1,449 @@ +# Copyright 2016-2017 Tobias Grosser +# +# Use of this software is governed by the MIT license +# +# Written by Tobias Grosser, Weststrasse 47, CH-8003, Zurich + +import sys +import isl + +# Test that isl objects can be constructed. +# +# This tests: +# - construction from a string +# - construction from an integer +# - static constructor without a parameter +# - conversion construction +# - construction of empty union set +# +# The tests to construct from integers and strings cover functionality that +# is also tested in the parameter type tests, but here the presence of +# multiple overloaded constructors and overload resolution is tested. +# +def test_constructors(): + zero1 = isl.val("0") + assert(zero1.is_zero()) + + zero2 = isl.val(0) + assert(zero2.is_zero()) + + zero3 = isl.val.zero() + assert(zero3.is_zero()) + + bs = isl.basic_set("{ [1] }") + result = isl.set("{ [1] }") + s = isl.set(bs) + assert(s.is_equal(result)) + + us = isl.union_set("{ A[1]; B[2, 3] }") + empty = isl.union_set.empty() + assert(us.is_equal(us.union(empty))) + +# Test integer function parameters for a particular integer value. +# +def test_int(i): + val_int = isl.val(i) + val_str = isl.val(str(i)) + assert(val_int.eq(val_str)) + +# Test integer function parameters. +# +# Verify that extreme values and zero work. +# +def test_parameters_int(): + test_int(sys.maxsize) + test_int(-sys.maxsize - 1) + test_int(0) + +# Test isl objects parameters. +# +# Verify that isl objects can be passed as lvalue and rvalue parameters. +# Also verify that isl object parameters are automatically type converted if +# there is an inheritance relation. Finally, test function calls without +# any additional parameters, apart from the isl object on which +# the method is called. +# +def test_parameters_obj(): + a = isl.set("{ [0] }") + b = isl.set("{ [1] }") + c = isl.set("{ [2] }") + expected = isl.set("{ [i] : 0 <= i <= 2 }") + + tmp = a.union(b) + res_lvalue_param = tmp.union(c) + assert(res_lvalue_param.is_equal(expected)) + + res_rvalue_param = a.union(b).union(c) + assert(res_rvalue_param.is_equal(expected)) + + a2 = isl.basic_set("{ [0] }") + assert(a.is_equal(a2)) + + two = isl.val(2) + half = isl.val("1/2") + res_only_this_param = two.inv() + assert(res_only_this_param.eq(half)) + +# Test different kinds of parameters to be passed to functions. +# +# This includes integer and isl object parameters. +# +def test_parameters(): + test_parameters_int() + test_parameters_obj() + +# Test that isl objects are returned correctly. +# +# This only tests that after combining two objects, the result is successfully +# returned. +# +def test_return_obj(): + one = isl.val("1") + two = isl.val("2") + three = isl.val("3") + + res = one.add(two) + + assert(res.eq(three)) + +# Test that integer values are returned correctly. +# +def test_return_int(): + one = isl.val("1") + neg_one = isl.val("-1") + zero = isl.val("0") + + assert(one.sgn() > 0) + assert(neg_one.sgn() < 0) + assert(zero.sgn() == 0) + +# Test that isl_bool values are returned correctly. +# +# In particular, check the conversion to bool in case of true and false. +# +def test_return_bool(): + empty = isl.set("{ : false }") + univ = isl.set("{ : }") + + b_true = empty.is_empty() + b_false = univ.is_empty() + + assert(b_true) + assert(not b_false) + +# Test that strings are returned correctly. +# Do so by calling overloaded isl.ast_build.from_expr methods. +# +def test_return_string(): + context = isl.set("[n] -> { : }") + build = isl.ast_build.from_context(context) + pw_aff = isl.pw_aff("[n] -> { [n] }") + set = isl.set("[n] -> { : n >= 0 }") + + expr = build.expr_from(pw_aff) + expected_string = "n" + assert(expected_string == expr.to_C_str()) + + expr = build.expr_from(set) + expected_string = "n >= 0" + assert(expected_string == expr.to_C_str()) + +# Test that return values are handled correctly. +# +# Test that isl objects, integers, boolean values, and strings are +# returned correctly. +# +def test_return(): + test_return_obj() + test_return_int() + test_return_bool() + test_return_string() + +# Test that foreach functions are modeled correctly. +# +# Verify that closures are correctly called as callback of a 'foreach' +# function and that variables captured by the closure work correctly. Also +# check that the foreach function handles exceptions thrown from +# the closure and that it propagates the exception. +# +def test_foreach(): + s = isl.set("{ [0]; [1]; [2] }") + + list = [] + def add(bs): + list.append(bs) + s.foreach_basic_set(add) + + assert(len(list) == 3) + assert(list[0].is_subset(s)) + assert(list[1].is_subset(s)) + assert(list[2].is_subset(s)) + assert(not list[0].is_equal(list[1])) + assert(not list[0].is_equal(list[2])) + assert(not list[1].is_equal(list[2])) + + def fail(bs): + raise "fail" + + caught = False + try: + s.foreach_basic_set(fail) + except: + caught = True + assert(caught) + +# Test the functionality of "every" functions. +# +# In particular, test the generic functionality and +# test that exceptions are properly propagated. +# +def test_every(): + us = isl.union_set("{ A[i]; B[j] }") + + def is_empty(s): + return s.is_empty() + assert(not us.every_set(is_empty)) + + def is_non_empty(s): + return not s.is_empty() + assert(us.every_set(is_non_empty)) + + def in_A(s): + return s.is_subset(isl.set("{ A[x] }")) + assert(not us.every_set(in_A)) + + def not_in_A(s): + return not s.is_subset(isl.set("{ A[x] }")) + assert(not us.every_set(not_in_A)) + + def fail(s): + raise "fail" + + caught = False + try: + us.ever_set(fail) + except: + caught = True + assert(caught) + +# Check basic construction of spaces. +# +def test_space(): + unit = isl.space.unit() + set_space = unit.add_named_tuple("A", 3) + map_space = set_space.add_named_tuple("B", 2) + + set = isl.set.universe(set_space) + map = isl.map.universe(map_space) + assert(set.is_equal(isl.set("{ A[*,*,*] }"))) + assert(map.is_equal(isl.map("{ A[*,*,*] -> B[*,*] }"))) + +# Construct a simple schedule tree with an outer sequence node and +# a single-dimensional band node in each branch, with one of them +# marked coincident. +# +def construct_schedule_tree(): + A = isl.union_set("{ A[i] : 0 <= i < 10 }") + B = isl.union_set("{ B[i] : 0 <= i < 20 }") + + node = isl.schedule_node.from_domain(A.union(B)) + node = node.child(0) + + filters = isl.union_set_list(A).add(B) + node = node.insert_sequence(filters) + + f_A = isl.multi_union_pw_aff("[ { A[i] -> [i] } ]") + node = node.child(0) + node = node.child(0) + node = node.insert_partial_schedule(f_A) + node = node.member_set_coincident(0, True) + node = node.ancestor(2) + + f_B = isl.multi_union_pw_aff("[ { B[i] -> [i] } ]") + node = node.child(1) + node = node.child(0) + node = node.insert_partial_schedule(f_B) + node = node.ancestor(2) + + return node.schedule() + +# Test basic schedule tree functionality. +# +# In particular, create a simple schedule tree and +# - check that the root node is a domain node +# - test map_descendant_bottom_up +# - test foreach_descendant_top_down +# - test every_descendant +# +def test_schedule_tree(): + schedule = construct_schedule_tree() + root = schedule.root() + + assert(type(root) == isl.schedule_node_domain) + + count = [0] + def inc_count(node): + count[0] += 1 + return node + root = root.map_descendant_bottom_up(inc_count) + assert(count[0] == 8) + + def fail_map(node): + raise "fail" + return node + caught = False + try: + root.map_descendant_bottom_up(fail_map) + except: + caught = True + assert(caught) + + count = [0] + def inc_count(node): + count[0] += 1 + return True + root.foreach_descendant_top_down(inc_count) + assert(count[0] == 8) + + count = [0] + def inc_count(node): + count[0] += 1 + return False + root.foreach_descendant_top_down(inc_count) + assert(count[0] == 1) + + def is_not_domain(node): + return type(node) != isl.schedule_node_domain + assert(root.child(0).every_descendant(is_not_domain)) + assert(not root.every_descendant(is_not_domain)) + + def fail(node): + raise "fail" + caught = False + try: + root.every_descendant(fail) + except: + caught = True + assert(caught) + + domain = root.domain() + filters = [isl.union_set("{}")] + def collect_filters(node): + if type(node) == isl.schedule_node_filter: + filters[0] = filters[0].union(node.filter()) + return True + root.every_descendant(collect_filters) + assert(domain.is_equal(filters[0])) + +# Test marking band members for unrolling. +# "schedule" is the schedule created by construct_schedule_tree. +# It schedules two statements, with 10 and 20 instances, respectively. +# Unrolling all band members therefore results in 30 at-domain calls +# by the AST generator. +# +def test_ast_build_unroll(schedule): + root = schedule.root() + def mark_unroll(node): + if type(node) == isl.schedule_node_band: + node = node.member_set_ast_loop_unroll(0) + return node + root = root.map_descendant_bottom_up(mark_unroll) + schedule = root.schedule() + + count_ast = [0] + def inc_count_ast(node, build): + count_ast[0] += 1 + return node + + build = isl.ast_build() + build = build.set_at_each_domain(inc_count_ast) + ast = build.node_from(schedule) + assert(count_ast[0] == 30) + +# Test basic AST generation from a schedule tree. +# +# In particular, create a simple schedule tree and +# - generate an AST from the schedule tree +# - test at_each_domain +# - test unrolling +# +def test_ast_build(): + schedule = construct_schedule_tree() + + count_ast = [0] + def inc_count_ast(node, build): + count_ast[0] += 1 + return node + + build = isl.ast_build() + build_copy = build.set_at_each_domain(inc_count_ast) + ast = build.node_from(schedule) + assert(count_ast[0] == 0) + count_ast[0] = 0 + ast = build_copy.node_from(schedule) + assert(count_ast[0] == 2) + build = build_copy + count_ast[0] = 0 + ast = build.node_from(schedule) + assert(count_ast[0] == 2) + + do_fail = True + count_ast_fail = [0] + def fail_inc_count_ast(node, build): + count_ast_fail[0] += 1 + if do_fail: + raise "fail" + return node + build = isl.ast_build() + build = build.set_at_each_domain(fail_inc_count_ast) + caught = False + try: + ast = build.node_from(schedule) + except: + caught = True + assert(caught) + assert(count_ast_fail[0] > 0) + build_copy = build + build_copy = build_copy.set_at_each_domain(inc_count_ast) + count_ast[0] = 0 + ast = build_copy.node_from(schedule) + assert(count_ast[0] == 2) + count_ast_fail[0] = 0 + do_fail = False + ast = build.node_from(schedule) + assert(count_ast_fail[0] == 2) + + test_ast_build_unroll(schedule) + +# Test basic AST expression generation from an affine expression. +# +def test_ast_build_expr(): + pa = isl.pw_aff("[n] -> { [n + 1] }") + build = isl.ast_build.from_context(pa.domain()) + + op = build.expr_from(pa) + assert(type(op) == isl.ast_expr_op_add) + assert(op.n_arg() == 2) + +# Test the isl Python interface +# +# This includes: +# - Object construction +# - Different parameter types +# - Different return types +# - Foreach functions +# - Every functions +# - Spaces +# - Schedule trees +# - AST generation +# - AST expression generation +# +test_constructors() +test_parameters() +test_return() +test_foreach() +test_every() +test_space() +test_schedule_tree() +test_ast_build() +test_ast_build_expr() diff --git a/gcc/isl/opt_type.h b/gcc/isl/opt_type.h new file mode 100644 index 0000000..9505e72 100644 --- /dev/null +++ a/gcc/isl/opt_type.h @@ -1,0 +1,16 @@ +#define NO_LOC +#ifdef HAS_TYPE +#define OPT_TYPE_PARAM , enum isl_fold type +#define OPT_TYPE_PARAM_FIRST enum isl_fold type, +#define OPT_TYPE_ARG(loc) , loc type +#define OPT_TYPE_ARG_FIRST(loc) loc type, +#define OPT_SET_TYPE(loc,val) loc type = (val); +#define OPT_EQUAL_TYPES(loc1, loc2) ((loc1 type) == (loc2 type)) +#else +#define OPT_TYPE_PARAM +#define OPT_TYPE_PARAM_FIRST +#define OPT_TYPE_ARG(loc) +#define OPT_TYPE_ARG_FIRST(loc) +#define OPT_SET_TYPE(loc,val) +#define OPT_EQUAL_TYPES(loc1, loc2) 1 +#endif diff --git a/gcc/isl/print_yaml_field_templ.c b/gcc/isl/print_yaml_field_templ.c new file mode 100644 index 0000000..088e701 100644 --- /dev/null +++ a/gcc/isl/print_yaml_field_templ.c @@ -1,0 +1,22 @@ +#define xCAT(A,B) A ## B +#define CAT(A,B) xCAT(A,B) +#undef TYPE +#define TYPE CAT(isl_,BASE) +#define xFN(TYPE,NAME) TYPE ## _ ## NAME +#define FN(TYPE,NAME) xFN(TYPE,NAME) + +/* Print a key-value pair of a YAML mapping to "p", + * with key "name" and value "val". + */ +static __isl_give isl_printer *FN(print_yaml_field,BASE)( + __isl_take isl_printer *p, const char *name, __isl_keep TYPE *val) +{ + p = isl_printer_print_str(p, name); + p = isl_printer_yaml_next(p); + p = isl_printer_print_str(p, "\""); + p = FN(isl_printer_print,BASE)(p, val); + p = isl_printer_print_str(p, "\""); + p = isl_printer_yaml_next(p); + + return p; +} diff --git a/gcc/isl/py-compile b/gcc/isl/py-compile new file mode 100755 index 0000000..3693d96 100755 --- /dev/null +++ a/gcc/isl/py-compile @@ -1,0 +1,170 @@ +#!/bin/sh +# py-compile - Compile a Python program + +scriptversion=2016-01-11.22; # UTC + +# Copyright (C) 2000-2017 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +if [ -z "$PYTHON" ]; then + PYTHON=python +fi + +me=py-compile + +usage_error () +{ + echo "$me: $*" >&2 + echo "Try '$me --help' for more information." >&2 + exit 1 +} + +basedir= +destdir= +while test $# -ne 0; do + case "$1" in + --basedir) + if test $# -lt 2; then + usage_error "option '--basedir' requires an argument" + else + basedir=$2 + fi + shift + ;; + --destdir) + if test $# -lt 2; then + usage_error "option '--destdir' requires an argument" + else + destdir=$2 + fi + shift + ;; + -h|--help) + cat <<\EOF +Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." + +Byte compile some python scripts FILES. Use --destdir to specify any +leading directory path to the FILES that you don't want to include in the +byte compiled file. Specify --basedir for any additional path information you +do want to be shown in the byte compiled file. + +Example: + py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py + +Report bugs to . +EOF + exit $? + ;; + -v|--version) + echo "$me $scriptversion" + exit $? + ;; + --) + shift + break + ;; + -*) + usage_error "unrecognized option '$1'" + ;; + *) + break + ;; + esac + shift +done + +files=$* +if test -z "$files"; then + usage_error "no files given" +fi + +# if basedir was given, then it should be prepended to filenames before +# byte compilation. +if [ -z "$basedir" ]; then + pathtrans="path = file" +else + pathtrans="path = os.path.join('$basedir', file)" +fi + +# if destdir was given, then it needs to be prepended to the filename to +# byte compile but not go into the compiled file. +if [ -z "$destdir" ]; then + filetrans="filepath = path" +else + filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" +fi + +$PYTHON -c " +import sys, os, py_compile, imp + +files = '''$files''' + +sys.stdout.write('Byte-compiling python modules...\n') +for file in files.split(): + $pathtrans + $filetrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + sys.stdout.write(file) + sys.stdout.flush() + if hasattr(imp, 'get_tag'): + py_compile.compile(filepath, imp.cache_from_source(filepath), path) + else: + py_compile.compile(filepath, filepath + 'c', path) +sys.stdout.write('\n')" || exit $? + +# this will fail for python < 1.5, but that doesn't matter ... +$PYTHON -O -c " +import sys, os, py_compile, imp + +# pypy does not use .pyo optimization +if hasattr(sys, 'pypy_translation_info'): + sys.exit(0) + +files = '''$files''' +sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n') +for file in files.split(): + $pathtrans + $filetrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + sys.stdout.write(file) + sys.stdout.flush() + if hasattr(imp, 'get_tag'): + py_compile.compile(filepath, imp.cache_from_source(filepath, False), path) + else: + py_compile.compile(filepath, filepath + 'o', path) +sys.stdout.write('\n')" 2>/dev/null || : + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/gcc/isl/set_list_from_map_list_inl.c b/gcc/isl/set_list_from_map_list_inl.c new file mode 100644 index 0000000..108c534 100644 --- /dev/null +++ a/gcc/isl/set_list_from_map_list_inl.c @@ -1,0 +1,9 @@ +#include + +/* Return the set list that was treated as the map list "list". + */ +static __isl_give isl_set_list *set_list_from_map_list( + __isl_take isl_map_list *list) +{ + return (isl_set_list *) list; +} diff --git a/gcc/isl/uset_from_umap.c b/gcc/isl/uset_from_umap.c new file mode 100644 index 0000000..cad6060 100644 --- /dev/null +++ a/gcc/isl/uset_from_umap.c @@ -1,0 +1,8 @@ +#include + +/* Return the union set that was treated as the union map "umap". + */ +static __isl_give isl_union_set *uset_from_umap(__isl_take isl_union_map *umap) +{ + return (isl_union_set *) umap; +} diff --git a/gcc/isl/cpp/cpp-checked-conversion.h.bot b/gcc/isl/cpp/cpp-checked-conversion.h.bot new file mode 100644 index 0000000..35ef163 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp-checked-conversion.h.bot @@ -1,0 +1,2 @@ + +#endif /* ISL_CPP_CHECKED_CONVERSION */ diff --git a/gcc/isl/cpp/cpp-checked-conversion.h.top b/gcc/isl/cpp/cpp-checked-conversion.h.top new file mode 100644 index 0000000..402fc3d 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp-checked-conversion.h.top @@ -1,0 +1,14 @@ +/// These are automatically generated conversions between +/// the default and the checked C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP_CHECKED_CONVERSION +#define ISL_CPP_CHECKED_CONVERSION + +#include +#include + diff --git a/gcc/isl/cpp/cpp-checked.h.bot b/gcc/isl/cpp/cpp-checked.h.bot new file mode 100644 index 0000000..4d66f89 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp-checked.h.bot @@ -1,0 +1,2 @@ + +#endif /* ISL_CPP_CHECKED */ diff --git a/gcc/isl/cpp/cpp-checked.h.pre b/gcc/isl/cpp/cpp-checked.h.pre new file mode 100644 index 0000000..988bedb 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp-checked.h.pre @@ -1,0 +1,180 @@ + +#include +#include + +#include +#include +#include +#include +#include + +namespace isl { +namespace checked { + +#define ISLPP_STRINGIZE_(X) #X +#define ISLPP_STRINGIZE(X) ISLPP_STRINGIZE_(X) + +#define ISLPP_ASSERT(test, message) \ + do { \ + if (test) \ + break; \ + fputs("Assertion \"" #test "\" failed at " __FILE__ \ + ":" ISLPP_STRINGIZE(__LINE__) "\n " message "\n", \ + stderr); \ + abort(); \ + } while (0) + +/* Class used to check that isl::checked::boolean, + * isl::checked::stat and isl::checked::size values are checked for errors. + */ +struct checker { + bool checked = false; + ~checker() { + ISLPP_ASSERT(checked, "IMPLEMENTATION ERROR: Unchecked state"); + } +}; + +class boolean { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_bool val; + + friend boolean manage(isl_bool val); + boolean(isl_bool val): val(val) {} +public: + static boolean error() { + return boolean(isl_bool_error); + } + boolean() + : val(isl_bool_error) {} + + /* implicit */ boolean(bool val) + : val(val ? isl_bool_true : isl_bool_false) {} + + isl_bool release() { + auto tmp = val; + val = isl_bool_error; + check->checked = true; + return tmp; + } + + bool is_error() const { check->checked = true; return val == isl_bool_error; } + bool is_false() const { check->checked = true; return val == isl_bool_false; } + bool is_true() const { check->checked = true; return val == isl_bool_true; } + + explicit operator bool() const { + ISLPP_ASSERT(check->checked, "IMPLEMENTATION ERROR: Unchecked error state"); + ISLPP_ASSERT(!is_error(), "IMPLEMENTATION ERROR: Unhandled error state"); + return is_true(); + } + + boolean negate() { + if (val == isl_bool_true) + val = isl_bool_false; + else if (val == isl_bool_false) + val = isl_bool_true; + return *this; + } + + boolean operator!() const { + return boolean(*this).negate(); + } +}; + +inline boolean manage(isl_bool val) { + return boolean(val); +} + +class ctx { + isl_ctx *ptr; +public: + /* implicit */ ctx(isl_ctx *ctx) + : ptr(ctx) {} + isl_ctx *release() { + auto tmp = ptr; + ptr = nullptr; + return tmp; + } + isl_ctx *get() { + return ptr; + } +}; + +/* Class encapsulating an isl_stat value. + */ +class stat { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_stat val; + + friend stat manage(isl_stat val); + stat(isl_stat val) : val(val) {} +public: + static stat ok() { + return stat(isl_stat_ok); + } + static stat error() { + return stat(isl_stat_error); + } + stat() : val(isl_stat_error) {} + + isl_stat release() { + check->checked = true; + return val; + } + + bool is_error() const { + check->checked = true; + return val == isl_stat_error; + } + bool is_ok() const { + check->checked = true; + return val == isl_stat_ok; + } +}; + +inline stat manage(isl_stat val) +{ + return stat(val); +} + +/* Class encapsulating an isl_size value. + */ +class size { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_size val; + + friend size manage(isl_size val); + size(isl_size val) : val(val) {} +public: + size() : val(isl_size_error) {} + + isl_size release() { + auto tmp = val; + val = isl_size_error; + check->checked = true; + return tmp; + } + + bool is_error() const { + check->checked = true; + return val == isl_size_error; + } + + explicit operator unsigned() const { + ISLPP_ASSERT(check->checked, + "IMPLEMENTATION ERROR: Unchecked error state"); + ISLPP_ASSERT(!is_error(), + "IMPLEMENTATION ERROR: Unhandled error state"); + return val; + } +}; + +inline size manage(isl_size val) +{ + return size(val); +} + +} +} // namespace isl diff --git a/gcc/isl/cpp/cpp-checked.h.top b/gcc/isl/cpp/cpp-checked.h.top new file mode 100644 index 0000000..d33ee35 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp-checked.h.top @@ -1,0 +1,10 @@ +/// These are automatically generated checked C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP_CHECKED +#define ISL_CPP_CHECKED + diff --git a/gcc/isl/cpp/cpp.h.bot b/gcc/isl/cpp/cpp.h.bot new file mode 100644 index 0000000..f98e87c 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp.h.bot @@ -1,0 +1,2 @@ + +#endif /* ISL_CPP */ diff --git a/gcc/isl/cpp/cpp.h.pre b/gcc/isl/cpp/cpp.h.pre new file mode 100644 index 0000000..1ac70c5 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp.h.pre @@ -1,0 +1,246 @@ + +#include +#include + +#include +#include +#include +#include +#include +#include + +/* ISL_USE_EXCEPTIONS should be defined to 1 if exceptions are available. + * gcc and clang define __cpp_exceptions; MSVC and xlC define _CPPUNWIND. + * Older versions of gcc (e.g., 4.9) only define __EXCEPTIONS. + * If exceptions are not available, any error condition will result + * in an abort. + */ +#ifndef ISL_USE_EXCEPTIONS +#if defined(__cpp_exceptions) || defined(_CPPUNWIND) || defined(__EXCEPTIONS) +#define ISL_USE_EXCEPTIONS 1 +#else +#define ISL_USE_EXCEPTIONS 0 +#endif +#endif + +namespace isl { + +class ctx { + isl_ctx *ptr; +public: + /* implicit */ ctx(isl_ctx *ctx) : ptr(ctx) {} + isl_ctx *release() { + auto tmp = ptr; + ptr = nullptr; + return tmp; + } + isl_ctx *get() { + return ptr; + } +}; + +/* Macros hiding try/catch. + * If exceptions are not available, then no exceptions will be thrown and + * there is nothing to catch. + */ +#if ISL_USE_EXCEPTIONS +#define ISL_CPP_TRY try +#define ISL_CPP_CATCH_ALL catch (...) +#else +#define ISL_CPP_TRY if (1) +#define ISL_CPP_CATCH_ALL if (0) +#endif + +#if ISL_USE_EXCEPTIONS + +/* Class capturing isl errors. + * + * The what() return value is stored in a reference counted string + * to ensure that the copy constructor and the assignment operator + * do not throw any exceptions. + */ +class exception : public std::exception { + std::shared_ptr what_str; + +protected: + inline exception(const char *what_arg, const char *msg, + const char *file, int line); +public: + exception() {} + exception(const char *what_arg) { + what_str = std::make_shared(what_arg); + } + static inline void throw_error(enum isl_error error, const char *msg, + const char *file, int line); + virtual const char *what() const noexcept { + return what_str->c_str(); + } + + /* Default behavior on error conditions that occur inside isl calls + * performed from inside the bindings. + * In the case exceptions are available, isl should continue + * without printing a warning since the warning message + * will be included in the exception thrown from inside the bindings. + */ + static constexpr auto on_error = ISL_ON_ERROR_CONTINUE; + /* Wrapper for throwing an exception with the given message. + */ + static void throw_invalid(const char *msg, const char *file, int line) { + throw_error(isl_error_invalid, msg, file, line); + } + static inline void throw_last_error(ctx ctx); +}; + +/* Create an exception of a type described by "what_arg", with + * error message "msg" in line "line" of file "file". + * + * Create a string holding the what() return value that + * corresponds to what isl would have printed. + * If no error message or no error file was set, then use "what_arg" instead. + */ +exception::exception(const char *what_arg, const char *msg, const char *file, + int line) +{ + if (!msg || !file) + what_str = std::make_shared(what_arg); + else + what_str = std::make_shared(std::string(file) + + ":" + std::to_string(line) + ": " + msg); +} + +class exception_abort : public exception { + friend exception; + exception_abort(const char *msg, const char *file, int line) : + exception("execution aborted", msg, file, line) {} +}; + +class exception_alloc : public exception { + friend exception; + exception_alloc(const char *msg, const char *file, int line) : + exception("memory allocation failure", msg, file, line) {} +}; + +class exception_unknown : public exception { + friend exception; + exception_unknown(const char *msg, const char *file, int line) : + exception("unknown failure", msg, file, line) {} +}; + +class exception_internal : public exception { + friend exception; + exception_internal(const char *msg, const char *file, int line) : + exception("internal error", msg, file, line) {} +}; + +class exception_invalid : public exception { + friend exception; + exception_invalid(const char *msg, const char *file, int line) : + exception("invalid argument", msg, file, line) {} +}; + +class exception_quota : public exception { + friend exception; + exception_quota(const char *msg, const char *file, int line) : + exception("quota exceeded", msg, file, line) {} +}; + +class exception_unsupported : public exception { + friend exception; + exception_unsupported(const char *msg, const char *file, int line) : + exception("unsupported operation", msg, file, line) {} +}; + +/* Throw an exception of the class that corresponds to "error", with + * error message "msg" in line "line" of file "file". + * + * isl_error_none is treated as an invalid error type. + */ +void exception::throw_error(enum isl_error error, const char *msg, + const char *file, int line) +{ + switch (error) { + case isl_error_none: + break; + case isl_error_abort: throw exception_abort(msg, file, line); + case isl_error_alloc: throw exception_alloc(msg, file, line); + case isl_error_unknown: throw exception_unknown(msg, file, line); + case isl_error_internal: throw exception_internal(msg, file, line); + case isl_error_invalid: throw exception_invalid(msg, file, line); + case isl_error_quota: throw exception_quota(msg, file, line); + case isl_error_unsupported: + throw exception_unsupported(msg, file, line); + } + + throw exception_invalid("invalid error type", file, line); +} + +/* Throw an exception corresponding to the last error on "ctx" and + * reset the error. + * + * If "ctx" is NULL or if it is not in an error state at the start, + * then an invalid argument exception is thrown. + */ +void exception::throw_last_error(ctx ctx) +{ + enum isl_error error; + const char *msg, *file; + int line; + + error = isl_ctx_last_error(ctx.get()); + msg = isl_ctx_last_error_msg(ctx.get()); + file = isl_ctx_last_error_file(ctx.get()); + line = isl_ctx_last_error_line(ctx.get()); + isl_ctx_reset_error(ctx.get()); + + throw_error(error, msg, file, line); +} + +#else + +#include +#include + +class exception { +public: + /* Default behavior on error conditions that occur inside isl calls + * performed from inside the bindings. + * In the case exceptions are not available, isl should abort. + */ + static constexpr auto on_error = ISL_ON_ERROR_ABORT; + /* Wrapper for throwing an exception with the given message. + * In the case exceptions are not available, print an error and abort. + */ + static void throw_invalid(const char *msg, const char *file, int line) { + fprintf(stderr, "%s:%d: %s\n", file, line, msg); + abort(); + } + /* Throw an exception corresponding to the last + * error on "ctx". + * isl should already abort when an error condition occurs, + * so this function should never be called. + */ + static void throw_last_error(ctx ctx) { + abort(); + } +}; + +#endif + +/* Helper class for setting the on_error and resetting the option + * to the original value when leaving the scope. + */ +class options_scoped_set_on_error { + isl_ctx *ctx; + int saved_on_error; +public: + options_scoped_set_on_error(class ctx ctx, int on_error) { + this->ctx = ctx.get(); + saved_on_error = isl_options_get_on_error(this->ctx); + isl_options_set_on_error(this->ctx, on_error); + } + ~options_scoped_set_on_error() { + isl_options_set_on_error(ctx, saved_on_error); + } +}; + +} // namespace isl diff --git a/gcc/isl/cpp/cpp.h.top b/gcc/isl/cpp/cpp.h.top new file mode 100644 index 0000000..793c0ef 100644 --- /dev/null +++ a/gcc/isl/cpp/cpp.h.top @@ -1,0 +1,10 @@ +/// These are automatically generated C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP +#define ISL_CPP + diff --git a/gcc/isl/interface/cpp.cc b/gcc/isl/interface/cpp.cc new file mode 100644 index 0000000..785e078 100644 --- /dev/null +++ a/gcc/isl/interface/cpp.cc @@ -1,0 +1,2589 @@ +/* + * Copyright 2016, 2017 Tobias Grosser. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY TOBIAS GROSSER ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SVEN VERDOOLAEGE OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation + * are those of the authors and should not be interpreted as + * representing official policies, either expressed or implied, of + * Tobias Grosser. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "cpp.h" +#include "isl_config.h" + +/* Print string formatted according to "fmt" to ostream "os". + * + * This osprintf method allows us to use printf style formatting constructs when + * writing to an ostream. + */ +static void osprintf(ostream &os, const char *format, va_list arguments) +{ + va_list copy; + char *string_pointer; + size_t size; + + va_copy(copy, arguments); + size = vsnprintf(NULL, 0, format, copy); + string_pointer = new char[size + 1]; + va_end(copy); + vsnprintf(string_pointer, size + 1, format, arguments); + os << string_pointer; + delete[] string_pointer; +} + +/* Print string formatted according to "fmt" to ostream "os". + * + * This osprintf method allows us to use printf style formatting constructs when + * writing to an ostream. + */ +static void osprintf(ostream &os, const char *format, ...) +{ + va_list arguments; + + va_start(arguments, format); + osprintf(os, format, arguments); + va_end(arguments); +} + +/* Print string formatted according to "fmt" to ostream "os" + * with the given indentation. + * + * This osprintf method allows us to use printf style formatting constructs when + * writing to an ostream. + */ +static void osprintf(ostream &os, int indent, const char *format, ...) +{ + va_list arguments; + + osprintf(os, "%*s", indent, " "); + va_start(arguments, format); + osprintf(os, format, arguments); + va_end(arguments); +} + +/* Convert "l" to a string. + */ +static std::string to_string(long l) +{ + std::ostringstream strm; + strm << l; + return strm.str(); +} + +/* Generate a cpp interface based on the extracted types and functions. + * + * Print first a set of forward declarations for all isl wrapper + * classes, then the declarations of the classes, and at the end all + * implementations. + * + * If checked C++ bindings are being generated, + * then wrap them in a namespace to avoid conflicts + * with the default C++ bindings (with automatic checks using exceptions). + */ +void cpp_generator::generate() +{ + ostream &os = cout; + + osprintf(os, "\n"); + osprintf(os, "namespace isl {\n\n"); + if (checked) + osprintf(os, "namespace checked {\n\n"); + + print_forward_declarations(os); + osprintf(os, "\n"); + print_declarations(os); + osprintf(os, "\n"); + print_implementations(os); + + if (checked) + osprintf(os, "} // namespace checked\n"); + osprintf(os, "} // namespace isl\n"); +} + +/* Print forward declarations for all classes to "os". +*/ +void cpp_generator::print_forward_declarations(ostream &os) +{ + map::iterator ci; + + osprintf(os, "// forward declarations\n"); + + for (ci = classes.begin(); ci != classes.end(); ++ci) + print_class_forward_decl(os, ci->second); +} + +/* Print all declarations to "os". + */ +void cpp_generator::print_declarations(ostream &os) +{ + map::iterator ci; + bool first = true; + + for (ci = classes.begin(); ci != classes.end(); ++ci) { + if (first) + first = false; + else + osprintf(os, "\n"); + + print_class(os, ci->second); + } +} + +/* Print all implementations to "os". + */ +void cpp_generator::print_implementations(ostream &os) +{ + map::iterator ci; + bool first = true; + + for (ci = classes.begin(); ci != classes.end(); ++ci) { + if (first) + first = false; + else + osprintf(os, "\n"); + + print_class_impl(os, ci->second); + } +} + +/* If "clazz" is a subclass that is based on a type function, + * then introduce a "type" field that holds the value of the type + * corresponding to the subclass and make the fields of the class + * accessible to the "isa" and "as" methods of the (immediate) superclass. + * In particular, "isa" needs access to the type field itself, + * while "as" needs access to the private constructor. + * In case of the "isa" method, all instances are made friends + * to avoid access right confusion. + */ +void cpp_generator::print_subclass_type(ostream &os, const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + std::string super; + const char *cppname = cppstring.c_str(); + const char *supername; + + if (!clazz.is_type_subclass()) + return; + + super = type2cpp(clazz.superclass_name); + supername = super.c_str(); + osprintf(os, " template \n"); + osprintf(os, " friend %s %s::isa() const;\n", + isl_bool2cpp().c_str(), supername); + osprintf(os, " friend %s %s::as<%s>() const;\n", + cppname, supername, cppname); + osprintf(os, " static const auto type = %s;\n", + clazz.subclass_name.c_str()); +} + +/* Print declarations for class "clazz" to "os". + * + * If "clazz" is a subclass based on a type function, + * then it is made to inherit from the (immediate) superclass and + * a "type" attribute is added for use in the "as" and "isa" + * methods of the superclass. + * + * Conversely, if "clazz" is a superclass with a type function, + * then declare those "as" and "isa" methods. + * + * The pointer to the isl object is only added for classes that + * are not subclasses, since subclasses refer to the same isl object. + */ +void cpp_generator::print_class(ostream &os, const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, "// declarations for isl::%s\n", cppname); + + print_class_factory_decl(os, clazz); + osprintf(os, "\n"); + osprintf(os, "class %s ", cppname); + if (clazz.is_type_subclass()) + osprintf(os, ": public %s ", + type2cpp(clazz.superclass_name).c_str()); + osprintf(os, "{\n"); + print_subclass_type(os, clazz); + print_class_factory_decl(os, clazz, " friend "); + osprintf(os, "\n"); + osprintf(os, "protected:\n"); + if (!clazz.is_type_subclass()) { + osprintf(os, " %s *ptr = nullptr;\n", name); + osprintf(os, "\n"); + } + print_protected_constructors_decl(os, clazz); + osprintf(os, "\n"); + osprintf(os, "public:\n"); + print_public_constructors_decl(os, clazz); + print_constructors_decl(os, clazz); + print_copy_assignment_decl(os, clazz); + print_destructor_decl(os, clazz); + print_ptr_decl(os, clazz); + print_downcast_decl(os, clazz); + print_ctx_decl(os); + osprintf(os, "\n"); + print_persistent_callbacks_decl(os, clazz); + print_methods_decl(os, clazz); + print_set_enums_decl(os, clazz); + + osprintf(os, "};\n"); +} + +/* Print forward declaration of class "clazz" to "os". + */ +void cpp_generator::print_class_forward_decl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, "class %s;\n", cppname); +} + +/* Print global factory functions to "os". + * + * Each class has two global factory functions: + * + * set manage(__isl_take isl_set *ptr); + * set manage_copy(__isl_keep isl_set *ptr); + * + * A user can construct isl C++ objects from a raw pointer and indicate whether + * they intend to take the ownership of the object or not through these global + * factory functions. This ensures isl object creation is very explicit and + * pointers are not converted by accident. Thanks to overloading, manage() and + * manage_copy() can be called on any isl raw pointer and the corresponding + * object is automatically created, without the user having to choose the right + * isl object type. + * + * For a subclass based on a type function, no factory functions + * are introduced because they share the C object type with + * the superclass. + */ +void cpp_generator::print_class_factory_decl(ostream &os, + const isl_class &clazz, const std::string &prefix) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (clazz.is_type_subclass()) + return; + + os << prefix; + osprintf(os, "inline %s manage(__isl_take %s *ptr);\n", cppname, name); + os << prefix; + osprintf(os, "inline %s manage_copy(__isl_keep %s *ptr);\n", + cppname, name); +} + +/* Print declarations of protected constructors for class "clazz" to "os". + * + * Each class has currently one protected constructor: + * + * 1) Constructor from a plain isl_* C pointer + * + * Example: + * + * set(__isl_take isl_set *ptr); + * + * The raw pointer constructor is kept protected. Object creation is only + * possible through manage() or manage_copy(). + */ +void cpp_generator::print_protected_constructors_decl(ostream &os, + const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, " inline explicit %s(__isl_take %s *ptr);\n", cppname, + name); +} + +/* Print declarations of public constructors for class "clazz" to "os". + * + * Each class currently has two public constructors: + * + * 1) A default constructor + * 2) A copy constructor + * + * Example: + * + * set(); + * set(const set &set); + */ +void cpp_generator::print_public_constructors_decl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + osprintf(os, " inline /* implicit */ %s();\n", cppname); + + osprintf(os, " inline /* implicit */ %s(const %s &obj);\n", + cppname, cppname); +} + +/* Print declarations for "method" in class "clazz" to "os". + * + * "kind" specifies the kind of method that should be generated. + * + * "convert" specifies which of the method arguments should + * be automatically converted. + */ +template <> +void cpp_generator::print_method(ostream &os, + const isl_class &clazz, FunctionDecl *method, function_kind kind, + const std::vector &convert) +{ + string name = clazz.method_name(method); + + print_named_method_decl(os, clazz, method, name, kind, convert); +} + +/* Print declarations for "method" in class "clazz" to "os", + * without any argument conversions. + * + * "kind" specifies the kind of method that should be generated. + */ +template <> +void cpp_generator::print_method(ostream &os, + const isl_class &clazz, FunctionDecl *method, function_kind kind) +{ + print_method(os, clazz,method, kind, {}); +} + +/* Print declarations for constructors for class "class" to "os". + * + * For each isl function that is marked as __isl_constructor, + * add a corresponding C++ constructor. + * + * Example: + * + * inline /\* implicit *\/ union_set(basic_set bset); + * inline /\* implicit *\/ union_set(set set); + * inline explicit val(ctx ctx, long i); + * inline explicit val(ctx ctx, const std::string &str); + */ +void cpp_generator::print_constructors_decl(ostream &os, + const isl_class &clazz) +{ + function_set::const_iterator in; + const function_set &constructors = clazz.constructors; + + for (in = constructors.begin(); in != constructors.end(); ++in) { + FunctionDecl *cons = *in; + + print_method(os, clazz, cons, function_kind_constructor); + } +} + +/* Print declarations of copy assignment operator for class "clazz" + * to "os". + * + * Each class has one assignment operator. + * + * isl:set &set::operator=(set obj) + * + */ +void cpp_generator::print_copy_assignment_decl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, " inline %s &operator=(%s obj);\n", cppname, cppname); +} + +/* Print declaration of destructor for class "clazz" to "os". + * + * No explicit destructor is needed for type based subclasses. + */ +void cpp_generator::print_destructor_decl(ostream &os, const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (clazz.is_type_subclass()) + return; + + osprintf(os, " inline ~%s();\n", cppname); +} + +/* Print declaration of pointer functions for class "clazz" to "os". + * Since type based subclasses share the pointer with their superclass, + * they can also reuse these functions from the superclass. + * + * To obtain a raw pointer three functions are provided: + * + * 1) __isl_give isl_set *copy() + * + * Returns a pointer to a _copy_ of the internal object + * + * 2) __isl_keep isl_set *get() + * + * Returns a pointer to the internal object + * + * 3) __isl_give isl_set *release() + * + * Returns a pointer to the internal object and resets the + * internal pointer to nullptr. + * + * We also provide functionality to explicitly check if a pointer is + * currently managed by this object. + * + * 4) bool is_null() + * + * Check if the current object is a null pointer. + * + * The functions get() and release() model the value_ptr proposed in + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3339.pdf. + * The copy() function is an extension to allow the user to explicitly + * copy the underlying object. + * + * Also generate a declaration to delete copy() for r-values, for + * r-values release() should be used to avoid unnecessary copies. + */ +void cpp_generator::print_ptr_decl(ostream &os, const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + + if (clazz.is_type_subclass()) + return; + + osprintf(os, " inline __isl_give %s *copy() const &;\n", name); + osprintf(os, " inline __isl_give %s *copy() && = delete;\n", name); + osprintf(os, " inline __isl_keep %s *get() const;\n", name); + osprintf(os, " inline __isl_give %s *release();\n", name); + osprintf(os, " inline bool is_null() const;\n"); +} + +/* Print a template declaration with given indentation + * for the "isa_type" method that ensures it is only enabled + * when called with a template argument + * that represents a type that is equal to that + * of the return type of the type function of "super". + * In particular, "isa_type" gets called from "isa" + * with as template argument the type of the "type" field + * of the subclass. + * The check ensures that this subclass is in fact a direct subclass + * of "super". + */ +void cpp_generator::print_isa_type_template(ostream &os, int indent, + const isl_class &super) +{ + osprintf(os, indent, + "template getNameAsString().c_str()); + osprintf(os, indent, + " const T>::value>::type>\n"); +} + +/* Print declarations for the "as" and "isa" methods, if "clazz" + * is a superclass with a type function. + * + * "isa" checks whether an object is of a given subclass type. + * "isa_type" does the same, but gets passed the value of the type field + * of the subclass as a function argument and the type of this field + * as a template argument. + * "as" tries to cast an object to a given subclass type, returning + * an invalid object if the object is not of the given type. + */ +void cpp_generator::print_downcast_decl(ostream &os, const isl_class &clazz) +{ + if (!clazz.fn_type) + return; + + osprintf(os, "private:\n"); + print_isa_type_template(os, 2, clazz); + osprintf(os, " inline %s isa_type(T subtype) const;\n", + isl_bool2cpp().c_str()); + osprintf(os, "public:\n"); + osprintf(os, " template inline %s isa() const;\n", + isl_bool2cpp().c_str()); + osprintf(os, " template inline T as() const;\n"); +} + +/* Print the declaration of the ctx method. + */ +void cpp_generator::print_ctx_decl(ostream &os) +{ + std::string ns = isl_namespace(); + + osprintf(os, " inline %sctx ctx() const;\n", ns.c_str()); +} + +/* Add a space to the return type "type" if needed, + * i.e., if it is not the type of a pointer. + */ +static string add_space_to_return_type(const string &type) +{ + if (type[type.size() - 1] == '*') + return type; + return type + " "; +} + +/* Print the prototype of the static inline method that is used + * as the C callback of "clazz" set by "method" to "os". + */ +void cpp_generator::print_persistent_callback_prototype(ostream &os, + const isl_class &clazz, FunctionDecl *method, bool is_declaration) +{ + string callback_name, rettype, c_args; + ParmVarDecl *param = persistent_callback_arg(method); + const FunctionProtoType *callback; + QualType ptype; + string classname; + + ptype = param->getType(); + callback = extract_prototype(ptype); + + rettype = callback->getReturnType().getAsString(); + rettype = add_space_to_return_type(rettype); + callback_name = clazz.persistent_callback_name(method); + c_args = generate_callback_args(ptype, false); + + if (!is_declaration) + classname = type2cpp(clazz) + "::"; + + osprintf(os, "%s%s%s(%s)", + rettype.c_str(), classname.c_str(), + callback_name.c_str(), c_args.c_str()); +} + +/* Print the prototype of the method for setting the callback function + * of "clazz" set by "method" to "os". + */ +void cpp_generator::print_persistent_callback_setter_prototype(ostream &os, + const isl_class &clazz, FunctionDecl *method, bool is_declaration) +{ + string classname, callback_name, cpptype; + ParmVarDecl *param = persistent_callback_arg(method); + + if (!is_declaration) + classname = type2cpp(clazz) + "::"; + + cpptype = type2cpp(param->getOriginalType()); + callback_name = clazz.persistent_callback_name(method); + osprintf(os, "void %sset_%s_data(const %s &%s)", + classname.c_str(), callback_name.c_str(), cpptype.c_str(), + param->getName().str().c_str()); +} + +/* Given a function "method" for setting a "clazz" persistent callback, + * print the fields that are needed for marshalling the callback to "os". + * + * In particular, print + * - the declaration of a data structure for storing the C++ callback function + * - a shared pointer to such a data structure + * - the declaration of a static inline method + * for use as the C callback function + * - the declaration of a private method for setting the callback function + */ +void cpp_generator::print_persistent_callback_data(ostream &os, + const isl_class &clazz, FunctionDecl *method) +{ + string callback_name; + ParmVarDecl *param = persistent_callback_arg(method); + + callback_name = clazz.persistent_callback_name(method); + print_callback_data_decl(os, param, callback_name); + osprintf(os, ";\n"); + osprintf(os, " std::shared_ptr<%s_data> %s_data;\n", + callback_name.c_str(), callback_name.c_str()); + osprintf(os, " static inline "); + print_persistent_callback_prototype(os, clazz, method, true); + osprintf(os, ";\n"); + osprintf(os, " inline "); + print_persistent_callback_setter_prototype(os, clazz, method, true); + osprintf(os, ";\n"); +} + +/* Print declarations needed for the persistent callbacks of "clazz". + * + * In particular, if there are any persistent callbacks, then + * print a private method for copying callback data from + * one object to another, + * private data for keeping track of the persistent callbacks and + * public methods for setting the persistent callbacks. + */ +void cpp_generator::print_persistent_callbacks_decl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + set::const_iterator in; + const set &callbacks = clazz.persistent_callbacks; + + if (!clazz.has_persistent_callbacks()) + return; + + osprintf(os, "private:\n"); + osprintf(os, " inline %s ©_callbacks(const %s &obj);\n", + cppname, cppname); + for (in = callbacks.begin(); in != callbacks.end(); ++in) + print_persistent_callback_data(os, clazz, *in); + + osprintf(os, "public:\n"); + for (in = callbacks.begin(); in != callbacks.end(); ++in) + print_method(os, clazz, *in, function_kind_member_method); +} + +/* Print declarations for methods in class "clazz" to "os". + */ +void cpp_generator::print_methods_decl(ostream &os, const isl_class &clazz) +{ + map::const_iterator it; + + for (it = clazz.methods.begin(); it != clazz.methods.end(); ++it) + print_method_group_decl(os, clazz, it->second); +} + +/* Print a declaration for a method "name" in "clazz" derived + * from "fd", which sets an enum, to "os". + * + * The last argument is removed because it is replaced by + * a break-up into several methods. + */ +void cpp_generator::print_set_enum_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &name) +{ + int n = fd->getNumParams(); + + print_method_header(os, clazz, fd, name, n - 1, true, + function_kind_member_method); +} + +/* Print declarations for the methods in "clazz" derived from "fd", + * which sets an enum, to "os". + * + * A method is generated for each value in the enum, setting + * the enum to that value. + */ +void cpp_generator::print_set_enums_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd) +{ + vector::const_iterator it; + const vector &set_enums = clazz.set_enums.at(fd); + + for (it = set_enums.begin(); it != set_enums.end(); ++it) + print_set_enum_decl(os, clazz, fd, it->method_name); +} + +/* Print declarations for methods in "clazz" derived from functions + * that set an enum, to "os". + */ +void cpp_generator::print_set_enums_decl(ostream &os, const isl_class &clazz) +{ + map >::const_iterator it; + + for (it = clazz.set_enums.begin(); it != clazz.set_enums.end(); ++it) + print_set_enums_decl(os, clazz, it->first); +} + +/* Print a declaration for the "get" method "fd" in class "clazz", + * using a name that includes the "get_" prefix, to "os". + */ +template<> +void cpp_generator::print_get_method(ostream &os, + const isl_class &clazz, FunctionDecl *fd) +{ + function_kind kind = function_kind_member_method; + string base = clazz.base_method_name(fd); + + print_named_method_decl(os, clazz, fd, base, kind); +} + +/* Update "convert" to reflect the next combination of automatic conversions + * for the arguments of "fd", + * returning false if there are no more combinations. + * + * In particular, find the last argument for which an automatic + * conversion function is available mapping to the type of this argument and + * that is not already marked for conversion. + * Mark this argument, if any, for conversion and clear the markings + * of all subsequent arguments. + * Repeated calls to this method therefore run through + * all possible combinations. + * + * Note that the first function argument is never considered + * for automatic conversion since this is the argument + * from which the isl_ctx used in the conversion is extracted. + */ +bool cpp_generator::next_variant(FunctionDecl *fd, std::vector &convert) +{ + size_t n = convert.size(); + + for (int i = n - 1; i >= 1; --i) { + ParmVarDecl *param = fd->getParamDecl(i); + const Type *type = param->getOriginalType().getTypePtr(); + + if (conversions.count(type) == 0) + continue; + if (convert[i]) + continue; + convert[i] = true; + for (size_t j = i + 1; j < n; ++j) + convert[j] = false; + return true; + } + + return false; +} + +/* Print a declaration or definition for method "fd" in class "clazz" + * to "os". + * + * For methods that are identified as "get" methods, also + * print a declaration or definition for the method + * using a name that includes the "get_" prefix. + * + * If the generated method is an object method, then check + * whether any of its arguments can be automatically converted + * from something else, and, if so, generate a method + * for each combination of converted arguments. + */ +template +void cpp_generator::print_method_variants(ostream &os, const isl_class &clazz, + FunctionDecl *fd) +{ + function_kind kind = get_method_kind(clazz, fd); + std::vector convert(fd->getNumParams()); + + print_method(os, clazz, fd, kind); + if (clazz.is_get_method(fd)) + print_get_method(os, clazz, fd); + if (kind == function_kind_member_method) + while (next_variant(fd, convert)) + print_method(os, clazz, fd, kind, convert); +} + +/* Print declarations for methods "methods" in class "clazz" to "os". + */ +void cpp_generator::print_method_group_decl(ostream &os, const isl_class &clazz, + const function_set &methods) +{ + function_set::const_iterator it; + + for (it = methods.begin(); it != methods.end(); ++it) + print_method_variants(os, clazz, *it); +} + +/* Print a declaration for a method called "name" in class "clazz" + * derived from "fd" to "os". + * + * "kind" specifies the kind of method that should be generated. + * + * "convert" specifies which of the method arguments should + * be automatically converted. + */ +void cpp_generator::print_named_method_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &name, function_kind kind, + const std::vector &convert) +{ + print_named_method_header(os, clazz, fd, name, true, kind, convert); +} + +/* Print implementations for class "clazz" to "os". + */ +void cpp_generator::print_class_impl(ostream &os, const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, "// implementations for isl::%s", cppname); + + print_class_factory_impl(os, clazz); + print_public_constructors_impl(os, clazz); + print_protected_constructors_impl(os, clazz); + print_constructors_impl(os, clazz); + print_copy_assignment_impl(os, clazz); + print_destructor_impl(os, clazz); + print_ptr_impl(os, clazz); + print_downcast_impl(os, clazz); + print_ctx_impl(os, clazz); + print_persistent_callbacks_impl(os, clazz); + print_methods_impl(os, clazz); + print_set_enums_impl(os, clazz); + print_stream_insertion(os, clazz); +} + +/* Print code for throwing an exception corresponding to the last error + * that occurred on "saved_ctx". + * This assumes that a valid isl::ctx is available in the "saved_ctx" variable, + * e.g., through a prior call to print_save_ctx. + */ +static void print_throw_last_error(ostream &os) +{ + osprintf(os, " exception::throw_last_error(saved_ctx);\n"); +} + +/* Print code with the given indentation + * for throwing an exception_invalid with the given message. + */ +static void print_throw_invalid(ostream &os, int indent, const char *msg) +{ + osprintf(os, indent, + "exception::throw_invalid(\"%s\", __FILE__, __LINE__);\n", msg); +} + +/* Print code for throwing an exception on NULL input. + */ +static void print_throw_NULL_input(ostream &os) +{ + print_throw_invalid(os, 4, "NULL input"); +} + +/* Print code with the given indentation + * for acting on an invalid error with message "msg". + * In particular, throw an exception_invalid. + * In the checked C++ bindings, isl_die is called instead with the code + * in "checked_code". + */ +void cpp_generator::print_invalid(ostream &os, int indent, const char *msg, + const char *checked_code) +{ + if (checked) + osprintf(os, indent, + "isl_die(ctx().get(), isl_error_invalid, " + "\"%s\", %s);\n", msg, checked_code); + else + print_throw_invalid(os, indent, msg); +} + +/* Print an operator for inserting objects of "class" + * into an output stream. + * + * Unless checked C++ bindings are being generated, + * the operator requires its argument to be non-NULL. + * An exception is thrown if anything went wrong during the printing. + * During this printing, isl is made not to print any error message + * because the error message is included in the exception. + * + * If checked C++ bindings are being generated and anything went wrong, + * then record this failure in the output stream. + */ +void cpp_generator::print_stream_insertion(ostream &os, const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (!clazz.fn_to_str) + return; + + osprintf(os, "\n"); + osprintf(os, "inline std::ostream &operator<<(std::ostream &os, "); + osprintf(os, "const %s &obj)\n", cppname); + osprintf(os, "{\n"); + print_check_ptr_start(os, clazz, "obj.get()"); + osprintf(os, " char *str = %s_to_str(obj.get());\n", name); + print_check_ptr_end(os, "str"); + if (checked) { + osprintf(os, " if (!str) {\n"); + osprintf(os, " os.setstate(std::ios_base::badbit);\n"); + osprintf(os, " return os;\n"); + osprintf(os, " }\n"); + } + osprintf(os, " os << str;\n"); + osprintf(os, " free(str);\n"); + osprintf(os, " return os;\n"); + osprintf(os, "}\n"); +} + +/* Print code that checks that "ptr" is not NULL at input. + * + * Omit the check if checked C++ bindings are being generated. + */ +void cpp_generator::print_check_ptr(ostream &os, const char *ptr) +{ + if (checked) + return; + + osprintf(os, " if (!%s)\n", ptr); + print_throw_NULL_input(os); +} + +/* Print code that checks that "ptr" is not NULL at input and + * that saves a copy of the isl_ctx of "ptr" for a later check. + * + * Omit the check if checked C++ bindings are being generated. + */ +void cpp_generator::print_check_ptr_start(ostream &os, const isl_class &clazz, + const char *ptr) +{ + if (checked) + return; + + print_check_ptr(os, ptr); + osprintf(os, " auto saved_ctx = %s_get_ctx(%s);\n", + clazz.name.c_str(), ptr); + print_on_error_continue(os); +} + +/* Print code that checks that "ptr" is not NULL at the end. + * A copy of the isl_ctx is expected to have been saved by + * code generated by print_check_ptr_start. + * + * Omit the check if checked C++ bindings are being generated. + */ +void cpp_generator::print_check_ptr_end(ostream &os, const char *ptr) +{ + if (checked) + return; + + osprintf(os, " if (!%s)\n", ptr); + print_throw_last_error(os); +} + +/* Print implementation of global factory functions to "os". + * + * Each class has two global factory functions: + * + * set manage(__isl_take isl_set *ptr); + * set manage_copy(__isl_keep isl_set *ptr); + * + * Unless checked C++ bindings are being generated, + * both functions require the argument to be non-NULL. + * An exception is thrown if anything went wrong during the copying + * in manage_copy. + * During the copying, isl is made not to print any error message + * because the error message is included in the exception. + * + * For a subclass based on a type function, no factory functions + * are introduced because they share the C object type with + * the superclass. + */ +void cpp_generator::print_class_factory_impl(ostream &os, + const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (clazz.is_type_subclass()) + return; + + osprintf(os, "\n"); + osprintf(os, "%s manage(__isl_take %s *ptr) {\n", cppname, name); + print_check_ptr(os, "ptr"); + osprintf(os, " return %s(ptr);\n", cppname); + osprintf(os, "}\n"); + + osprintf(os, "%s manage_copy(__isl_keep %s *ptr) {\n", cppname, + name); + print_check_ptr_start(os, clazz, "ptr"); + osprintf(os, " ptr = %s_copy(ptr);\n", name); + print_check_ptr_end(os, "ptr"); + osprintf(os, " return %s(ptr);\n", cppname); + osprintf(os, "}\n"); +} + +/* Print implementations of protected constructors for class "clazz" to "os". + * + * The pointer to the isl object is either initialized directly or + * through the (immediate) superclass. + */ +void cpp_generator::print_protected_constructors_impl(ostream &os, + const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + bool subclass = clazz.is_type_subclass(); + + osprintf(os, "\n"); + osprintf(os, "%s::%s(__isl_take %s *ptr)\n", cppname, cppname, name); + if (subclass) + osprintf(os, " : %s(ptr) {}\n", + type2cpp(clazz.superclass_name).c_str()); + else + osprintf(os, " : ptr(ptr) {}\n"); +} + +/* Print implementations of public constructors for class "clazz" to "os". + * + * The pointer to the isl object is either initialized directly or + * through the (immediate) superclass. + * + * If the class has any persistent callbacks, then copy them + * from the original object in the copy constructor. + * If the class is a subclass, then the persistent callbacks + * are assumed to be copied by the copy constructor of the superclass. + * + * Throw an exception from the copy constructor if anything went wrong + * during the copying or if the input is NULL, if any copying is performed. + * During the copying, isl is made not to print any error message + * because the error message is included in the exception. + * No exceptions are thrown if checked C++ bindings + * are being generated, + */ +void cpp_generator::print_public_constructors_impl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + std::string super; + const char *cppname = cppstring.c_str(); + bool subclass = clazz.is_type_subclass(); + + osprintf(os, "\n"); + if (subclass) + super = type2cpp(clazz.superclass_name); + osprintf(os, "%s::%s()\n", cppname, cppname); + if (subclass) + osprintf(os, " : %s() {}\n\n", super.c_str()); + else + osprintf(os, " : ptr(nullptr) {}\n\n"); + osprintf(os, "%s::%s(const %s &obj)\n", cppname, cppname, cppname); + if (subclass) + osprintf(os, " : %s(obj)\n", super.c_str()); + else + osprintf(os, " : ptr(nullptr)\n"); + osprintf(os, "{\n"); + if (!subclass) { + print_check_ptr_start(os, clazz, "obj.ptr"); + osprintf(os, " ptr = obj.copy();\n"); + if (clazz.has_persistent_callbacks()) + osprintf(os, " copy_callbacks(obj);\n"); + print_check_ptr_end(os, "ptr"); + } + osprintf(os, "}\n"); +} + +/* Print definition for "method" in class "clazz" to "os", + * without any automatic type conversions. + * + * "kind" specifies the kind of method that should be generated. + * + * This method distinguishes three kinds of methods: member methods, static + * methods, and constructors. + * + * Member methods call "method" by passing to the underlying isl function the + * isl object belonging to "this" as first argument and the remaining arguments + * as subsequent arguments. + * + * Static methods call "method" by passing all arguments to the underlying isl + * function, as no this-pointer is available. The result is a newly managed + * isl C++ object. + * + * Constructors create a new object from a given set of input parameters. They + * do not return a value, but instead update the pointer stored inside the + * newly created object. + * + * If the method has a callback argument, we reduce the number of parameters + * that are exposed by one to hide the user pointer from the interface. On + * the C++ side no user pointer is needed, as arguments can be forwarded + * as part of the std::function argument which specifies the callback function. + * + * Unless checked C++ bindings are being generated, + * the inputs of the method are first checked for being valid isl objects and + * a copy of the associated isl::ctx is saved (if needed). + * If any failure occurs, either during the check for the inputs or + * during the isl function call, an exception is thrown. + * During the function call, isl is made not to print any error message + * because the error message is included in the exception. + */ +template<> +void cpp_generator::print_method(ostream &os, + const isl_class &clazz, FunctionDecl *method, function_kind kind) +{ + string methodname = method->getName(); + int num_params = method->getNumParams(); + + osprintf(os, "\n"); + print_method_header(os, clazz, method, false, kind); + osprintf(os, "{\n"); + print_argument_validity_check(os, method, kind); + print_save_ctx(os, method, kind); + print_on_error_continue(os); + + for (int i = 0; i < num_params; ++i) { + ParmVarDecl *param = method->getParamDecl(i); + if (is_callback(param->getType())) { + num_params -= 1; + print_callback_local(os, param); + } + } + + osprintf(os, " auto res = %s(", methodname.c_str()); + + for (int i = 0; i < num_params; ++i) { + ParmVarDecl *param = method->getParamDecl(i); + bool load_from_this_ptr = false; + + if (i == 0 && kind == function_kind_member_method) + load_from_this_ptr = true; + + print_method_param_use(os, param, load_from_this_ptr); + + if (i != num_params - 1) + osprintf(os, ", "); + } + osprintf(os, ");\n"); + + print_exceptional_execution_check(os, clazz, method, kind); + if (kind == function_kind_constructor) { + osprintf(os, " ptr = res;\n"); + } else { + print_method_return(os, clazz, method); + } + + osprintf(os, "}\n"); +} + +/* Print a definition for "method" in class "clazz" to "os", + * where at least one of the argument types needs to be converted, + * as specified by "convert". + * + * "kind" specifies the kind of method that should be generated and + * is assumed to be set to function_kind_member_method. + * + * The generated method performs the required conversion(s) and + * calls the method generated without conversions. + * + * Each conversion is performed by calling the conversion function + * with as arguments the isl_ctx of the object and the argument + * to the generated method. + * In order to be able to use this isl_ctx, the current object needs + * to valid. The validity of other arguments is checked + * by the called method. + */ +template<> +void cpp_generator::print_method(ostream &os, + const isl_class &clazz, FunctionDecl *method, function_kind kind, + const std::vector &convert) +{ + string name = clazz.method_name(method); + int num_params = method->getNumParams(); + + if (kind != function_kind_member_method) + die("Automatic conversion currently only supported " + "for object methods"); + + osprintf(os, "\n"); + print_named_method_header(os, clazz, method, name, false, + kind, convert); + osprintf(os, "{\n"); + print_check_ptr(os, "ptr"); + osprintf(os, " return this->%s(", name.c_str()); + for (int i = 1; i < num_params; ++i) { + ParmVarDecl *param = method->getParamDecl(i); + std::string name = param->getName().str(); + + if (i != 1) + osprintf(os, ", "); + if (convert[i]) { + QualType type = param->getOriginalType(); + string cpptype = type2cpp(type); + osprintf(os, "%s(ctx(), %s)", + cpptype.c_str(), name.c_str()); + } else { + osprintf(os, "%s", name.c_str()); + } + } + osprintf(os, ");\n"); + osprintf(os, "}\n"); +} + +/* Print implementations of constructors for class "clazz" to "os". + */ +void cpp_generator::print_constructors_impl(ostream &os, + const isl_class &clazz) +{ + function_set::const_iterator in; + const function_set constructors = clazz.constructors; + + for (in = constructors.begin(); in != constructors.end(); ++in) { + FunctionDecl *cons = *in; + + print_method(os, clazz, cons, function_kind_constructor); + } +} + +/* Print implementation of copy assignment operator for class "clazz" to "os". + * + * If the class has any persistent callbacks, then copy them + * from the original object. + */ +void cpp_generator::print_copy_assignment_impl(ostream &os, + const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + osprintf(os, "\n"); + osprintf(os, "%s &%s::operator=(%s obj) {\n", cppname, + cppname, cppname); + osprintf(os, " std::swap(this->ptr, obj.ptr);\n", name); + if (clazz.has_persistent_callbacks()) + osprintf(os, " copy_callbacks(obj);\n"); + osprintf(os, " return *this;\n"); + osprintf(os, "}\n"); +} + +/* Print implementation of destructor for class "clazz" to "os". + * + * No explicit destructor is needed for type based subclasses. + */ +void cpp_generator::print_destructor_impl(ostream &os, + const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (clazz.is_type_subclass()) + return; + + osprintf(os, "\n"); + osprintf(os, "%s::~%s() {\n", cppname, cppname); + osprintf(os, " if (ptr)\n"); + osprintf(os, " %s_free(ptr);\n", name); + osprintf(os, "}\n"); +} + +/* Print a check that the persistent callback corresponding to "fd" + * is not set, throwing an exception (or printing an error message + * and returning nullptr) if it is set. + */ +void cpp_generator::print_check_no_persistent_callback(ostream &os, + const isl_class &clazz, FunctionDecl *fd) +{ + string callback_name = clazz.persistent_callback_name(fd); + + osprintf(os, " if (%s_data)\n", callback_name.c_str()); + print_invalid(os, 4, "cannot release object with persistent callbacks", + "return nullptr"); +} + +/* Print implementation of ptr() functions for class "clazz" to "os". + * Since type based subclasses share the pointer with their superclass, + * they can also reuse these functions from the superclass. + * + * If an object has persistent callbacks set, then the underlying + * C object pointer cannot be released because it references data + * in the C++ object. + */ +void cpp_generator::print_ptr_impl(ostream &os, const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + set::const_iterator in; + const set &callbacks = clazz.persistent_callbacks; + + if (clazz.is_type_subclass()) + return; + + osprintf(os, "\n"); + osprintf(os, "__isl_give %s *%s::copy() const & {\n", name, cppname); + osprintf(os, " return %s_copy(ptr);\n", name); + osprintf(os, "}\n\n"); + osprintf(os, "__isl_keep %s *%s::get() const {\n", name, cppname); + osprintf(os, " return ptr;\n"); + osprintf(os, "}\n\n"); + osprintf(os, "__isl_give %s *%s::release() {\n", name, cppname); + for (in = callbacks.begin(); in != callbacks.end(); ++in) + print_check_no_persistent_callback(os, clazz, *in); + osprintf(os, " %s *tmp = ptr;\n", name); + osprintf(os, " ptr = nullptr;\n"); + osprintf(os, " return tmp;\n"); + osprintf(os, "}\n\n"); + osprintf(os, "bool %s::is_null() const {\n", cppname); + osprintf(os, " return ptr == nullptr;\n"); + osprintf(os, "}\n"); +} + +/* Print implementations for the "as" and "isa" methods, if "clazz" + * is a superclass with a type function. + * + * "isa" checks whether an object is of a given subclass type. + * "isa_type" does the same, but gets passed the value of the type field + * of the subclass as a function argument and the type of this field + * as a template argument. + * "as" casts an object to a given subclass type, erroring out + * if the object is not of the given type. + * + * If the input is an invalid object, then these methods raise + * an exception. + * If checked bindings are being generated, + * then an invalid boolean or object is returned instead. + */ +void cpp_generator::print_downcast_impl(ostream &os, const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + + if (!clazz.fn_type) + return; + + osprintf(os, "\n"); + osprintf(os, "template \n"); + osprintf(os, "%s %s::isa_type(T subtype) const\n", + isl_bool2cpp().c_str(), cppname); + osprintf(os, "{\n"); + osprintf(os, " if (is_null())\n"); + if (checked) + osprintf(os, " return boolean();\n"); + else + print_throw_NULL_input(os); + osprintf(os, " return %s(get()) == subtype;\n", + clazz.fn_type->getNameAsString().c_str()); + osprintf(os, "}\n"); + + osprintf(os, "template \n"); + osprintf(os, "%s %s::isa() const\n", isl_bool2cpp().c_str(), cppname); + osprintf(os, "{\n"); + osprintf(os, " return isa_type(T::type);\n"); + osprintf(os, "}\n"); + + osprintf(os, "template \n"); + osprintf(os, "T %s::as() const\n", cppname); + osprintf(os, "{\n"); + if (checked) + osprintf(os, " if (isa().is_false())\n"); + else + osprintf(os, " if (!isa())\n"); + print_invalid(os, 4, "not an object of the requested subtype", + "return T()"); + osprintf(os, " return T(copy());\n"); + osprintf(os, "}\n"); +} + +/* Print the implementation of the ctx method. + */ +void cpp_generator::print_ctx_impl(ostream &os, const isl_class &clazz) +{ + const char *name = clazz.name.c_str(); + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + std::string ns = isl_namespace(); + + osprintf(os, "\n"); + osprintf(os, "%sctx %s::ctx() const {\n", ns.c_str(), cppname); + osprintf(os, " return %sctx(%s_get_ctx(ptr));\n", ns.c_str(), name); + osprintf(os, "}\n"); +} + +/* Print the implementations of the methods needed for the persistent callbacks + * of "clazz". + */ +void cpp_generator::print_persistent_callbacks_impl(ostream &os, + const isl_class &clazz) +{ + std::string cppstring = type2cpp(clazz); + const char *cppname = cppstring.c_str(); + string classname = type2cpp(clazz); + set::const_iterator in; + const set &callbacks = clazz.persistent_callbacks; + + if (!clazz.has_persistent_callbacks()) + return; + + osprintf(os, "\n"); + osprintf(os, "%s &%s::copy_callbacks(const %s &obj)\n", + cppname, classname.c_str(), cppname); + osprintf(os, "{\n"); + for (in = callbacks.begin(); in != callbacks.end(); ++in) { + string callback_name = clazz.persistent_callback_name(*in); + + osprintf(os, " %s_data = obj.%s_data;\n", + callback_name.c_str(), callback_name.c_str()); + } + osprintf(os, " return *this;\n"); + osprintf(os, "}\n"); + + for (in = callbacks.begin(); in != callbacks.end(); ++in) { + function_kind kind = function_kind_member_method; + + print_set_persistent_callback(os, clazz, *in, kind); + } +} + +/* Print definitions for methods of class "clazz" to "os". + */ +void cpp_generator::print_methods_impl(ostream &os, const isl_class &clazz) +{ + map::const_iterator it; + + for (it = clazz.methods.begin(); it != clazz.methods.end(); ++it) + print_method_group_impl(os, clazz, it->second); +} + +/* Print the definition for a method "method_name" in "clazz" derived + * from "fd", which sets an enum, to "os". + * In particular, the method "method_name" sets the enum to "enum_name". + * + * The last argument of the C function does not appear in the method call, + * but is fixed to "enum_name" instead. + * Other than that, the method printed here is similar to one + * printed by cpp_generator::print_method_impl, except that + * some of the special cases do not occur. + */ +void cpp_generator::print_set_enum_impl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &enum_name, const string &method_name) +{ + string c_name = fd->getName(); + int n = fd->getNumParams(); + function_kind kind = function_kind_member_method; + + osprintf(os, "\n"); + print_method_header(os, clazz, fd, method_name, n - 1, false, kind); + osprintf(os, "{\n"); + + print_argument_validity_check(os, fd, kind); + print_save_ctx(os, fd, kind); + print_on_error_continue(os); + + osprintf(os, " auto res = %s(", c_name.c_str()); + + for (int i = 0; i < n - 1; ++i) { + ParmVarDecl *param = fd->getParamDecl(i); + + if (i > 0) + osprintf(os, ", "); + print_method_param_use(os, param, i == 0); + } + osprintf(os, ", %s", enum_name.c_str()); + osprintf(os, ");\n"); + + print_exceptional_execution_check(os, clazz, fd, kind); + print_method_return(os, clazz, fd); + + osprintf(os, "}\n"); +} + +/* Print definitions for the methods in "clazz" derived from "fd", + * which sets an enum, to "os". + * + * A method is generated for each value in the enum, setting + * the enum to that value. + */ +void cpp_generator::print_set_enums_impl(ostream &os, const isl_class &clazz, + FunctionDecl *fd) +{ + vector::const_iterator it; + const vector &set_enums = clazz.set_enums.at(fd); + + for (it = set_enums.begin(); it != set_enums.end(); ++it) { + osprintf(os, "\n"); + print_set_enum_impl(os, clazz, fd, it->name, it->method_name); + } +} + +/* Print definitions for methods in "clazz" derived from functions + * that set an enum, to "os". + */ +void cpp_generator::print_set_enums_impl(ostream &os, const isl_class &clazz) +{ + map >::const_iterator it; + + for (it = clazz.set_enums.begin(); it != clazz.set_enums.end(); ++it) + print_set_enums_impl(os, clazz, it->first); +} + +/* Print a definition for the "get" method "fd" in class "clazz", + * using a name that includes the "get_" prefix, to "os". + * + * This definition simply calls the variant without the "get_" prefix and + * returns its result. + * Note that static methods are not considered to be "get" methods. + */ +template<> +void cpp_generator::print_get_method(ostream &os, + const isl_class &clazz, FunctionDecl *fd) +{ + string get_name = clazz.base_method_name(fd); + string name = clazz.method_name(fd); + function_kind kind = function_kind_member_method; + int num_params = fd->getNumParams(); + + osprintf(os, "\n"); + print_named_method_header(os, clazz, fd, get_name, false, kind); + osprintf(os, "{\n"); + osprintf(os, " return %s(", name.c_str()); + for (int i = 1; i < num_params; ++i) { + ParmVarDecl *param = fd->getParamDecl(i); + + if (i != 1) + osprintf(os, ", "); + osprintf(os, "%s", param->getName().str().c_str()); + } + osprintf(os, ");\n"); + osprintf(os, "}\n"); +} + +/* Print definitions for methods "methods" in class "clazz" to "os". + */ +void cpp_generator::print_method_group_impl(ostream &os, const isl_class &clazz, + const function_set &methods) +{ + function_set::const_iterator it; + + for (it = methods.begin(); it != methods.end(); ++it) + print_method_variants(os, clazz, *it); +} + +/* Print the use of "param" to "os". + * + * "load_from_this_ptr" specifies whether the parameter should be loaded from + * the this-ptr. In case a value is loaded from a this pointer, the original + * value must be preserved and must consequently be copied. Values that are + * loaded from parameters do not need to be preserved, as such values will + * already be copies of the actual parameters. It is consequently possible + * to directly take the pointer from these values, which saves + * an unnecessary copy. + * + * In case the parameter is a callback function, two parameters get printed, + * a wrapper for the callback function and a pointer to the actual + * callback function. The wrapper is expected to be available + * in a previously declared variable _lambda, while + * the actual callback function is expected to be stored + * in a structure called _data. + * The caller of this function must ensure that these variables exist. + */ +void cpp_generator::print_method_param_use(ostream &os, ParmVarDecl *param, + bool load_from_this_ptr) +{ + string name = param->getName().str(); + const char *name_str = name.c_str(); + QualType type = param->getOriginalType(); + + if (type->isIntegerType()) { + osprintf(os, "%s", name_str); + return; + } + + if (is_string(type)) { + osprintf(os, "%s.c_str()", name_str); + return; + } + + if (is_callback(type)) { + osprintf(os, "%s_lambda, ", name_str); + osprintf(os, "&%s_data", name_str); + return; + } + + if (!load_from_this_ptr) + osprintf(os, "%s.", name_str); + + if (keeps(param)) { + osprintf(os, "get()"); + } else { + if (load_from_this_ptr) + osprintf(os, "copy()"); + else + osprintf(os, "release()"); + } +} + +/* Print code that checks that all isl object arguments to "method" are valid + * (not NULL) and throws an exception if they are not. + * "kind" specifies the kind of method that is being generated. + * + * If checked bindings are being generated, + * then no such check is performed. + */ +void cpp_generator::print_argument_validity_check(ostream &os, + FunctionDecl *method, function_kind kind) +{ + int n; + bool first = true; + + if (checked) + return; + + n = method->getNumParams(); + for (int i = 0; i < n; ++i) { + bool is_this; + ParmVarDecl *param = method->getParamDecl(i); + string name = param->getName().str(); + const char *name_str = name.c_str(); + QualType type = param->getOriginalType(); + + is_this = i == 0 && kind == function_kind_member_method; + if (!is_this && (is_isl_ctx(type) || !is_isl_type(type))) + continue; + + if (first) + osprintf(os, " if ("); + else + osprintf(os, " || "); + + if (is_this) + osprintf(os, "!ptr"); + else + osprintf(os, "%s.is_null()", name_str); + + first = false; + } + if (first) + return; + osprintf(os, ")\n"); + print_throw_NULL_input(os); +} + +/* Print code for saving a copy of the isl::ctx available at the start + * of the method "method" in a "saved_ctx" variable, + * for use in exception handling. + * "kind" specifies what kind of method "method" is. + * + * If checked bindings are being generated, + * then the "saved_ctx" variable is not needed. + * If "method" is a member function, then obtain the isl_ctx from + * the "this" object. + * If the first argument of the method is an isl::ctx, then use that one. + * Otherwise, save a copy of the isl::ctx associated to the first argument + * of isl object type. + */ +void cpp_generator::print_save_ctx(ostream &os, FunctionDecl *method, + function_kind kind) +{ + int n; + ParmVarDecl *param = method->getParamDecl(0); + QualType type = param->getOriginalType(); + + if (checked) + return; + if (kind == function_kind_member_method) { + osprintf(os, " auto saved_ctx = ctx();\n"); + return; + } + if (is_isl_ctx(type)) { + const char *name; + + name = param->getName().str().c_str(); + osprintf(os, " auto saved_ctx = %s;\n", name); + return; + } + n = method->getNumParams(); + for (int i = 0; i < n; ++i) { + ParmVarDecl *param = method->getParamDecl(i); + QualType type = param->getOriginalType(); + + if (!is_isl_type(type)) + continue; + osprintf(os, " auto saved_ctx = %s.ctx();\n", + param->getName().str().c_str()); + return; + } +} + +/* Print code to make isl not print an error message when an error occurs + * within the current scope (if exceptions are available), + * since the error message will be included in the exception. + * If exceptions are not available, then exception::on_error + * is set to ISL_ON_ERROR_ABORT and isl is therefore made to abort instead. + * + * If checked bindings are being generated, + * then leave it to the user to decide what isl should do on error. + * Otherwise, assume that a valid isl::ctx is available + * in the "saved_ctx" variable, + * e.g., through a prior call to print_save_ctx. + */ +void cpp_generator::print_on_error_continue(ostream &os) +{ + if (checked) + return; + osprintf(os, " options_scoped_set_on_error saved_on_error(saved_ctx, " + "exception::on_error);\n"); +} + +/* Print code to "os" that checks whether any of the persistent callbacks + * of "clazz" is set and if it failed with an exception. If so, the "eptr" + * in the corresponding data structure contains the exception + * that was caught and that needs to be rethrown. + * This field is cleared because the callback and its data may get reused. + * + * The check only needs to be generated for member methods since + * an object is needed for any of the persistent callbacks to be set. + */ +static void print_persistent_callback_exceptional_execution_check(ostream &os, + const isl_class &clazz, cpp_generator::function_kind kind) +{ + const set &callbacks = clazz.persistent_callbacks; + set::const_iterator in; + + if (kind != cpp_generator::function_kind_member_method) + return; + + for (in = callbacks.begin(); in != callbacks.end(); ++in) { + string callback_name = clazz.persistent_callback_name(*in); + + osprintf(os, " if (%s_data && %s_data->eptr) {\n", + callback_name.c_str(), callback_name.c_str()); + osprintf(os, " std::exception_ptr eptr = %s_data->eptr;\n", + callback_name.c_str()); + osprintf(os, " %s_data->eptr = nullptr;\n", + callback_name.c_str()); + osprintf(os, " std::rethrow_exception(eptr);\n"); + osprintf(os, " }\n"); + } +} + +/* Print code that checks whether the execution of the core of "method" + * of class "clazz" was successful. + * "kind" specifies what kind of method "method" is. + * + * If checked bindings are being generated, + * then no checks are performed. + * + * Otherwise, first check if any of the callbacks failed with + * an exception. If so, the "eptr" in the corresponding data structure + * contains the exception that was caught and that needs to be rethrown. + * Then check if the function call failed in any other way and throw + * the appropriate exception. + * In particular, if the return type is isl_stat, isl_bool or isl_size, + * then a negative value indicates a failure. If the return type + * is an isl type, then a NULL value indicates a failure. + * Assume print_save_ctx has made sure that a valid isl::ctx + * is available in the "ctx" variable. + */ +void cpp_generator::print_exceptional_execution_check(ostream &os, + const isl_class &clazz, FunctionDecl *method, function_kind kind) +{ + int n; + bool check_null, check_neg; + QualType return_type = method->getReturnType(); + + if (checked) + return; + + print_persistent_callback_exceptional_execution_check(os, clazz, kind); + + n = method->getNumParams(); + for (int i = 0; i < n; ++i) { + ParmVarDecl *param = method->getParamDecl(i); + const char *name; + + if (!is_callback(param->getOriginalType())) + continue; + name = param->getName().str().c_str(); + osprintf(os, " if (%s_data.eptr)\n", name); + osprintf(os, " std::rethrow_exception(%s_data.eptr);\n", + name); + } + + check_neg = is_isl_neg_error(return_type); + check_null = is_isl_type(return_type); + if (!check_null && !check_neg) + return; + + if (check_neg) + osprintf(os, " if (res < 0)\n"); + else + osprintf(os, " if (!res)\n"); + print_throw_last_error(os); +} + +/* Does "fd" modify an object of a subclass based on a type function? + */ +static bool is_subclass_mutator(const isl_class &clazz, FunctionDecl *fd) +{ + return clazz.is_type_subclass() && generator::is_mutator(clazz, fd); +} + +/* Return the C++ return type of the method corresponding to "fd" in "clazz". + * + * If "fd" modifies an object of a subclass, then return + * the type of this subclass. + * Otherwise, return the C++ counterpart of the actual return type. + */ +std::string cpp_generator::get_return_type(const isl_class &clazz, + FunctionDecl *fd) +{ + if (is_subclass_mutator(clazz, fd)) + return type2cpp(clazz); + else + return type2cpp(fd->getReturnType()); +} + +/* Given a function "method" for setting a "clazz" persistent callback, + * print the implementations of the methods needed for that callback. + * + * In particular, print + * - the implementation of a static inline method + * for use as the C callback function + * - the definition of a private method for setting the callback function + * - the public method for constructing a new object with the callback set. + */ +void cpp_generator::print_set_persistent_callback(ostream &os, + const isl_class &clazz, FunctionDecl *method, + function_kind kind) +{ + string fullname = method->getName(); + ParmVarDecl *param = persistent_callback_arg(method); + string classname = type2cpp(clazz); + string pname; + string callback_name = clazz.persistent_callback_name(method); + + osprintf(os, "\n"); + print_persistent_callback_prototype(os, clazz, method, false); + osprintf(os, "\n"); + osprintf(os, "{\n"); + print_callback_body(os, 2, param, callback_name); + osprintf(os, "}\n\n"); + + pname = param->getName().str(); + print_persistent_callback_setter_prototype(os, clazz, method, false); + osprintf(os, "\n"); + osprintf(os, "{\n"); + print_check_ptr_start(os, clazz, "ptr"); + osprintf(os, " %s_data = std::make_shared();\n", + callback_name.c_str(), callback_name.c_str()); + osprintf(os, " %s_data->func = %s;\n", + callback_name.c_str(), pname.c_str()); + osprintf(os, " ptr = %s(ptr, &%s, %s_data.get());\n", + fullname.c_str(), callback_name.c_str(), callback_name.c_str()); + print_check_ptr_end(os, "ptr"); + osprintf(os, "}\n\n"); + + print_method_header(os, clazz, method, false, kind); + osprintf(os, "{\n"); + osprintf(os, " auto copy = *this;\n"); + osprintf(os, " copy.set_%s_data(%s);\n", + callback_name.c_str(), pname.c_str()); + osprintf(os, " return copy;\n"); + osprintf(os, "}\n"); +} + +/* Print the return statement of the C++ method corresponding + * to the C function "method" in class "clazz" to "os". + * + * The result of the isl function is returned as a new + * object if the underlying isl function returns an isl_* ptr, as a bool + * if the isl function returns an isl_bool, as void if the isl functions + * returns an isl_stat, + * as std::string if the isl function returns 'const char *', and as + * unmodified return value otherwise. + * If checked C++ bindings are being generated, + * then an isl_bool return type is transformed into a boolean and + * an isl_stat into a stat since no exceptions can be generated + * on negative results from the isl function. + * If the method returns a new instance of the same object type and + * if the class has any persistent callbacks, then the data + * for these callbacks are copied from the original to the new object. + * If "clazz" is a subclass that is based on a type function and + * if the return type corresponds to the superclass data type, + * then it is replaced by the subclass data type. + */ +void cpp_generator::print_method_return(ostream &os, const isl_class &clazz, + FunctionDecl *method) +{ + QualType return_type = method->getReturnType(); + string rettype_str = get_return_type(clazz, method); + bool returns_super = is_subclass_mutator(clazz, method); + + if (is_isl_type(return_type) || + (checked && is_isl_neg_error(return_type))) { + osprintf(os, " return manage(res)"); + if (is_mutator(clazz, method) && + clazz.has_persistent_callbacks()) + osprintf(os, ".copy_callbacks(*this)"); + if (returns_super) + osprintf(os, ".as<%s>()", rettype_str.c_str()); + osprintf(os, ";\n"); + } else if (is_isl_stat(return_type)) { + osprintf(os, " return;\n"); + } else if (is_string(return_type)) { + osprintf(os, " std::string tmp(res);\n"); + if (gives(method)) + osprintf(os, " free(res);\n"); + osprintf(os, " return tmp;\n"); + } else { + osprintf(os, " return res;\n"); + } +} + +/* Return the formal parameter at position "pos" of "fd". + * However, if this parameter should be converted, as indicated + * by "convert", then return the second formal parameter + * of the conversion function instead. + * + * If "convert" is empty, then it is assumed that + * none of the arguments should be converted. + */ +ParmVarDecl *cpp_generator::get_param(FunctionDecl *fd, int pos, + const std::vector &convert) +{ + ParmVarDecl *param = fd->getParamDecl(pos); + + if (convert.size() == 0) + return param; + if (!convert[pos]) + return param; + return conversions[param->getOriginalType().getTypePtr()]; +} + +/* Print the header for "method" in class "clazz", with name "cname" and + * "num_params" number of arguments, to "os". + * + * Print the header of a declaration if "is_declaration" is set, otherwise print + * the header of a method definition. + * + * "kind" specifies the kind of method that should be generated. + * + * "convert" specifies which of the method arguments should + * be automatically converted. + * + * This function prints headers for member methods, static methods, and + * constructors, either for their declaration or definition. + * + * Member functions are declared as "const", as they do not change the current + * object, but instead create a new object. They always retrieve the first + * parameter of the original isl function from the this-pointer of the object, + * such that only starting at the second parameter the parameters of the + * original function become part of the method's interface. + * + * A function + * + * __isl_give isl_set *isl_set_intersect(__isl_take isl_set *s1, + * __isl_take isl_set *s2); + * + * is translated into: + * + * inline set intersect(set set2) const; + * + * For static functions and constructors all parameters of the original isl + * function are exposed. + * + * Parameters that are defined as __isl_keep or are of type string, are passed + * as const reference, which allows the compiler to optimize the parameter + * transfer. + * + * Constructors are marked as explicit using the C++ keyword 'explicit' or as + * implicit using a comment in place of the explicit keyword. By annotating + * implicit constructors with a comment, users of the interface are made + * aware of the potential danger that implicit construction is possible + * for these constructors, whereas without a comment not every user would + * know that implicit construction is allowed in absence of an explicit keyword. + * + * If any of the arguments needs to be converted, then the argument + * of the method is changed to that of the source of the conversion. + * The name of the argument is, however, derived from the original + * function argument. + */ +void cpp_generator::print_method_header(ostream &os, const isl_class &clazz, + FunctionDecl *method, const string &cname, int num_params, + bool is_declaration, function_kind kind, + const std::vector &convert) +{ + string rettype_str = get_return_type(clazz, method); + string classname = type2cpp(clazz); + int first_param = 0; + + if (kind == function_kind_member_method) + first_param = 1; + + if (is_declaration) { + osprintf(os, " "); + + if (kind == function_kind_static_method) + osprintf(os, "static "); + + osprintf(os, "inline "); + + if (kind == function_kind_constructor) { + if (is_implicit_conversion(clazz, method)) + osprintf(os, "/* implicit */ "); + else + osprintf(os, "explicit "); + } + } + + if (kind != function_kind_constructor) + osprintf(os, "%s ", rettype_str.c_str()); + + if (!is_declaration) + osprintf(os, "%s::", classname.c_str()); + + if (kind != function_kind_constructor) + osprintf(os, "%s", cname.c_str()); + else + osprintf(os, "%s", classname.c_str()); + + osprintf(os, "("); + + for (int i = first_param; i < num_params; ++i) { + std::string name = method->getParamDecl(i)->getName().str(); + ParmVarDecl *param = get_param(method, i, convert); + QualType type = param->getOriginalType(); + string cpptype = type2cpp(type); + + if (is_callback(type)) + num_params--; + + if (keeps(param) || is_string(type) || is_callback(type)) + osprintf(os, "const %s &%s", cpptype.c_str(), + name.c_str()); + else + osprintf(os, "%s %s", cpptype.c_str(), name.c_str()); + + if (i != num_params - 1) + osprintf(os, ", "); + } + + osprintf(os, ")"); + + if (kind == function_kind_member_method) + osprintf(os, " const"); + + if (is_declaration) + osprintf(os, ";"); + osprintf(os, "\n"); +} + +/* Print the header for a method called "name" in class "clazz" + * derived from "method" to "os". + * + * Print the header of a declaration if "is_declaration" is set, otherwise print + * the header of a method definition. + * + * "kind" specifies the kind of method that should be generated. + * + * "convert" specifies which of the method arguments should + * be automatically converted. + */ +void cpp_generator::print_named_method_header(ostream &os, + const isl_class &clazz, FunctionDecl *method, string name, + bool is_declaration, function_kind kind, + const std::vector &convert) +{ + int num_params = method->getNumParams(); + + name = rename_method(name); + print_method_header(os, clazz, method, name, num_params, + is_declaration, kind, convert); +} + +/* Print the header for "method" in class "clazz" to "os" + * using its default name. + * + * Print the header of a declaration if "is_declaration" is set, otherwise print + * the header of a method definition. + * + * "kind" specifies the kind of method that should be generated. + */ +void cpp_generator::print_method_header(ostream &os, const isl_class &clazz, + FunctionDecl *method, bool is_declaration, function_kind kind) +{ + string name = clazz.method_name(method); + + print_named_method_header(os, clazz, method, name, is_declaration, + kind); +} + +/* Generate the list of argument types for a callback function of + * type "type". If "cpp" is set, then generate the C++ type list, otherwise + * the C type list. + * + * For a callback of type + * + * isl_stat (*)(__isl_take isl_map *map, void *user) + * + * the following C++ argument list is generated: + * + * map + */ +string cpp_generator::generate_callback_args(QualType type, bool cpp) +{ + std::string type_str; + const FunctionProtoType *callback; + int num_params; + + callback = extract_prototype(type); + num_params = callback->getNumArgs(); + if (cpp) + num_params--; + + for (long i = 0; i < num_params; i++) { + QualType type = callback->getArgType(i); + + if (cpp) + type_str += type2cpp(type); + else + type_str += type.getAsString(); + + if (!cpp) + type_str += "arg_" + ::to_string(i); + + if (i != num_params - 1) + type_str += ", "; + } + + return type_str; +} + +/* Generate the full cpp type of a callback function of type "type". + * + * For a callback of type + * + * isl_stat (*)(__isl_take isl_map *map, void *user) + * + * the following type is generated: + * + * std::function + */ +string cpp_generator::generate_callback_type(QualType type) +{ + std::string type_str; + const FunctionProtoType *callback = extract_prototype(type); + QualType return_type = callback->getReturnType(); + string rettype_str = type2cpp(return_type); + + type_str = "std::function<"; + type_str += rettype_str; + type_str += "("; + type_str += generate_callback_args(type, true); + type_str += ")>"; + + return type_str; +} + +/* Print the call to the C++ callback function "call", + * with the given indentation, wrapped + * for use inside the lambda function that is used as the C callback function, + * in the case where checked C++ bindings are being generated. + * + * In particular, print + * + * auto ret = @call@; + * return ret.release(); + */ +void cpp_generator::print_wrapped_call_checked(ostream &os, int indent, + const string &call) +{ + osprintf(os, indent, "auto ret = %s;\n", call.c_str()); + osprintf(os, indent, "return ret.release();\n"); +} + +/* Print the call to the C++ callback function "call", + * with the given indentation and with return type "rtype", wrapped + * for use inside the lambda function that is used as the C callback function. + * + * In particular, print + * + * ISL_CPP_TRY { + * @call@; + * return isl_stat_ok; + * } ISL_CPP_CATCH_ALL { + * data->eptr = std::current_exception(); + * return isl_stat_error; + * } + * or + * ISL_CPP_TRY { + * auto ret = @call@; + * return ret ? isl_bool_true : isl_bool_false; + * } ISL_CPP_CATCH_ALL { + * data->eptr = std::current_exception(); + * return isl_bool_error; + * } + * or + * ISL_CPP_TRY { + * auto ret = @call@; + * return ret.release(); + * } ISL_CPP_CATCH_ALL { + * data->eptr = std::current_exception(); + * return NULL; + * } + * + * depending on the return type. + * + * where ISL_CPP_TRY is defined to "try" and ISL_CPP_CATCH_ALL to "catch (...)" + * (if exceptions are available). + * + * If checked C++ bindings are being generated, then + * the call is wrapped differently. + */ +void cpp_generator::print_wrapped_call(ostream &os, int indent, + const string &call, QualType rtype) +{ + if (checked) + return print_wrapped_call_checked(os, indent, call); + + osprintf(os, indent, "ISL_CPP_TRY {\n"); + if (is_isl_stat(rtype)) + osprintf(os, indent, " %s;\n", call.c_str()); + else + osprintf(os, indent, " auto ret = %s;\n", call.c_str()); + if (is_isl_stat(rtype)) + osprintf(os, indent, " return isl_stat_ok;\n"); + else if (is_isl_bool(rtype)) + osprintf(os, indent, + " return ret ? isl_bool_true : isl_bool_false;\n"); + else + osprintf(os, indent, " return ret.release();\n"); + osprintf(os, indent, "} ISL_CPP_CATCH_ALL {\n"); + osprintf(os, indent, " data->eptr = std::current_exception();\n"); + if (is_isl_stat(rtype)) + osprintf(os, indent, " return isl_stat_error;\n"); + else if (is_isl_bool(rtype)) + osprintf(os, indent, " return isl_bool_error;\n"); + else + osprintf(os, indent, " return NULL;\n"); + osprintf(os, indent, "}\n"); +} + +/* Print the declaration for a "prefix"_data data structure + * that can be used for passing to a C callback function + * containing a copy of the C++ callback function "param", + * along with an std::exception_ptr that is used to store any + * exceptions thrown in the C++ callback. + * + * If the C callback is of the form + * + * isl_stat (*fn)(__isl_take isl_map *map, void *user) + * + * then the following declaration is printed: + * + * struct _data { + * std::function func; + * std::exception_ptr eptr; + * } + * + * (without a newline or a semicolon). + * + * The std::exception_ptr object is not added to "prefix"_data + * if checked C++ bindings are being generated. + */ +void cpp_generator::print_callback_data_decl(ostream &os, ParmVarDecl *param, + const string &prefix) +{ + string cpp_args; + + cpp_args = generate_callback_type(param->getType()); + + osprintf(os, " struct %s_data {\n", prefix.c_str()); + osprintf(os, " %s func;\n", cpp_args.c_str()); + if (!checked) + osprintf(os, " std::exception_ptr eptr;\n"); + osprintf(os, " }"); +} + +/* Print the body of C function callback with the given indentation + * that can be use as an argument to "param" for marshalling + * the corresponding C++ callback. + * The data structure that contains the C++ callback is of type + * "prefix"_data. + * + * For a callback of the form + * + * isl_stat (*fn)(__isl_take isl_map *map, void *user) + * + * the following code is generated: + * + * auto *data = static_cast_data *>(arg_1); + * ISL_CPP_TRY { + * stat ret = (data->func)(manage(arg_0)); + * return isl_stat_ok; + * } ISL_CPP_CATCH_ALL { + * data->eptr = std::current_exception(); + * return isl_stat_error; + * } + * + * If checked C++ bindings are being generated, then + * generate the following code: + * + * auto *data = static_cast_data *>(arg_1); + * stat ret = (data->func)(manage(arg_0)); + * return isl_stat(ret); + */ +void cpp_generator::print_callback_body(ostream &os, int indent, + ParmVarDecl *param, const string &prefix) +{ + QualType ptype, rtype; + string call, last_idx; + const FunctionProtoType *callback; + int num_params; + + ptype = param->getType(); + + callback = extract_prototype(ptype); + rtype = callback->getReturnType(); + num_params = callback->getNumArgs(); + + last_idx = ::to_string(num_params - 1); + + call = "(data->func)("; + for (long i = 0; i < num_params - 1; i++) { + if (!callback_takes_argument(param, i)) + call += "manage_copy"; + else + call += "manage"; + call += "(arg_" + ::to_string(i) + ")"; + if (i != num_params - 2) + call += ", "; + } + call += ")"; + + osprintf(os, indent, + "auto *data = static_cast(arg_%s);\n", + prefix.c_str(), last_idx.c_str()); + print_wrapped_call(os, indent, call, rtype); +} + +/* Print the local variables that are needed for a callback argument, + * in particular, print a lambda function that wraps the callback and + * a pointer to the actual C++ callback function. + * + * For a callback of the form + * + * isl_stat (*fn)(__isl_take isl_map *map, void *user) + * + * the following lambda function is generated: + * + * auto fn_lambda = [](isl_map *arg_0, void *arg_1) -> isl_stat { + * auto *data = static_cast(arg_1); + * try { + * stat ret = (data->func)(manage(arg_0)); + * return isl_stat_ok; + * } catch (...) { + * data->eptr = std::current_exception(); + * return isl_stat_error; + * } + * }; + * + * A copy of the std::function C++ callback function is stored in + * a fn_data data structure for passing to the C callback function, + * along with an std::exception_ptr that is used to store any + * exceptions thrown in the C++ callback. + * + * struct fn_data { + * std::function func; + * std::exception_ptr eptr; + * } fn_data = { fn }; + * + * This std::function object represents the actual user + * callback function together with the locally captured state at the caller. + * + * The lambda function is expected to be used as a C callback function + * where the lambda itself is provided as the function pointer and + * where the user void pointer is a pointer to fn_data. + * The std::function object is extracted from the pointer to fn_data + * inside the lambda function. + * + * The std::exception_ptr object is not added to fn_data + * if checked C++ bindings are being generated. + * The body of the generated lambda function then is as follows: + * + * stat ret = (data->func)(manage(arg_0)); + * return isl_stat(ret); + * + * If the C callback does not take its arguments, then + * manage_copy is used instead of manage. + */ +void cpp_generator::print_callback_local(ostream &os, ParmVarDecl *param) +{ + string pname; + QualType ptype, rtype; + string c_args, cpp_args, rettype; + const FunctionProtoType *callback; + + pname = param->getName().str(); + ptype = param->getType(); + + c_args = generate_callback_args(ptype, false); + + callback = extract_prototype(ptype); + rtype = callback->getReturnType(); + rettype = rtype.getAsString(); + + print_callback_data_decl(os, param, pname); + osprintf(os, " %s_data = { %s };\n", pname.c_str(), pname.c_str()); + osprintf(os, " auto %s_lambda = [](%s) -> %s {\n", + pname.c_str(), c_args.c_str(), rettype.c_str()); + print_callback_body(os, 4, param, pname); + osprintf(os, " };\n"); +} + +/* An array listing functions that must be renamed and the function name they + * should be renamed to. We currently rename functions in case their name would + * match a reserved C++ keyword, which is not allowed in C++. + */ +static const char *rename_map[][2] = { + { "union", "unite" }, +}; + +/* Rename method "name" in case the method name in the C++ bindings should not + * match the name in the C bindings. We do this for example to avoid + * C++ keywords. + */ +std::string cpp_generator::rename_method(std::string name) +{ + for (size_t i = 0; i < sizeof(rename_map) / sizeof(rename_map[0]); i++) + if (name.compare(rename_map[i][0]) == 0) + return rename_map[i][1]; + + return name; +} + +/* Translate isl class "clazz" to its corresponding C++ type. + * Use the name of the type based subclass, if any. + */ +string cpp_generator::type2cpp(const isl_class &clazz) +{ + return type2cpp(clazz.subclass_name); +} + +/* Translate type string "type_str" to its C++ name counterpart. +*/ +string cpp_generator::type2cpp(string type_str) +{ + return type_str.substr(4); +} + +/* Return the C++ counterpart to the isl_bool type. + * If checked C++ bindings are being generated, + * then this is "boolean". Otherwise, it is simply "bool". + */ +string cpp_generator::isl_bool2cpp() +{ + return checked ? "boolean" : "bool"; +} + +/* Return the namespace of the generated C++ bindings. + */ +string cpp_generator::isl_namespace() +{ + return checked ? "isl::checked::" : "isl::"; +} + +/* Translate QualType "type" to its C++ name counterpart. + * + * An isl_bool return type is translated into "bool", + * while an isl_stat is translated into "void" and + * an isl_size is translated to "unsigned". + * The exceptional cases are handled through exceptions. + * If checked C++ bindings are being generated, then + * C++ counterparts of isl_bool, isl_stat and isl_size need to be used instead. + */ +string cpp_generator::type2cpp(QualType type) +{ + if (is_isl_type(type)) + return isl_namespace() + + type2cpp(type->getPointeeType().getAsString()); + + if (is_isl_bool(type)) + return isl_bool2cpp(); + + if (is_isl_stat(type)) + return checked ? "stat" : "void"; + + if (is_isl_size(type)) + return checked ? "class size" : "unsigned"; + + if (type->isIntegerType()) + return type.getAsString(); + + if (is_string(type)) + return "std::string"; + + if (is_callback(type)) + return generate_callback_type(type); + + die("Cannot convert type to C++ type"); +} + +/* Check if "subclass_type" is a subclass of "class_type". + */ +bool cpp_generator::is_subclass(QualType subclass_type, + const isl_class &class_type) +{ + std::string type_str = subclass_type->getPointeeType().getAsString(); + std::vector superclasses; + std::vector parents; + std::vector::iterator ci; + + superclasses = generator::find_superclasses(classes[type_str].type); + + for (ci = superclasses.begin(); ci < superclasses.end(); ci++) + parents.push_back(&classes[*ci]); + + while (!parents.empty()) { + const isl_class *candidate = parents.back(); + + parents.pop_back(); + + if (&class_type == candidate) + return true; + + superclasses = generator::find_superclasses(candidate->type); + + for (ci = superclasses.begin(); ci < superclasses.end(); ci++) + parents.push_back(&classes[*ci]); + } + + return false; +} + +/* Check if "cons" is an implicit conversion constructor of class "clazz". + * + * An implicit conversion constructor is generated in case "cons" has a single + * parameter, where the parameter type is a subclass of the class that is + * currently being generated. + */ +bool cpp_generator::is_implicit_conversion(const isl_class &clazz, + FunctionDecl *cons) +{ + ParmVarDecl *param = cons->getParamDecl(0); + QualType type = param->getOriginalType(); + + int num_params = cons->getNumParams(); + if (num_params != 1) + return false; + + if (is_isl_type(type) && !is_isl_ctx(type) && is_subclass(type, clazz)) + return true; + + return false; +} + +/* Get kind of "method" in "clazz". + * + * Given the declaration of a static or member method, returns its kind. + */ +cpp_generator::function_kind cpp_generator::get_method_kind( + const isl_class &clazz, FunctionDecl *method) +{ + if (is_static(clazz, method)) + return function_kind_static_method; + else + return function_kind_member_method; +} diff --git a/gcc/isl/interface/cpp.h b/gcc/isl/interface/cpp.h new file mode 100644 index 0000000..c207af1 100644 --- /dev/null +++ a/gcc/isl/interface/cpp.h @@ -1,0 +1,169 @@ +#include "generator.h" + +using namespace std; +using namespace clang; + +/* Generator for C++ bindings. + * + * "checked" is set if C++ bindings should be generated + * that rely on the user to check for error conditions. + */ +class cpp_generator : public generator { +protected: + bool checked; +public: + cpp_generator(SourceManager &SM, set &exported_types, + set exported_functions, + set functions, + bool checked = false) : + generator(SM, exported_types, exported_functions, functions), + checked(checked) {} + + enum function_kind { + function_kind_static_method, + function_kind_member_method, + function_kind_constructor, + }; + enum method_part { + decl, + impl, + }; + + virtual void generate(); +private: + void print_forward_declarations(ostream &os); + void print_declarations(ostream &os); + void print_class(ostream &os, const isl_class &clazz); + void print_subclass_type(ostream &os, const isl_class &clazz); + void print_class_forward_decl(ostream &os, const isl_class &clazz); + void print_class_factory_decl(ostream &os, const isl_class &clazz, + const std::string &prefix = std::string()); + void print_protected_constructors_decl(ostream &os, + const isl_class &clazz); + void print_copy_assignment_decl(ostream &os, const isl_class &clazz); + void print_public_constructors_decl(ostream &os, + const isl_class &clazz); + void print_constructors_decl(ostream &os, const isl_class &clazz); + void print_destructor_decl(ostream &os, const isl_class &clazz); + void print_ptr_decl(ostream &os, const isl_class &clazz); + void print_isa_type_template(ostream &os, int indent, + const isl_class &super); + void print_downcast_decl(ostream &os, const isl_class &clazz); + void print_ctx_decl(ostream &os); + void print_persistent_callback_prototype(ostream &os, + const isl_class &clazz, FunctionDecl *method, + bool is_declaration); + void print_persistent_callback_setter_prototype(ostream &os, + const isl_class &clazz, FunctionDecl *method, + bool is_declaration); + void print_persistent_callback_data(ostream &os, const isl_class &clazz, + FunctionDecl *method); + void print_persistent_callbacks_decl(ostream &os, + const isl_class &clazz); + void print_methods_decl(ostream &os, const isl_class &clazz); + bool next_variant(FunctionDecl *fd, std::vector &convert); + template + void print_method_variants(ostream &os, const isl_class &clazz, + FunctionDecl *fd); + void print_method_group_decl(ostream &os, const isl_class &clazz, + const function_set &methods); + void print_named_method_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &name, function_kind kind, + const std::vector &convert = {}); + template + void print_method(ostream &os, const isl_class &clazz, + FunctionDecl *method, function_kind kind); + template + void print_method(ostream &os, const isl_class &clazz, + FunctionDecl *method, function_kind kind, + const std::vector &convert); + void print_set_enum_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &name); + void print_set_enums_decl(ostream &os, const isl_class &clazz, + FunctionDecl *fd); + void print_set_enums_decl(ostream &os, const isl_class &clazz); + void print_implementations(ostream &os); + void print_class_impl(ostream &os, const isl_class &clazz); + void print_check_ptr(ostream &os, const char *ptr); + void print_check_ptr_start(ostream &os, const isl_class &clazz, + const char *ptr); + void print_check_ptr_end(ostream &os, const char *ptr); + void print_class_factory_impl(ostream &os, const isl_class &clazz); + void print_protected_constructors_impl(ostream &os, + const isl_class &clazz); + void print_public_constructors_impl(ostream &os, + const isl_class &clazz); + void print_constructors_impl(ostream &os, const isl_class &clazz); + void print_copy_assignment_impl(ostream &os, const isl_class &clazz); + void print_destructor_impl(ostream &os, const isl_class &clazz); + void print_check_no_persistent_callback(ostream &os, + const isl_class &clazz, FunctionDecl *fd); + void print_ptr_impl(ostream &os, const isl_class &clazz); + void print_downcast_impl(ostream &os, const isl_class &clazz); + void print_ctx_impl(ostream &os, const isl_class &clazz); + void print_persistent_callbacks_impl(ostream &os, + const isl_class &clazz); + void print_methods_impl(ostream &os, const isl_class &clazz); + void print_method_group_impl(ostream &os, const isl_class &clazz, + const function_set &methods); + void print_argument_validity_check(ostream &os, FunctionDecl *method, + function_kind kind); + void print_save_ctx(ostream &os, FunctionDecl *method, + function_kind kind); + void print_on_error_continue(ostream &os); + void print_exceptional_execution_check(ostream &os, + const isl_class &clazz, FunctionDecl *method, + function_kind kind); + void print_set_persistent_callback(ostream &os, const isl_class &clazz, + FunctionDecl *method, function_kind kind); + void print_method_return(ostream &os, const isl_class &clazz, + FunctionDecl *method); + void print_set_enum_impl(ostream &os, const isl_class &clazz, + FunctionDecl *fd, const string &enum_name, + const string &method_name); + void print_set_enums_impl(ostream &os, const isl_class &clazz, + FunctionDecl *fd); + void print_set_enums_impl(ostream &os, const isl_class &clazz); + template + void print_get_method(ostream &os, const isl_class &clazz, + FunctionDecl *fd); + void print_invalid(ostream &os, int indent, const char *msg, + const char *checked_code); + void print_stream_insertion(ostream &os, const isl_class &clazz); + void print_method_param_use(ostream &os, ParmVarDecl *param, + bool load_from_this_ptr); + std::string get_return_type(const isl_class &clazz, FunctionDecl *fd); + ParmVarDecl *get_param(FunctionDecl *fd, int pos, + const std::vector &convert); + void print_method_header(ostream &os, const isl_class &clazz, + FunctionDecl *method, const string &cname, int num_params, + bool is_declaration, function_kind kind, + const std::vector &convert = {}); + void print_named_method_header(ostream &os, const isl_class &clazz, + FunctionDecl *method, string name, bool is_declaration, + function_kind kind, const std::vector &convert = {}); + void print_method_header(ostream &os, const isl_class &clazz, + FunctionDecl *method, bool is_declaration, function_kind kind); + string generate_callback_args(QualType type, bool cpp); + string generate_callback_type(QualType type); + void print_wrapped_call_checked(std::ostream &os, int indent, + const std::string &call); + void print_wrapped_call(std::ostream &os, int indent, + const std::string &call, QualType rtype); + void print_callback_data_decl(ostream &os, ParmVarDecl *param, + const string &name); + void print_callback_body(ostream &os, int indent, ParmVarDecl *param, + const string &name); + void print_callback_local(ostream &os, ParmVarDecl *param); + std::string rename_method(std::string name); + string isl_bool2cpp(); + string isl_namespace(); + string type2cpp(QualType type); + bool is_implicit_conversion(const isl_class &clazz, FunctionDecl *cons); + bool is_subclass(QualType subclass_type, const isl_class &class_type); + function_kind get_method_kind(const isl_class &clazz, + FunctionDecl *method); +public: + static string type2cpp(const isl_class &clazz); + static string type2cpp(string type_string); +}; diff --git a/gcc/isl/interface/cpp_conversion.cc b/gcc/isl/interface/cpp_conversion.cc new file mode 100644 index 0000000..58294d5 100644 --- /dev/null +++ a/gcc/isl/interface/cpp_conversion.cc @@ -1,0 +1,86 @@ +/* + * Copyright 2018 Sven Verdoolaege + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege. + */ + +#include +#include +#include + +#include "cpp.h" +#include "cpp_conversion.h" + +/* If "clazz" describes a subclass of a C type, then print code + * for converting an object of the class derived from the C type + * to the subclass. Do this by first converting this class + * to the immediate superclass of the subclass and then converting + * from this superclass to the subclass. + */ +void cpp_conversion_generator::cast(const isl_class &clazz, const char *to) +{ + string name = cpp_generator::type2cpp(clazz); + + if (!clazz.is_type_subclass()) + return; + + cast(classes[clazz.superclass_name], to); + printf(".as<%s%s>()", to, name.c_str()); +} + +/* Print a function called "function" for converting objects of + * "clazz" from the "from" bindings to the "to" bindings. + * If "clazz" describes a subclass of a C type, then the result + * of the conversion between bindings is derived from the C type and + * needs to be converted back to the subclass. + */ +void cpp_conversion_generator::convert(const isl_class &clazz, + const char *from, const char *to, const char *function) +{ + string name = cpp_generator::type2cpp(clazz); + + printf("%s%s %s(%s%s obj) {\n", + to, name.c_str(), function, from, name.c_str()); + printf("\t""return %s""manage(obj.copy())", to); + cast(clazz, to); + printf(";\n"); + printf("}\n"); + printf("\n"); +} + +/* Print functions for converting objects of "clazz" + * between the default and the checked C++ bindings. + * + * The conversion from default to checked is called "check". + * The inverse conversion is called "uncheck". + * For example, to "set", the following two functions are generated: + * + * checked::set check(set obj) { + * return checked::manage(obj.copy()); + * } + * + * set uncheck(checked::set obj) { + * return manage(obj.copy()); + * } + */ +void cpp_conversion_generator::print(const isl_class &clazz) +{ + convert(clazz, "", "checked::", "check"); + convert(clazz, "checked::", "", "uncheck"); +} + +/* Generate conversion functions for converting objects between + * the default and the checked C++ bindings. + * Do this for each exported class. + */ +void cpp_conversion_generator::generate() +{ + map::iterator ci; + + printf("namespace isl {\n\n"); + for (ci = classes.begin(); ci != classes.end(); ++ci) + print(ci->second); + printf("} // namespace isl\n"); +} diff --git a/gcc/isl/interface/cpp_conversion.h b/gcc/isl/interface/cpp_conversion.h new file mode 100644 index 0000000..57856b2 100644 --- /dev/null +++ a/gcc/isl/interface/cpp_conversion.h @@ -1,0 +1,15 @@ +#include "generator.h" + +class cpp_conversion_generator : public generator { + void cast(const isl_class &clazz, const char *to); + void convert(const isl_class &clazz, const char *from, const char *to, + const char *function); + void print(const isl_class &clazz); +public: + cpp_conversion_generator(SourceManager &SM, + set &exported_types, + set exported_functions, + set functions) : + generator(SM, exported_types, exported_functions, functions) {} + virtual void generate(); +}; diff --git a/gcc/isl/m4/ax_cxx_compile_stdcxx.m4 b/gcc/isl/m4/ax_cxx_compile_stdcxx.m4 new file mode 100644 index 0000000..5032bba 100644 --- /dev/null +++ a/gcc/isl/m4/ax_cxx_compile_stdcxx.m4 @@ -1,0 +1,982 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the specified +# version of the C++ standard. If necessary, add switches to CXX and +# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) +# or '14' (for the C++14 standard). +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016 Krzesimir Nowak +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro +dnl (serial version number 13). + +AX_REQUIRE_DEFINED([AC_MSG_WARN]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], + [$3], [optional], [ax_cxx_compile_cxx$1_required=false], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi + + m4_if([$2], [noext], [], [dnl + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success = xno; then + dnl HP's aCC needs +std=c++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=c++11" + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) + fi + fi + if test x$ac_success = xno; then + HAVE_CXX$1=0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1=1 + AC_DEFINE(HAVE_CXX$1,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1) + m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])]) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + +]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus <= 201402L + +#error "This is not a C++17 compiler" + +#else + +#if defined(__clang__) + #define REALLY_CLANG +#else + #if defined(__GNUC__) + #define REALLY_GCC + #endif +#endif + +#include +#include +#include + +namespace cxx17 +{ + +#if !defined(REALLY_CLANG) + namespace test_constexpr_lambdas + { + + // TODO: test it with clang++ from git + + constexpr int foo = [](){return 42;}(); + + } +#endif // !defined(REALLY_CLANG) + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + +#if !defined(REALLY_CLANG) + namespace test_template_argument_deduction_for_class_templates + { + + // TODO: test it with clang++ from git + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } +#endif // !defined(REALLY_CLANG) + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + +#if !defined(REALLY_CLANG) + namespace test_structured_bindings + { + + // TODO: test it with clang++ from git + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } +#endif // !defined(REALLY_CLANG) + +#if !defined(REALLY_CLANG) + namespace test_exception_spec_type_system + { + + // TODO: test it with clang++ from git + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } +#endif // !defined(REALLY_CLANG) + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus <= 201402L + +]]) diff --git a/gcc/isl/m4/ax_cxx_compile_stdcxx_11.m4 b/gcc/isl/m4/ax_cxx_compile_stdcxx_11.m4 new file mode 100644 index 0000000..0aadeaf 100644 --- /dev/null +++ a/gcc/isl/m4/ax_cxx_compile_stdcxx_11.m4 @@ -1,0 +1,39 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++11 +# standard; if necessary, add switches to CXX and CXXCPP to enable +# support. +# +# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX +# macro with the version set to C++11. The two optional arguments are +# forwarded literally as the second and third argument respectively. +# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for +# more information. If you want to use this macro, you also need to +# download the ax_cxx_compile_stdcxx.m4 file. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 17 + +AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])]) diff --git a/gcc/isl/python/isl.py.top b/gcc/isl/python/isl.py.top new file mode 100644 index 0000000..5c858c9 100644 --- /dev/null +++ a/gcc/isl/python/isl.py.top @@ -1,0 +1,37 @@ +import os +from ctypes import * +from ctypes.util import find_library + +isl_dyld_library_path = os.environ.get('ISL_DYLD_LIBRARY_PATH') +if isl_dyld_library_path != None: + os.environ['DYLD_LIBRARY_PATH'] = isl_dyld_library_path +try: + isl = cdll.LoadLibrary(isl_dlname) +except: + isl = cdll.LoadLibrary(find_library("isl")) +libc = cdll.LoadLibrary(find_library("c")) + +class Error(Exception): + pass + +class Context: + defaultInstance = None + + def __init__(self): + ptr = isl.isl_ctx_alloc() + self.ptr = ptr + + def __del__(self): + isl.isl_ctx_free(self) + + def from_param(self): + return c_void_p(self.ptr) + + @staticmethod + def getDefaultInstance(): + if Context.defaultInstance == None: + Context.defaultInstance = Context() + return Context.defaultInstance + +isl.isl_ctx_alloc.restype = c_void_p +isl.isl_ctx_free.argtypes = [Context] diff --git a/gcc/isl/include/isl/cpp-checked-conversion.h b/gcc/isl/include/isl/cpp-checked-conversion.h new file mode 100644 index 0000000..20e422e 100644 --- /dev/null +++ a/gcc/isl/include/isl/cpp-checked-conversion.h @@ -1,0 +1,675 @@ +/// These are automatically generated conversions between +/// the default and the checked C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP_CHECKED_CONVERSION +#define ISL_CPP_CHECKED_CONVERSION + +#include +#include + +namespace isl { + +checked::aff check(aff obj) { + return checked::manage(obj.copy()); +} + +aff uncheck(checked::aff obj) { + return manage(obj.copy()); +} + +checked::aff_list check(aff_list obj) { + return checked::manage(obj.copy()); +} + +aff_list uncheck(checked::aff_list obj) { + return manage(obj.copy()); +} + +checked::ast_build check(ast_build obj) { + return checked::manage(obj.copy()); +} + +ast_build uncheck(checked::ast_build obj) { + return manage(obj.copy()); +} + +checked::ast_expr check(ast_expr obj) { + return checked::manage(obj.copy()); +} + +ast_expr uncheck(checked::ast_expr obj) { + return manage(obj.copy()); +} + +checked::ast_expr_id check(ast_expr_id obj) { + return checked::manage(obj.copy()).as(); +} + +ast_expr_id uncheck(checked::ast_expr_id obj) { + return manage(obj.copy()).as(); +} + +checked::ast_expr_int check(ast_expr_int obj) { + return checked::manage(obj.copy()).as(); +} + +ast_expr_int uncheck(checked::ast_expr_int obj) { + return manage(obj.copy()).as(); +} + +checked::ast_expr_op check(ast_expr_op obj) { + return checked::manage(obj.copy()).as(); +} + +ast_expr_op uncheck(checked::ast_expr_op obj) { + return manage(obj.copy()).as(); +} + +checked::ast_expr_op_access check(ast_expr_op_access obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_access uncheck(checked::ast_expr_op_access obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_add check(ast_expr_op_add obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_add uncheck(checked::ast_expr_op_add obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_address_of check(ast_expr_op_address_of obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_address_of uncheck(checked::ast_expr_op_address_of obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_and check(ast_expr_op_and obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_and uncheck(checked::ast_expr_op_and obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_and_then check(ast_expr_op_and_then obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_and_then uncheck(checked::ast_expr_op_and_then obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_call check(ast_expr_op_call obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_call uncheck(checked::ast_expr_op_call obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_cond check(ast_expr_op_cond obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_cond uncheck(checked::ast_expr_op_cond obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_div check(ast_expr_op_div obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_div uncheck(checked::ast_expr_op_div obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_eq check(ast_expr_op_eq obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_eq uncheck(checked::ast_expr_op_eq obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_fdiv_q check(ast_expr_op_fdiv_q obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_fdiv_q uncheck(checked::ast_expr_op_fdiv_q obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_ge check(ast_expr_op_ge obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_ge uncheck(checked::ast_expr_op_ge obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_gt check(ast_expr_op_gt obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_gt uncheck(checked::ast_expr_op_gt obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_le check(ast_expr_op_le obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_le uncheck(checked::ast_expr_op_le obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_lt check(ast_expr_op_lt obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_lt uncheck(checked::ast_expr_op_lt obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_max check(ast_expr_op_max obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_max uncheck(checked::ast_expr_op_max obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_member check(ast_expr_op_member obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_member uncheck(checked::ast_expr_op_member obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_min check(ast_expr_op_min obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_min uncheck(checked::ast_expr_op_min obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_minus check(ast_expr_op_minus obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_minus uncheck(checked::ast_expr_op_minus obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_mul check(ast_expr_op_mul obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_mul uncheck(checked::ast_expr_op_mul obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_or check(ast_expr_op_or obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_or uncheck(checked::ast_expr_op_or obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_or_else check(ast_expr_op_or_else obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_or_else uncheck(checked::ast_expr_op_or_else obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_pdiv_q check(ast_expr_op_pdiv_q obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_pdiv_q uncheck(checked::ast_expr_op_pdiv_q obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_pdiv_r check(ast_expr_op_pdiv_r obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_pdiv_r uncheck(checked::ast_expr_op_pdiv_r obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_select check(ast_expr_op_select obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_select uncheck(checked::ast_expr_op_select obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_sub check(ast_expr_op_sub obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_sub uncheck(checked::ast_expr_op_sub obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_expr_op_zdiv_r check(ast_expr_op_zdiv_r obj) { + return checked::manage(obj.copy()).as().as(); +} + +ast_expr_op_zdiv_r uncheck(checked::ast_expr_op_zdiv_r obj) { + return manage(obj.copy()).as().as(); +} + +checked::ast_node check(ast_node obj) { + return checked::manage(obj.copy()); +} + +ast_node uncheck(checked::ast_node obj) { + return manage(obj.copy()); +} + +checked::ast_node_block check(ast_node_block obj) { + return checked::manage(obj.copy()).as(); +} + +ast_node_block uncheck(checked::ast_node_block obj) { + return manage(obj.copy()).as(); +} + +checked::ast_node_for check(ast_node_for obj) { + return checked::manage(obj.copy()).as(); +} + +ast_node_for uncheck(checked::ast_node_for obj) { + return manage(obj.copy()).as(); +} + +checked::ast_node_if check(ast_node_if obj) { + return checked::manage(obj.copy()).as(); +} + +ast_node_if uncheck(checked::ast_node_if obj) { + return manage(obj.copy()).as(); +} + +checked::ast_node_list check(ast_node_list obj) { + return checked::manage(obj.copy()); +} + +ast_node_list uncheck(checked::ast_node_list obj) { + return manage(obj.copy()); +} + +checked::ast_node_mark check(ast_node_mark obj) { + return checked::manage(obj.copy()).as(); +} + +ast_node_mark uncheck(checked::ast_node_mark obj) { + return manage(obj.copy()).as(); +} + +checked::ast_node_user check(ast_node_user obj) { + return checked::manage(obj.copy()).as(); +} + +ast_node_user uncheck(checked::ast_node_user obj) { + return manage(obj.copy()).as(); +} + +checked::basic_map check(basic_map obj) { + return checked::manage(obj.copy()); +} + +basic_map uncheck(checked::basic_map obj) { + return manage(obj.copy()); +} + +checked::basic_set check(basic_set obj) { + return checked::manage(obj.copy()); +} + +basic_set uncheck(checked::basic_set obj) { + return manage(obj.copy()); +} + +checked::fixed_box check(fixed_box obj) { + return checked::manage(obj.copy()); +} + +fixed_box uncheck(checked::fixed_box obj) { + return manage(obj.copy()); +} + +checked::id check(id obj) { + return checked::manage(obj.copy()); +} + +id uncheck(checked::id obj) { + return manage(obj.copy()); +} + +checked::id_list check(id_list obj) { + return checked::manage(obj.copy()); +} + +id_list uncheck(checked::id_list obj) { + return manage(obj.copy()); +} + +checked::map check(map obj) { + return checked::manage(obj.copy()); +} + +map uncheck(checked::map obj) { + return manage(obj.copy()); +} + +checked::multi_aff check(multi_aff obj) { + return checked::manage(obj.copy()); +} + +multi_aff uncheck(checked::multi_aff obj) { + return manage(obj.copy()); +} + +checked::multi_id check(multi_id obj) { + return checked::manage(obj.copy()); +} + +multi_id uncheck(checked::multi_id obj) { + return manage(obj.copy()); +} + +checked::multi_pw_aff check(multi_pw_aff obj) { + return checked::manage(obj.copy()); +} + +multi_pw_aff uncheck(checked::multi_pw_aff obj) { + return manage(obj.copy()); +} + +checked::multi_union_pw_aff check(multi_union_pw_aff obj) { + return checked::manage(obj.copy()); +} + +multi_union_pw_aff uncheck(checked::multi_union_pw_aff obj) { + return manage(obj.copy()); +} + +checked::multi_val check(multi_val obj) { + return checked::manage(obj.copy()); +} + +multi_val uncheck(checked::multi_val obj) { + return manage(obj.copy()); +} + +checked::point check(point obj) { + return checked::manage(obj.copy()); +} + +point uncheck(checked::point obj) { + return manage(obj.copy()); +} + +checked::pw_aff check(pw_aff obj) { + return checked::manage(obj.copy()); +} + +pw_aff uncheck(checked::pw_aff obj) { + return manage(obj.copy()); +} + +checked::pw_aff_list check(pw_aff_list obj) { + return checked::manage(obj.copy()); +} + +pw_aff_list uncheck(checked::pw_aff_list obj) { + return manage(obj.copy()); +} + +checked::pw_multi_aff check(pw_multi_aff obj) { + return checked::manage(obj.copy()); +} + +pw_multi_aff uncheck(checked::pw_multi_aff obj) { + return manage(obj.copy()); +} + +checked::pw_multi_aff_list check(pw_multi_aff_list obj) { + return checked::manage(obj.copy()); +} + +pw_multi_aff_list uncheck(checked::pw_multi_aff_list obj) { + return manage(obj.copy()); +} + +checked::schedule check(schedule obj) { + return checked::manage(obj.copy()); +} + +schedule uncheck(checked::schedule obj) { + return manage(obj.copy()); +} + +checked::schedule_constraints check(schedule_constraints obj) { + return checked::manage(obj.copy()); +} + +schedule_constraints uncheck(checked::schedule_constraints obj) { + return manage(obj.copy()); +} + +checked::schedule_node check(schedule_node obj) { + return checked::manage(obj.copy()); +} + +schedule_node uncheck(checked::schedule_node obj) { + return manage(obj.copy()); +} + +checked::schedule_node_band check(schedule_node_band obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_band uncheck(checked::schedule_node_band obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_context check(schedule_node_context obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_context uncheck(checked::schedule_node_context obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_domain check(schedule_node_domain obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_domain uncheck(checked::schedule_node_domain obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_expansion check(schedule_node_expansion obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_expansion uncheck(checked::schedule_node_expansion obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_extension check(schedule_node_extension obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_extension uncheck(checked::schedule_node_extension obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_filter check(schedule_node_filter obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_filter uncheck(checked::schedule_node_filter obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_guard check(schedule_node_guard obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_guard uncheck(checked::schedule_node_guard obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_leaf check(schedule_node_leaf obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_leaf uncheck(checked::schedule_node_leaf obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_mark check(schedule_node_mark obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_mark uncheck(checked::schedule_node_mark obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_sequence check(schedule_node_sequence obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_sequence uncheck(checked::schedule_node_sequence obj) { + return manage(obj.copy()).as(); +} + +checked::schedule_node_set check(schedule_node_set obj) { + return checked::manage(obj.copy()).as(); +} + +schedule_node_set uncheck(checked::schedule_node_set obj) { + return manage(obj.copy()).as(); +} + +checked::set check(set obj) { + return checked::manage(obj.copy()); +} + +set uncheck(checked::set obj) { + return manage(obj.copy()); +} + +checked::space check(space obj) { + return checked::manage(obj.copy()); +} + +space uncheck(checked::space obj) { + return manage(obj.copy()); +} + +checked::union_access_info check(union_access_info obj) { + return checked::manage(obj.copy()); +} + +union_access_info uncheck(checked::union_access_info obj) { + return manage(obj.copy()); +} + +checked::union_flow check(union_flow obj) { + return checked::manage(obj.copy()); +} + +union_flow uncheck(checked::union_flow obj) { + return manage(obj.copy()); +} + +checked::union_map check(union_map obj) { + return checked::manage(obj.copy()); +} + +union_map uncheck(checked::union_map obj) { + return manage(obj.copy()); +} + +checked::union_pw_aff check(union_pw_aff obj) { + return checked::manage(obj.copy()); +} + +union_pw_aff uncheck(checked::union_pw_aff obj) { + return manage(obj.copy()); +} + +checked::union_pw_aff_list check(union_pw_aff_list obj) { + return checked::manage(obj.copy()); +} + +union_pw_aff_list uncheck(checked::union_pw_aff_list obj) { + return manage(obj.copy()); +} + +checked::union_pw_multi_aff check(union_pw_multi_aff obj) { + return checked::manage(obj.copy()); +} + +union_pw_multi_aff uncheck(checked::union_pw_multi_aff obj) { + return manage(obj.copy()); +} + +checked::union_set check(union_set obj) { + return checked::manage(obj.copy()); +} + +union_set uncheck(checked::union_set obj) { + return manage(obj.copy()); +} + +checked::union_set_list check(union_set_list obj) { + return checked::manage(obj.copy()); +} + +union_set_list uncheck(checked::union_set_list obj) { + return manage(obj.copy()); +} + +checked::val check(val obj) { + return checked::manage(obj.copy()); +} + +val uncheck(checked::val obj) { + return manage(obj.copy()); +} + +checked::val_list check(val_list obj) { + return checked::manage(obj.copy()); +} + +val_list uncheck(checked::val_list obj) { + return manage(obj.copy()); +} + +} // namespace isl + +#endif /* ISL_CPP_CHECKED_CONVERSION */ diff --git a/gcc/isl/include/isl/cpp-checked.h b/gcc/isl/include/isl/cpp-checked.h new file mode 100644 index 0000000..bbed849 100644 --- /dev/null +++ a/gcc/isl/include/isl/cpp-checked.h @@ -1,0 +1,12532 @@ +/// These are automatically generated checked C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP_CHECKED +#define ISL_CPP_CHECKED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace isl { +namespace checked { + +#define ISLPP_STRINGIZE_(X) #X +#define ISLPP_STRINGIZE(X) ISLPP_STRINGIZE_(X) + +#define ISLPP_ASSERT(test, message) \ + do { \ + if (test) \ + break; \ + fputs("Assertion \"" #test "\" failed at " __FILE__ \ + ":" ISLPP_STRINGIZE(__LINE__) "\n " message "\n", \ + stderr); \ + abort(); \ + } while (0) + +/* Class used to check that isl::checked::boolean, + * isl::checked::stat and isl::checked::size values are checked for errors. + */ +struct checker { + bool checked = false; + ~checker() { + ISLPP_ASSERT(checked, "IMPLEMENTATION ERROR: Unchecked state"); + } +}; + +class boolean { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_bool val; + + friend boolean manage(isl_bool val); + boolean(isl_bool val): val(val) {} +public: + static boolean error() { + return boolean(isl_bool_error); + } + boolean() + : val(isl_bool_error) {} + + /* implicit */ boolean(bool val) + : val(val ? isl_bool_true : isl_bool_false) {} + + isl_bool release() { + auto tmp = val; + val = isl_bool_error; + check->checked = true; + return tmp; + } + + bool is_error() const { check->checked = true; return val == isl_bool_error; } + bool is_false() const { check->checked = true; return val == isl_bool_false; } + bool is_true() const { check->checked = true; return val == isl_bool_true; } + + explicit operator bool() const { + ISLPP_ASSERT(check->checked, "IMPLEMENTATION ERROR: Unchecked error state"); + ISLPP_ASSERT(!is_error(), "IMPLEMENTATION ERROR: Unhandled error state"); + return is_true(); + } + + boolean negate() { + if (val == isl_bool_true) + val = isl_bool_false; + else if (val == isl_bool_false) + val = isl_bool_true; + return *this; + } + + boolean operator!() const { + return boolean(*this).negate(); + } +}; + +inline boolean manage(isl_bool val) { + return boolean(val); +} + +class ctx { + isl_ctx *ptr; +public: + /* implicit */ ctx(isl_ctx *ctx) + : ptr(ctx) {} + isl_ctx *release() { + auto tmp = ptr; + ptr = nullptr; + return tmp; + } + isl_ctx *get() { + return ptr; + } +}; + +/* Class encapsulating an isl_stat value. + */ +class stat { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_stat val; + + friend stat manage(isl_stat val); + stat(isl_stat val) : val(val) {} +public: + static stat ok() { + return stat(isl_stat_ok); + } + static stat error() { + return stat(isl_stat_error); + } + stat() : val(isl_stat_error) {} + + isl_stat release() { + check->checked = true; + return val; + } + + bool is_error() const { + check->checked = true; + return val == isl_stat_error; + } + bool is_ok() const { + check->checked = true; + return val == isl_stat_ok; + } +}; + +inline stat manage(isl_stat val) +{ + return stat(val); +} + +/* Class encapsulating an isl_size value. + */ +class size { +private: + mutable std::shared_ptr check = std::make_shared(); + isl_size val; + + friend size manage(isl_size val); + size(isl_size val) : val(val) {} +public: + size() : val(isl_size_error) {} + + isl_size release() { + auto tmp = val; + val = isl_size_error; + check->checked = true; + return tmp; + } + + bool is_error() const { + check->checked = true; + return val == isl_size_error; + } + + explicit operator unsigned() const { + ISLPP_ASSERT(check->checked, + "IMPLEMENTATION ERROR: Unchecked error state"); + ISLPP_ASSERT(!is_error(), + "IMPLEMENTATION ERROR: Unhandled error state"); + return val; + } +}; + +inline size manage(isl_size val) +{ + return size(val); +} + +} +} // namespace isl + +namespace isl { + +namespace checked { + +// forward declarations +class aff; +class aff_list; +class ast_build; +class ast_expr; +class ast_expr_id; +class ast_expr_int; +class ast_expr_op; +class ast_expr_op_access; +class ast_expr_op_add; +class ast_expr_op_address_of; +class ast_expr_op_and; +class ast_expr_op_and_then; +class ast_expr_op_call; +class ast_expr_op_cond; +class ast_expr_op_div; +class ast_expr_op_eq; +class ast_expr_op_fdiv_q; +class ast_expr_op_ge; +class ast_expr_op_gt; +class ast_expr_op_le; +class ast_expr_op_lt; +class ast_expr_op_max; +class ast_expr_op_member; +class ast_expr_op_min; +class ast_expr_op_minus; +class ast_expr_op_mul; +class ast_expr_op_or; +class ast_expr_op_or_else; +class ast_expr_op_pdiv_q; +class ast_expr_op_pdiv_r; +class ast_expr_op_select; +class ast_expr_op_sub; +class ast_expr_op_zdiv_r; +class ast_node; +class ast_node_block; +class ast_node_for; +class ast_node_if; +class ast_node_list; +class ast_node_mark; +class ast_node_user; +class basic_map; +class basic_set; +class fixed_box; +class id; +class id_list; +class map; +class multi_aff; +class multi_id; +class multi_pw_aff; +class multi_union_pw_aff; +class multi_val; +class point; +class pw_aff; +class pw_aff_list; +class pw_multi_aff; +class pw_multi_aff_list; +class schedule; +class schedule_constraints; +class schedule_node; +class schedule_node_band; +class schedule_node_context; +class schedule_node_domain; +class schedule_node_expansion; +class schedule_node_extension; +class schedule_node_filter; +class schedule_node_guard; +class schedule_node_leaf; +class schedule_node_mark; +class schedule_node_sequence; +class schedule_node_set; +class set; +class space; +class union_access_info; +class union_flow; +class union_map; +class union_pw_aff; +class union_pw_aff_list; +class union_pw_multi_aff; +class union_set; +class union_set_list; +class val; +class val_list; + +// declarations for isl::aff +inline aff manage(__isl_take isl_aff *ptr); +inline aff manage_copy(__isl_keep isl_aff *ptr); + +class aff { + friend inline aff manage(__isl_take isl_aff *ptr); + friend inline aff manage_copy(__isl_keep isl_aff *ptr); + +protected: + isl_aff *ptr = nullptr; + + inline explicit aff(__isl_take isl_aff *ptr); + +public: + inline /* implicit */ aff(); + inline /* implicit */ aff(const aff &obj); + inline explicit aff(isl::checked::ctx ctx, const std::string &str); + inline aff &operator=(aff obj); + inline ~aff(); + inline __isl_give isl_aff *copy() const &; + inline __isl_give isl_aff *copy() && = delete; + inline __isl_keep isl_aff *get() const; + inline __isl_give isl_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::aff add(isl::checked::aff aff2) const; + inline isl::checked::aff add_constant(isl::checked::val v) const; + inline isl::checked::aff add_constant(long v) const; + inline isl::checked::basic_set bind(isl::checked::id id) const; + inline isl::checked::basic_set bind(const std::string &id) const; + inline isl::checked::aff ceil() const; + inline isl::checked::aff div(isl::checked::aff aff2) const; + inline isl::checked::set eq_set(isl::checked::aff aff2) const; + inline isl::checked::val eval(isl::checked::point pnt) const; + inline isl::checked::aff floor() const; + inline isl::checked::set ge_set(isl::checked::aff aff2) const; + inline isl::checked::aff gist(isl::checked::set context) const; + inline isl::checked::set gt_set(isl::checked::aff aff2) const; + inline isl::checked::set le_set(isl::checked::aff aff2) const; + inline isl::checked::set lt_set(isl::checked::aff aff2) const; + inline isl::checked::aff mod(isl::checked::val mod) const; + inline isl::checked::aff mod(long mod) const; + inline isl::checked::aff mul(isl::checked::aff aff2) const; + inline isl::checked::set ne_set(isl::checked::aff aff2) const; + inline isl::checked::aff neg() const; + inline isl::checked::aff pullback(isl::checked::multi_aff ma) const; + inline isl::checked::aff scale(isl::checked::val v) const; + inline isl::checked::aff scale(long v) const; + inline isl::checked::aff scale_down(isl::checked::val v) const; + inline isl::checked::aff scale_down(long v) const; + inline isl::checked::aff sub(isl::checked::aff aff2) const; + inline isl::checked::aff unbind_params_insert_domain(isl::checked::multi_id domain) const; +}; + +// declarations for isl::aff_list +inline aff_list manage(__isl_take isl_aff_list *ptr); +inline aff_list manage_copy(__isl_keep isl_aff_list *ptr); + +class aff_list { + friend inline aff_list manage(__isl_take isl_aff_list *ptr); + friend inline aff_list manage_copy(__isl_keep isl_aff_list *ptr); + +protected: + isl_aff_list *ptr = nullptr; + + inline explicit aff_list(__isl_take isl_aff_list *ptr); + +public: + inline /* implicit */ aff_list(); + inline /* implicit */ aff_list(const aff_list &obj); + inline explicit aff_list(isl::checked::ctx ctx, int n); + inline explicit aff_list(isl::checked::aff el); + inline aff_list &operator=(aff_list obj); + inline ~aff_list(); + inline __isl_give isl_aff_list *copy() const &; + inline __isl_give isl_aff_list *copy() && = delete; + inline __isl_keep isl_aff_list *get() const; + inline __isl_give isl_aff_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::aff_list add(isl::checked::aff el) const; + inline isl::checked::aff_list clear() const; + inline isl::checked::aff_list concat(isl::checked::aff_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::aff at(int index) const; + inline isl::checked::aff get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::ast_build +inline ast_build manage(__isl_take isl_ast_build *ptr); +inline ast_build manage_copy(__isl_keep isl_ast_build *ptr); + +class ast_build { + friend inline ast_build manage(__isl_take isl_ast_build *ptr); + friend inline ast_build manage_copy(__isl_keep isl_ast_build *ptr); + +protected: + isl_ast_build *ptr = nullptr; + + inline explicit ast_build(__isl_take isl_ast_build *ptr); + +public: + inline /* implicit */ ast_build(); + inline /* implicit */ ast_build(const ast_build &obj); + inline explicit ast_build(isl::checked::ctx ctx); + inline ast_build &operator=(ast_build obj); + inline ~ast_build(); + inline __isl_give isl_ast_build *copy() const &; + inline __isl_give isl_ast_build *copy() && = delete; + inline __isl_keep isl_ast_build *get() const; + inline __isl_give isl_ast_build *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + +private: + inline ast_build ©_callbacks(const ast_build &obj); + struct at_each_domain_data { + std::function func; + }; + std::shared_ptr at_each_domain_data; + static inline isl_ast_node *at_each_domain(isl_ast_node *arg_0, isl_ast_build *arg_1, void *arg_2); + inline void set_at_each_domain_data(const std::function &fn); +public: + inline isl::checked::ast_build set_at_each_domain(const std::function &fn) const; + inline isl::checked::ast_expr access_from(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::ast_expr access_from(isl::checked::pw_multi_aff pma) const; + inline isl::checked::ast_expr call_from(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::ast_expr call_from(isl::checked::pw_multi_aff pma) const; + inline isl::checked::ast_expr expr_from(isl::checked::pw_aff pa) const; + inline isl::checked::ast_expr expr_from(isl::checked::set set) const; + static inline isl::checked::ast_build from_context(isl::checked::set set); + inline isl::checked::union_map schedule() const; + inline isl::checked::union_map get_schedule() const; + inline isl::checked::ast_node node_from(isl::checked::schedule schedule) const; + inline isl::checked::ast_node node_from_schedule_map(isl::checked::union_map schedule) const; +}; + +// declarations for isl::ast_expr +inline ast_expr manage(__isl_take isl_ast_expr *ptr); +inline ast_expr manage_copy(__isl_keep isl_ast_expr *ptr); + +class ast_expr { + friend inline ast_expr manage(__isl_take isl_ast_expr *ptr); + friend inline ast_expr manage_copy(__isl_keep isl_ast_expr *ptr); + +protected: + isl_ast_expr *ptr = nullptr; + + inline explicit ast_expr(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr(); + inline /* implicit */ ast_expr(const ast_expr &obj); + inline ast_expr &operator=(ast_expr obj); + inline ~ast_expr(); + inline __isl_give isl_ast_expr *copy() const &; + inline __isl_give isl_ast_expr *copy() && = delete; + inline __isl_keep isl_ast_expr *get() const; + inline __isl_give isl_ast_expr *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline boolean isa_type(T subtype) const; +public: + template inline boolean isa() const; + template inline T as() const; + inline isl::checked::ctx ctx() const; + + inline std::string to_C_str() const; +}; + +// declarations for isl::ast_expr_id + +class ast_expr_id : public ast_expr { + template + friend boolean ast_expr::isa() const; + friend ast_expr_id ast_expr::as() const; + static const auto type = isl_ast_expr_id; + +protected: + inline explicit ast_expr_id(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_id(); + inline /* implicit */ ast_expr_id(const ast_expr_id &obj); + inline ast_expr_id &operator=(ast_expr_id obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::id id() const; + inline isl::checked::id get_id() const; +}; + +// declarations for isl::ast_expr_int + +class ast_expr_int : public ast_expr { + template + friend boolean ast_expr::isa() const; + friend ast_expr_int ast_expr::as() const; + static const auto type = isl_ast_expr_int; + +protected: + inline explicit ast_expr_int(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_int(); + inline /* implicit */ ast_expr_int(const ast_expr_int &obj); + inline ast_expr_int &operator=(ast_expr_int obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::val val() const; + inline isl::checked::val get_val() const; +}; + +// declarations for isl::ast_expr_op + +class ast_expr_op : public ast_expr { + template + friend boolean ast_expr::isa() const; + friend ast_expr_op ast_expr::as() const; + static const auto type = isl_ast_expr_op; + +protected: + inline explicit ast_expr_op(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op(); + inline /* implicit */ ast_expr_op(const ast_expr_op &obj); + inline ast_expr_op &operator=(ast_expr_op obj); +private: + template ::value>::type> + inline boolean isa_type(T subtype) const; +public: + template inline boolean isa() const; + template inline T as() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_expr arg(int pos) const; + inline isl::checked::ast_expr get_arg(int pos) const; + inline class size n_arg() const; + inline class size get_n_arg() const; +}; + +// declarations for isl::ast_expr_op_access + +class ast_expr_op_access : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_access ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_access; + +protected: + inline explicit ast_expr_op_access(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_access(); + inline /* implicit */ ast_expr_op_access(const ast_expr_op_access &obj); + inline ast_expr_op_access &operator=(ast_expr_op_access obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_add + +class ast_expr_op_add : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_add ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_add; + +protected: + inline explicit ast_expr_op_add(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_add(); + inline /* implicit */ ast_expr_op_add(const ast_expr_op_add &obj); + inline ast_expr_op_add &operator=(ast_expr_op_add obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_address_of + +class ast_expr_op_address_of : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_address_of ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_address_of; + +protected: + inline explicit ast_expr_op_address_of(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_address_of(); + inline /* implicit */ ast_expr_op_address_of(const ast_expr_op_address_of &obj); + inline ast_expr_op_address_of &operator=(ast_expr_op_address_of obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_and + +class ast_expr_op_and : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_and ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_and; + +protected: + inline explicit ast_expr_op_and(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_and(); + inline /* implicit */ ast_expr_op_and(const ast_expr_op_and &obj); + inline ast_expr_op_and &operator=(ast_expr_op_and obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_and_then + +class ast_expr_op_and_then : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_and_then ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_and_then; + +protected: + inline explicit ast_expr_op_and_then(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_and_then(); + inline /* implicit */ ast_expr_op_and_then(const ast_expr_op_and_then &obj); + inline ast_expr_op_and_then &operator=(ast_expr_op_and_then obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_call + +class ast_expr_op_call : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_call ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_call; + +protected: + inline explicit ast_expr_op_call(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_call(); + inline /* implicit */ ast_expr_op_call(const ast_expr_op_call &obj); + inline ast_expr_op_call &operator=(ast_expr_op_call obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_cond + +class ast_expr_op_cond : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_cond ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_cond; + +protected: + inline explicit ast_expr_op_cond(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_cond(); + inline /* implicit */ ast_expr_op_cond(const ast_expr_op_cond &obj); + inline ast_expr_op_cond &operator=(ast_expr_op_cond obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_div + +class ast_expr_op_div : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_div ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_div; + +protected: + inline explicit ast_expr_op_div(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_div(); + inline /* implicit */ ast_expr_op_div(const ast_expr_op_div &obj); + inline ast_expr_op_div &operator=(ast_expr_op_div obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_eq + +class ast_expr_op_eq : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_eq ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_eq; + +protected: + inline explicit ast_expr_op_eq(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_eq(); + inline /* implicit */ ast_expr_op_eq(const ast_expr_op_eq &obj); + inline ast_expr_op_eq &operator=(ast_expr_op_eq obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_fdiv_q + +class ast_expr_op_fdiv_q : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_fdiv_q ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_fdiv_q; + +protected: + inline explicit ast_expr_op_fdiv_q(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_fdiv_q(); + inline /* implicit */ ast_expr_op_fdiv_q(const ast_expr_op_fdiv_q &obj); + inline ast_expr_op_fdiv_q &operator=(ast_expr_op_fdiv_q obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_ge + +class ast_expr_op_ge : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_ge ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_ge; + +protected: + inline explicit ast_expr_op_ge(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_ge(); + inline /* implicit */ ast_expr_op_ge(const ast_expr_op_ge &obj); + inline ast_expr_op_ge &operator=(ast_expr_op_ge obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_gt + +class ast_expr_op_gt : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_gt ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_gt; + +protected: + inline explicit ast_expr_op_gt(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_gt(); + inline /* implicit */ ast_expr_op_gt(const ast_expr_op_gt &obj); + inline ast_expr_op_gt &operator=(ast_expr_op_gt obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_le + +class ast_expr_op_le : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_le ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_le; + +protected: + inline explicit ast_expr_op_le(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_le(); + inline /* implicit */ ast_expr_op_le(const ast_expr_op_le &obj); + inline ast_expr_op_le &operator=(ast_expr_op_le obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_lt + +class ast_expr_op_lt : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_lt ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_lt; + +protected: + inline explicit ast_expr_op_lt(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_lt(); + inline /* implicit */ ast_expr_op_lt(const ast_expr_op_lt &obj); + inline ast_expr_op_lt &operator=(ast_expr_op_lt obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_max + +class ast_expr_op_max : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_max ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_max; + +protected: + inline explicit ast_expr_op_max(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_max(); + inline /* implicit */ ast_expr_op_max(const ast_expr_op_max &obj); + inline ast_expr_op_max &operator=(ast_expr_op_max obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_member + +class ast_expr_op_member : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_member ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_member; + +protected: + inline explicit ast_expr_op_member(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_member(); + inline /* implicit */ ast_expr_op_member(const ast_expr_op_member &obj); + inline ast_expr_op_member &operator=(ast_expr_op_member obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_min + +class ast_expr_op_min : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_min ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_min; + +protected: + inline explicit ast_expr_op_min(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_min(); + inline /* implicit */ ast_expr_op_min(const ast_expr_op_min &obj); + inline ast_expr_op_min &operator=(ast_expr_op_min obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_minus + +class ast_expr_op_minus : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_minus ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_minus; + +protected: + inline explicit ast_expr_op_minus(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_minus(); + inline /* implicit */ ast_expr_op_minus(const ast_expr_op_minus &obj); + inline ast_expr_op_minus &operator=(ast_expr_op_minus obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_mul + +class ast_expr_op_mul : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_mul ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_mul; + +protected: + inline explicit ast_expr_op_mul(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_mul(); + inline /* implicit */ ast_expr_op_mul(const ast_expr_op_mul &obj); + inline ast_expr_op_mul &operator=(ast_expr_op_mul obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_or + +class ast_expr_op_or : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_or ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_or; + +protected: + inline explicit ast_expr_op_or(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_or(); + inline /* implicit */ ast_expr_op_or(const ast_expr_op_or &obj); + inline ast_expr_op_or &operator=(ast_expr_op_or obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_or_else + +class ast_expr_op_or_else : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_or_else ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_or_else; + +protected: + inline explicit ast_expr_op_or_else(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_or_else(); + inline /* implicit */ ast_expr_op_or_else(const ast_expr_op_or_else &obj); + inline ast_expr_op_or_else &operator=(ast_expr_op_or_else obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_pdiv_q + +class ast_expr_op_pdiv_q : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_pdiv_q ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_pdiv_q; + +protected: + inline explicit ast_expr_op_pdiv_q(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_pdiv_q(); + inline /* implicit */ ast_expr_op_pdiv_q(const ast_expr_op_pdiv_q &obj); + inline ast_expr_op_pdiv_q &operator=(ast_expr_op_pdiv_q obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_pdiv_r + +class ast_expr_op_pdiv_r : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_pdiv_r ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_pdiv_r; + +protected: + inline explicit ast_expr_op_pdiv_r(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_pdiv_r(); + inline /* implicit */ ast_expr_op_pdiv_r(const ast_expr_op_pdiv_r &obj); + inline ast_expr_op_pdiv_r &operator=(ast_expr_op_pdiv_r obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_select + +class ast_expr_op_select : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_select ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_select; + +protected: + inline explicit ast_expr_op_select(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_select(); + inline /* implicit */ ast_expr_op_select(const ast_expr_op_select &obj); + inline ast_expr_op_select &operator=(ast_expr_op_select obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_sub + +class ast_expr_op_sub : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_sub ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_sub; + +protected: + inline explicit ast_expr_op_sub(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_sub(); + inline /* implicit */ ast_expr_op_sub(const ast_expr_op_sub &obj); + inline ast_expr_op_sub &operator=(ast_expr_op_sub obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_zdiv_r + +class ast_expr_op_zdiv_r : public ast_expr_op { + template + friend boolean ast_expr_op::isa() const; + friend ast_expr_op_zdiv_r ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_zdiv_r; + +protected: + inline explicit ast_expr_op_zdiv_r(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_zdiv_r(); + inline /* implicit */ ast_expr_op_zdiv_r(const ast_expr_op_zdiv_r &obj); + inline ast_expr_op_zdiv_r &operator=(ast_expr_op_zdiv_r obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::ast_node +inline ast_node manage(__isl_take isl_ast_node *ptr); +inline ast_node manage_copy(__isl_keep isl_ast_node *ptr); + +class ast_node { + friend inline ast_node manage(__isl_take isl_ast_node *ptr); + friend inline ast_node manage_copy(__isl_keep isl_ast_node *ptr); + +protected: + isl_ast_node *ptr = nullptr; + + inline explicit ast_node(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node(); + inline /* implicit */ ast_node(const ast_node &obj); + inline ast_node &operator=(ast_node obj); + inline ~ast_node(); + inline __isl_give isl_ast_node *copy() const &; + inline __isl_give isl_ast_node *copy() && = delete; + inline __isl_keep isl_ast_node *get() const; + inline __isl_give isl_ast_node *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline boolean isa_type(T subtype) const; +public: + template inline boolean isa() const; + template inline T as() const; + inline isl::checked::ctx ctx() const; + + inline std::string to_C_str() const; +}; + +// declarations for isl::ast_node_block + +class ast_node_block : public ast_node { + template + friend boolean ast_node::isa() const; + friend ast_node_block ast_node::as() const; + static const auto type = isl_ast_node_block; + +protected: + inline explicit ast_node_block(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_block(); + inline /* implicit */ ast_node_block(const ast_node_block &obj); + inline ast_node_block &operator=(ast_node_block obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_node_list children() const; + inline isl::checked::ast_node_list get_children() const; +}; + +// declarations for isl::ast_node_for + +class ast_node_for : public ast_node { + template + friend boolean ast_node::isa() const; + friend ast_node_for ast_node::as() const; + static const auto type = isl_ast_node_for; + +protected: + inline explicit ast_node_for(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_for(); + inline /* implicit */ ast_node_for(const ast_node_for &obj); + inline ast_node_for &operator=(ast_node_for obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_node body() const; + inline isl::checked::ast_node get_body() const; + inline isl::checked::ast_expr cond() const; + inline isl::checked::ast_expr get_cond() const; + inline isl::checked::ast_expr inc() const; + inline isl::checked::ast_expr get_inc() const; + inline isl::checked::ast_expr init() const; + inline isl::checked::ast_expr get_init() const; + inline isl::checked::ast_expr iterator() const; + inline isl::checked::ast_expr get_iterator() const; + inline boolean is_degenerate() const; +}; + +// declarations for isl::ast_node_if + +class ast_node_if : public ast_node { + template + friend boolean ast_node::isa() const; + friend ast_node_if ast_node::as() const; + static const auto type = isl_ast_node_if; + +protected: + inline explicit ast_node_if(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_if(); + inline /* implicit */ ast_node_if(const ast_node_if &obj); + inline ast_node_if &operator=(ast_node_if obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_expr cond() const; + inline isl::checked::ast_expr get_cond() const; + inline isl::checked::ast_node else_node() const; + inline isl::checked::ast_node get_else_node() const; + inline isl::checked::ast_node then_node() const; + inline isl::checked::ast_node get_then_node() const; + inline boolean has_else_node() const; +}; + +// declarations for isl::ast_node_list +inline ast_node_list manage(__isl_take isl_ast_node_list *ptr); +inline ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr); + +class ast_node_list { + friend inline ast_node_list manage(__isl_take isl_ast_node_list *ptr); + friend inline ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr); + +protected: + isl_ast_node_list *ptr = nullptr; + + inline explicit ast_node_list(__isl_take isl_ast_node_list *ptr); + +public: + inline /* implicit */ ast_node_list(); + inline /* implicit */ ast_node_list(const ast_node_list &obj); + inline explicit ast_node_list(isl::checked::ctx ctx, int n); + inline explicit ast_node_list(isl::checked::ast_node el); + inline ast_node_list &operator=(ast_node_list obj); + inline ~ast_node_list(); + inline __isl_give isl_ast_node_list *copy() const &; + inline __isl_give isl_ast_node_list *copy() && = delete; + inline __isl_keep isl_ast_node_list *get() const; + inline __isl_give isl_ast_node_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_node_list add(isl::checked::ast_node el) const; + inline isl::checked::ast_node_list clear() const; + inline isl::checked::ast_node_list concat(isl::checked::ast_node_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::ast_node at(int index) const; + inline isl::checked::ast_node get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::ast_node_mark + +class ast_node_mark : public ast_node { + template + friend boolean ast_node::isa() const; + friend ast_node_mark ast_node::as() const; + static const auto type = isl_ast_node_mark; + +protected: + inline explicit ast_node_mark(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_mark(); + inline /* implicit */ ast_node_mark(const ast_node_mark &obj); + inline ast_node_mark &operator=(ast_node_mark obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::id id() const; + inline isl::checked::id get_id() const; + inline isl::checked::ast_node node() const; + inline isl::checked::ast_node get_node() const; +}; + +// declarations for isl::ast_node_user + +class ast_node_user : public ast_node { + template + friend boolean ast_node::isa() const; + friend ast_node_user ast_node::as() const; + static const auto type = isl_ast_node_user; + +protected: + inline explicit ast_node_user(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_user(); + inline /* implicit */ ast_node_user(const ast_node_user &obj); + inline ast_node_user &operator=(ast_node_user obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::ast_expr expr() const; + inline isl::checked::ast_expr get_expr() const; +}; + +// declarations for isl::basic_map +inline basic_map manage(__isl_take isl_basic_map *ptr); +inline basic_map manage_copy(__isl_keep isl_basic_map *ptr); + +class basic_map { + friend inline basic_map manage(__isl_take isl_basic_map *ptr); + friend inline basic_map manage_copy(__isl_keep isl_basic_map *ptr); + +protected: + isl_basic_map *ptr = nullptr; + + inline explicit basic_map(__isl_take isl_basic_map *ptr); + +public: + inline /* implicit */ basic_map(); + inline /* implicit */ basic_map(const basic_map &obj); + inline explicit basic_map(isl::checked::ctx ctx, const std::string &str); + inline basic_map &operator=(basic_map obj); + inline ~basic_map(); + inline __isl_give isl_basic_map *copy() const &; + inline __isl_give isl_basic_map *copy() && = delete; + inline __isl_keep isl_basic_map *get() const; + inline __isl_give isl_basic_map *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::basic_map affine_hull() const; + inline isl::checked::basic_map apply_domain(isl::checked::basic_map bmap2) const; + inline isl::checked::basic_map apply_range(isl::checked::basic_map bmap2) const; + inline isl::checked::basic_set deltas() const; + inline isl::checked::basic_map detect_equalities() const; + inline isl::checked::basic_map flatten() const; + inline isl::checked::basic_map flatten_domain() const; + inline isl::checked::basic_map flatten_range() const; + inline isl::checked::basic_map gist(isl::checked::basic_map context) const; + inline isl::checked::basic_map intersect(isl::checked::basic_map bmap2) const; + inline isl::checked::basic_map intersect_domain(isl::checked::basic_set bset) const; + inline isl::checked::basic_map intersect_range(isl::checked::basic_set bset) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::basic_map &bmap2) const; + inline boolean is_subset(const isl::checked::basic_map &bmap2) const; + inline isl::checked::map lexmax() const; + inline isl::checked::map lexmin() const; + inline isl::checked::basic_map reverse() const; + inline isl::checked::basic_map sample() const; + inline isl::checked::map unite(isl::checked::basic_map bmap2) const; +}; + +// declarations for isl::basic_set +inline basic_set manage(__isl_take isl_basic_set *ptr); +inline basic_set manage_copy(__isl_keep isl_basic_set *ptr); + +class basic_set { + friend inline basic_set manage(__isl_take isl_basic_set *ptr); + friend inline basic_set manage_copy(__isl_keep isl_basic_set *ptr); + +protected: + isl_basic_set *ptr = nullptr; + + inline explicit basic_set(__isl_take isl_basic_set *ptr); + +public: + inline /* implicit */ basic_set(); + inline /* implicit */ basic_set(const basic_set &obj); + inline /* implicit */ basic_set(isl::checked::point pnt); + inline explicit basic_set(isl::checked::ctx ctx, const std::string &str); + inline basic_set &operator=(basic_set obj); + inline ~basic_set(); + inline __isl_give isl_basic_set *copy() const &; + inline __isl_give isl_basic_set *copy() && = delete; + inline __isl_keep isl_basic_set *get() const; + inline __isl_give isl_basic_set *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::basic_set affine_hull() const; + inline isl::checked::basic_set apply(isl::checked::basic_map bmap) const; + inline isl::checked::basic_set detect_equalities() const; + inline isl::checked::val dim_max_val(int pos) const; + inline isl::checked::basic_set flatten() const; + inline isl::checked::basic_set gist(isl::checked::basic_set context) const; + inline isl::checked::basic_set intersect(isl::checked::basic_set bset2) const; + inline isl::checked::basic_set intersect_params(isl::checked::basic_set bset2) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::basic_set &bset2) const; + inline boolean is_subset(const isl::checked::basic_set &bset2) const; + inline boolean is_wrapping() const; + inline isl::checked::set lexmax() const; + inline isl::checked::set lexmin() const; + inline isl::checked::basic_set params() const; + inline isl::checked::basic_set sample() const; + inline isl::checked::point sample_point() const; + inline isl::checked::set unite(isl::checked::basic_set bset2) const; +}; + +// declarations for isl::fixed_box +inline fixed_box manage(__isl_take isl_fixed_box *ptr); +inline fixed_box manage_copy(__isl_keep isl_fixed_box *ptr); + +class fixed_box { + friend inline fixed_box manage(__isl_take isl_fixed_box *ptr); + friend inline fixed_box manage_copy(__isl_keep isl_fixed_box *ptr); + +protected: + isl_fixed_box *ptr = nullptr; + + inline explicit fixed_box(__isl_take isl_fixed_box *ptr); + +public: + inline /* implicit */ fixed_box(); + inline /* implicit */ fixed_box(const fixed_box &obj); + inline fixed_box &operator=(fixed_box obj); + inline ~fixed_box(); + inline __isl_give isl_fixed_box *copy() const &; + inline __isl_give isl_fixed_box *copy() && = delete; + inline __isl_keep isl_fixed_box *get() const; + inline __isl_give isl_fixed_box *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_aff offset() const; + inline isl::checked::multi_aff get_offset() const; + inline isl::checked::multi_val size() const; + inline isl::checked::multi_val get_size() const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline boolean is_valid() const; +}; + +// declarations for isl::id +inline id manage(__isl_take isl_id *ptr); +inline id manage_copy(__isl_keep isl_id *ptr); + +class id { + friend inline id manage(__isl_take isl_id *ptr); + friend inline id manage_copy(__isl_keep isl_id *ptr); + +protected: + isl_id *ptr = nullptr; + + inline explicit id(__isl_take isl_id *ptr); + +public: + inline /* implicit */ id(); + inline /* implicit */ id(const id &obj); + inline explicit id(isl::checked::ctx ctx, const std::string &str); + inline id &operator=(id obj); + inline ~id(); + inline __isl_give isl_id *copy() const &; + inline __isl_give isl_id *copy() && = delete; + inline __isl_keep isl_id *get() const; + inline __isl_give isl_id *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline std::string name() const; + inline std::string get_name() const; +}; + +// declarations for isl::id_list +inline id_list manage(__isl_take isl_id_list *ptr); +inline id_list manage_copy(__isl_keep isl_id_list *ptr); + +class id_list { + friend inline id_list manage(__isl_take isl_id_list *ptr); + friend inline id_list manage_copy(__isl_keep isl_id_list *ptr); + +protected: + isl_id_list *ptr = nullptr; + + inline explicit id_list(__isl_take isl_id_list *ptr); + +public: + inline /* implicit */ id_list(); + inline /* implicit */ id_list(const id_list &obj); + inline explicit id_list(isl::checked::ctx ctx, int n); + inline explicit id_list(isl::checked::id el); + inline id_list &operator=(id_list obj); + inline ~id_list(); + inline __isl_give isl_id_list *copy() const &; + inline __isl_give isl_id_list *copy() && = delete; + inline __isl_keep isl_id_list *get() const; + inline __isl_give isl_id_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::id_list add(isl::checked::id el) const; + inline isl::checked::id_list add(const std::string &el) const; + inline isl::checked::id_list clear() const; + inline isl::checked::id_list concat(isl::checked::id_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::id at(int index) const; + inline isl::checked::id get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::map +inline map manage(__isl_take isl_map *ptr); +inline map manage_copy(__isl_keep isl_map *ptr); + +class map { + friend inline map manage(__isl_take isl_map *ptr); + friend inline map manage_copy(__isl_keep isl_map *ptr); + +protected: + isl_map *ptr = nullptr; + + inline explicit map(__isl_take isl_map *ptr); + +public: + inline /* implicit */ map(); + inline /* implicit */ map(const map &obj); + inline /* implicit */ map(isl::checked::basic_map bmap); + inline explicit map(isl::checked::ctx ctx, const std::string &str); + inline map &operator=(map obj); + inline ~map(); + inline __isl_give isl_map *copy() const &; + inline __isl_give isl_map *copy() && = delete; + inline __isl_keep isl_map *get() const; + inline __isl_give isl_map *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::basic_map affine_hull() const; + inline isl::checked::map apply_domain(isl::checked::map map2) const; + inline isl::checked::map apply_range(isl::checked::map map2) const; + inline isl::checked::set bind_domain(isl::checked::multi_id tuple) const; + inline isl::checked::set bind_range(isl::checked::multi_id tuple) const; + inline isl::checked::map coalesce() const; + inline isl::checked::map complement() const; + inline isl::checked::map curry() const; + inline isl::checked::set deltas() const; + inline isl::checked::map detect_equalities() const; + inline isl::checked::set domain() const; + inline isl::checked::map domain_factor_domain() const; + inline isl::checked::map domain_factor_range() const; + inline isl::checked::map domain_product(isl::checked::map map2) const; + static inline isl::checked::map empty(isl::checked::space space); + inline isl::checked::map factor_domain() const; + inline isl::checked::map factor_range() const; + inline isl::checked::map flatten() const; + inline isl::checked::map flatten_domain() const; + inline isl::checked::map flatten_range() const; + inline stat foreach_basic_map(const std::function &fn) const; + inline isl::checked::fixed_box range_simple_fixed_box_hull() const; + inline isl::checked::fixed_box get_range_simple_fixed_box_hull() const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::map gist(isl::checked::map context) const; + inline isl::checked::map gist_domain(isl::checked::set context) const; + inline isl::checked::map intersect(isl::checked::map map2) const; + inline isl::checked::map intersect_domain(isl::checked::set set) const; + inline isl::checked::map intersect_params(isl::checked::set params) const; + inline isl::checked::map intersect_range(isl::checked::set set) const; + inline boolean is_bijective() const; + inline boolean is_disjoint(const isl::checked::map &map2) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::map &map2) const; + inline boolean is_injective() const; + inline boolean is_single_valued() const; + inline boolean is_strict_subset(const isl::checked::map &map2) const; + inline boolean is_subset(const isl::checked::map &map2) const; + inline isl::checked::map lexmax() const; + inline isl::checked::pw_multi_aff lexmax_pw_multi_aff() const; + inline isl::checked::map lexmin() const; + inline isl::checked::pw_multi_aff lexmin_pw_multi_aff() const; + inline isl::checked::basic_map polyhedral_hull() const; + inline isl::checked::map preimage_domain(isl::checked::multi_aff ma) const; + inline isl::checked::map preimage_domain(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::map preimage_domain(isl::checked::pw_multi_aff pma) const; + inline isl::checked::map preimage_range(isl::checked::multi_aff ma) const; + inline isl::checked::map preimage_range(isl::checked::pw_multi_aff pma) const; + inline isl::checked::map project_out_all_params() const; + inline isl::checked::set range() const; + inline isl::checked::map range_factor_domain() const; + inline isl::checked::map range_factor_range() const; + inline isl::checked::map range_product(isl::checked::map map2) const; + inline isl::checked::map reverse() const; + inline isl::checked::basic_map sample() const; + inline isl::checked::map subtract(isl::checked::map map2) const; + inline isl::checked::map uncurry() const; + inline isl::checked::map unite(isl::checked::map map2) const; + static inline isl::checked::map universe(isl::checked::space space); + inline isl::checked::basic_map unshifted_simple_hull() const; + inline isl::checked::set wrap() const; +}; + +// declarations for isl::multi_aff +inline multi_aff manage(__isl_take isl_multi_aff *ptr); +inline multi_aff manage_copy(__isl_keep isl_multi_aff *ptr); + +class multi_aff { + friend inline multi_aff manage(__isl_take isl_multi_aff *ptr); + friend inline multi_aff manage_copy(__isl_keep isl_multi_aff *ptr); + +protected: + isl_multi_aff *ptr = nullptr; + + inline explicit multi_aff(__isl_take isl_multi_aff *ptr); + +public: + inline /* implicit */ multi_aff(); + inline /* implicit */ multi_aff(const multi_aff &obj); + inline /* implicit */ multi_aff(isl::checked::aff aff); + inline explicit multi_aff(isl::checked::space space, isl::checked::aff_list list); + inline explicit multi_aff(isl::checked::ctx ctx, const std::string &str); + inline multi_aff &operator=(multi_aff obj); + inline ~multi_aff(); + inline __isl_give isl_multi_aff *copy() const &; + inline __isl_give isl_multi_aff *copy() && = delete; + inline __isl_keep isl_multi_aff *get() const; + inline __isl_give isl_multi_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_aff add(isl::checked::multi_aff multi2) const; + inline isl::checked::basic_set bind(isl::checked::multi_id tuple) const; + inline isl::checked::multi_aff bind_domain(isl::checked::multi_id tuple) const; + inline isl::checked::multi_aff bind_domain_wrapped_domain(isl::checked::multi_id tuple) const; + static inline isl::checked::multi_aff domain_map(isl::checked::space space); + inline isl::checked::multi_aff flat_range_product(isl::checked::multi_aff multi2) const; + inline isl::checked::multi_aff floor() const; + inline isl::checked::aff at(int pos) const; + inline isl::checked::aff get_at(int pos) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::multi_aff gist(isl::checked::set context) const; + inline isl::checked::multi_aff identity() const; + static inline isl::checked::multi_aff identity_on_domain(isl::checked::space space); + inline boolean involves_locals() const; + inline isl::checked::multi_aff neg() const; + inline boolean plain_is_equal(const isl::checked::multi_aff &multi2) const; + inline isl::checked::multi_aff product(isl::checked::multi_aff multi2) const; + inline isl::checked::multi_aff pullback(isl::checked::multi_aff ma2) const; + static inline isl::checked::multi_aff range_map(isl::checked::space space); + inline isl::checked::multi_aff range_product(isl::checked::multi_aff multi2) const; + inline isl::checked::multi_aff scale(isl::checked::multi_val mv) const; + inline isl::checked::multi_aff scale(isl::checked::val v) const; + inline isl::checked::multi_aff scale(long v) const; + inline isl::checked::multi_aff scale_down(isl::checked::multi_val mv) const; + inline isl::checked::multi_aff scale_down(isl::checked::val v) const; + inline isl::checked::multi_aff scale_down(long v) const; + inline isl::checked::multi_aff set_at(int pos, isl::checked::aff el) const; + inline class size size() const; + inline isl::checked::multi_aff sub(isl::checked::multi_aff multi2) const; + static inline isl::checked::multi_aff zero(isl::checked::space space); +}; + +// declarations for isl::multi_id +inline multi_id manage(__isl_take isl_multi_id *ptr); +inline multi_id manage_copy(__isl_keep isl_multi_id *ptr); + +class multi_id { + friend inline multi_id manage(__isl_take isl_multi_id *ptr); + friend inline multi_id manage_copy(__isl_keep isl_multi_id *ptr); + +protected: + isl_multi_id *ptr = nullptr; + + inline explicit multi_id(__isl_take isl_multi_id *ptr); + +public: + inline /* implicit */ multi_id(); + inline /* implicit */ multi_id(const multi_id &obj); + inline explicit multi_id(isl::checked::space space, isl::checked::id_list list); + inline explicit multi_id(isl::checked::ctx ctx, const std::string &str); + inline multi_id &operator=(multi_id obj); + inline ~multi_id(); + inline __isl_give isl_multi_id *copy() const &; + inline __isl_give isl_multi_id *copy() && = delete; + inline __isl_keep isl_multi_id *get() const; + inline __isl_give isl_multi_id *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_id flat_range_product(isl::checked::multi_id multi2) const; + inline isl::checked::id at(int pos) const; + inline isl::checked::id get_at(int pos) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline boolean plain_is_equal(const isl::checked::multi_id &multi2) const; + inline isl::checked::multi_id range_product(isl::checked::multi_id multi2) const; + inline isl::checked::multi_id set_at(int pos, isl::checked::id el) const; + inline isl::checked::multi_id set_at(int pos, const std::string &el) const; + inline class size size() const; +}; + +// declarations for isl::multi_pw_aff +inline multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr); +inline multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr); + +class multi_pw_aff { + friend inline multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr); + friend inline multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr); + +protected: + isl_multi_pw_aff *ptr = nullptr; + + inline explicit multi_pw_aff(__isl_take isl_multi_pw_aff *ptr); + +public: + inline /* implicit */ multi_pw_aff(); + inline /* implicit */ multi_pw_aff(const multi_pw_aff &obj); + inline /* implicit */ multi_pw_aff(isl::checked::multi_aff ma); + inline /* implicit */ multi_pw_aff(isl::checked::pw_aff pa); + inline explicit multi_pw_aff(isl::checked::space space, isl::checked::pw_aff_list list); + inline /* implicit */ multi_pw_aff(isl::checked::pw_multi_aff pma); + inline explicit multi_pw_aff(isl::checked::ctx ctx, const std::string &str); + inline multi_pw_aff &operator=(multi_pw_aff obj); + inline ~multi_pw_aff(); + inline __isl_give isl_multi_pw_aff *copy() const &; + inline __isl_give isl_multi_pw_aff *copy() && = delete; + inline __isl_keep isl_multi_pw_aff *get() const; + inline __isl_give isl_multi_pw_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_pw_aff add(isl::checked::multi_pw_aff multi2) const; + inline isl::checked::set bind(isl::checked::multi_id tuple) const; + inline isl::checked::multi_pw_aff bind_domain(isl::checked::multi_id tuple) const; + inline isl::checked::multi_pw_aff bind_domain_wrapped_domain(isl::checked::multi_id tuple) const; + inline isl::checked::set domain() const; + inline isl::checked::multi_pw_aff flat_range_product(isl::checked::multi_pw_aff multi2) const; + inline isl::checked::pw_aff at(int pos) const; + inline isl::checked::pw_aff get_at(int pos) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::multi_pw_aff gist(isl::checked::set set) const; + inline isl::checked::multi_pw_aff identity() const; + static inline isl::checked::multi_pw_aff identity_on_domain(isl::checked::space space); + inline isl::checked::multi_pw_aff intersect_domain(isl::checked::set domain) const; + inline isl::checked::multi_pw_aff intersect_params(isl::checked::set set) const; + inline boolean involves_param(const isl::checked::id &id) const; + inline boolean involves_param(const std::string &id) const; + inline boolean involves_param(const isl::checked::id_list &list) const; + inline isl::checked::multi_pw_aff neg() const; + inline boolean plain_is_equal(const isl::checked::multi_pw_aff &multi2) const; + inline isl::checked::multi_pw_aff product(isl::checked::multi_pw_aff multi2) const; + inline isl::checked::multi_pw_aff pullback(isl::checked::multi_aff ma) const; + inline isl::checked::multi_pw_aff pullback(isl::checked::multi_pw_aff mpa2) const; + inline isl::checked::multi_pw_aff pullback(isl::checked::pw_multi_aff pma) const; + inline isl::checked::multi_pw_aff range_product(isl::checked::multi_pw_aff multi2) const; + inline isl::checked::multi_pw_aff scale(isl::checked::multi_val mv) const; + inline isl::checked::multi_pw_aff scale(isl::checked::val v) const; + inline isl::checked::multi_pw_aff scale(long v) const; + inline isl::checked::multi_pw_aff scale_down(isl::checked::multi_val mv) const; + inline isl::checked::multi_pw_aff scale_down(isl::checked::val v) const; + inline isl::checked::multi_pw_aff scale_down(long v) const; + inline isl::checked::multi_pw_aff set_at(int pos, isl::checked::pw_aff el) const; + inline class size size() const; + inline isl::checked::multi_pw_aff sub(isl::checked::multi_pw_aff multi2) const; + static inline isl::checked::multi_pw_aff zero(isl::checked::space space); +}; + +// declarations for isl::multi_union_pw_aff +inline multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr); +inline multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr); + +class multi_union_pw_aff { + friend inline multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr); + friend inline multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr); + +protected: + isl_multi_union_pw_aff *ptr = nullptr; + + inline explicit multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *ptr); + +public: + inline /* implicit */ multi_union_pw_aff(); + inline /* implicit */ multi_union_pw_aff(const multi_union_pw_aff &obj); + inline /* implicit */ multi_union_pw_aff(isl::checked::multi_pw_aff mpa); + inline /* implicit */ multi_union_pw_aff(isl::checked::union_pw_aff upa); + inline explicit multi_union_pw_aff(isl::checked::space space, isl::checked::union_pw_aff_list list); + inline explicit multi_union_pw_aff(isl::checked::ctx ctx, const std::string &str); + inline multi_union_pw_aff &operator=(multi_union_pw_aff obj); + inline ~multi_union_pw_aff(); + inline __isl_give isl_multi_union_pw_aff *copy() const &; + inline __isl_give isl_multi_union_pw_aff *copy() && = delete; + inline __isl_keep isl_multi_union_pw_aff *get() const; + inline __isl_give isl_multi_union_pw_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_union_pw_aff add(isl::checked::multi_union_pw_aff multi2) const; + inline isl::checked::union_set bind(isl::checked::multi_id tuple) const; + inline isl::checked::union_set domain() const; + inline isl::checked::multi_union_pw_aff flat_range_product(isl::checked::multi_union_pw_aff multi2) const; + inline isl::checked::union_pw_aff at(int pos) const; + inline isl::checked::union_pw_aff get_at(int pos) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::multi_union_pw_aff gist(isl::checked::union_set context) const; + inline isl::checked::multi_union_pw_aff intersect_domain(isl::checked::union_set uset) const; + inline isl::checked::multi_union_pw_aff intersect_params(isl::checked::set params) const; + inline isl::checked::multi_union_pw_aff neg() const; + inline boolean plain_is_equal(const isl::checked::multi_union_pw_aff &multi2) const; + inline isl::checked::multi_union_pw_aff pullback(isl::checked::union_pw_multi_aff upma) const; + inline isl::checked::multi_union_pw_aff range_product(isl::checked::multi_union_pw_aff multi2) const; + inline isl::checked::multi_union_pw_aff scale(isl::checked::multi_val mv) const; + inline isl::checked::multi_union_pw_aff scale(isl::checked::val v) const; + inline isl::checked::multi_union_pw_aff scale(long v) const; + inline isl::checked::multi_union_pw_aff scale_down(isl::checked::multi_val mv) const; + inline isl::checked::multi_union_pw_aff scale_down(isl::checked::val v) const; + inline isl::checked::multi_union_pw_aff scale_down(long v) const; + inline isl::checked::multi_union_pw_aff set_at(int pos, isl::checked::union_pw_aff el) const; + inline class size size() const; + inline isl::checked::multi_union_pw_aff sub(isl::checked::multi_union_pw_aff multi2) const; + inline isl::checked::multi_union_pw_aff union_add(isl::checked::multi_union_pw_aff mupa2) const; + static inline isl::checked::multi_union_pw_aff zero(isl::checked::space space); +}; + +// declarations for isl::multi_val +inline multi_val manage(__isl_take isl_multi_val *ptr); +inline multi_val manage_copy(__isl_keep isl_multi_val *ptr); + +class multi_val { + friend inline multi_val manage(__isl_take isl_multi_val *ptr); + friend inline multi_val manage_copy(__isl_keep isl_multi_val *ptr); + +protected: + isl_multi_val *ptr = nullptr; + + inline explicit multi_val(__isl_take isl_multi_val *ptr); + +public: + inline /* implicit */ multi_val(); + inline /* implicit */ multi_val(const multi_val &obj); + inline explicit multi_val(isl::checked::space space, isl::checked::val_list list); + inline explicit multi_val(isl::checked::ctx ctx, const std::string &str); + inline multi_val &operator=(multi_val obj); + inline ~multi_val(); + inline __isl_give isl_multi_val *copy() const &; + inline __isl_give isl_multi_val *copy() && = delete; + inline __isl_keep isl_multi_val *get() const; + inline __isl_give isl_multi_val *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::multi_val add(isl::checked::multi_val multi2) const; + inline isl::checked::multi_val add(isl::checked::val v) const; + inline isl::checked::multi_val add(long v) const; + inline isl::checked::multi_val flat_range_product(isl::checked::multi_val multi2) const; + inline isl::checked::val at(int pos) const; + inline isl::checked::val get_at(int pos) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::multi_val neg() const; + inline boolean plain_is_equal(const isl::checked::multi_val &multi2) const; + inline isl::checked::multi_val product(isl::checked::multi_val multi2) const; + inline isl::checked::multi_val range_product(isl::checked::multi_val multi2) const; + inline isl::checked::multi_val scale(isl::checked::multi_val mv) const; + inline isl::checked::multi_val scale(isl::checked::val v) const; + inline isl::checked::multi_val scale(long v) const; + inline isl::checked::multi_val scale_down(isl::checked::multi_val mv) const; + inline isl::checked::multi_val scale_down(isl::checked::val v) const; + inline isl::checked::multi_val scale_down(long v) const; + inline isl::checked::multi_val set_at(int pos, isl::checked::val el) const; + inline isl::checked::multi_val set_at(int pos, long el) const; + inline class size size() const; + inline isl::checked::multi_val sub(isl::checked::multi_val multi2) const; + static inline isl::checked::multi_val zero(isl::checked::space space); +}; + +// declarations for isl::point +inline point manage(__isl_take isl_point *ptr); +inline point manage_copy(__isl_keep isl_point *ptr); + +class point { + friend inline point manage(__isl_take isl_point *ptr); + friend inline point manage_copy(__isl_keep isl_point *ptr); + +protected: + isl_point *ptr = nullptr; + + inline explicit point(__isl_take isl_point *ptr); + +public: + inline /* implicit */ point(); + inline /* implicit */ point(const point &obj); + inline point &operator=(point obj); + inline ~point(); + inline __isl_give isl_point *copy() const &; + inline __isl_give isl_point *copy() && = delete; + inline __isl_keep isl_point *get() const; + inline __isl_give isl_point *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::pw_aff +inline pw_aff manage(__isl_take isl_pw_aff *ptr); +inline pw_aff manage_copy(__isl_keep isl_pw_aff *ptr); + +class pw_aff { + friend inline pw_aff manage(__isl_take isl_pw_aff *ptr); + friend inline pw_aff manage_copy(__isl_keep isl_pw_aff *ptr); + +protected: + isl_pw_aff *ptr = nullptr; + + inline explicit pw_aff(__isl_take isl_pw_aff *ptr); + +public: + inline /* implicit */ pw_aff(); + inline /* implicit */ pw_aff(const pw_aff &obj); + inline /* implicit */ pw_aff(isl::checked::aff aff); + inline explicit pw_aff(isl::checked::ctx ctx, const std::string &str); + inline pw_aff &operator=(pw_aff obj); + inline ~pw_aff(); + inline __isl_give isl_pw_aff *copy() const &; + inline __isl_give isl_pw_aff *copy() && = delete; + inline __isl_keep isl_pw_aff *get() const; + inline __isl_give isl_pw_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::pw_aff add(isl::checked::pw_aff pwaff2) const; + inline isl::checked::aff as_aff() const; + inline isl::checked::set bind(isl::checked::id id) const; + inline isl::checked::set bind(const std::string &id) const; + inline isl::checked::pw_aff bind_domain(isl::checked::multi_id tuple) const; + inline isl::checked::pw_aff bind_domain_wrapped_domain(isl::checked::multi_id tuple) const; + inline isl::checked::pw_aff ceil() const; + inline isl::checked::pw_aff cond(isl::checked::pw_aff pwaff_true, isl::checked::pw_aff pwaff_false) const; + inline isl::checked::pw_aff div(isl::checked::pw_aff pa2) const; + inline isl::checked::set domain() const; + inline isl::checked::set eq_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::val eval(isl::checked::point pnt) const; + inline isl::checked::pw_aff floor() const; + inline isl::checked::set ge_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff gist(isl::checked::set context) const; + inline isl::checked::set gt_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff intersect_domain(isl::checked::set set) const; + inline isl::checked::pw_aff intersect_params(isl::checked::set set) const; + inline boolean isa_aff() const; + inline isl::checked::set le_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::set lt_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff max(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff min(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff mod(isl::checked::val mod) const; + inline isl::checked::pw_aff mod(long mod) const; + inline isl::checked::pw_aff mul(isl::checked::pw_aff pwaff2) const; + inline isl::checked::set ne_set(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff neg() const; + static inline isl::checked::pw_aff param_on_domain(isl::checked::set domain, isl::checked::id id); + inline isl::checked::pw_aff pullback(isl::checked::multi_aff ma) const; + inline isl::checked::pw_aff pullback(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::pw_aff pullback(isl::checked::pw_multi_aff pma) const; + inline isl::checked::pw_aff scale(isl::checked::val v) const; + inline isl::checked::pw_aff scale(long v) const; + inline isl::checked::pw_aff scale_down(isl::checked::val f) const; + inline isl::checked::pw_aff scale_down(long f) const; + inline isl::checked::pw_aff sub(isl::checked::pw_aff pwaff2) const; + inline isl::checked::pw_aff subtract_domain(isl::checked::set set) const; + inline isl::checked::pw_aff tdiv_q(isl::checked::pw_aff pa2) const; + inline isl::checked::pw_aff tdiv_r(isl::checked::pw_aff pa2) const; + inline isl::checked::pw_aff union_add(isl::checked::pw_aff pwaff2) const; +}; + +// declarations for isl::pw_aff_list +inline pw_aff_list manage(__isl_take isl_pw_aff_list *ptr); +inline pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr); + +class pw_aff_list { + friend inline pw_aff_list manage(__isl_take isl_pw_aff_list *ptr); + friend inline pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr); + +protected: + isl_pw_aff_list *ptr = nullptr; + + inline explicit pw_aff_list(__isl_take isl_pw_aff_list *ptr); + +public: + inline /* implicit */ pw_aff_list(); + inline /* implicit */ pw_aff_list(const pw_aff_list &obj); + inline explicit pw_aff_list(isl::checked::ctx ctx, int n); + inline explicit pw_aff_list(isl::checked::pw_aff el); + inline pw_aff_list &operator=(pw_aff_list obj); + inline ~pw_aff_list(); + inline __isl_give isl_pw_aff_list *copy() const &; + inline __isl_give isl_pw_aff_list *copy() && = delete; + inline __isl_keep isl_pw_aff_list *get() const; + inline __isl_give isl_pw_aff_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::pw_aff_list add(isl::checked::pw_aff el) const; + inline isl::checked::pw_aff_list clear() const; + inline isl::checked::pw_aff_list concat(isl::checked::pw_aff_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::pw_aff at(int index) const; + inline isl::checked::pw_aff get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::pw_multi_aff +inline pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr); +inline pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr); + +class pw_multi_aff { + friend inline pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr); + friend inline pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr); + +protected: + isl_pw_multi_aff *ptr = nullptr; + + inline explicit pw_multi_aff(__isl_take isl_pw_multi_aff *ptr); + +public: + inline /* implicit */ pw_multi_aff(); + inline /* implicit */ pw_multi_aff(const pw_multi_aff &obj); + inline /* implicit */ pw_multi_aff(isl::checked::multi_aff ma); + inline /* implicit */ pw_multi_aff(isl::checked::pw_aff pa); + inline explicit pw_multi_aff(isl::checked::ctx ctx, const std::string &str); + inline pw_multi_aff &operator=(pw_multi_aff obj); + inline ~pw_multi_aff(); + inline __isl_give isl_pw_multi_aff *copy() const &; + inline __isl_give isl_pw_multi_aff *copy() && = delete; + inline __isl_keep isl_pw_multi_aff *get() const; + inline __isl_give isl_pw_multi_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::pw_multi_aff add(isl::checked::pw_multi_aff pma2) const; + inline isl::checked::multi_aff as_multi_aff() const; + inline isl::checked::pw_multi_aff bind_domain(isl::checked::multi_id tuple) const; + inline isl::checked::pw_multi_aff bind_domain_wrapped_domain(isl::checked::multi_id tuple) const; + inline isl::checked::set domain() const; + inline isl::checked::pw_multi_aff flat_range_product(isl::checked::pw_multi_aff pma2) const; + inline stat foreach_piece(const std::function &fn) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::pw_multi_aff gist(isl::checked::set set) const; + inline isl::checked::pw_multi_aff intersect_domain(isl::checked::set set) const; + inline isl::checked::pw_multi_aff intersect_params(isl::checked::set set) const; + inline boolean isa_multi_aff() const; + inline class size n_piece() const; + inline isl::checked::pw_multi_aff product(isl::checked::pw_multi_aff pma2) const; + inline isl::checked::pw_multi_aff pullback(isl::checked::multi_aff ma) const; + inline isl::checked::pw_multi_aff pullback(isl::checked::pw_multi_aff pma2) const; + inline isl::checked::pw_multi_aff range_factor_domain() const; + inline isl::checked::pw_multi_aff range_factor_range() const; + inline isl::checked::pw_multi_aff range_product(isl::checked::pw_multi_aff pma2) const; + inline isl::checked::pw_multi_aff scale(isl::checked::val v) const; + inline isl::checked::pw_multi_aff scale(long v) const; + inline isl::checked::pw_multi_aff scale_down(isl::checked::val v) const; + inline isl::checked::pw_multi_aff scale_down(long v) const; + inline isl::checked::pw_multi_aff sub(isl::checked::pw_multi_aff pma2) const; + inline isl::checked::pw_multi_aff subtract_domain(isl::checked::set set) const; + inline isl::checked::pw_multi_aff union_add(isl::checked::pw_multi_aff pma2) const; + static inline isl::checked::pw_multi_aff zero(isl::checked::space space); +}; + +// declarations for isl::pw_multi_aff_list +inline pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr); +inline pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr); + +class pw_multi_aff_list { + friend inline pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr); + friend inline pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr); + +protected: + isl_pw_multi_aff_list *ptr = nullptr; + + inline explicit pw_multi_aff_list(__isl_take isl_pw_multi_aff_list *ptr); + +public: + inline /* implicit */ pw_multi_aff_list(); + inline /* implicit */ pw_multi_aff_list(const pw_multi_aff_list &obj); + inline explicit pw_multi_aff_list(isl::checked::ctx ctx, int n); + inline explicit pw_multi_aff_list(isl::checked::pw_multi_aff el); + inline pw_multi_aff_list &operator=(pw_multi_aff_list obj); + inline ~pw_multi_aff_list(); + inline __isl_give isl_pw_multi_aff_list *copy() const &; + inline __isl_give isl_pw_multi_aff_list *copy() && = delete; + inline __isl_keep isl_pw_multi_aff_list *get() const; + inline __isl_give isl_pw_multi_aff_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::pw_multi_aff_list add(isl::checked::pw_multi_aff el) const; + inline isl::checked::pw_multi_aff_list clear() const; + inline isl::checked::pw_multi_aff_list concat(isl::checked::pw_multi_aff_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::pw_multi_aff at(int index) const; + inline isl::checked::pw_multi_aff get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::schedule +inline schedule manage(__isl_take isl_schedule *ptr); +inline schedule manage_copy(__isl_keep isl_schedule *ptr); + +class schedule { + friend inline schedule manage(__isl_take isl_schedule *ptr); + friend inline schedule manage_copy(__isl_keep isl_schedule *ptr); + +protected: + isl_schedule *ptr = nullptr; + + inline explicit schedule(__isl_take isl_schedule *ptr); + +public: + inline /* implicit */ schedule(); + inline /* implicit */ schedule(const schedule &obj); + inline explicit schedule(isl::checked::ctx ctx, const std::string &str); + inline schedule &operator=(schedule obj); + inline ~schedule(); + inline __isl_give isl_schedule *copy() const &; + inline __isl_give isl_schedule *copy() && = delete; + inline __isl_keep isl_schedule *get() const; + inline __isl_give isl_schedule *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + static inline isl::checked::schedule from_domain(isl::checked::union_set domain); + inline isl::checked::union_map map() const; + inline isl::checked::union_map get_map() const; + inline isl::checked::schedule_node root() const; + inline isl::checked::schedule_node get_root() const; + inline isl::checked::schedule pullback(isl::checked::union_pw_multi_aff upma) const; +}; + +// declarations for isl::schedule_constraints +inline schedule_constraints manage(__isl_take isl_schedule_constraints *ptr); +inline schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr); + +class schedule_constraints { + friend inline schedule_constraints manage(__isl_take isl_schedule_constraints *ptr); + friend inline schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr); + +protected: + isl_schedule_constraints *ptr = nullptr; + + inline explicit schedule_constraints(__isl_take isl_schedule_constraints *ptr); + +public: + inline /* implicit */ schedule_constraints(); + inline /* implicit */ schedule_constraints(const schedule_constraints &obj); + inline explicit schedule_constraints(isl::checked::ctx ctx, const std::string &str); + inline schedule_constraints &operator=(schedule_constraints obj); + inline ~schedule_constraints(); + inline __isl_give isl_schedule_constraints *copy() const &; + inline __isl_give isl_schedule_constraints *copy() && = delete; + inline __isl_keep isl_schedule_constraints *get() const; + inline __isl_give isl_schedule_constraints *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::schedule compute_schedule() const; + inline isl::checked::union_map coincidence() const; + inline isl::checked::union_map get_coincidence() const; + inline isl::checked::union_map conditional_validity() const; + inline isl::checked::union_map get_conditional_validity() const; + inline isl::checked::union_map conditional_validity_condition() const; + inline isl::checked::union_map get_conditional_validity_condition() const; + inline isl::checked::set context() const; + inline isl::checked::set get_context() const; + inline isl::checked::union_set domain() const; + inline isl::checked::union_set get_domain() const; + inline isl::checked::union_map proximity() const; + inline isl::checked::union_map get_proximity() const; + inline isl::checked::union_map validity() const; + inline isl::checked::union_map get_validity() const; + static inline isl::checked::schedule_constraints on_domain(isl::checked::union_set domain); + inline isl::checked::schedule_constraints set_coincidence(isl::checked::union_map coincidence) const; + inline isl::checked::schedule_constraints set_conditional_validity(isl::checked::union_map condition, isl::checked::union_map validity) const; + inline isl::checked::schedule_constraints set_context(isl::checked::set context) const; + inline isl::checked::schedule_constraints set_proximity(isl::checked::union_map proximity) const; + inline isl::checked::schedule_constraints set_validity(isl::checked::union_map validity) const; +}; + +// declarations for isl::schedule_node +inline schedule_node manage(__isl_take isl_schedule_node *ptr); +inline schedule_node manage_copy(__isl_keep isl_schedule_node *ptr); + +class schedule_node { + friend inline schedule_node manage(__isl_take isl_schedule_node *ptr); + friend inline schedule_node manage_copy(__isl_keep isl_schedule_node *ptr); + +protected: + isl_schedule_node *ptr = nullptr; + + inline explicit schedule_node(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node(); + inline /* implicit */ schedule_node(const schedule_node &obj); + inline schedule_node &operator=(schedule_node obj); + inline ~schedule_node(); + inline __isl_give isl_schedule_node *copy() const &; + inline __isl_give isl_schedule_node *copy() && = delete; + inline __isl_keep isl_schedule_node *get() const; + inline __isl_give isl_schedule_node *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline boolean isa_type(T subtype) const; +public: + template inline boolean isa() const; + template inline T as() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::schedule_node ancestor(int generation) const; + inline isl::checked::schedule_node child(int pos) const; + inline boolean every_descendant(const std::function &test) const; + inline isl::checked::schedule_node first_child() const; + inline stat foreach_ancestor_top_down(const std::function &fn) const; + inline stat foreach_descendant_top_down(const std::function &fn) const; + static inline isl::checked::schedule_node from_domain(isl::checked::union_set domain); + static inline isl::checked::schedule_node from_extension(isl::checked::union_map extension); + inline class size ancestor_child_position(const isl::checked::schedule_node &ancestor) const; + inline class size get_ancestor_child_position(const isl::checked::schedule_node &ancestor) const; + inline class size child_position() const; + inline class size get_child_position() const; + inline isl::checked::multi_union_pw_aff prefix_schedule_multi_union_pw_aff() const; + inline isl::checked::multi_union_pw_aff get_prefix_schedule_multi_union_pw_aff() const; + inline isl::checked::union_map prefix_schedule_union_map() const; + inline isl::checked::union_map get_prefix_schedule_union_map() const; + inline isl::checked::union_pw_multi_aff prefix_schedule_union_pw_multi_aff() const; + inline isl::checked::union_pw_multi_aff get_prefix_schedule_union_pw_multi_aff() const; + inline isl::checked::schedule schedule() const; + inline isl::checked::schedule get_schedule() const; + inline isl::checked::schedule_node shared_ancestor(const isl::checked::schedule_node &node2) const; + inline isl::checked::schedule_node get_shared_ancestor(const isl::checked::schedule_node &node2) const; + inline class size tree_depth() const; + inline class size get_tree_depth() const; + inline isl::checked::schedule_node graft_after(isl::checked::schedule_node graft) const; + inline isl::checked::schedule_node graft_before(isl::checked::schedule_node graft) const; + inline boolean has_children() const; + inline boolean has_next_sibling() const; + inline boolean has_parent() const; + inline boolean has_previous_sibling() const; + inline isl::checked::schedule_node insert_context(isl::checked::set context) const; + inline isl::checked::schedule_node insert_filter(isl::checked::union_set filter) const; + inline isl::checked::schedule_node insert_guard(isl::checked::set context) const; + inline isl::checked::schedule_node insert_mark(isl::checked::id mark) const; + inline isl::checked::schedule_node insert_mark(const std::string &mark) const; + inline isl::checked::schedule_node insert_partial_schedule(isl::checked::multi_union_pw_aff schedule) const; + inline isl::checked::schedule_node insert_sequence(isl::checked::union_set_list filters) const; + inline isl::checked::schedule_node insert_set(isl::checked::union_set_list filters) const; + inline boolean is_equal(const isl::checked::schedule_node &node2) const; + inline boolean is_subtree_anchored() const; + inline isl::checked::schedule_node map_descendant_bottom_up(const std::function &fn) const; + inline class size n_children() const; + inline isl::checked::schedule_node next_sibling() const; + inline isl::checked::schedule_node order_after(isl::checked::union_set filter) const; + inline isl::checked::schedule_node order_before(isl::checked::union_set filter) const; + inline isl::checked::schedule_node parent() const; + inline isl::checked::schedule_node previous_sibling() const; + inline isl::checked::schedule_node root() const; +}; + +// declarations for isl::schedule_node_band + +class schedule_node_band : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_band schedule_node::as() const; + static const auto type = isl_schedule_node_band; + +protected: + inline explicit schedule_node_band(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_band(); + inline /* implicit */ schedule_node_band(const schedule_node_band &obj); + inline schedule_node_band &operator=(schedule_node_band obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_set ast_build_options() const; + inline isl::checked::union_set get_ast_build_options() const; + inline isl::checked::set ast_isolate_option() const; + inline isl::checked::set get_ast_isolate_option() const; + inline isl::checked::multi_union_pw_aff partial_schedule() const; + inline isl::checked::multi_union_pw_aff get_partial_schedule() const; + inline boolean permutable() const; + inline boolean get_permutable() const; + inline boolean member_get_coincident(int pos) const; + inline schedule_node_band member_set_coincident(int pos, int coincident) const; + inline schedule_node_band mod(isl::checked::multi_val mv) const; + inline class size n_member() const; + inline schedule_node_band scale(isl::checked::multi_val mv) const; + inline schedule_node_band scale_down(isl::checked::multi_val mv) const; + inline schedule_node_band set_ast_build_options(isl::checked::union_set options) const; + inline schedule_node_band set_permutable(int permutable) const; + inline schedule_node_band shift(isl::checked::multi_union_pw_aff shift) const; + inline schedule_node_band split(int pos) const; + inline schedule_node_band tile(isl::checked::multi_val sizes) const; + inline schedule_node_band member_set_ast_loop_default(int pos) const; + inline schedule_node_band member_set_ast_loop_atomic(int pos) const; + inline schedule_node_band member_set_ast_loop_unroll(int pos) const; + inline schedule_node_band member_set_ast_loop_separate(int pos) const; +}; + +// declarations for isl::schedule_node_context + +class schedule_node_context : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_context schedule_node::as() const; + static const auto type = isl_schedule_node_context; + +protected: + inline explicit schedule_node_context(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_context(); + inline /* implicit */ schedule_node_context(const schedule_node_context &obj); + inline schedule_node_context &operator=(schedule_node_context obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::set context() const; + inline isl::checked::set get_context() const; +}; + +// declarations for isl::schedule_node_domain + +class schedule_node_domain : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_domain schedule_node::as() const; + static const auto type = isl_schedule_node_domain; + +protected: + inline explicit schedule_node_domain(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_domain(); + inline /* implicit */ schedule_node_domain(const schedule_node_domain &obj); + inline schedule_node_domain &operator=(schedule_node_domain obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_set domain() const; + inline isl::checked::union_set get_domain() const; +}; + +// declarations for isl::schedule_node_expansion + +class schedule_node_expansion : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_expansion schedule_node::as() const; + static const auto type = isl_schedule_node_expansion; + +protected: + inline explicit schedule_node_expansion(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_expansion(); + inline /* implicit */ schedule_node_expansion(const schedule_node_expansion &obj); + inline schedule_node_expansion &operator=(schedule_node_expansion obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_pw_multi_aff contraction() const; + inline isl::checked::union_pw_multi_aff get_contraction() const; + inline isl::checked::union_map expansion() const; + inline isl::checked::union_map get_expansion() const; +}; + +// declarations for isl::schedule_node_extension + +class schedule_node_extension : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_extension schedule_node::as() const; + static const auto type = isl_schedule_node_extension; + +protected: + inline explicit schedule_node_extension(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_extension(); + inline /* implicit */ schedule_node_extension(const schedule_node_extension &obj); + inline schedule_node_extension &operator=(schedule_node_extension obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_map extension() const; + inline isl::checked::union_map get_extension() const; +}; + +// declarations for isl::schedule_node_filter + +class schedule_node_filter : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_filter schedule_node::as() const; + static const auto type = isl_schedule_node_filter; + +protected: + inline explicit schedule_node_filter(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_filter(); + inline /* implicit */ schedule_node_filter(const schedule_node_filter &obj); + inline schedule_node_filter &operator=(schedule_node_filter obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_set filter() const; + inline isl::checked::union_set get_filter() const; +}; + +// declarations for isl::schedule_node_guard + +class schedule_node_guard : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_guard schedule_node::as() const; + static const auto type = isl_schedule_node_guard; + +protected: + inline explicit schedule_node_guard(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_guard(); + inline /* implicit */ schedule_node_guard(const schedule_node_guard &obj); + inline schedule_node_guard &operator=(schedule_node_guard obj); + inline isl::checked::ctx ctx() const; + + inline isl::checked::set guard() const; + inline isl::checked::set get_guard() const; +}; + +// declarations for isl::schedule_node_leaf + +class schedule_node_leaf : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_leaf schedule_node::as() const; + static const auto type = isl_schedule_node_leaf; + +protected: + inline explicit schedule_node_leaf(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_leaf(); + inline /* implicit */ schedule_node_leaf(const schedule_node_leaf &obj); + inline schedule_node_leaf &operator=(schedule_node_leaf obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_mark + +class schedule_node_mark : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_mark schedule_node::as() const; + static const auto type = isl_schedule_node_mark; + +protected: + inline explicit schedule_node_mark(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_mark(); + inline /* implicit */ schedule_node_mark(const schedule_node_mark &obj); + inline schedule_node_mark &operator=(schedule_node_mark obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_sequence + +class schedule_node_sequence : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_sequence schedule_node::as() const; + static const auto type = isl_schedule_node_sequence; + +protected: + inline explicit schedule_node_sequence(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_sequence(); + inline /* implicit */ schedule_node_sequence(const schedule_node_sequence &obj); + inline schedule_node_sequence &operator=(schedule_node_sequence obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_set + +class schedule_node_set : public schedule_node { + template + friend boolean schedule_node::isa() const; + friend schedule_node_set schedule_node::as() const; + static const auto type = isl_schedule_node_set; + +protected: + inline explicit schedule_node_set(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_set(); + inline /* implicit */ schedule_node_set(const schedule_node_set &obj); + inline schedule_node_set &operator=(schedule_node_set obj); + inline isl::checked::ctx ctx() const; + +}; + +// declarations for isl::set +inline set manage(__isl_take isl_set *ptr); +inline set manage_copy(__isl_keep isl_set *ptr); + +class set { + friend inline set manage(__isl_take isl_set *ptr); + friend inline set manage_copy(__isl_keep isl_set *ptr); + +protected: + isl_set *ptr = nullptr; + + inline explicit set(__isl_take isl_set *ptr); + +public: + inline /* implicit */ set(); + inline /* implicit */ set(const set &obj); + inline /* implicit */ set(isl::checked::basic_set bset); + inline /* implicit */ set(isl::checked::point pnt); + inline explicit set(isl::checked::ctx ctx, const std::string &str); + inline set &operator=(set obj); + inline ~set(); + inline __isl_give isl_set *copy() const &; + inline __isl_give isl_set *copy() && = delete; + inline __isl_keep isl_set *get() const; + inline __isl_give isl_set *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::basic_set affine_hull() const; + inline isl::checked::set apply(isl::checked::map map) const; + inline isl::checked::set bind(isl::checked::multi_id tuple) const; + inline isl::checked::set coalesce() const; + inline isl::checked::set complement() const; + inline isl::checked::set detect_equalities() const; + static inline isl::checked::set empty(isl::checked::space space); + inline isl::checked::set flatten() const; + inline stat foreach_basic_set(const std::function &fn) const; + inline stat foreach_point(const std::function &fn) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::val stride(int pos) const; + inline isl::checked::val get_stride(int pos) const; + inline isl::checked::set gist(isl::checked::set context) const; + inline isl::checked::map identity() const; + inline isl::checked::set intersect(isl::checked::set set2) const; + inline isl::checked::set intersect_params(isl::checked::set params) const; + inline boolean is_disjoint(const isl::checked::set &set2) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::set &set2) const; + inline boolean is_singleton() const; + inline boolean is_strict_subset(const isl::checked::set &set2) const; + inline boolean is_subset(const isl::checked::set &set2) const; + inline boolean is_wrapping() const; + inline isl::checked::set lexmax() const; + inline isl::checked::pw_multi_aff lexmax_pw_multi_aff() const; + inline isl::checked::set lexmin() const; + inline isl::checked::pw_multi_aff lexmin_pw_multi_aff() const; + inline isl::checked::val max_val(const isl::checked::aff &obj) const; + inline isl::checked::val min_val(const isl::checked::aff &obj) const; + inline isl::checked::set params() const; + inline isl::checked::basic_set polyhedral_hull() const; + inline isl::checked::set preimage(isl::checked::multi_aff ma) const; + inline isl::checked::set preimage(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::set preimage(isl::checked::pw_multi_aff pma) const; + inline isl::checked::set product(isl::checked::set set2) const; + inline isl::checked::set project_out_all_params() const; + inline isl::checked::set project_out_param(isl::checked::id id) const; + inline isl::checked::set project_out_param(const std::string &id) const; + inline isl::checked::set project_out_param(isl::checked::id_list list) const; + inline isl::checked::basic_set sample() const; + inline isl::checked::point sample_point() const; + inline isl::checked::set subtract(isl::checked::set set2) const; + inline isl::checked::set unbind_params(isl::checked::multi_id tuple) const; + inline isl::checked::map unbind_params_insert_domain(isl::checked::multi_id domain) const; + inline isl::checked::set unite(isl::checked::set set2) const; + static inline isl::checked::set universe(isl::checked::space space); + inline isl::checked::basic_set unshifted_simple_hull() const; + inline isl::checked::map unwrap() const; +}; + +// declarations for isl::space +inline space manage(__isl_take isl_space *ptr); +inline space manage_copy(__isl_keep isl_space *ptr); + +class space { + friend inline space manage(__isl_take isl_space *ptr); + friend inline space manage_copy(__isl_keep isl_space *ptr); + +protected: + isl_space *ptr = nullptr; + + inline explicit space(__isl_take isl_space *ptr); + +public: + inline /* implicit */ space(); + inline /* implicit */ space(const space &obj); + inline space &operator=(space obj); + inline ~space(); + inline __isl_give isl_space *copy() const &; + inline __isl_give isl_space *copy() && = delete; + inline __isl_keep isl_space *get() const; + inline __isl_give isl_space *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::space add_named_tuple(isl::checked::id tuple_id, unsigned int dim) const; + inline isl::checked::space add_named_tuple(const std::string &tuple_id, unsigned int dim) const; + inline isl::checked::space add_unnamed_tuple(unsigned int dim) const; + inline isl::checked::space domain() const; + inline isl::checked::space flatten_domain() const; + inline isl::checked::space flatten_range() const; + inline boolean is_equal(const isl::checked::space &space2) const; + inline boolean is_wrapping() const; + inline isl::checked::space map_from_set() const; + inline isl::checked::space params() const; + inline isl::checked::space range() const; + static inline isl::checked::space unit(isl::checked::ctx ctx); + inline isl::checked::space unwrap() const; + inline isl::checked::space wrap() const; +}; + +// declarations for isl::union_access_info +inline union_access_info manage(__isl_take isl_union_access_info *ptr); +inline union_access_info manage_copy(__isl_keep isl_union_access_info *ptr); + +class union_access_info { + friend inline union_access_info manage(__isl_take isl_union_access_info *ptr); + friend inline union_access_info manage_copy(__isl_keep isl_union_access_info *ptr); + +protected: + isl_union_access_info *ptr = nullptr; + + inline explicit union_access_info(__isl_take isl_union_access_info *ptr); + +public: + inline /* implicit */ union_access_info(); + inline /* implicit */ union_access_info(const union_access_info &obj); + inline explicit union_access_info(isl::checked::union_map sink); + inline union_access_info &operator=(union_access_info obj); + inline ~union_access_info(); + inline __isl_give isl_union_access_info *copy() const &; + inline __isl_give isl_union_access_info *copy() && = delete; + inline __isl_keep isl_union_access_info *get() const; + inline __isl_give isl_union_access_info *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_flow compute_flow() const; + inline isl::checked::union_access_info set_kill(isl::checked::union_map kill) const; + inline isl::checked::union_access_info set_may_source(isl::checked::union_map may_source) const; + inline isl::checked::union_access_info set_must_source(isl::checked::union_map must_source) const; + inline isl::checked::union_access_info set_schedule(isl::checked::schedule schedule) const; + inline isl::checked::union_access_info set_schedule_map(isl::checked::union_map schedule_map) const; +}; + +// declarations for isl::union_flow +inline union_flow manage(__isl_take isl_union_flow *ptr); +inline union_flow manage_copy(__isl_keep isl_union_flow *ptr); + +class union_flow { + friend inline union_flow manage(__isl_take isl_union_flow *ptr); + friend inline union_flow manage_copy(__isl_keep isl_union_flow *ptr); + +protected: + isl_union_flow *ptr = nullptr; + + inline explicit union_flow(__isl_take isl_union_flow *ptr); + +public: + inline /* implicit */ union_flow(); + inline /* implicit */ union_flow(const union_flow &obj); + inline union_flow &operator=(union_flow obj); + inline ~union_flow(); + inline __isl_give isl_union_flow *copy() const &; + inline __isl_give isl_union_flow *copy() && = delete; + inline __isl_keep isl_union_flow *get() const; + inline __isl_give isl_union_flow *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_map full_may_dependence() const; + inline isl::checked::union_map get_full_may_dependence() const; + inline isl::checked::union_map full_must_dependence() const; + inline isl::checked::union_map get_full_must_dependence() const; + inline isl::checked::union_map may_dependence() const; + inline isl::checked::union_map get_may_dependence() const; + inline isl::checked::union_map may_no_source() const; + inline isl::checked::union_map get_may_no_source() const; + inline isl::checked::union_map must_dependence() const; + inline isl::checked::union_map get_must_dependence() const; + inline isl::checked::union_map must_no_source() const; + inline isl::checked::union_map get_must_no_source() const; +}; + +// declarations for isl::union_map +inline union_map manage(__isl_take isl_union_map *ptr); +inline union_map manage_copy(__isl_keep isl_union_map *ptr); + +class union_map { + friend inline union_map manage(__isl_take isl_union_map *ptr); + friend inline union_map manage_copy(__isl_keep isl_union_map *ptr); + +protected: + isl_union_map *ptr = nullptr; + + inline explicit union_map(__isl_take isl_union_map *ptr); + +public: + inline /* implicit */ union_map(); + inline /* implicit */ union_map(const union_map &obj); + inline /* implicit */ union_map(isl::checked::basic_map bmap); + inline /* implicit */ union_map(isl::checked::map map); + inline explicit union_map(isl::checked::ctx ctx, const std::string &str); + inline union_map &operator=(union_map obj); + inline ~union_map(); + inline __isl_give isl_union_map *copy() const &; + inline __isl_give isl_union_map *copy() && = delete; + inline __isl_keep isl_union_map *get() const; + inline __isl_give isl_union_map *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_map affine_hull() const; + inline isl::checked::union_map apply_domain(isl::checked::union_map umap2) const; + inline isl::checked::union_map apply_range(isl::checked::union_map umap2) const; + inline isl::checked::union_set bind_range(isl::checked::multi_id tuple) const; + inline isl::checked::union_map coalesce() const; + inline isl::checked::union_map compute_divs() const; + inline isl::checked::union_map curry() const; + inline isl::checked::union_set deltas() const; + inline isl::checked::union_map detect_equalities() const; + inline isl::checked::union_set domain() const; + inline isl::checked::union_map domain_factor_domain() const; + inline isl::checked::union_map domain_factor_range() const; + inline isl::checked::union_map domain_map() const; + inline isl::checked::union_pw_multi_aff domain_map_union_pw_multi_aff() const; + inline isl::checked::union_map domain_product(isl::checked::union_map umap2) const; + static inline isl::checked::union_map empty(isl::checked::ctx ctx); + inline isl::checked::union_map eq_at(isl::checked::multi_union_pw_aff mupa) const; + inline boolean every_map(const std::function &test) const; + inline isl::checked::map extract_map(isl::checked::space dim) const; + inline isl::checked::union_map factor_domain() const; + inline isl::checked::union_map factor_range() const; + inline isl::checked::union_map fixed_power(isl::checked::val exp) const; + inline isl::checked::union_map fixed_power(long exp) const; + inline stat foreach_map(const std::function &fn) const; + static inline isl::checked::union_map from(isl::checked::multi_union_pw_aff mupa); + static inline isl::checked::union_map from(isl::checked::union_pw_multi_aff upma); + static inline isl::checked::union_map from_domain(isl::checked::union_set uset); + static inline isl::checked::union_map from_domain_and_range(isl::checked::union_set domain, isl::checked::union_set range); + static inline isl::checked::union_map from_range(isl::checked::union_set uset); + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::union_map gist(isl::checked::union_map context) const; + inline isl::checked::union_map gist_domain(isl::checked::union_set uset) const; + inline isl::checked::union_map gist_params(isl::checked::set set) const; + inline isl::checked::union_map gist_range(isl::checked::union_set uset) const; + inline isl::checked::union_map intersect(isl::checked::union_map umap2) const; + inline isl::checked::union_map intersect_domain(isl::checked::union_set uset) const; + inline isl::checked::union_map intersect_params(isl::checked::set set) const; + inline isl::checked::union_map intersect_range(isl::checked::union_set uset) const; + inline boolean is_bijective() const; + inline boolean is_disjoint(const isl::checked::union_map &umap2) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::union_map &umap2) const; + inline boolean is_injective() const; + inline boolean is_single_valued() const; + inline boolean is_strict_subset(const isl::checked::union_map &umap2) const; + inline boolean is_subset(const isl::checked::union_map &umap2) const; + inline boolean isa_map() const; + inline isl::checked::union_map lexmax() const; + inline isl::checked::union_map lexmin() const; + inline isl::checked::union_map polyhedral_hull() const; + inline isl::checked::union_map preimage_domain(isl::checked::multi_aff ma) const; + inline isl::checked::union_map preimage_domain(isl::checked::multi_pw_aff mpa) const; + inline isl::checked::union_map preimage_domain(isl::checked::pw_multi_aff pma) const; + inline isl::checked::union_map preimage_domain(isl::checked::union_pw_multi_aff upma) const; + inline isl::checked::union_map preimage_range(isl::checked::multi_aff ma) const; + inline isl::checked::union_map preimage_range(isl::checked::pw_multi_aff pma) const; + inline isl::checked::union_map preimage_range(isl::checked::union_pw_multi_aff upma) const; + inline isl::checked::union_map product(isl::checked::union_map umap2) const; + inline isl::checked::union_map project_out_all_params() const; + inline isl::checked::union_set range() const; + inline isl::checked::union_map range_factor_domain() const; + inline isl::checked::union_map range_factor_range() const; + inline isl::checked::union_map range_map() const; + inline isl::checked::union_map range_product(isl::checked::union_map umap2) const; + inline isl::checked::union_map reverse() const; + inline isl::checked::union_map subtract(isl::checked::union_map umap2) const; + inline isl::checked::union_map subtract_domain(isl::checked::union_set dom) const; + inline isl::checked::union_map subtract_range(isl::checked::union_set dom) const; + inline isl::checked::union_map uncurry() const; + inline isl::checked::union_map unite(isl::checked::union_map umap2) const; + inline isl::checked::union_map universe() const; + inline isl::checked::union_set wrap() const; + inline isl::checked::union_map zip() const; +}; + +// declarations for isl::union_pw_aff +inline union_pw_aff manage(__isl_take isl_union_pw_aff *ptr); +inline union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr); + +class union_pw_aff { + friend inline union_pw_aff manage(__isl_take isl_union_pw_aff *ptr); + friend inline union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr); + +protected: + isl_union_pw_aff *ptr = nullptr; + + inline explicit union_pw_aff(__isl_take isl_union_pw_aff *ptr); + +public: + inline /* implicit */ union_pw_aff(); + inline /* implicit */ union_pw_aff(const union_pw_aff &obj); + inline /* implicit */ union_pw_aff(isl::checked::pw_aff pa); + inline explicit union_pw_aff(isl::checked::ctx ctx, const std::string &str); + inline union_pw_aff &operator=(union_pw_aff obj); + inline ~union_pw_aff(); + inline __isl_give isl_union_pw_aff *copy() const &; + inline __isl_give isl_union_pw_aff *copy() && = delete; + inline __isl_keep isl_union_pw_aff *get() const; + inline __isl_give isl_union_pw_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_pw_aff add(isl::checked::union_pw_aff upa2) const; + inline isl::checked::union_set bind(isl::checked::id id) const; + inline isl::checked::union_set bind(const std::string &id) const; + inline isl::checked::union_set domain() const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::union_pw_aff gist(isl::checked::union_set context) const; + inline isl::checked::union_pw_aff intersect_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_aff intersect_domain_wrapped_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_aff intersect_domain_wrapped_range(isl::checked::union_set uset) const; + inline isl::checked::union_pw_aff intersect_params(isl::checked::set set) const; + inline isl::checked::union_pw_aff pullback(isl::checked::union_pw_multi_aff upma) const; + inline isl::checked::union_pw_aff sub(isl::checked::union_pw_aff upa2) const; + inline isl::checked::union_pw_aff subtract_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_aff union_add(isl::checked::union_pw_aff upa2) const; +}; + +// declarations for isl::union_pw_aff_list +inline union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr); +inline union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr); + +class union_pw_aff_list { + friend inline union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr); + friend inline union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr); + +protected: + isl_union_pw_aff_list *ptr = nullptr; + + inline explicit union_pw_aff_list(__isl_take isl_union_pw_aff_list *ptr); + +public: + inline /* implicit */ union_pw_aff_list(); + inline /* implicit */ union_pw_aff_list(const union_pw_aff_list &obj); + inline explicit union_pw_aff_list(isl::checked::ctx ctx, int n); + inline explicit union_pw_aff_list(isl::checked::union_pw_aff el); + inline union_pw_aff_list &operator=(union_pw_aff_list obj); + inline ~union_pw_aff_list(); + inline __isl_give isl_union_pw_aff_list *copy() const &; + inline __isl_give isl_union_pw_aff_list *copy() && = delete; + inline __isl_keep isl_union_pw_aff_list *get() const; + inline __isl_give isl_union_pw_aff_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_pw_aff_list add(isl::checked::union_pw_aff el) const; + inline isl::checked::union_pw_aff_list clear() const; + inline isl::checked::union_pw_aff_list concat(isl::checked::union_pw_aff_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::union_pw_aff at(int index) const; + inline isl::checked::union_pw_aff get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::union_pw_multi_aff +inline union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr); +inline union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr); + +class union_pw_multi_aff { + friend inline union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr); + friend inline union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr); + +protected: + isl_union_pw_multi_aff *ptr = nullptr; + + inline explicit union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *ptr); + +public: + inline /* implicit */ union_pw_multi_aff(); + inline /* implicit */ union_pw_multi_aff(const union_pw_multi_aff &obj); + inline /* implicit */ union_pw_multi_aff(isl::checked::pw_multi_aff pma); + inline /* implicit */ union_pw_multi_aff(isl::checked::union_pw_aff upa); + inline explicit union_pw_multi_aff(isl::checked::ctx ctx, const std::string &str); + inline union_pw_multi_aff &operator=(union_pw_multi_aff obj); + inline ~union_pw_multi_aff(); + inline __isl_give isl_union_pw_multi_aff *copy() const &; + inline __isl_give isl_union_pw_multi_aff *copy() && = delete; + inline __isl_keep isl_union_pw_multi_aff *get() const; + inline __isl_give isl_union_pw_multi_aff *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_pw_multi_aff add(isl::checked::union_pw_multi_aff upma2) const; + inline isl::checked::pw_multi_aff as_pw_multi_aff() const; + inline isl::checked::union_set domain() const; + static inline isl::checked::union_pw_multi_aff empty(isl::checked::ctx ctx); + inline isl::checked::pw_multi_aff extract_pw_multi_aff(isl::checked::space space) const; + inline isl::checked::union_pw_multi_aff flat_range_product(isl::checked::union_pw_multi_aff upma2) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::union_pw_multi_aff gist(isl::checked::union_set context) const; + inline isl::checked::union_pw_multi_aff intersect_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_multi_aff intersect_domain_wrapped_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_multi_aff intersect_domain_wrapped_range(isl::checked::union_set uset) const; + inline isl::checked::union_pw_multi_aff intersect_params(isl::checked::set set) const; + inline boolean isa_pw_multi_aff() const; + inline isl::checked::union_pw_multi_aff pullback(isl::checked::union_pw_multi_aff upma2) const; + inline isl::checked::union_pw_multi_aff range_factor_domain() const; + inline isl::checked::union_pw_multi_aff range_factor_range() const; + inline isl::checked::union_pw_multi_aff sub(isl::checked::union_pw_multi_aff upma2) const; + inline isl::checked::union_pw_multi_aff subtract_domain(isl::checked::union_set uset) const; + inline isl::checked::union_pw_multi_aff union_add(isl::checked::union_pw_multi_aff upma2) const; +}; + +// declarations for isl::union_set +inline union_set manage(__isl_take isl_union_set *ptr); +inline union_set manage_copy(__isl_keep isl_union_set *ptr); + +class union_set { + friend inline union_set manage(__isl_take isl_union_set *ptr); + friend inline union_set manage_copy(__isl_keep isl_union_set *ptr); + +protected: + isl_union_set *ptr = nullptr; + + inline explicit union_set(__isl_take isl_union_set *ptr); + +public: + inline /* implicit */ union_set(); + inline /* implicit */ union_set(const union_set &obj); + inline /* implicit */ union_set(isl::checked::basic_set bset); + inline /* implicit */ union_set(isl::checked::point pnt); + inline /* implicit */ union_set(isl::checked::set set); + inline explicit union_set(isl::checked::ctx ctx, const std::string &str); + inline union_set &operator=(union_set obj); + inline ~union_set(); + inline __isl_give isl_union_set *copy() const &; + inline __isl_give isl_union_set *copy() && = delete; + inline __isl_keep isl_union_set *get() const; + inline __isl_give isl_union_set *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_set affine_hull() const; + inline isl::checked::union_set apply(isl::checked::union_map umap) const; + inline isl::checked::union_set coalesce() const; + inline isl::checked::union_set compute_divs() const; + inline isl::checked::union_set detect_equalities() const; + static inline isl::checked::union_set empty(isl::checked::ctx ctx); + inline boolean every_set(const std::function &test) const; + inline isl::checked::set extract_set(isl::checked::space dim) const; + inline stat foreach_point(const std::function &fn) const; + inline stat foreach_set(const std::function &fn) const; + inline isl::checked::space space() const; + inline isl::checked::space get_space() const; + inline isl::checked::union_set gist(isl::checked::union_set context) const; + inline isl::checked::union_set gist_params(isl::checked::set set) const; + inline isl::checked::union_map identity() const; + inline isl::checked::union_set intersect(isl::checked::union_set uset2) const; + inline isl::checked::union_set intersect_params(isl::checked::set set) const; + inline boolean is_disjoint(const isl::checked::union_set &uset2) const; + inline boolean is_empty() const; + inline boolean is_equal(const isl::checked::union_set &uset2) const; + inline boolean is_strict_subset(const isl::checked::union_set &uset2) const; + inline boolean is_subset(const isl::checked::union_set &uset2) const; + inline boolean isa_set() const; + inline isl::checked::union_set lexmax() const; + inline isl::checked::union_set lexmin() const; + inline isl::checked::union_set polyhedral_hull() const; + inline isl::checked::union_set preimage(isl::checked::multi_aff ma) const; + inline isl::checked::union_set preimage(isl::checked::pw_multi_aff pma) const; + inline isl::checked::union_set preimage(isl::checked::union_pw_multi_aff upma) const; + inline isl::checked::point sample_point() const; + inline isl::checked::union_set subtract(isl::checked::union_set uset2) const; + inline isl::checked::union_set unite(isl::checked::union_set uset2) const; + inline isl::checked::union_set universe() const; + inline isl::checked::union_map unwrap() const; +}; + +// declarations for isl::union_set_list +inline union_set_list manage(__isl_take isl_union_set_list *ptr); +inline union_set_list manage_copy(__isl_keep isl_union_set_list *ptr); + +class union_set_list { + friend inline union_set_list manage(__isl_take isl_union_set_list *ptr); + friend inline union_set_list manage_copy(__isl_keep isl_union_set_list *ptr); + +protected: + isl_union_set_list *ptr = nullptr; + + inline explicit union_set_list(__isl_take isl_union_set_list *ptr); + +public: + inline /* implicit */ union_set_list(); + inline /* implicit */ union_set_list(const union_set_list &obj); + inline explicit union_set_list(isl::checked::ctx ctx, int n); + inline explicit union_set_list(isl::checked::union_set el); + inline union_set_list &operator=(union_set_list obj); + inline ~union_set_list(); + inline __isl_give isl_union_set_list *copy() const &; + inline __isl_give isl_union_set_list *copy() && = delete; + inline __isl_keep isl_union_set_list *get() const; + inline __isl_give isl_union_set_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::union_set_list add(isl::checked::union_set el) const; + inline isl::checked::union_set_list clear() const; + inline isl::checked::union_set_list concat(isl::checked::union_set_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::union_set at(int index) const; + inline isl::checked::union_set get_at(int index) const; + inline class size size() const; +}; + +// declarations for isl::val +inline val manage(__isl_take isl_val *ptr); +inline val manage_copy(__isl_keep isl_val *ptr); + +class val { + friend inline val manage(__isl_take isl_val *ptr); + friend inline val manage_copy(__isl_keep isl_val *ptr); + +protected: + isl_val *ptr = nullptr; + + inline explicit val(__isl_take isl_val *ptr); + +public: + inline /* implicit */ val(); + inline /* implicit */ val(const val &obj); + inline explicit val(isl::checked::ctx ctx, long i); + inline explicit val(isl::checked::ctx ctx, const std::string &str); + inline val &operator=(val obj); + inline ~val(); + inline __isl_give isl_val *copy() const &; + inline __isl_give isl_val *copy() && = delete; + inline __isl_keep isl_val *get() const; + inline __isl_give isl_val *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::val abs() const; + inline boolean abs_eq(const isl::checked::val &v2) const; + inline boolean abs_eq(long v2) const; + inline isl::checked::val add(isl::checked::val v2) const; + inline isl::checked::val add(long v2) const; + inline isl::checked::val ceil() const; + inline int cmp_si(long i) const; + inline isl::checked::val div(isl::checked::val v2) const; + inline isl::checked::val div(long v2) const; + inline boolean eq(const isl::checked::val &v2) const; + inline boolean eq(long v2) const; + inline isl::checked::val floor() const; + inline isl::checked::val gcd(isl::checked::val v2) const; + inline isl::checked::val gcd(long v2) const; + inline boolean ge(const isl::checked::val &v2) const; + inline boolean ge(long v2) const; + inline long den_si() const; + inline long get_den_si() const; + inline long num_si() const; + inline long get_num_si() const; + inline boolean gt(const isl::checked::val &v2) const; + inline boolean gt(long v2) const; + static inline isl::checked::val infty(isl::checked::ctx ctx); + inline isl::checked::val inv() const; + inline boolean is_divisible_by(const isl::checked::val &v2) const; + inline boolean is_divisible_by(long v2) const; + inline boolean is_infty() const; + inline boolean is_int() const; + inline boolean is_nan() const; + inline boolean is_neg() const; + inline boolean is_neginfty() const; + inline boolean is_negone() const; + inline boolean is_nonneg() const; + inline boolean is_nonpos() const; + inline boolean is_one() const; + inline boolean is_pos() const; + inline boolean is_rat() const; + inline boolean is_zero() const; + inline boolean le(const isl::checked::val &v2) const; + inline boolean le(long v2) const; + inline boolean lt(const isl::checked::val &v2) const; + inline boolean lt(long v2) const; + inline isl::checked::val max(isl::checked::val v2) const; + inline isl::checked::val max(long v2) const; + inline isl::checked::val min(isl::checked::val v2) const; + inline isl::checked::val min(long v2) const; + inline isl::checked::val mod(isl::checked::val v2) const; + inline isl::checked::val mod(long v2) const; + inline isl::checked::val mul(isl::checked::val v2) const; + inline isl::checked::val mul(long v2) const; + static inline isl::checked::val nan(isl::checked::ctx ctx); + inline boolean ne(const isl::checked::val &v2) const; + inline boolean ne(long v2) const; + inline isl::checked::val neg() const; + static inline isl::checked::val neginfty(isl::checked::ctx ctx); + static inline isl::checked::val negone(isl::checked::ctx ctx); + static inline isl::checked::val one(isl::checked::ctx ctx); + inline isl::checked::val pow2() const; + inline int sgn() const; + inline isl::checked::val sub(isl::checked::val v2) const; + inline isl::checked::val sub(long v2) const; + inline isl::checked::val trunc() const; + static inline isl::checked::val zero(isl::checked::ctx ctx); +}; + +// declarations for isl::val_list +inline val_list manage(__isl_take isl_val_list *ptr); +inline val_list manage_copy(__isl_keep isl_val_list *ptr); + +class val_list { + friend inline val_list manage(__isl_take isl_val_list *ptr); + friend inline val_list manage_copy(__isl_keep isl_val_list *ptr); + +protected: + isl_val_list *ptr = nullptr; + + inline explicit val_list(__isl_take isl_val_list *ptr); + +public: + inline /* implicit */ val_list(); + inline /* implicit */ val_list(const val_list &obj); + inline explicit val_list(isl::checked::ctx ctx, int n); + inline explicit val_list(isl::checked::val el); + inline val_list &operator=(val_list obj); + inline ~val_list(); + inline __isl_give isl_val_list *copy() const &; + inline __isl_give isl_val_list *copy() && = delete; + inline __isl_keep isl_val_list *get() const; + inline __isl_give isl_val_list *release(); + inline bool is_null() const; + inline isl::checked::ctx ctx() const; + + inline isl::checked::val_list add(isl::checked::val el) const; + inline isl::checked::val_list add(long el) const; + inline isl::checked::val_list clear() const; + inline isl::checked::val_list concat(isl::checked::val_list list2) const; + inline stat foreach(const std::function &fn) const; + inline isl::checked::val at(int index) const; + inline isl::checked::val get_at(int index) const; + inline class size size() const; +}; + +// implementations for isl::aff +aff manage(__isl_take isl_aff *ptr) { + return aff(ptr); +} +aff manage_copy(__isl_keep isl_aff *ptr) { + ptr = isl_aff_copy(ptr); + return aff(ptr); +} + +aff::aff() + : ptr(nullptr) {} + +aff::aff(const aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +aff::aff(__isl_take isl_aff *ptr) + : ptr(ptr) {} + +aff::aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +aff &aff::operator=(aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +aff::~aff() { + if (ptr) + isl_aff_free(ptr); +} + +__isl_give isl_aff *aff::copy() const & { + return isl_aff_copy(ptr); +} + +__isl_keep isl_aff *aff::get() const { + return ptr; +} + +__isl_give isl_aff *aff::release() { + isl_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx aff::ctx() const { + return isl::checked::ctx(isl_aff_get_ctx(ptr)); +} + +isl::checked::aff aff::add(isl::checked::aff aff2) const +{ + auto res = isl_aff_add(copy(), aff2.release()); + return manage(res); +} + +isl::checked::aff aff::add_constant(isl::checked::val v) const +{ + auto res = isl_aff_add_constant_val(copy(), v.release()); + return manage(res); +} + +isl::checked::aff aff::add_constant(long v) const +{ + return this->add_constant(isl::checked::val(ctx(), v)); +} + +isl::checked::basic_set aff::bind(isl::checked::id id) const +{ + auto res = isl_aff_bind_id(copy(), id.release()); + return manage(res); +} + +isl::checked::basic_set aff::bind(const std::string &id) const +{ + return this->bind(isl::checked::id(ctx(), id)); +} + +isl::checked::aff aff::ceil() const +{ + auto res = isl_aff_ceil(copy()); + return manage(res); +} + +isl::checked::aff aff::div(isl::checked::aff aff2) const +{ + auto res = isl_aff_div(copy(), aff2.release()); + return manage(res); +} + +isl::checked::set aff::eq_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_eq_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::val aff::eval(isl::checked::point pnt) const +{ + auto res = isl_aff_eval(copy(), pnt.release()); + return manage(res); +} + +isl::checked::aff aff::floor() const +{ + auto res = isl_aff_floor(copy()); + return manage(res); +} + +isl::checked::set aff::ge_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_ge_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::aff aff::gist(isl::checked::set context) const +{ + auto res = isl_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::set aff::gt_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_gt_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::set aff::le_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_le_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::set aff::lt_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_lt_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::aff aff::mod(isl::checked::val mod) const +{ + auto res = isl_aff_mod_val(copy(), mod.release()); + return manage(res); +} + +isl::checked::aff aff::mod(long mod) const +{ + return this->mod(isl::checked::val(ctx(), mod)); +} + +isl::checked::aff aff::mul(isl::checked::aff aff2) const +{ + auto res = isl_aff_mul(copy(), aff2.release()); + return manage(res); +} + +isl::checked::set aff::ne_set(isl::checked::aff aff2) const +{ + auto res = isl_aff_ne_set(copy(), aff2.release()); + return manage(res); +} + +isl::checked::aff aff::neg() const +{ + auto res = isl_aff_neg(copy()); + return manage(res); +} + +isl::checked::aff aff::pullback(isl::checked::multi_aff ma) const +{ + auto res = isl_aff_pullback_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::aff aff::scale(isl::checked::val v) const +{ + auto res = isl_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::aff aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::aff aff::scale_down(isl::checked::val v) const +{ + auto res = isl_aff_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::aff aff::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::aff aff::sub(isl::checked::aff aff2) const +{ + auto res = isl_aff_sub(copy(), aff2.release()); + return manage(res); +} + +isl::checked::aff aff::unbind_params_insert_domain(isl::checked::multi_id domain) const +{ + auto res = isl_aff_unbind_params_insert_domain(copy(), domain.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const aff &obj) +{ + char *str = isl_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::aff_list +aff_list manage(__isl_take isl_aff_list *ptr) { + return aff_list(ptr); +} +aff_list manage_copy(__isl_keep isl_aff_list *ptr) { + ptr = isl_aff_list_copy(ptr); + return aff_list(ptr); +} + +aff_list::aff_list() + : ptr(nullptr) {} + +aff_list::aff_list(const aff_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +aff_list::aff_list(__isl_take isl_aff_list *ptr) + : ptr(ptr) {} + +aff_list::aff_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_aff_list_alloc(ctx.release(), n); + ptr = res; +} + +aff_list::aff_list(isl::checked::aff el) +{ + auto res = isl_aff_list_from_aff(el.release()); + ptr = res; +} + +aff_list &aff_list::operator=(aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +aff_list::~aff_list() { + if (ptr) + isl_aff_list_free(ptr); +} + +__isl_give isl_aff_list *aff_list::copy() const & { + return isl_aff_list_copy(ptr); +} + +__isl_keep isl_aff_list *aff_list::get() const { + return ptr; +} + +__isl_give isl_aff_list *aff_list::release() { + isl_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool aff_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx aff_list::ctx() const { + return isl::checked::ctx(isl_aff_list_get_ctx(ptr)); +} + +isl::checked::aff_list aff_list::add(isl::checked::aff el) const +{ + auto res = isl_aff_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::aff_list aff_list::clear() const +{ + auto res = isl_aff_list_clear(copy()); + return manage(res); +} + +isl::checked::aff_list aff_list::concat(isl::checked::aff_list list2) const +{ + auto res = isl_aff_list_concat(copy(), list2.release()); + return manage(res); +} + +stat aff_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_aff_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::aff aff_list::at(int index) const +{ + auto res = isl_aff_list_get_at(get(), index); + return manage(res); +} + +isl::checked::aff aff_list::get_at(int index) const +{ + return at(index); +} + +class size aff_list::size() const +{ + auto res = isl_aff_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const aff_list &obj) +{ + char *str = isl_aff_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_build +ast_build manage(__isl_take isl_ast_build *ptr) { + return ast_build(ptr); +} +ast_build manage_copy(__isl_keep isl_ast_build *ptr) { + ptr = isl_ast_build_copy(ptr); + return ast_build(ptr); +} + +ast_build::ast_build() + : ptr(nullptr) {} + +ast_build::ast_build(const ast_build &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); + copy_callbacks(obj); +} + +ast_build::ast_build(__isl_take isl_ast_build *ptr) + : ptr(ptr) {} + +ast_build::ast_build(isl::checked::ctx ctx) +{ + auto res = isl_ast_build_alloc(ctx.release()); + ptr = res; +} + +ast_build &ast_build::operator=(ast_build obj) { + std::swap(this->ptr, obj.ptr); + copy_callbacks(obj); + return *this; +} + +ast_build::~ast_build() { + if (ptr) + isl_ast_build_free(ptr); +} + +__isl_give isl_ast_build *ast_build::copy() const & { + return isl_ast_build_copy(ptr); +} + +__isl_keep isl_ast_build *ast_build::get() const { + return ptr; +} + +__isl_give isl_ast_build *ast_build::release() { + if (at_each_domain_data) + isl_die(ctx().get(), isl_error_invalid, "cannot release object with persistent callbacks", return nullptr); + isl_ast_build *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_build::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx ast_build::ctx() const { + return isl::checked::ctx(isl_ast_build_get_ctx(ptr)); +} + +ast_build &ast_build::copy_callbacks(const ast_build &obj) +{ + at_each_domain_data = obj.at_each_domain_data; + return *this; +} + +isl_ast_node *ast_build::at_each_domain(isl_ast_node *arg_0, isl_ast_build *arg_1, void *arg_2) +{ + auto *data = static_cast(arg_2); + auto ret = (data->func)(manage(arg_0), manage_copy(arg_1)); + return ret.release(); +} + +void ast_build::set_at_each_domain_data(const std::function &fn) +{ + at_each_domain_data = std::make_shared(); + at_each_domain_data->func = fn; + ptr = isl_ast_build_set_at_each_domain(ptr, &at_each_domain, at_each_domain_data.get()); +} + +isl::checked::ast_build ast_build::set_at_each_domain(const std::function &fn) const +{ + auto copy = *this; + copy.set_at_each_domain_data(fn); + return copy; +} + +isl::checked::ast_expr ast_build::access_from(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_ast_build_access_from_multi_pw_aff(get(), mpa.release()); + return manage(res); +} + +isl::checked::ast_expr ast_build::access_from(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_ast_build_access_from_pw_multi_aff(get(), pma.release()); + return manage(res); +} + +isl::checked::ast_expr ast_build::call_from(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_ast_build_call_from_multi_pw_aff(get(), mpa.release()); + return manage(res); +} + +isl::checked::ast_expr ast_build::call_from(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_ast_build_call_from_pw_multi_aff(get(), pma.release()); + return manage(res); +} + +isl::checked::ast_expr ast_build::expr_from(isl::checked::pw_aff pa) const +{ + auto res = isl_ast_build_expr_from_pw_aff(get(), pa.release()); + return manage(res); +} + +isl::checked::ast_expr ast_build::expr_from(isl::checked::set set) const +{ + auto res = isl_ast_build_expr_from_set(get(), set.release()); + return manage(res); +} + +isl::checked::ast_build ast_build::from_context(isl::checked::set set) +{ + auto res = isl_ast_build_from_context(set.release()); + return manage(res); +} + +isl::checked::union_map ast_build::schedule() const +{ + auto res = isl_ast_build_get_schedule(get()); + return manage(res); +} + +isl::checked::union_map ast_build::get_schedule() const +{ + return schedule(); +} + +isl::checked::ast_node ast_build::node_from(isl::checked::schedule schedule) const +{ + auto res = isl_ast_build_node_from_schedule(get(), schedule.release()); + return manage(res); +} + +isl::checked::ast_node ast_build::node_from_schedule_map(isl::checked::union_map schedule) const +{ + auto res = isl_ast_build_node_from_schedule_map(get(), schedule.release()); + return manage(res); +} + +// implementations for isl::ast_expr +ast_expr manage(__isl_take isl_ast_expr *ptr) { + return ast_expr(ptr); +} +ast_expr manage_copy(__isl_keep isl_ast_expr *ptr) { + ptr = isl_ast_expr_copy(ptr); + return ast_expr(ptr); +} + +ast_expr::ast_expr() + : ptr(nullptr) {} + +ast_expr::ast_expr(const ast_expr &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +ast_expr::ast_expr(__isl_take isl_ast_expr *ptr) + : ptr(ptr) {} + +ast_expr &ast_expr::operator=(ast_expr obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_expr::~ast_expr() { + if (ptr) + isl_ast_expr_free(ptr); +} + +__isl_give isl_ast_expr *ast_expr::copy() const & { + return isl_ast_expr_copy(ptr); +} + +__isl_keep isl_ast_expr *ast_expr::get() const { + return ptr; +} + +__isl_give isl_ast_expr *ast_expr::release() { + isl_ast_expr *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_expr::is_null() const { + return ptr == nullptr; +} + +template +boolean ast_expr::isa_type(T subtype) const +{ + if (is_null()) + return boolean(); + return isl_ast_expr_get_type(get()) == subtype; +} +template +boolean ast_expr::isa() const +{ + return isa_type(T::type); +} +template +T ast_expr::as() const +{ + if (isa().is_false()) + isl_die(ctx().get(), isl_error_invalid, "not an object of the requested subtype", return T()); + return T(copy()); +} + +isl::checked::ctx ast_expr::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +std::string ast_expr::to_C_str() const +{ + auto res = isl_ast_expr_to_C_str(get()); + std::string tmp(res); + free(res); + return tmp; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_id +ast_expr_id::ast_expr_id() + : ast_expr() {} + +ast_expr_id::ast_expr_id(const ast_expr_id &obj) + : ast_expr(obj) +{ +} + +ast_expr_id::ast_expr_id(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_id &ast_expr_id::operator=(ast_expr_id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_id::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::checked::id ast_expr_id::id() const +{ + auto res = isl_ast_expr_id_get_id(get()); + return manage(res); +} + +isl::checked::id ast_expr_id::get_id() const +{ + return id(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_id &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_int +ast_expr_int::ast_expr_int() + : ast_expr() {} + +ast_expr_int::ast_expr_int(const ast_expr_int &obj) + : ast_expr(obj) +{ +} + +ast_expr_int::ast_expr_int(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_int &ast_expr_int::operator=(ast_expr_int obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_int::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::checked::val ast_expr_int::val() const +{ + auto res = isl_ast_expr_int_get_val(get()); + return manage(res); +} + +isl::checked::val ast_expr_int::get_val() const +{ + return val(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_int &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op +ast_expr_op::ast_expr_op() + : ast_expr() {} + +ast_expr_op::ast_expr_op(const ast_expr_op &obj) + : ast_expr(obj) +{ +} + +ast_expr_op::ast_expr_op(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_op &ast_expr_op::operator=(ast_expr_op obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +template +boolean ast_expr_op::isa_type(T subtype) const +{ + if (is_null()) + return boolean(); + return isl_ast_expr_op_get_type(get()) == subtype; +} +template +boolean ast_expr_op::isa() const +{ + return isa_type(T::type); +} +template +T ast_expr_op::as() const +{ + if (isa().is_false()) + isl_die(ctx().get(), isl_error_invalid, "not an object of the requested subtype", return T()); + return T(copy()); +} + +isl::checked::ctx ast_expr_op::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::checked::ast_expr ast_expr_op::arg(int pos) const +{ + auto res = isl_ast_expr_op_get_arg(get(), pos); + return manage(res); +} + +isl::checked::ast_expr ast_expr_op::get_arg(int pos) const +{ + return arg(pos); +} + +class size ast_expr_op::n_arg() const +{ + auto res = isl_ast_expr_op_get_n_arg(get()); + return manage(res); +} + +class size ast_expr_op::get_n_arg() const +{ + return n_arg(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_access +ast_expr_op_access::ast_expr_op_access() + : ast_expr_op() {} + +ast_expr_op_access::ast_expr_op_access(const ast_expr_op_access &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_access::ast_expr_op_access(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_access &ast_expr_op_access::operator=(ast_expr_op_access obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_access::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_access &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_add +ast_expr_op_add::ast_expr_op_add() + : ast_expr_op() {} + +ast_expr_op_add::ast_expr_op_add(const ast_expr_op_add &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_add::ast_expr_op_add(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_add &ast_expr_op_add::operator=(ast_expr_op_add obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_add::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_add &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_address_of +ast_expr_op_address_of::ast_expr_op_address_of() + : ast_expr_op() {} + +ast_expr_op_address_of::ast_expr_op_address_of(const ast_expr_op_address_of &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_address_of::ast_expr_op_address_of(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_address_of &ast_expr_op_address_of::operator=(ast_expr_op_address_of obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_address_of::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_address_of &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_and +ast_expr_op_and::ast_expr_op_and() + : ast_expr_op() {} + +ast_expr_op_and::ast_expr_op_and(const ast_expr_op_and &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_and::ast_expr_op_and(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_and &ast_expr_op_and::operator=(ast_expr_op_and obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_and::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_and &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_and_then +ast_expr_op_and_then::ast_expr_op_and_then() + : ast_expr_op() {} + +ast_expr_op_and_then::ast_expr_op_and_then(const ast_expr_op_and_then &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_and_then::ast_expr_op_and_then(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_and_then &ast_expr_op_and_then::operator=(ast_expr_op_and_then obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_and_then::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_and_then &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_call +ast_expr_op_call::ast_expr_op_call() + : ast_expr_op() {} + +ast_expr_op_call::ast_expr_op_call(const ast_expr_op_call &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_call::ast_expr_op_call(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_call &ast_expr_op_call::operator=(ast_expr_op_call obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_call::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_call &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_cond +ast_expr_op_cond::ast_expr_op_cond() + : ast_expr_op() {} + +ast_expr_op_cond::ast_expr_op_cond(const ast_expr_op_cond &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_cond::ast_expr_op_cond(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_cond &ast_expr_op_cond::operator=(ast_expr_op_cond obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_cond::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_cond &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_div +ast_expr_op_div::ast_expr_op_div() + : ast_expr_op() {} + +ast_expr_op_div::ast_expr_op_div(const ast_expr_op_div &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_div::ast_expr_op_div(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_div &ast_expr_op_div::operator=(ast_expr_op_div obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_div::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_div &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_eq +ast_expr_op_eq::ast_expr_op_eq() + : ast_expr_op() {} + +ast_expr_op_eq::ast_expr_op_eq(const ast_expr_op_eq &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_eq::ast_expr_op_eq(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_eq &ast_expr_op_eq::operator=(ast_expr_op_eq obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_eq::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_eq &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_fdiv_q +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q() + : ast_expr_op() {} + +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q(const ast_expr_op_fdiv_q &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_fdiv_q &ast_expr_op_fdiv_q::operator=(ast_expr_op_fdiv_q obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_fdiv_q::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_fdiv_q &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_ge +ast_expr_op_ge::ast_expr_op_ge() + : ast_expr_op() {} + +ast_expr_op_ge::ast_expr_op_ge(const ast_expr_op_ge &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_ge::ast_expr_op_ge(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_ge &ast_expr_op_ge::operator=(ast_expr_op_ge obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_ge::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_ge &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_gt +ast_expr_op_gt::ast_expr_op_gt() + : ast_expr_op() {} + +ast_expr_op_gt::ast_expr_op_gt(const ast_expr_op_gt &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_gt::ast_expr_op_gt(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_gt &ast_expr_op_gt::operator=(ast_expr_op_gt obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_gt::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_gt &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_le +ast_expr_op_le::ast_expr_op_le() + : ast_expr_op() {} + +ast_expr_op_le::ast_expr_op_le(const ast_expr_op_le &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_le::ast_expr_op_le(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_le &ast_expr_op_le::operator=(ast_expr_op_le obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_le::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_le &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_lt +ast_expr_op_lt::ast_expr_op_lt() + : ast_expr_op() {} + +ast_expr_op_lt::ast_expr_op_lt(const ast_expr_op_lt &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_lt::ast_expr_op_lt(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_lt &ast_expr_op_lt::operator=(ast_expr_op_lt obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_lt::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_lt &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_max +ast_expr_op_max::ast_expr_op_max() + : ast_expr_op() {} + +ast_expr_op_max::ast_expr_op_max(const ast_expr_op_max &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_max::ast_expr_op_max(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_max &ast_expr_op_max::operator=(ast_expr_op_max obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_max::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_max &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_member +ast_expr_op_member::ast_expr_op_member() + : ast_expr_op() {} + +ast_expr_op_member::ast_expr_op_member(const ast_expr_op_member &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_member::ast_expr_op_member(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_member &ast_expr_op_member::operator=(ast_expr_op_member obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_member::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_member &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_min +ast_expr_op_min::ast_expr_op_min() + : ast_expr_op() {} + +ast_expr_op_min::ast_expr_op_min(const ast_expr_op_min &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_min::ast_expr_op_min(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_min &ast_expr_op_min::operator=(ast_expr_op_min obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_min::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_min &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_minus +ast_expr_op_minus::ast_expr_op_minus() + : ast_expr_op() {} + +ast_expr_op_minus::ast_expr_op_minus(const ast_expr_op_minus &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_minus::ast_expr_op_minus(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_minus &ast_expr_op_minus::operator=(ast_expr_op_minus obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_minus::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_minus &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_mul +ast_expr_op_mul::ast_expr_op_mul() + : ast_expr_op() {} + +ast_expr_op_mul::ast_expr_op_mul(const ast_expr_op_mul &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_mul::ast_expr_op_mul(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_mul &ast_expr_op_mul::operator=(ast_expr_op_mul obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_mul::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_mul &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_or +ast_expr_op_or::ast_expr_op_or() + : ast_expr_op() {} + +ast_expr_op_or::ast_expr_op_or(const ast_expr_op_or &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_or::ast_expr_op_or(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_or &ast_expr_op_or::operator=(ast_expr_op_or obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_or::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_or &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_or_else +ast_expr_op_or_else::ast_expr_op_or_else() + : ast_expr_op() {} + +ast_expr_op_or_else::ast_expr_op_or_else(const ast_expr_op_or_else &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_or_else::ast_expr_op_or_else(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_or_else &ast_expr_op_or_else::operator=(ast_expr_op_or_else obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_or_else::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_or_else &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_pdiv_q +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q() + : ast_expr_op() {} + +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q(const ast_expr_op_pdiv_q &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_pdiv_q &ast_expr_op_pdiv_q::operator=(ast_expr_op_pdiv_q obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_pdiv_q::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_pdiv_q &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_pdiv_r +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r() + : ast_expr_op() {} + +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r(const ast_expr_op_pdiv_r &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_pdiv_r &ast_expr_op_pdiv_r::operator=(ast_expr_op_pdiv_r obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_pdiv_r::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_pdiv_r &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_select +ast_expr_op_select::ast_expr_op_select() + : ast_expr_op() {} + +ast_expr_op_select::ast_expr_op_select(const ast_expr_op_select &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_select::ast_expr_op_select(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_select &ast_expr_op_select::operator=(ast_expr_op_select obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_select::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_select &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_sub +ast_expr_op_sub::ast_expr_op_sub() + : ast_expr_op() {} + +ast_expr_op_sub::ast_expr_op_sub(const ast_expr_op_sub &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_sub::ast_expr_op_sub(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_sub &ast_expr_op_sub::operator=(ast_expr_op_sub obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_sub::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_sub &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_zdiv_r +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r() + : ast_expr_op() {} + +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r(const ast_expr_op_zdiv_r &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_zdiv_r &ast_expr_op_zdiv_r::operator=(ast_expr_op_zdiv_r obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_expr_op_zdiv_r::ctx() const { + return isl::checked::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_zdiv_r &obj) +{ + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node +ast_node manage(__isl_take isl_ast_node *ptr) { + return ast_node(ptr); +} +ast_node manage_copy(__isl_keep isl_ast_node *ptr) { + ptr = isl_ast_node_copy(ptr); + return ast_node(ptr); +} + +ast_node::ast_node() + : ptr(nullptr) {} + +ast_node::ast_node(const ast_node &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +ast_node::ast_node(__isl_take isl_ast_node *ptr) + : ptr(ptr) {} + +ast_node &ast_node::operator=(ast_node obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_node::~ast_node() { + if (ptr) + isl_ast_node_free(ptr); +} + +__isl_give isl_ast_node *ast_node::copy() const & { + return isl_ast_node_copy(ptr); +} + +__isl_keep isl_ast_node *ast_node::get() const { + return ptr; +} + +__isl_give isl_ast_node *ast_node::release() { + isl_ast_node *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_node::is_null() const { + return ptr == nullptr; +} + +template +boolean ast_node::isa_type(T subtype) const +{ + if (is_null()) + return boolean(); + return isl_ast_node_get_type(get()) == subtype; +} +template +boolean ast_node::isa() const +{ + return isa_type(T::type); +} +template +T ast_node::as() const +{ + if (isa().is_false()) + isl_die(ctx().get(), isl_error_invalid, "not an object of the requested subtype", return T()); + return T(copy()); +} + +isl::checked::ctx ast_node::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +std::string ast_node::to_C_str() const +{ + auto res = isl_ast_node_to_C_str(get()); + std::string tmp(res); + free(res); + return tmp; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_block +ast_node_block::ast_node_block() + : ast_node() {} + +ast_node_block::ast_node_block(const ast_node_block &obj) + : ast_node(obj) +{ +} + +ast_node_block::ast_node_block(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_block &ast_node_block::operator=(ast_node_block obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_node_block::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::checked::ast_node_list ast_node_block::children() const +{ + auto res = isl_ast_node_block_get_children(get()); + return manage(res); +} + +isl::checked::ast_node_list ast_node_block::get_children() const +{ + return children(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_block &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_for +ast_node_for::ast_node_for() + : ast_node() {} + +ast_node_for::ast_node_for(const ast_node_for &obj) + : ast_node(obj) +{ +} + +ast_node_for::ast_node_for(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_for &ast_node_for::operator=(ast_node_for obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_node_for::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::checked::ast_node ast_node_for::body() const +{ + auto res = isl_ast_node_for_get_body(get()); + return manage(res); +} + +isl::checked::ast_node ast_node_for::get_body() const +{ + return body(); +} + +isl::checked::ast_expr ast_node_for::cond() const +{ + auto res = isl_ast_node_for_get_cond(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_for::get_cond() const +{ + return cond(); +} + +isl::checked::ast_expr ast_node_for::inc() const +{ + auto res = isl_ast_node_for_get_inc(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_for::get_inc() const +{ + return inc(); +} + +isl::checked::ast_expr ast_node_for::init() const +{ + auto res = isl_ast_node_for_get_init(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_for::get_init() const +{ + return init(); +} + +isl::checked::ast_expr ast_node_for::iterator() const +{ + auto res = isl_ast_node_for_get_iterator(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_for::get_iterator() const +{ + return iterator(); +} + +boolean ast_node_for::is_degenerate() const +{ + auto res = isl_ast_node_for_is_degenerate(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_for &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_if +ast_node_if::ast_node_if() + : ast_node() {} + +ast_node_if::ast_node_if(const ast_node_if &obj) + : ast_node(obj) +{ +} + +ast_node_if::ast_node_if(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_if &ast_node_if::operator=(ast_node_if obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_node_if::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::checked::ast_expr ast_node_if::cond() const +{ + auto res = isl_ast_node_if_get_cond(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_if::get_cond() const +{ + return cond(); +} + +isl::checked::ast_node ast_node_if::else_node() const +{ + auto res = isl_ast_node_if_get_else_node(get()); + return manage(res); +} + +isl::checked::ast_node ast_node_if::get_else_node() const +{ + return else_node(); +} + +isl::checked::ast_node ast_node_if::then_node() const +{ + auto res = isl_ast_node_if_get_then_node(get()); + return manage(res); +} + +isl::checked::ast_node ast_node_if::get_then_node() const +{ + return then_node(); +} + +boolean ast_node_if::has_else_node() const +{ + auto res = isl_ast_node_if_has_else_node(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_if &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_list +ast_node_list manage(__isl_take isl_ast_node_list *ptr) { + return ast_node_list(ptr); +} +ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr) { + ptr = isl_ast_node_list_copy(ptr); + return ast_node_list(ptr); +} + +ast_node_list::ast_node_list() + : ptr(nullptr) {} + +ast_node_list::ast_node_list(const ast_node_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +ast_node_list::ast_node_list(__isl_take isl_ast_node_list *ptr) + : ptr(ptr) {} + +ast_node_list::ast_node_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_ast_node_list_alloc(ctx.release(), n); + ptr = res; +} + +ast_node_list::ast_node_list(isl::checked::ast_node el) +{ + auto res = isl_ast_node_list_from_ast_node(el.release()); + ptr = res; +} + +ast_node_list &ast_node_list::operator=(ast_node_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_node_list::~ast_node_list() { + if (ptr) + isl_ast_node_list_free(ptr); +} + +__isl_give isl_ast_node_list *ast_node_list::copy() const & { + return isl_ast_node_list_copy(ptr); +} + +__isl_keep isl_ast_node_list *ast_node_list::get() const { + return ptr; +} + +__isl_give isl_ast_node_list *ast_node_list::release() { + isl_ast_node_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_node_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx ast_node_list::ctx() const { + return isl::checked::ctx(isl_ast_node_list_get_ctx(ptr)); +} + +isl::checked::ast_node_list ast_node_list::add(isl::checked::ast_node el) const +{ + auto res = isl_ast_node_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::ast_node_list ast_node_list::clear() const +{ + auto res = isl_ast_node_list_clear(copy()); + return manage(res); +} + +isl::checked::ast_node_list ast_node_list::concat(isl::checked::ast_node_list list2) const +{ + auto res = isl_ast_node_list_concat(copy(), list2.release()); + return manage(res); +} + +stat ast_node_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_ast_node *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_ast_node_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::ast_node ast_node_list::at(int index) const +{ + auto res = isl_ast_node_list_get_at(get(), index); + return manage(res); +} + +isl::checked::ast_node ast_node_list::get_at(int index) const +{ + return at(index); +} + +class size ast_node_list::size() const +{ + auto res = isl_ast_node_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_list &obj) +{ + char *str = isl_ast_node_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_mark +ast_node_mark::ast_node_mark() + : ast_node() {} + +ast_node_mark::ast_node_mark(const ast_node_mark &obj) + : ast_node(obj) +{ +} + +ast_node_mark::ast_node_mark(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_mark &ast_node_mark::operator=(ast_node_mark obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_node_mark::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::checked::id ast_node_mark::id() const +{ + auto res = isl_ast_node_mark_get_id(get()); + return manage(res); +} + +isl::checked::id ast_node_mark::get_id() const +{ + return id(); +} + +isl::checked::ast_node ast_node_mark::node() const +{ + auto res = isl_ast_node_mark_get_node(get()); + return manage(res); +} + +isl::checked::ast_node ast_node_mark::get_node() const +{ + return node(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_mark &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_user +ast_node_user::ast_node_user() + : ast_node() {} + +ast_node_user::ast_node_user(const ast_node_user &obj) + : ast_node(obj) +{ +} + +ast_node_user::ast_node_user(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_user &ast_node_user::operator=(ast_node_user obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx ast_node_user::ctx() const { + return isl::checked::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::checked::ast_expr ast_node_user::expr() const +{ + auto res = isl_ast_node_user_get_expr(get()); + return manage(res); +} + +isl::checked::ast_expr ast_node_user::get_expr() const +{ + return expr(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_user &obj) +{ + char *str = isl_ast_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::basic_map +basic_map manage(__isl_take isl_basic_map *ptr) { + return basic_map(ptr); +} +basic_map manage_copy(__isl_keep isl_basic_map *ptr) { + ptr = isl_basic_map_copy(ptr); + return basic_map(ptr); +} + +basic_map::basic_map() + : ptr(nullptr) {} + +basic_map::basic_map(const basic_map &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +basic_map::basic_map(__isl_take isl_basic_map *ptr) + : ptr(ptr) {} + +basic_map::basic_map(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_basic_map_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +basic_map &basic_map::operator=(basic_map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +basic_map::~basic_map() { + if (ptr) + isl_basic_map_free(ptr); +} + +__isl_give isl_basic_map *basic_map::copy() const & { + return isl_basic_map_copy(ptr); +} + +__isl_keep isl_basic_map *basic_map::get() const { + return ptr; +} + +__isl_give isl_basic_map *basic_map::release() { + isl_basic_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool basic_map::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx basic_map::ctx() const { + return isl::checked::ctx(isl_basic_map_get_ctx(ptr)); +} + +isl::checked::basic_map basic_map::affine_hull() const +{ + auto res = isl_basic_map_affine_hull(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::apply_domain(isl::checked::basic_map bmap2) const +{ + auto res = isl_basic_map_apply_domain(copy(), bmap2.release()); + return manage(res); +} + +isl::checked::basic_map basic_map::apply_range(isl::checked::basic_map bmap2) const +{ + auto res = isl_basic_map_apply_range(copy(), bmap2.release()); + return manage(res); +} + +isl::checked::basic_set basic_map::deltas() const +{ + auto res = isl_basic_map_deltas(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::detect_equalities() const +{ + auto res = isl_basic_map_detect_equalities(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::flatten() const +{ + auto res = isl_basic_map_flatten(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::flatten_domain() const +{ + auto res = isl_basic_map_flatten_domain(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::flatten_range() const +{ + auto res = isl_basic_map_flatten_range(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::gist(isl::checked::basic_map context) const +{ + auto res = isl_basic_map_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::basic_map basic_map::intersect(isl::checked::basic_map bmap2) const +{ + auto res = isl_basic_map_intersect(copy(), bmap2.release()); + return manage(res); +} + +isl::checked::basic_map basic_map::intersect_domain(isl::checked::basic_set bset) const +{ + auto res = isl_basic_map_intersect_domain(copy(), bset.release()); + return manage(res); +} + +isl::checked::basic_map basic_map::intersect_range(isl::checked::basic_set bset) const +{ + auto res = isl_basic_map_intersect_range(copy(), bset.release()); + return manage(res); +} + +boolean basic_map::is_empty() const +{ + auto res = isl_basic_map_is_empty(get()); + return manage(res); +} + +boolean basic_map::is_equal(const isl::checked::basic_map &bmap2) const +{ + auto res = isl_basic_map_is_equal(get(), bmap2.get()); + return manage(res); +} + +boolean basic_map::is_subset(const isl::checked::basic_map &bmap2) const +{ + auto res = isl_basic_map_is_subset(get(), bmap2.get()); + return manage(res); +} + +isl::checked::map basic_map::lexmax() const +{ + auto res = isl_basic_map_lexmax(copy()); + return manage(res); +} + +isl::checked::map basic_map::lexmin() const +{ + auto res = isl_basic_map_lexmin(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::reverse() const +{ + auto res = isl_basic_map_reverse(copy()); + return manage(res); +} + +isl::checked::basic_map basic_map::sample() const +{ + auto res = isl_basic_map_sample(copy()); + return manage(res); +} + +isl::checked::map basic_map::unite(isl::checked::basic_map bmap2) const +{ + auto res = isl_basic_map_union(copy(), bmap2.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const basic_map &obj) +{ + char *str = isl_basic_map_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::basic_set +basic_set manage(__isl_take isl_basic_set *ptr) { + return basic_set(ptr); +} +basic_set manage_copy(__isl_keep isl_basic_set *ptr) { + ptr = isl_basic_set_copy(ptr); + return basic_set(ptr); +} + +basic_set::basic_set() + : ptr(nullptr) {} + +basic_set::basic_set(const basic_set &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +basic_set::basic_set(__isl_take isl_basic_set *ptr) + : ptr(ptr) {} + +basic_set::basic_set(isl::checked::point pnt) +{ + auto res = isl_basic_set_from_point(pnt.release()); + ptr = res; +} + +basic_set::basic_set(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_basic_set_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +basic_set &basic_set::operator=(basic_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +basic_set::~basic_set() { + if (ptr) + isl_basic_set_free(ptr); +} + +__isl_give isl_basic_set *basic_set::copy() const & { + return isl_basic_set_copy(ptr); +} + +__isl_keep isl_basic_set *basic_set::get() const { + return ptr; +} + +__isl_give isl_basic_set *basic_set::release() { + isl_basic_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool basic_set::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx basic_set::ctx() const { + return isl::checked::ctx(isl_basic_set_get_ctx(ptr)); +} + +isl::checked::basic_set basic_set::affine_hull() const +{ + auto res = isl_basic_set_affine_hull(copy()); + return manage(res); +} + +isl::checked::basic_set basic_set::apply(isl::checked::basic_map bmap) const +{ + auto res = isl_basic_set_apply(copy(), bmap.release()); + return manage(res); +} + +isl::checked::basic_set basic_set::detect_equalities() const +{ + auto res = isl_basic_set_detect_equalities(copy()); + return manage(res); +} + +isl::checked::val basic_set::dim_max_val(int pos) const +{ + auto res = isl_basic_set_dim_max_val(copy(), pos); + return manage(res); +} + +isl::checked::basic_set basic_set::flatten() const +{ + auto res = isl_basic_set_flatten(copy()); + return manage(res); +} + +isl::checked::basic_set basic_set::gist(isl::checked::basic_set context) const +{ + auto res = isl_basic_set_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::basic_set basic_set::intersect(isl::checked::basic_set bset2) const +{ + auto res = isl_basic_set_intersect(copy(), bset2.release()); + return manage(res); +} + +isl::checked::basic_set basic_set::intersect_params(isl::checked::basic_set bset2) const +{ + auto res = isl_basic_set_intersect_params(copy(), bset2.release()); + return manage(res); +} + +boolean basic_set::is_empty() const +{ + auto res = isl_basic_set_is_empty(get()); + return manage(res); +} + +boolean basic_set::is_equal(const isl::checked::basic_set &bset2) const +{ + auto res = isl_basic_set_is_equal(get(), bset2.get()); + return manage(res); +} + +boolean basic_set::is_subset(const isl::checked::basic_set &bset2) const +{ + auto res = isl_basic_set_is_subset(get(), bset2.get()); + return manage(res); +} + +boolean basic_set::is_wrapping() const +{ + auto res = isl_basic_set_is_wrapping(get()); + return manage(res); +} + +isl::checked::set basic_set::lexmax() const +{ + auto res = isl_basic_set_lexmax(copy()); + return manage(res); +} + +isl::checked::set basic_set::lexmin() const +{ + auto res = isl_basic_set_lexmin(copy()); + return manage(res); +} + +isl::checked::basic_set basic_set::params() const +{ + auto res = isl_basic_set_params(copy()); + return manage(res); +} + +isl::checked::basic_set basic_set::sample() const +{ + auto res = isl_basic_set_sample(copy()); + return manage(res); +} + +isl::checked::point basic_set::sample_point() const +{ + auto res = isl_basic_set_sample_point(copy()); + return manage(res); +} + +isl::checked::set basic_set::unite(isl::checked::basic_set bset2) const +{ + auto res = isl_basic_set_union(copy(), bset2.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const basic_set &obj) +{ + char *str = isl_basic_set_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::fixed_box +fixed_box manage(__isl_take isl_fixed_box *ptr) { + return fixed_box(ptr); +} +fixed_box manage_copy(__isl_keep isl_fixed_box *ptr) { + ptr = isl_fixed_box_copy(ptr); + return fixed_box(ptr); +} + +fixed_box::fixed_box() + : ptr(nullptr) {} + +fixed_box::fixed_box(const fixed_box &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +fixed_box::fixed_box(__isl_take isl_fixed_box *ptr) + : ptr(ptr) {} + +fixed_box &fixed_box::operator=(fixed_box obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +fixed_box::~fixed_box() { + if (ptr) + isl_fixed_box_free(ptr); +} + +__isl_give isl_fixed_box *fixed_box::copy() const & { + return isl_fixed_box_copy(ptr); +} + +__isl_keep isl_fixed_box *fixed_box::get() const { + return ptr; +} + +__isl_give isl_fixed_box *fixed_box::release() { + isl_fixed_box *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool fixed_box::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx fixed_box::ctx() const { + return isl::checked::ctx(isl_fixed_box_get_ctx(ptr)); +} + +isl::checked::multi_aff fixed_box::offset() const +{ + auto res = isl_fixed_box_get_offset(get()); + return manage(res); +} + +isl::checked::multi_aff fixed_box::get_offset() const +{ + return offset(); +} + +isl::checked::multi_val fixed_box::size() const +{ + auto res = isl_fixed_box_get_size(get()); + return manage(res); +} + +isl::checked::multi_val fixed_box::get_size() const +{ + return size(); +} + +isl::checked::space fixed_box::space() const +{ + auto res = isl_fixed_box_get_space(get()); + return manage(res); +} + +isl::checked::space fixed_box::get_space() const +{ + return space(); +} + +boolean fixed_box::is_valid() const +{ + auto res = isl_fixed_box_is_valid(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const fixed_box &obj) +{ + char *str = isl_fixed_box_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::id +id manage(__isl_take isl_id *ptr) { + return id(ptr); +} +id manage_copy(__isl_keep isl_id *ptr) { + ptr = isl_id_copy(ptr); + return id(ptr); +} + +id::id() + : ptr(nullptr) {} + +id::id(const id &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +id::id(__isl_take isl_id *ptr) + : ptr(ptr) {} + +id::id(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_id_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +id &id::operator=(id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +id::~id() { + if (ptr) + isl_id_free(ptr); +} + +__isl_give isl_id *id::copy() const & { + return isl_id_copy(ptr); +} + +__isl_keep isl_id *id::get() const { + return ptr; +} + +__isl_give isl_id *id::release() { + isl_id *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool id::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx id::ctx() const { + return isl::checked::ctx(isl_id_get_ctx(ptr)); +} + +std::string id::name() const +{ + auto res = isl_id_get_name(get()); + std::string tmp(res); + return tmp; +} + +std::string id::get_name() const +{ + return name(); +} + +inline std::ostream &operator<<(std::ostream &os, const id &obj) +{ + char *str = isl_id_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::id_list +id_list manage(__isl_take isl_id_list *ptr) { + return id_list(ptr); +} +id_list manage_copy(__isl_keep isl_id_list *ptr) { + ptr = isl_id_list_copy(ptr); + return id_list(ptr); +} + +id_list::id_list() + : ptr(nullptr) {} + +id_list::id_list(const id_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +id_list::id_list(__isl_take isl_id_list *ptr) + : ptr(ptr) {} + +id_list::id_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_id_list_alloc(ctx.release(), n); + ptr = res; +} + +id_list::id_list(isl::checked::id el) +{ + auto res = isl_id_list_from_id(el.release()); + ptr = res; +} + +id_list &id_list::operator=(id_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +id_list::~id_list() { + if (ptr) + isl_id_list_free(ptr); +} + +__isl_give isl_id_list *id_list::copy() const & { + return isl_id_list_copy(ptr); +} + +__isl_keep isl_id_list *id_list::get() const { + return ptr; +} + +__isl_give isl_id_list *id_list::release() { + isl_id_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool id_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx id_list::ctx() const { + return isl::checked::ctx(isl_id_list_get_ctx(ptr)); +} + +isl::checked::id_list id_list::add(isl::checked::id el) const +{ + auto res = isl_id_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::id_list id_list::add(const std::string &el) const +{ + return this->add(isl::checked::id(ctx(), el)); +} + +isl::checked::id_list id_list::clear() const +{ + auto res = isl_id_list_clear(copy()); + return manage(res); +} + +isl::checked::id_list id_list::concat(isl::checked::id_list list2) const +{ + auto res = isl_id_list_concat(copy(), list2.release()); + return manage(res); +} + +stat id_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_id *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_id_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::id id_list::at(int index) const +{ + auto res = isl_id_list_get_at(get(), index); + return manage(res); +} + +isl::checked::id id_list::get_at(int index) const +{ + return at(index); +} + +class size id_list::size() const +{ + auto res = isl_id_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const id_list &obj) +{ + char *str = isl_id_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::map +map manage(__isl_take isl_map *ptr) { + return map(ptr); +} +map manage_copy(__isl_keep isl_map *ptr) { + ptr = isl_map_copy(ptr); + return map(ptr); +} + +map::map() + : ptr(nullptr) {} + +map::map(const map &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +map::map(__isl_take isl_map *ptr) + : ptr(ptr) {} + +map::map(isl::checked::basic_map bmap) +{ + auto res = isl_map_from_basic_map(bmap.release()); + ptr = res; +} + +map::map(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_map_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +map &map::operator=(map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +map::~map() { + if (ptr) + isl_map_free(ptr); +} + +__isl_give isl_map *map::copy() const & { + return isl_map_copy(ptr); +} + +__isl_keep isl_map *map::get() const { + return ptr; +} + +__isl_give isl_map *map::release() { + isl_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool map::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx map::ctx() const { + return isl::checked::ctx(isl_map_get_ctx(ptr)); +} + +isl::checked::basic_map map::affine_hull() const +{ + auto res = isl_map_affine_hull(copy()); + return manage(res); +} + +isl::checked::map map::apply_domain(isl::checked::map map2) const +{ + auto res = isl_map_apply_domain(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::apply_range(isl::checked::map map2) const +{ + auto res = isl_map_apply_range(copy(), map2.release()); + return manage(res); +} + +isl::checked::set map::bind_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_map_bind_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::set map::bind_range(isl::checked::multi_id tuple) const +{ + auto res = isl_map_bind_range(copy(), tuple.release()); + return manage(res); +} + +isl::checked::map map::coalesce() const +{ + auto res = isl_map_coalesce(copy()); + return manage(res); +} + +isl::checked::map map::complement() const +{ + auto res = isl_map_complement(copy()); + return manage(res); +} + +isl::checked::map map::curry() const +{ + auto res = isl_map_curry(copy()); + return manage(res); +} + +isl::checked::set map::deltas() const +{ + auto res = isl_map_deltas(copy()); + return manage(res); +} + +isl::checked::map map::detect_equalities() const +{ + auto res = isl_map_detect_equalities(copy()); + return manage(res); +} + +isl::checked::set map::domain() const +{ + auto res = isl_map_domain(copy()); + return manage(res); +} + +isl::checked::map map::domain_factor_domain() const +{ + auto res = isl_map_domain_factor_domain(copy()); + return manage(res); +} + +isl::checked::map map::domain_factor_range() const +{ + auto res = isl_map_domain_factor_range(copy()); + return manage(res); +} + +isl::checked::map map::domain_product(isl::checked::map map2) const +{ + auto res = isl_map_domain_product(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::empty(isl::checked::space space) +{ + auto res = isl_map_empty(space.release()); + return manage(res); +} + +isl::checked::map map::factor_domain() const +{ + auto res = isl_map_factor_domain(copy()); + return manage(res); +} + +isl::checked::map map::factor_range() const +{ + auto res = isl_map_factor_range(copy()); + return manage(res); +} + +isl::checked::map map::flatten() const +{ + auto res = isl_map_flatten(copy()); + return manage(res); +} + +isl::checked::map map::flatten_domain() const +{ + auto res = isl_map_flatten_domain(copy()); + return manage(res); +} + +isl::checked::map map::flatten_range() const +{ + auto res = isl_map_flatten_range(copy()); + return manage(res); +} + +stat map::foreach_basic_map(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_basic_map *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_map_foreach_basic_map(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::fixed_box map::range_simple_fixed_box_hull() const +{ + auto res = isl_map_get_range_simple_fixed_box_hull(get()); + return manage(res); +} + +isl::checked::fixed_box map::get_range_simple_fixed_box_hull() const +{ + return range_simple_fixed_box_hull(); +} + +isl::checked::space map::space() const +{ + auto res = isl_map_get_space(get()); + return manage(res); +} + +isl::checked::space map::get_space() const +{ + return space(); +} + +isl::checked::map map::gist(isl::checked::map context) const +{ + auto res = isl_map_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::map map::gist_domain(isl::checked::set context) const +{ + auto res = isl_map_gist_domain(copy(), context.release()); + return manage(res); +} + +isl::checked::map map::intersect(isl::checked::map map2) const +{ + auto res = isl_map_intersect(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::intersect_domain(isl::checked::set set) const +{ + auto res = isl_map_intersect_domain(copy(), set.release()); + return manage(res); +} + +isl::checked::map map::intersect_params(isl::checked::set params) const +{ + auto res = isl_map_intersect_params(copy(), params.release()); + return manage(res); +} + +isl::checked::map map::intersect_range(isl::checked::set set) const +{ + auto res = isl_map_intersect_range(copy(), set.release()); + return manage(res); +} + +boolean map::is_bijective() const +{ + auto res = isl_map_is_bijective(get()); + return manage(res); +} + +boolean map::is_disjoint(const isl::checked::map &map2) const +{ + auto res = isl_map_is_disjoint(get(), map2.get()); + return manage(res); +} + +boolean map::is_empty() const +{ + auto res = isl_map_is_empty(get()); + return manage(res); +} + +boolean map::is_equal(const isl::checked::map &map2) const +{ + auto res = isl_map_is_equal(get(), map2.get()); + return manage(res); +} + +boolean map::is_injective() const +{ + auto res = isl_map_is_injective(get()); + return manage(res); +} + +boolean map::is_single_valued() const +{ + auto res = isl_map_is_single_valued(get()); + return manage(res); +} + +boolean map::is_strict_subset(const isl::checked::map &map2) const +{ + auto res = isl_map_is_strict_subset(get(), map2.get()); + return manage(res); +} + +boolean map::is_subset(const isl::checked::map &map2) const +{ + auto res = isl_map_is_subset(get(), map2.get()); + return manage(res); +} + +isl::checked::map map::lexmax() const +{ + auto res = isl_map_lexmax(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff map::lexmax_pw_multi_aff() const +{ + auto res = isl_map_lexmax_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::map map::lexmin() const +{ + auto res = isl_map_lexmin(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff map::lexmin_pw_multi_aff() const +{ + auto res = isl_map_lexmin_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::basic_map map::polyhedral_hull() const +{ + auto res = isl_map_polyhedral_hull(copy()); + return manage(res); +} + +isl::checked::map map::preimage_domain(isl::checked::multi_aff ma) const +{ + auto res = isl_map_preimage_domain_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::map map::preimage_domain(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_map_preimage_domain_multi_pw_aff(copy(), mpa.release()); + return manage(res); +} + +isl::checked::map map::preimage_domain(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_map_preimage_domain_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::map map::preimage_range(isl::checked::multi_aff ma) const +{ + auto res = isl_map_preimage_range_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::map map::preimage_range(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_map_preimage_range_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::map map::project_out_all_params() const +{ + auto res = isl_map_project_out_all_params(copy()); + return manage(res); +} + +isl::checked::set map::range() const +{ + auto res = isl_map_range(copy()); + return manage(res); +} + +isl::checked::map map::range_factor_domain() const +{ + auto res = isl_map_range_factor_domain(copy()); + return manage(res); +} + +isl::checked::map map::range_factor_range() const +{ + auto res = isl_map_range_factor_range(copy()); + return manage(res); +} + +isl::checked::map map::range_product(isl::checked::map map2) const +{ + auto res = isl_map_range_product(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::reverse() const +{ + auto res = isl_map_reverse(copy()); + return manage(res); +} + +isl::checked::basic_map map::sample() const +{ + auto res = isl_map_sample(copy()); + return manage(res); +} + +isl::checked::map map::subtract(isl::checked::map map2) const +{ + auto res = isl_map_subtract(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::uncurry() const +{ + auto res = isl_map_uncurry(copy()); + return manage(res); +} + +isl::checked::map map::unite(isl::checked::map map2) const +{ + auto res = isl_map_union(copy(), map2.release()); + return manage(res); +} + +isl::checked::map map::universe(isl::checked::space space) +{ + auto res = isl_map_universe(space.release()); + return manage(res); +} + +isl::checked::basic_map map::unshifted_simple_hull() const +{ + auto res = isl_map_unshifted_simple_hull(copy()); + return manage(res); +} + +isl::checked::set map::wrap() const +{ + auto res = isl_map_wrap(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const map &obj) +{ + char *str = isl_map_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::multi_aff +multi_aff manage(__isl_take isl_multi_aff *ptr) { + return multi_aff(ptr); +} +multi_aff manage_copy(__isl_keep isl_multi_aff *ptr) { + ptr = isl_multi_aff_copy(ptr); + return multi_aff(ptr); +} + +multi_aff::multi_aff() + : ptr(nullptr) {} + +multi_aff::multi_aff(const multi_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +multi_aff::multi_aff(__isl_take isl_multi_aff *ptr) + : ptr(ptr) {} + +multi_aff::multi_aff(isl::checked::aff aff) +{ + auto res = isl_multi_aff_from_aff(aff.release()); + ptr = res; +} + +multi_aff::multi_aff(isl::checked::space space, isl::checked::aff_list list) +{ + auto res = isl_multi_aff_from_aff_list(space.release(), list.release()); + ptr = res; +} + +multi_aff::multi_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_multi_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +multi_aff &multi_aff::operator=(multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_aff::~multi_aff() { + if (ptr) + isl_multi_aff_free(ptr); +} + +__isl_give isl_multi_aff *multi_aff::copy() const & { + return isl_multi_aff_copy(ptr); +} + +__isl_keep isl_multi_aff *multi_aff::get() const { + return ptr; +} + +__isl_give isl_multi_aff *multi_aff::release() { + isl_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx multi_aff::ctx() const { + return isl::checked::ctx(isl_multi_aff_get_ctx(ptr)); +} + +isl::checked::multi_aff multi_aff::add(isl::checked::multi_aff multi2) const +{ + auto res = isl_multi_aff_add(copy(), multi2.release()); + return manage(res); +} + +isl::checked::basic_set multi_aff::bind(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_aff_bind(copy(), tuple.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::bind_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_aff_bind_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::bind_domain_wrapped_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::domain_map(isl::checked::space space) +{ + auto res = isl_multi_aff_domain_map(space.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::flat_range_product(isl::checked::multi_aff multi2) const +{ + auto res = isl_multi_aff_flat_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::floor() const +{ + auto res = isl_multi_aff_floor(copy()); + return manage(res); +} + +isl::checked::aff multi_aff::at(int pos) const +{ + auto res = isl_multi_aff_get_at(get(), pos); + return manage(res); +} + +isl::checked::aff multi_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::checked::space multi_aff::space() const +{ + auto res = isl_multi_aff_get_space(get()); + return manage(res); +} + +isl::checked::space multi_aff::get_space() const +{ + return space(); +} + +isl::checked::multi_aff multi_aff::gist(isl::checked::set context) const +{ + auto res = isl_multi_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::identity() const +{ + auto res = isl_multi_aff_identity_multi_aff(copy()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::identity_on_domain(isl::checked::space space) +{ + auto res = isl_multi_aff_identity_on_domain_space(space.release()); + return manage(res); +} + +boolean multi_aff::involves_locals() const +{ + auto res = isl_multi_aff_involves_locals(get()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::neg() const +{ + auto res = isl_multi_aff_neg(copy()); + return manage(res); +} + +boolean multi_aff::plain_is_equal(const isl::checked::multi_aff &multi2) const +{ + auto res = isl_multi_aff_plain_is_equal(get(), multi2.get()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::product(isl::checked::multi_aff multi2) const +{ + auto res = isl_multi_aff_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::pullback(isl::checked::multi_aff ma2) const +{ + auto res = isl_multi_aff_pullback_multi_aff(copy(), ma2.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::range_map(isl::checked::space space) +{ + auto res = isl_multi_aff_range_map(space.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::range_product(isl::checked::multi_aff multi2) const +{ + auto res = isl_multi_aff_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::scale(isl::checked::multi_val mv) const +{ + auto res = isl_multi_aff_scale_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::scale(isl::checked::val v) const +{ + auto res = isl_multi_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_aff multi_aff::scale_down(isl::checked::multi_val mv) const +{ + auto res = isl_multi_aff_scale_down_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::scale_down(isl::checked::val v) const +{ + auto res = isl_multi_aff_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_aff multi_aff::set_at(int pos, isl::checked::aff el) const +{ + auto res = isl_multi_aff_set_at(copy(), pos, el.release()); + return manage(res); +} + +class size multi_aff::size() const +{ + auto res = isl_multi_aff_size(get()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::sub(isl::checked::multi_aff multi2) const +{ + auto res = isl_multi_aff_sub(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_aff multi_aff::zero(isl::checked::space space) +{ + auto res = isl_multi_aff_zero(space.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_aff &obj) +{ + char *str = isl_multi_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::multi_id +multi_id manage(__isl_take isl_multi_id *ptr) { + return multi_id(ptr); +} +multi_id manage_copy(__isl_keep isl_multi_id *ptr) { + ptr = isl_multi_id_copy(ptr); + return multi_id(ptr); +} + +multi_id::multi_id() + : ptr(nullptr) {} + +multi_id::multi_id(const multi_id &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +multi_id::multi_id(__isl_take isl_multi_id *ptr) + : ptr(ptr) {} + +multi_id::multi_id(isl::checked::space space, isl::checked::id_list list) +{ + auto res = isl_multi_id_from_id_list(space.release(), list.release()); + ptr = res; +} + +multi_id::multi_id(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_multi_id_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +multi_id &multi_id::operator=(multi_id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_id::~multi_id() { + if (ptr) + isl_multi_id_free(ptr); +} + +__isl_give isl_multi_id *multi_id::copy() const & { + return isl_multi_id_copy(ptr); +} + +__isl_keep isl_multi_id *multi_id::get() const { + return ptr; +} + +__isl_give isl_multi_id *multi_id::release() { + isl_multi_id *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_id::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx multi_id::ctx() const { + return isl::checked::ctx(isl_multi_id_get_ctx(ptr)); +} + +isl::checked::multi_id multi_id::flat_range_product(isl::checked::multi_id multi2) const +{ + auto res = isl_multi_id_flat_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::id multi_id::at(int pos) const +{ + auto res = isl_multi_id_get_at(get(), pos); + return manage(res); +} + +isl::checked::id multi_id::get_at(int pos) const +{ + return at(pos); +} + +isl::checked::space multi_id::space() const +{ + auto res = isl_multi_id_get_space(get()); + return manage(res); +} + +isl::checked::space multi_id::get_space() const +{ + return space(); +} + +boolean multi_id::plain_is_equal(const isl::checked::multi_id &multi2) const +{ + auto res = isl_multi_id_plain_is_equal(get(), multi2.get()); + return manage(res); +} + +isl::checked::multi_id multi_id::range_product(isl::checked::multi_id multi2) const +{ + auto res = isl_multi_id_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_id multi_id::set_at(int pos, isl::checked::id el) const +{ + auto res = isl_multi_id_set_at(copy(), pos, el.release()); + return manage(res); +} + +isl::checked::multi_id multi_id::set_at(int pos, const std::string &el) const +{ + return this->set_at(pos, isl::checked::id(ctx(), el)); +} + +class size multi_id::size() const +{ + auto res = isl_multi_id_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_id &obj) +{ + char *str = isl_multi_id_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::multi_pw_aff +multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr) { + return multi_pw_aff(ptr); +} +multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr) { + ptr = isl_multi_pw_aff_copy(ptr); + return multi_pw_aff(ptr); +} + +multi_pw_aff::multi_pw_aff() + : ptr(nullptr) {} + +multi_pw_aff::multi_pw_aff(const multi_pw_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +multi_pw_aff::multi_pw_aff(__isl_take isl_multi_pw_aff *ptr) + : ptr(ptr) {} + +multi_pw_aff::multi_pw_aff(isl::checked::multi_aff ma) +{ + auto res = isl_multi_pw_aff_from_multi_aff(ma.release()); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::checked::pw_aff pa) +{ + auto res = isl_multi_pw_aff_from_pw_aff(pa.release()); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::checked::space space, isl::checked::pw_aff_list list) +{ + auto res = isl_multi_pw_aff_from_pw_aff_list(space.release(), list.release()); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::checked::pw_multi_aff pma) +{ + auto res = isl_multi_pw_aff_from_pw_multi_aff(pma.release()); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_multi_pw_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +multi_pw_aff &multi_pw_aff::operator=(multi_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_pw_aff::~multi_pw_aff() { + if (ptr) + isl_multi_pw_aff_free(ptr); +} + +__isl_give isl_multi_pw_aff *multi_pw_aff::copy() const & { + return isl_multi_pw_aff_copy(ptr); +} + +__isl_keep isl_multi_pw_aff *multi_pw_aff::get() const { + return ptr; +} + +__isl_give isl_multi_pw_aff *multi_pw_aff::release() { + isl_multi_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx multi_pw_aff::ctx() const { + return isl::checked::ctx(isl_multi_pw_aff_get_ctx(ptr)); +} + +isl::checked::multi_pw_aff multi_pw_aff::add(isl::checked::multi_pw_aff multi2) const +{ + auto res = isl_multi_pw_aff_add(copy(), multi2.release()); + return manage(res); +} + +isl::checked::set multi_pw_aff::bind(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_pw_aff_bind(copy(), tuple.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::bind_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_pw_aff_bind_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::bind_domain_wrapped_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_pw_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::set multi_pw_aff::domain() const +{ + auto res = isl_multi_pw_aff_domain(copy()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::flat_range_product(isl::checked::multi_pw_aff multi2) const +{ + auto res = isl_multi_pw_aff_flat_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::pw_aff multi_pw_aff::at(int pos) const +{ + auto res = isl_multi_pw_aff_get_at(get(), pos); + return manage(res); +} + +isl::checked::pw_aff multi_pw_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::checked::space multi_pw_aff::space() const +{ + auto res = isl_multi_pw_aff_get_space(get()); + return manage(res); +} + +isl::checked::space multi_pw_aff::get_space() const +{ + return space(); +} + +isl::checked::multi_pw_aff multi_pw_aff::gist(isl::checked::set set) const +{ + auto res = isl_multi_pw_aff_gist(copy(), set.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::identity() const +{ + auto res = isl_multi_pw_aff_identity_multi_pw_aff(copy()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::identity_on_domain(isl::checked::space space) +{ + auto res = isl_multi_pw_aff_identity_on_domain_space(space.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::intersect_domain(isl::checked::set domain) const +{ + auto res = isl_multi_pw_aff_intersect_domain(copy(), domain.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::intersect_params(isl::checked::set set) const +{ + auto res = isl_multi_pw_aff_intersect_params(copy(), set.release()); + return manage(res); +} + +boolean multi_pw_aff::involves_param(const isl::checked::id &id) const +{ + auto res = isl_multi_pw_aff_involves_param_id(get(), id.get()); + return manage(res); +} + +boolean multi_pw_aff::involves_param(const std::string &id) const +{ + return this->involves_param(isl::checked::id(ctx(), id)); +} + +boolean multi_pw_aff::involves_param(const isl::checked::id_list &list) const +{ + auto res = isl_multi_pw_aff_involves_param_id_list(get(), list.get()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::neg() const +{ + auto res = isl_multi_pw_aff_neg(copy()); + return manage(res); +} + +boolean multi_pw_aff::plain_is_equal(const isl::checked::multi_pw_aff &multi2) const +{ + auto res = isl_multi_pw_aff_plain_is_equal(get(), multi2.get()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::product(isl::checked::multi_pw_aff multi2) const +{ + auto res = isl_multi_pw_aff_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::pullback(isl::checked::multi_aff ma) const +{ + auto res = isl_multi_pw_aff_pullback_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::pullback(isl::checked::multi_pw_aff mpa2) const +{ + auto res = isl_multi_pw_aff_pullback_multi_pw_aff(copy(), mpa2.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::pullback(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_multi_pw_aff_pullback_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::range_product(isl::checked::multi_pw_aff multi2) const +{ + auto res = isl_multi_pw_aff_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale(isl::checked::multi_val mv) const +{ + auto res = isl_multi_pw_aff_scale_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale(isl::checked::val v) const +{ + auto res = isl_multi_pw_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale_down(isl::checked::multi_val mv) const +{ + auto res = isl_multi_pw_aff_scale_down_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale_down(isl::checked::val v) const +{ + auto res = isl_multi_pw_aff_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_pw_aff multi_pw_aff::set_at(int pos, isl::checked::pw_aff el) const +{ + auto res = isl_multi_pw_aff_set_at(copy(), pos, el.release()); + return manage(res); +} + +class size multi_pw_aff::size() const +{ + auto res = isl_multi_pw_aff_size(get()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::sub(isl::checked::multi_pw_aff multi2) const +{ + auto res = isl_multi_pw_aff_sub(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_pw_aff multi_pw_aff::zero(isl::checked::space space) +{ + auto res = isl_multi_pw_aff_zero(space.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_pw_aff &obj) +{ + char *str = isl_multi_pw_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::multi_union_pw_aff +multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr) { + return multi_union_pw_aff(ptr); +} +multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr) { + ptr = isl_multi_union_pw_aff_copy(ptr); + return multi_union_pw_aff(ptr); +} + +multi_union_pw_aff::multi_union_pw_aff() + : ptr(nullptr) {} + +multi_union_pw_aff::multi_union_pw_aff(const multi_union_pw_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +multi_union_pw_aff::multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *ptr) + : ptr(ptr) {} + +multi_union_pw_aff::multi_union_pw_aff(isl::checked::multi_pw_aff mpa) +{ + auto res = isl_multi_union_pw_aff_from_multi_pw_aff(mpa.release()); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::checked::union_pw_aff upa) +{ + auto res = isl_multi_union_pw_aff_from_union_pw_aff(upa.release()); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::checked::space space, isl::checked::union_pw_aff_list list) +{ + auto res = isl_multi_union_pw_aff_from_union_pw_aff_list(space.release(), list.release()); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_multi_union_pw_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +multi_union_pw_aff &multi_union_pw_aff::operator=(multi_union_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_union_pw_aff::~multi_union_pw_aff() { + if (ptr) + isl_multi_union_pw_aff_free(ptr); +} + +__isl_give isl_multi_union_pw_aff *multi_union_pw_aff::copy() const & { + return isl_multi_union_pw_aff_copy(ptr); +} + +__isl_keep isl_multi_union_pw_aff *multi_union_pw_aff::get() const { + return ptr; +} + +__isl_give isl_multi_union_pw_aff *multi_union_pw_aff::release() { + isl_multi_union_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_union_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx multi_union_pw_aff::ctx() const { + return isl::checked::ctx(isl_multi_union_pw_aff_get_ctx(ptr)); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::add(isl::checked::multi_union_pw_aff multi2) const +{ + auto res = isl_multi_union_pw_aff_add(copy(), multi2.release()); + return manage(res); +} + +isl::checked::union_set multi_union_pw_aff::bind(isl::checked::multi_id tuple) const +{ + auto res = isl_multi_union_pw_aff_bind(copy(), tuple.release()); + return manage(res); +} + +isl::checked::union_set multi_union_pw_aff::domain() const +{ + auto res = isl_multi_union_pw_aff_domain(copy()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::flat_range_product(isl::checked::multi_union_pw_aff multi2) const +{ + auto res = isl_multi_union_pw_aff_flat_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::union_pw_aff multi_union_pw_aff::at(int pos) const +{ + auto res = isl_multi_union_pw_aff_get_at(get(), pos); + return manage(res); +} + +isl::checked::union_pw_aff multi_union_pw_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::checked::space multi_union_pw_aff::space() const +{ + auto res = isl_multi_union_pw_aff_get_space(get()); + return manage(res); +} + +isl::checked::space multi_union_pw_aff::get_space() const +{ + return space(); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::gist(isl::checked::union_set context) const +{ + auto res = isl_multi_union_pw_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::intersect_domain(isl::checked::union_set uset) const +{ + auto res = isl_multi_union_pw_aff_intersect_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::intersect_params(isl::checked::set params) const +{ + auto res = isl_multi_union_pw_aff_intersect_params(copy(), params.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::neg() const +{ + auto res = isl_multi_union_pw_aff_neg(copy()); + return manage(res); +} + +boolean multi_union_pw_aff::plain_is_equal(const isl::checked::multi_union_pw_aff &multi2) const +{ + auto res = isl_multi_union_pw_aff_plain_is_equal(get(), multi2.get()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::pullback(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_multi_union_pw_aff_pullback_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::range_product(isl::checked::multi_union_pw_aff multi2) const +{ + auto res = isl_multi_union_pw_aff_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale(isl::checked::multi_val mv) const +{ + auto res = isl_multi_union_pw_aff_scale_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale(isl::checked::val v) const +{ + auto res = isl_multi_union_pw_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale_down(isl::checked::multi_val mv) const +{ + auto res = isl_multi_union_pw_aff_scale_down_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale_down(isl::checked::val v) const +{ + auto res = isl_multi_union_pw_aff_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::set_at(int pos, isl::checked::union_pw_aff el) const +{ + auto res = isl_multi_union_pw_aff_set_at(copy(), pos, el.release()); + return manage(res); +} + +class size multi_union_pw_aff::size() const +{ + auto res = isl_multi_union_pw_aff_size(get()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::sub(isl::checked::multi_union_pw_aff multi2) const +{ + auto res = isl_multi_union_pw_aff_sub(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::union_add(isl::checked::multi_union_pw_aff mupa2) const +{ + auto res = isl_multi_union_pw_aff_union_add(copy(), mupa2.release()); + return manage(res); +} + +isl::checked::multi_union_pw_aff multi_union_pw_aff::zero(isl::checked::space space) +{ + auto res = isl_multi_union_pw_aff_zero(space.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_union_pw_aff &obj) +{ + char *str = isl_multi_union_pw_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::multi_val +multi_val manage(__isl_take isl_multi_val *ptr) { + return multi_val(ptr); +} +multi_val manage_copy(__isl_keep isl_multi_val *ptr) { + ptr = isl_multi_val_copy(ptr); + return multi_val(ptr); +} + +multi_val::multi_val() + : ptr(nullptr) {} + +multi_val::multi_val(const multi_val &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +multi_val::multi_val(__isl_take isl_multi_val *ptr) + : ptr(ptr) {} + +multi_val::multi_val(isl::checked::space space, isl::checked::val_list list) +{ + auto res = isl_multi_val_from_val_list(space.release(), list.release()); + ptr = res; +} + +multi_val::multi_val(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_multi_val_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +multi_val &multi_val::operator=(multi_val obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_val::~multi_val() { + if (ptr) + isl_multi_val_free(ptr); +} + +__isl_give isl_multi_val *multi_val::copy() const & { + return isl_multi_val_copy(ptr); +} + +__isl_keep isl_multi_val *multi_val::get() const { + return ptr; +} + +__isl_give isl_multi_val *multi_val::release() { + isl_multi_val *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_val::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx multi_val::ctx() const { + return isl::checked::ctx(isl_multi_val_get_ctx(ptr)); +} + +isl::checked::multi_val multi_val::add(isl::checked::multi_val multi2) const +{ + auto res = isl_multi_val_add(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::add(isl::checked::val v) const +{ + auto res = isl_multi_val_add_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::add(long v) const +{ + return this->add(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_val multi_val::flat_range_product(isl::checked::multi_val multi2) const +{ + auto res = isl_multi_val_flat_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::val multi_val::at(int pos) const +{ + auto res = isl_multi_val_get_at(get(), pos); + return manage(res); +} + +isl::checked::val multi_val::get_at(int pos) const +{ + return at(pos); +} + +isl::checked::space multi_val::space() const +{ + auto res = isl_multi_val_get_space(get()); + return manage(res); +} + +isl::checked::space multi_val::get_space() const +{ + return space(); +} + +isl::checked::multi_val multi_val::neg() const +{ + auto res = isl_multi_val_neg(copy()); + return manage(res); +} + +boolean multi_val::plain_is_equal(const isl::checked::multi_val &multi2) const +{ + auto res = isl_multi_val_plain_is_equal(get(), multi2.get()); + return manage(res); +} + +isl::checked::multi_val multi_val::product(isl::checked::multi_val multi2) const +{ + auto res = isl_multi_val_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::range_product(isl::checked::multi_val multi2) const +{ + auto res = isl_multi_val_range_product(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::scale(isl::checked::multi_val mv) const +{ + auto res = isl_multi_val_scale_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::scale(isl::checked::val v) const +{ + auto res = isl_multi_val_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_val multi_val::scale_down(isl::checked::multi_val mv) const +{ + auto res = isl_multi_val_scale_down_multi_val(copy(), mv.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::scale_down(isl::checked::val v) const +{ + auto res = isl_multi_val_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::multi_val multi_val::set_at(int pos, isl::checked::val el) const +{ + auto res = isl_multi_val_set_at(copy(), pos, el.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::set_at(int pos, long el) const +{ + return this->set_at(pos, isl::checked::val(ctx(), el)); +} + +class size multi_val::size() const +{ + auto res = isl_multi_val_size(get()); + return manage(res); +} + +isl::checked::multi_val multi_val::sub(isl::checked::multi_val multi2) const +{ + auto res = isl_multi_val_sub(copy(), multi2.release()); + return manage(res); +} + +isl::checked::multi_val multi_val::zero(isl::checked::space space) +{ + auto res = isl_multi_val_zero(space.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_val &obj) +{ + char *str = isl_multi_val_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::point +point manage(__isl_take isl_point *ptr) { + return point(ptr); +} +point manage_copy(__isl_keep isl_point *ptr) { + ptr = isl_point_copy(ptr); + return point(ptr); +} + +point::point() + : ptr(nullptr) {} + +point::point(const point &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +point::point(__isl_take isl_point *ptr) + : ptr(ptr) {} + +point &point::operator=(point obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +point::~point() { + if (ptr) + isl_point_free(ptr); +} + +__isl_give isl_point *point::copy() const & { + return isl_point_copy(ptr); +} + +__isl_keep isl_point *point::get() const { + return ptr; +} + +__isl_give isl_point *point::release() { + isl_point *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool point::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx point::ctx() const { + return isl::checked::ctx(isl_point_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const point &obj) +{ + char *str = isl_point_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::pw_aff +pw_aff manage(__isl_take isl_pw_aff *ptr) { + return pw_aff(ptr); +} +pw_aff manage_copy(__isl_keep isl_pw_aff *ptr) { + ptr = isl_pw_aff_copy(ptr); + return pw_aff(ptr); +} + +pw_aff::pw_aff() + : ptr(nullptr) {} + +pw_aff::pw_aff(const pw_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +pw_aff::pw_aff(__isl_take isl_pw_aff *ptr) + : ptr(ptr) {} + +pw_aff::pw_aff(isl::checked::aff aff) +{ + auto res = isl_pw_aff_from_aff(aff.release()); + ptr = res; +} + +pw_aff::pw_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_pw_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +pw_aff &pw_aff::operator=(pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_aff::~pw_aff() { + if (ptr) + isl_pw_aff_free(ptr); +} + +__isl_give isl_pw_aff *pw_aff::copy() const & { + return isl_pw_aff_copy(ptr); +} + +__isl_keep isl_pw_aff *pw_aff::get() const { + return ptr; +} + +__isl_give isl_pw_aff *pw_aff::release() { + isl_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx pw_aff::ctx() const { + return isl::checked::ctx(isl_pw_aff_get_ctx(ptr)); +} + +isl::checked::pw_aff pw_aff::add(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_add(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::aff pw_aff::as_aff() const +{ + auto res = isl_pw_aff_as_aff(copy()); + return manage(res); +} + +isl::checked::set pw_aff::bind(isl::checked::id id) const +{ + auto res = isl_pw_aff_bind_id(copy(), id.release()); + return manage(res); +} + +isl::checked::set pw_aff::bind(const std::string &id) const +{ + return this->bind(isl::checked::id(ctx(), id)); +} + +isl::checked::pw_aff pw_aff::bind_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_pw_aff_bind_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::bind_domain_wrapped_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_pw_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::ceil() const +{ + auto res = isl_pw_aff_ceil(copy()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::cond(isl::checked::pw_aff pwaff_true, isl::checked::pw_aff pwaff_false) const +{ + auto res = isl_pw_aff_cond(copy(), pwaff_true.release(), pwaff_false.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::div(isl::checked::pw_aff pa2) const +{ + auto res = isl_pw_aff_div(copy(), pa2.release()); + return manage(res); +} + +isl::checked::set pw_aff::domain() const +{ + auto res = isl_pw_aff_domain(copy()); + return manage(res); +} + +isl::checked::set pw_aff::eq_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_eq_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::val pw_aff::eval(isl::checked::point pnt) const +{ + auto res = isl_pw_aff_eval(copy(), pnt.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::floor() const +{ + auto res = isl_pw_aff_floor(copy()); + return manage(res); +} + +isl::checked::set pw_aff::ge_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_ge_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::gist(isl::checked::set context) const +{ + auto res = isl_pw_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::set pw_aff::gt_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_gt_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::intersect_domain(isl::checked::set set) const +{ + auto res = isl_pw_aff_intersect_domain(copy(), set.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::intersect_params(isl::checked::set set) const +{ + auto res = isl_pw_aff_intersect_params(copy(), set.release()); + return manage(res); +} + +boolean pw_aff::isa_aff() const +{ + auto res = isl_pw_aff_isa_aff(get()); + return manage(res); +} + +isl::checked::set pw_aff::le_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_le_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::set pw_aff::lt_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_lt_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::max(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_max(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::min(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_min(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::mod(isl::checked::val mod) const +{ + auto res = isl_pw_aff_mod_val(copy(), mod.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::mod(long mod) const +{ + return this->mod(isl::checked::val(ctx(), mod)); +} + +isl::checked::pw_aff pw_aff::mul(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_mul(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::set pw_aff::ne_set(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_ne_set(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::neg() const +{ + auto res = isl_pw_aff_neg(copy()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::param_on_domain(isl::checked::set domain, isl::checked::id id) +{ + auto res = isl_pw_aff_param_on_domain_id(domain.release(), id.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::pullback(isl::checked::multi_aff ma) const +{ + auto res = isl_pw_aff_pullback_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::pullback(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_pw_aff_pullback_multi_pw_aff(copy(), mpa.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::pullback(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_pw_aff_pullback_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::scale(isl::checked::val v) const +{ + auto res = isl_pw_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::pw_aff pw_aff::scale_down(isl::checked::val f) const +{ + auto res = isl_pw_aff_scale_down_val(copy(), f.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::scale_down(long f) const +{ + return this->scale_down(isl::checked::val(ctx(), f)); +} + +isl::checked::pw_aff pw_aff::sub(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_sub(copy(), pwaff2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::subtract_domain(isl::checked::set set) const +{ + auto res = isl_pw_aff_subtract_domain(copy(), set.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::tdiv_q(isl::checked::pw_aff pa2) const +{ + auto res = isl_pw_aff_tdiv_q(copy(), pa2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::tdiv_r(isl::checked::pw_aff pa2) const +{ + auto res = isl_pw_aff_tdiv_r(copy(), pa2.release()); + return manage(res); +} + +isl::checked::pw_aff pw_aff::union_add(isl::checked::pw_aff pwaff2) const +{ + auto res = isl_pw_aff_union_add(copy(), pwaff2.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_aff &obj) +{ + char *str = isl_pw_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::pw_aff_list +pw_aff_list manage(__isl_take isl_pw_aff_list *ptr) { + return pw_aff_list(ptr); +} +pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr) { + ptr = isl_pw_aff_list_copy(ptr); + return pw_aff_list(ptr); +} + +pw_aff_list::pw_aff_list() + : ptr(nullptr) {} + +pw_aff_list::pw_aff_list(const pw_aff_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +pw_aff_list::pw_aff_list(__isl_take isl_pw_aff_list *ptr) + : ptr(ptr) {} + +pw_aff_list::pw_aff_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_pw_aff_list_alloc(ctx.release(), n); + ptr = res; +} + +pw_aff_list::pw_aff_list(isl::checked::pw_aff el) +{ + auto res = isl_pw_aff_list_from_pw_aff(el.release()); + ptr = res; +} + +pw_aff_list &pw_aff_list::operator=(pw_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_aff_list::~pw_aff_list() { + if (ptr) + isl_pw_aff_list_free(ptr); +} + +__isl_give isl_pw_aff_list *pw_aff_list::copy() const & { + return isl_pw_aff_list_copy(ptr); +} + +__isl_keep isl_pw_aff_list *pw_aff_list::get() const { + return ptr; +} + +__isl_give isl_pw_aff_list *pw_aff_list::release() { + isl_pw_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx pw_aff_list::ctx() const { + return isl::checked::ctx(isl_pw_aff_list_get_ctx(ptr)); +} + +isl::checked::pw_aff_list pw_aff_list::add(isl::checked::pw_aff el) const +{ + auto res = isl_pw_aff_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::pw_aff_list pw_aff_list::clear() const +{ + auto res = isl_pw_aff_list_clear(copy()); + return manage(res); +} + +isl::checked::pw_aff_list pw_aff_list::concat(isl::checked::pw_aff_list list2) const +{ + auto res = isl_pw_aff_list_concat(copy(), list2.release()); + return manage(res); +} + +stat pw_aff_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_pw_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_pw_aff_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::pw_aff pw_aff_list::at(int index) const +{ + auto res = isl_pw_aff_list_get_at(get(), index); + return manage(res); +} + +isl::checked::pw_aff pw_aff_list::get_at(int index) const +{ + return at(index); +} + +class size pw_aff_list::size() const +{ + auto res = isl_pw_aff_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_aff_list &obj) +{ + char *str = isl_pw_aff_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::pw_multi_aff +pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr) { + return pw_multi_aff(ptr); +} +pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr) { + ptr = isl_pw_multi_aff_copy(ptr); + return pw_multi_aff(ptr); +} + +pw_multi_aff::pw_multi_aff() + : ptr(nullptr) {} + +pw_multi_aff::pw_multi_aff(const pw_multi_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +pw_multi_aff::pw_multi_aff(__isl_take isl_pw_multi_aff *ptr) + : ptr(ptr) {} + +pw_multi_aff::pw_multi_aff(isl::checked::multi_aff ma) +{ + auto res = isl_pw_multi_aff_from_multi_aff(ma.release()); + ptr = res; +} + +pw_multi_aff::pw_multi_aff(isl::checked::pw_aff pa) +{ + auto res = isl_pw_multi_aff_from_pw_aff(pa.release()); + ptr = res; +} + +pw_multi_aff::pw_multi_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_pw_multi_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +pw_multi_aff &pw_multi_aff::operator=(pw_multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_multi_aff::~pw_multi_aff() { + if (ptr) + isl_pw_multi_aff_free(ptr); +} + +__isl_give isl_pw_multi_aff *pw_multi_aff::copy() const & { + return isl_pw_multi_aff_copy(ptr); +} + +__isl_keep isl_pw_multi_aff *pw_multi_aff::get() const { + return ptr; +} + +__isl_give isl_pw_multi_aff *pw_multi_aff::release() { + isl_pw_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx pw_multi_aff::ctx() const { + return isl::checked::ctx(isl_pw_multi_aff_get_ctx(ptr)); +} + +isl::checked::pw_multi_aff pw_multi_aff::add(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_add(copy(), pma2.release()); + return manage(res); +} + +isl::checked::multi_aff pw_multi_aff::as_multi_aff() const +{ + auto res = isl_pw_multi_aff_as_multi_aff(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::bind_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_pw_multi_aff_bind_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::bind_domain_wrapped_domain(isl::checked::multi_id tuple) const +{ + auto res = isl_pw_multi_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + return manage(res); +} + +isl::checked::set pw_multi_aff::domain() const +{ + auto res = isl_pw_multi_aff_domain(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::flat_range_product(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_flat_range_product(copy(), pma2.release()); + return manage(res); +} + +stat pw_multi_aff::foreach_piece(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_set *arg_0, isl_multi_aff *arg_1, void *arg_2) -> isl_stat { + auto *data = static_cast(arg_2); + auto ret = (data->func)(manage(arg_0), manage(arg_1)); + return ret.release(); + }; + auto res = isl_pw_multi_aff_foreach_piece(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::space pw_multi_aff::space() const +{ + auto res = isl_pw_multi_aff_get_space(get()); + return manage(res); +} + +isl::checked::space pw_multi_aff::get_space() const +{ + return space(); +} + +isl::checked::pw_multi_aff pw_multi_aff::gist(isl::checked::set set) const +{ + auto res = isl_pw_multi_aff_gist(copy(), set.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::intersect_domain(isl::checked::set set) const +{ + auto res = isl_pw_multi_aff_intersect_domain(copy(), set.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::intersect_params(isl::checked::set set) const +{ + auto res = isl_pw_multi_aff_intersect_params(copy(), set.release()); + return manage(res); +} + +boolean pw_multi_aff::isa_multi_aff() const +{ + auto res = isl_pw_multi_aff_isa_multi_aff(get()); + return manage(res); +} + +class size pw_multi_aff::n_piece() const +{ + auto res = isl_pw_multi_aff_n_piece(get()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::product(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_product(copy(), pma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::pullback(isl::checked::multi_aff ma) const +{ + auto res = isl_pw_multi_aff_pullback_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::pullback(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_pullback_pw_multi_aff(copy(), pma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::range_factor_domain() const +{ + auto res = isl_pw_multi_aff_range_factor_domain(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::range_factor_range() const +{ + auto res = isl_pw_multi_aff_range_factor_range(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::range_product(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_range_product(copy(), pma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::scale(isl::checked::val v) const +{ + auto res = isl_pw_multi_aff_scale_val(copy(), v.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::scale(long v) const +{ + return this->scale(isl::checked::val(ctx(), v)); +} + +isl::checked::pw_multi_aff pw_multi_aff::scale_down(isl::checked::val v) const +{ + auto res = isl_pw_multi_aff_scale_down_val(copy(), v.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::scale_down(long v) const +{ + return this->scale_down(isl::checked::val(ctx(), v)); +} + +isl::checked::pw_multi_aff pw_multi_aff::sub(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_sub(copy(), pma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::subtract_domain(isl::checked::set set) const +{ + auto res = isl_pw_multi_aff_subtract_domain(copy(), set.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::union_add(isl::checked::pw_multi_aff pma2) const +{ + auto res = isl_pw_multi_aff_union_add(copy(), pma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff::zero(isl::checked::space space) +{ + auto res = isl_pw_multi_aff_zero(space.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_multi_aff &obj) +{ + char *str = isl_pw_multi_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::pw_multi_aff_list +pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr) { + return pw_multi_aff_list(ptr); +} +pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr) { + ptr = isl_pw_multi_aff_list_copy(ptr); + return pw_multi_aff_list(ptr); +} + +pw_multi_aff_list::pw_multi_aff_list() + : ptr(nullptr) {} + +pw_multi_aff_list::pw_multi_aff_list(const pw_multi_aff_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +pw_multi_aff_list::pw_multi_aff_list(__isl_take isl_pw_multi_aff_list *ptr) + : ptr(ptr) {} + +pw_multi_aff_list::pw_multi_aff_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_pw_multi_aff_list_alloc(ctx.release(), n); + ptr = res; +} + +pw_multi_aff_list::pw_multi_aff_list(isl::checked::pw_multi_aff el) +{ + auto res = isl_pw_multi_aff_list_from_pw_multi_aff(el.release()); + ptr = res; +} + +pw_multi_aff_list &pw_multi_aff_list::operator=(pw_multi_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_multi_aff_list::~pw_multi_aff_list() { + if (ptr) + isl_pw_multi_aff_list_free(ptr); +} + +__isl_give isl_pw_multi_aff_list *pw_multi_aff_list::copy() const & { + return isl_pw_multi_aff_list_copy(ptr); +} + +__isl_keep isl_pw_multi_aff_list *pw_multi_aff_list::get() const { + return ptr; +} + +__isl_give isl_pw_multi_aff_list *pw_multi_aff_list::release() { + isl_pw_multi_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_multi_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx pw_multi_aff_list::ctx() const { + return isl::checked::ctx(isl_pw_multi_aff_list_get_ctx(ptr)); +} + +isl::checked::pw_multi_aff_list pw_multi_aff_list::add(isl::checked::pw_multi_aff el) const +{ + auto res = isl_pw_multi_aff_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::pw_multi_aff_list pw_multi_aff_list::clear() const +{ + auto res = isl_pw_multi_aff_list_clear(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff_list pw_multi_aff_list::concat(isl::checked::pw_multi_aff_list list2) const +{ + auto res = isl_pw_multi_aff_list_concat(copy(), list2.release()); + return manage(res); +} + +stat pw_multi_aff_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_pw_multi_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_pw_multi_aff_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff_list::at(int index) const +{ + auto res = isl_pw_multi_aff_list_get_at(get(), index); + return manage(res); +} + +isl::checked::pw_multi_aff pw_multi_aff_list::get_at(int index) const +{ + return at(index); +} + +class size pw_multi_aff_list::size() const +{ + auto res = isl_pw_multi_aff_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_multi_aff_list &obj) +{ + char *str = isl_pw_multi_aff_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule +schedule manage(__isl_take isl_schedule *ptr) { + return schedule(ptr); +} +schedule manage_copy(__isl_keep isl_schedule *ptr) { + ptr = isl_schedule_copy(ptr); + return schedule(ptr); +} + +schedule::schedule() + : ptr(nullptr) {} + +schedule::schedule(const schedule &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +schedule::schedule(__isl_take isl_schedule *ptr) + : ptr(ptr) {} + +schedule::schedule(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_schedule_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +schedule &schedule::operator=(schedule obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule::~schedule() { + if (ptr) + isl_schedule_free(ptr); +} + +__isl_give isl_schedule *schedule::copy() const & { + return isl_schedule_copy(ptr); +} + +__isl_keep isl_schedule *schedule::get() const { + return ptr; +} + +__isl_give isl_schedule *schedule::release() { + isl_schedule *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx schedule::ctx() const { + return isl::checked::ctx(isl_schedule_get_ctx(ptr)); +} + +isl::checked::schedule schedule::from_domain(isl::checked::union_set domain) +{ + auto res = isl_schedule_from_domain(domain.release()); + return manage(res); +} + +isl::checked::union_map schedule::map() const +{ + auto res = isl_schedule_get_map(get()); + return manage(res); +} + +isl::checked::union_map schedule::get_map() const +{ + return map(); +} + +isl::checked::schedule_node schedule::root() const +{ + auto res = isl_schedule_get_root(get()); + return manage(res); +} + +isl::checked::schedule_node schedule::get_root() const +{ + return root(); +} + +isl::checked::schedule schedule::pullback(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_schedule_pullback_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule &obj) +{ + char *str = isl_schedule_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_constraints +schedule_constraints manage(__isl_take isl_schedule_constraints *ptr) { + return schedule_constraints(ptr); +} +schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr) { + ptr = isl_schedule_constraints_copy(ptr); + return schedule_constraints(ptr); +} + +schedule_constraints::schedule_constraints() + : ptr(nullptr) {} + +schedule_constraints::schedule_constraints(const schedule_constraints &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +schedule_constraints::schedule_constraints(__isl_take isl_schedule_constraints *ptr) + : ptr(ptr) {} + +schedule_constraints::schedule_constraints(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_schedule_constraints_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +schedule_constraints &schedule_constraints::operator=(schedule_constraints obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule_constraints::~schedule_constraints() { + if (ptr) + isl_schedule_constraints_free(ptr); +} + +__isl_give isl_schedule_constraints *schedule_constraints::copy() const & { + return isl_schedule_constraints_copy(ptr); +} + +__isl_keep isl_schedule_constraints *schedule_constraints::get() const { + return ptr; +} + +__isl_give isl_schedule_constraints *schedule_constraints::release() { + isl_schedule_constraints *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule_constraints::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx schedule_constraints::ctx() const { + return isl::checked::ctx(isl_schedule_constraints_get_ctx(ptr)); +} + +isl::checked::schedule schedule_constraints::compute_schedule() const +{ + auto res = isl_schedule_constraints_compute_schedule(copy()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::coincidence() const +{ + auto res = isl_schedule_constraints_get_coincidence(get()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::get_coincidence() const +{ + return coincidence(); +} + +isl::checked::union_map schedule_constraints::conditional_validity() const +{ + auto res = isl_schedule_constraints_get_conditional_validity(get()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::get_conditional_validity() const +{ + return conditional_validity(); +} + +isl::checked::union_map schedule_constraints::conditional_validity_condition() const +{ + auto res = isl_schedule_constraints_get_conditional_validity_condition(get()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::get_conditional_validity_condition() const +{ + return conditional_validity_condition(); +} + +isl::checked::set schedule_constraints::context() const +{ + auto res = isl_schedule_constraints_get_context(get()); + return manage(res); +} + +isl::checked::set schedule_constraints::get_context() const +{ + return context(); +} + +isl::checked::union_set schedule_constraints::domain() const +{ + auto res = isl_schedule_constraints_get_domain(get()); + return manage(res); +} + +isl::checked::union_set schedule_constraints::get_domain() const +{ + return domain(); +} + +isl::checked::union_map schedule_constraints::proximity() const +{ + auto res = isl_schedule_constraints_get_proximity(get()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::get_proximity() const +{ + return proximity(); +} + +isl::checked::union_map schedule_constraints::validity() const +{ + auto res = isl_schedule_constraints_get_validity(get()); + return manage(res); +} + +isl::checked::union_map schedule_constraints::get_validity() const +{ + return validity(); +} + +isl::checked::schedule_constraints schedule_constraints::on_domain(isl::checked::union_set domain) +{ + auto res = isl_schedule_constraints_on_domain(domain.release()); + return manage(res); +} + +isl::checked::schedule_constraints schedule_constraints::set_coincidence(isl::checked::union_map coincidence) const +{ + auto res = isl_schedule_constraints_set_coincidence(copy(), coincidence.release()); + return manage(res); +} + +isl::checked::schedule_constraints schedule_constraints::set_conditional_validity(isl::checked::union_map condition, isl::checked::union_map validity) const +{ + auto res = isl_schedule_constraints_set_conditional_validity(copy(), condition.release(), validity.release()); + return manage(res); +} + +isl::checked::schedule_constraints schedule_constraints::set_context(isl::checked::set context) const +{ + auto res = isl_schedule_constraints_set_context(copy(), context.release()); + return manage(res); +} + +isl::checked::schedule_constraints schedule_constraints::set_proximity(isl::checked::union_map proximity) const +{ + auto res = isl_schedule_constraints_set_proximity(copy(), proximity.release()); + return manage(res); +} + +isl::checked::schedule_constraints schedule_constraints::set_validity(isl::checked::union_map validity) const +{ + auto res = isl_schedule_constraints_set_validity(copy(), validity.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_constraints &obj) +{ + char *str = isl_schedule_constraints_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node +schedule_node manage(__isl_take isl_schedule_node *ptr) { + return schedule_node(ptr); +} +schedule_node manage_copy(__isl_keep isl_schedule_node *ptr) { + ptr = isl_schedule_node_copy(ptr); + return schedule_node(ptr); +} + +schedule_node::schedule_node() + : ptr(nullptr) {} + +schedule_node::schedule_node(const schedule_node &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +schedule_node::schedule_node(__isl_take isl_schedule_node *ptr) + : ptr(ptr) {} + +schedule_node &schedule_node::operator=(schedule_node obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule_node::~schedule_node() { + if (ptr) + isl_schedule_node_free(ptr); +} + +__isl_give isl_schedule_node *schedule_node::copy() const & { + return isl_schedule_node_copy(ptr); +} + +__isl_keep isl_schedule_node *schedule_node::get() const { + return ptr; +} + +__isl_give isl_schedule_node *schedule_node::release() { + isl_schedule_node *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule_node::is_null() const { + return ptr == nullptr; +} + +template +boolean schedule_node::isa_type(T subtype) const +{ + if (is_null()) + return boolean(); + return isl_schedule_node_get_type(get()) == subtype; +} +template +boolean schedule_node::isa() const +{ + return isa_type(T::type); +} +template +T schedule_node::as() const +{ + if (isa().is_false()) + isl_die(ctx().get(), isl_error_invalid, "not an object of the requested subtype", return T()); + return T(copy()); +} + +isl::checked::ctx schedule_node::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::schedule_node schedule_node::ancestor(int generation) const +{ + auto res = isl_schedule_node_ancestor(copy(), generation); + return manage(res); +} + +isl::checked::schedule_node schedule_node::child(int pos) const +{ + auto res = isl_schedule_node_child(copy(), pos); + return manage(res); +} + +boolean schedule_node::every_descendant(const std::function &test) const +{ + struct test_data { + std::function func; + } test_data = { test }; + auto test_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage_copy(arg_0)); + return ret.release(); + }; + auto res = isl_schedule_node_every_descendant(get(), test_lambda, &test_data); + return manage(res); +} + +isl::checked::schedule_node schedule_node::first_child() const +{ + auto res = isl_schedule_node_first_child(copy()); + return manage(res); +} + +stat schedule_node::foreach_ancestor_top_down(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage_copy(arg_0)); + return ret.release(); + }; + auto res = isl_schedule_node_foreach_ancestor_top_down(get(), fn_lambda, &fn_data); + return manage(res); +} + +stat schedule_node::foreach_descendant_top_down(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage_copy(arg_0)); + return ret.release(); + }; + auto res = isl_schedule_node_foreach_descendant_top_down(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::schedule_node schedule_node::from_domain(isl::checked::union_set domain) +{ + auto res = isl_schedule_node_from_domain(domain.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::from_extension(isl::checked::union_map extension) +{ + auto res = isl_schedule_node_from_extension(extension.release()); + return manage(res); +} + +class size schedule_node::ancestor_child_position(const isl::checked::schedule_node &ancestor) const +{ + auto res = isl_schedule_node_get_ancestor_child_position(get(), ancestor.get()); + return manage(res); +} + +class size schedule_node::get_ancestor_child_position(const isl::checked::schedule_node &ancestor) const +{ + return ancestor_child_position(ancestor); +} + +class size schedule_node::child_position() const +{ + auto res = isl_schedule_node_get_child_position(get()); + return manage(res); +} + +class size schedule_node::get_child_position() const +{ + return child_position(); +} + +isl::checked::multi_union_pw_aff schedule_node::prefix_schedule_multi_union_pw_aff() const +{ + auto res = isl_schedule_node_get_prefix_schedule_multi_union_pw_aff(get()); + return manage(res); +} + +isl::checked::multi_union_pw_aff schedule_node::get_prefix_schedule_multi_union_pw_aff() const +{ + return prefix_schedule_multi_union_pw_aff(); +} + +isl::checked::union_map schedule_node::prefix_schedule_union_map() const +{ + auto res = isl_schedule_node_get_prefix_schedule_union_map(get()); + return manage(res); +} + +isl::checked::union_map schedule_node::get_prefix_schedule_union_map() const +{ + return prefix_schedule_union_map(); +} + +isl::checked::union_pw_multi_aff schedule_node::prefix_schedule_union_pw_multi_aff() const +{ + auto res = isl_schedule_node_get_prefix_schedule_union_pw_multi_aff(get()); + return manage(res); +} + +isl::checked::union_pw_multi_aff schedule_node::get_prefix_schedule_union_pw_multi_aff() const +{ + return prefix_schedule_union_pw_multi_aff(); +} + +isl::checked::schedule schedule_node::schedule() const +{ + auto res = isl_schedule_node_get_schedule(get()); + return manage(res); +} + +isl::checked::schedule schedule_node::get_schedule() const +{ + return schedule(); +} + +isl::checked::schedule_node schedule_node::shared_ancestor(const isl::checked::schedule_node &node2) const +{ + auto res = isl_schedule_node_get_shared_ancestor(get(), node2.get()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::get_shared_ancestor(const isl::checked::schedule_node &node2) const +{ + return shared_ancestor(node2); +} + +class size schedule_node::tree_depth() const +{ + auto res = isl_schedule_node_get_tree_depth(get()); + return manage(res); +} + +class size schedule_node::get_tree_depth() const +{ + return tree_depth(); +} + +isl::checked::schedule_node schedule_node::graft_after(isl::checked::schedule_node graft) const +{ + auto res = isl_schedule_node_graft_after(copy(), graft.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::graft_before(isl::checked::schedule_node graft) const +{ + auto res = isl_schedule_node_graft_before(copy(), graft.release()); + return manage(res); +} + +boolean schedule_node::has_children() const +{ + auto res = isl_schedule_node_has_children(get()); + return manage(res); +} + +boolean schedule_node::has_next_sibling() const +{ + auto res = isl_schedule_node_has_next_sibling(get()); + return manage(res); +} + +boolean schedule_node::has_parent() const +{ + auto res = isl_schedule_node_has_parent(get()); + return manage(res); +} + +boolean schedule_node::has_previous_sibling() const +{ + auto res = isl_schedule_node_has_previous_sibling(get()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_context(isl::checked::set context) const +{ + auto res = isl_schedule_node_insert_context(copy(), context.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_filter(isl::checked::union_set filter) const +{ + auto res = isl_schedule_node_insert_filter(copy(), filter.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_guard(isl::checked::set context) const +{ + auto res = isl_schedule_node_insert_guard(copy(), context.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_mark(isl::checked::id mark) const +{ + auto res = isl_schedule_node_insert_mark(copy(), mark.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_mark(const std::string &mark) const +{ + return this->insert_mark(isl::checked::id(ctx(), mark)); +} + +isl::checked::schedule_node schedule_node::insert_partial_schedule(isl::checked::multi_union_pw_aff schedule) const +{ + auto res = isl_schedule_node_insert_partial_schedule(copy(), schedule.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_sequence(isl::checked::union_set_list filters) const +{ + auto res = isl_schedule_node_insert_sequence(copy(), filters.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::insert_set(isl::checked::union_set_list filters) const +{ + auto res = isl_schedule_node_insert_set(copy(), filters.release()); + return manage(res); +} + +boolean schedule_node::is_equal(const isl::checked::schedule_node &node2) const +{ + auto res = isl_schedule_node_is_equal(get(), node2.get()); + return manage(res); +} + +boolean schedule_node::is_subtree_anchored() const +{ + auto res = isl_schedule_node_is_subtree_anchored(get()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::map_descendant_bottom_up(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_schedule_node * { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_schedule_node_map_descendant_bottom_up(copy(), fn_lambda, &fn_data); + return manage(res); +} + +class size schedule_node::n_children() const +{ + auto res = isl_schedule_node_n_children(get()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::next_sibling() const +{ + auto res = isl_schedule_node_next_sibling(copy()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::order_after(isl::checked::union_set filter) const +{ + auto res = isl_schedule_node_order_after(copy(), filter.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::order_before(isl::checked::union_set filter) const +{ + auto res = isl_schedule_node_order_before(copy(), filter.release()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::parent() const +{ + auto res = isl_schedule_node_parent(copy()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::previous_sibling() const +{ + auto res = isl_schedule_node_previous_sibling(copy()); + return manage(res); +} + +isl::checked::schedule_node schedule_node::root() const +{ + auto res = isl_schedule_node_root(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_band +schedule_node_band::schedule_node_band() + : schedule_node() {} + +schedule_node_band::schedule_node_band(const schedule_node_band &obj) + : schedule_node(obj) +{ +} + +schedule_node_band::schedule_node_band(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_band &schedule_node_band::operator=(schedule_node_band obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_band::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::union_set schedule_node_band::ast_build_options() const +{ + auto res = isl_schedule_node_band_get_ast_build_options(get()); + return manage(res); +} + +isl::checked::union_set schedule_node_band::get_ast_build_options() const +{ + return ast_build_options(); +} + +isl::checked::set schedule_node_band::ast_isolate_option() const +{ + auto res = isl_schedule_node_band_get_ast_isolate_option(get()); + return manage(res); +} + +isl::checked::set schedule_node_band::get_ast_isolate_option() const +{ + return ast_isolate_option(); +} + +isl::checked::multi_union_pw_aff schedule_node_band::partial_schedule() const +{ + auto res = isl_schedule_node_band_get_partial_schedule(get()); + return manage(res); +} + +isl::checked::multi_union_pw_aff schedule_node_band::get_partial_schedule() const +{ + return partial_schedule(); +} + +boolean schedule_node_band::permutable() const +{ + auto res = isl_schedule_node_band_get_permutable(get()); + return manage(res); +} + +boolean schedule_node_band::get_permutable() const +{ + return permutable(); +} + +boolean schedule_node_band::member_get_coincident(int pos) const +{ + auto res = isl_schedule_node_band_member_get_coincident(get(), pos); + return manage(res); +} + +schedule_node_band schedule_node_band::member_set_coincident(int pos, int coincident) const +{ + auto res = isl_schedule_node_band_member_set_coincident(copy(), pos, coincident); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::mod(isl::checked::multi_val mv) const +{ + auto res = isl_schedule_node_band_mod(copy(), mv.release()); + return manage(res).as(); +} + +class size schedule_node_band::n_member() const +{ + auto res = isl_schedule_node_band_n_member(get()); + return manage(res); +} + +schedule_node_band schedule_node_band::scale(isl::checked::multi_val mv) const +{ + auto res = isl_schedule_node_band_scale(copy(), mv.release()); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::scale_down(isl::checked::multi_val mv) const +{ + auto res = isl_schedule_node_band_scale_down(copy(), mv.release()); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::set_ast_build_options(isl::checked::union_set options) const +{ + auto res = isl_schedule_node_band_set_ast_build_options(copy(), options.release()); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::set_permutable(int permutable) const +{ + auto res = isl_schedule_node_band_set_permutable(copy(), permutable); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::shift(isl::checked::multi_union_pw_aff shift) const +{ + auto res = isl_schedule_node_band_shift(copy(), shift.release()); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::split(int pos) const +{ + auto res = isl_schedule_node_band_split(copy(), pos); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::tile(isl::checked::multi_val sizes) const +{ + auto res = isl_schedule_node_band_tile(copy(), sizes.release()); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_default(int pos) const +{ + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_default); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_atomic(int pos) const +{ + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_atomic); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_unroll(int pos) const +{ + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_unroll); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_separate(int pos) const +{ + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_separate); + return manage(res).as(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_band &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_context +schedule_node_context::schedule_node_context() + : schedule_node() {} + +schedule_node_context::schedule_node_context(const schedule_node_context &obj) + : schedule_node(obj) +{ +} + +schedule_node_context::schedule_node_context(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_context &schedule_node_context::operator=(schedule_node_context obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_context::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::set schedule_node_context::context() const +{ + auto res = isl_schedule_node_context_get_context(get()); + return manage(res); +} + +isl::checked::set schedule_node_context::get_context() const +{ + return context(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_context &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_domain +schedule_node_domain::schedule_node_domain() + : schedule_node() {} + +schedule_node_domain::schedule_node_domain(const schedule_node_domain &obj) + : schedule_node(obj) +{ +} + +schedule_node_domain::schedule_node_domain(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_domain &schedule_node_domain::operator=(schedule_node_domain obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_domain::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::union_set schedule_node_domain::domain() const +{ + auto res = isl_schedule_node_domain_get_domain(get()); + return manage(res); +} + +isl::checked::union_set schedule_node_domain::get_domain() const +{ + return domain(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_domain &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_expansion +schedule_node_expansion::schedule_node_expansion() + : schedule_node() {} + +schedule_node_expansion::schedule_node_expansion(const schedule_node_expansion &obj) + : schedule_node(obj) +{ +} + +schedule_node_expansion::schedule_node_expansion(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_expansion &schedule_node_expansion::operator=(schedule_node_expansion obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_expansion::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::union_pw_multi_aff schedule_node_expansion::contraction() const +{ + auto res = isl_schedule_node_expansion_get_contraction(get()); + return manage(res); +} + +isl::checked::union_pw_multi_aff schedule_node_expansion::get_contraction() const +{ + return contraction(); +} + +isl::checked::union_map schedule_node_expansion::expansion() const +{ + auto res = isl_schedule_node_expansion_get_expansion(get()); + return manage(res); +} + +isl::checked::union_map schedule_node_expansion::get_expansion() const +{ + return expansion(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_expansion &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_extension +schedule_node_extension::schedule_node_extension() + : schedule_node() {} + +schedule_node_extension::schedule_node_extension(const schedule_node_extension &obj) + : schedule_node(obj) +{ +} + +schedule_node_extension::schedule_node_extension(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_extension &schedule_node_extension::operator=(schedule_node_extension obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_extension::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::union_map schedule_node_extension::extension() const +{ + auto res = isl_schedule_node_extension_get_extension(get()); + return manage(res); +} + +isl::checked::union_map schedule_node_extension::get_extension() const +{ + return extension(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_extension &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_filter +schedule_node_filter::schedule_node_filter() + : schedule_node() {} + +schedule_node_filter::schedule_node_filter(const schedule_node_filter &obj) + : schedule_node(obj) +{ +} + +schedule_node_filter::schedule_node_filter(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_filter &schedule_node_filter::operator=(schedule_node_filter obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_filter::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::union_set schedule_node_filter::filter() const +{ + auto res = isl_schedule_node_filter_get_filter(get()); + return manage(res); +} + +isl::checked::union_set schedule_node_filter::get_filter() const +{ + return filter(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_filter &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_guard +schedule_node_guard::schedule_node_guard() + : schedule_node() {} + +schedule_node_guard::schedule_node_guard(const schedule_node_guard &obj) + : schedule_node(obj) +{ +} + +schedule_node_guard::schedule_node_guard(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_guard &schedule_node_guard::operator=(schedule_node_guard obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_guard::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::checked::set schedule_node_guard::guard() const +{ + auto res = isl_schedule_node_guard_get_guard(get()); + return manage(res); +} + +isl::checked::set schedule_node_guard::get_guard() const +{ + return guard(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_guard &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_leaf +schedule_node_leaf::schedule_node_leaf() + : schedule_node() {} + +schedule_node_leaf::schedule_node_leaf(const schedule_node_leaf &obj) + : schedule_node(obj) +{ +} + +schedule_node_leaf::schedule_node_leaf(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_leaf &schedule_node_leaf::operator=(schedule_node_leaf obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_leaf::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_leaf &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_mark +schedule_node_mark::schedule_node_mark() + : schedule_node() {} + +schedule_node_mark::schedule_node_mark(const schedule_node_mark &obj) + : schedule_node(obj) +{ +} + +schedule_node_mark::schedule_node_mark(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_mark &schedule_node_mark::operator=(schedule_node_mark obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_mark::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_mark &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_sequence +schedule_node_sequence::schedule_node_sequence() + : schedule_node() {} + +schedule_node_sequence::schedule_node_sequence(const schedule_node_sequence &obj) + : schedule_node(obj) +{ +} + +schedule_node_sequence::schedule_node_sequence(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_sequence &schedule_node_sequence::operator=(schedule_node_sequence obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_sequence::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_sequence &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_set +schedule_node_set::schedule_node_set() + : schedule_node() {} + +schedule_node_set::schedule_node_set(const schedule_node_set &obj) + : schedule_node(obj) +{ +} + +schedule_node_set::schedule_node_set(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_set &schedule_node_set::operator=(schedule_node_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::checked::ctx schedule_node_set::ctx() const { + return isl::checked::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_set &obj) +{ + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::set +set manage(__isl_take isl_set *ptr) { + return set(ptr); +} +set manage_copy(__isl_keep isl_set *ptr) { + ptr = isl_set_copy(ptr); + return set(ptr); +} + +set::set() + : ptr(nullptr) {} + +set::set(const set &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +set::set(__isl_take isl_set *ptr) + : ptr(ptr) {} + +set::set(isl::checked::basic_set bset) +{ + auto res = isl_set_from_basic_set(bset.release()); + ptr = res; +} + +set::set(isl::checked::point pnt) +{ + auto res = isl_set_from_point(pnt.release()); + ptr = res; +} + +set::set(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_set_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +set &set::operator=(set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +set::~set() { + if (ptr) + isl_set_free(ptr); +} + +__isl_give isl_set *set::copy() const & { + return isl_set_copy(ptr); +} + +__isl_keep isl_set *set::get() const { + return ptr; +} + +__isl_give isl_set *set::release() { + isl_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool set::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx set::ctx() const { + return isl::checked::ctx(isl_set_get_ctx(ptr)); +} + +isl::checked::basic_set set::affine_hull() const +{ + auto res = isl_set_affine_hull(copy()); + return manage(res); +} + +isl::checked::set set::apply(isl::checked::map map) const +{ + auto res = isl_set_apply(copy(), map.release()); + return manage(res); +} + +isl::checked::set set::bind(isl::checked::multi_id tuple) const +{ + auto res = isl_set_bind(copy(), tuple.release()); + return manage(res); +} + +isl::checked::set set::coalesce() const +{ + auto res = isl_set_coalesce(copy()); + return manage(res); +} + +isl::checked::set set::complement() const +{ + auto res = isl_set_complement(copy()); + return manage(res); +} + +isl::checked::set set::detect_equalities() const +{ + auto res = isl_set_detect_equalities(copy()); + return manage(res); +} + +isl::checked::set set::empty(isl::checked::space space) +{ + auto res = isl_set_empty(space.release()); + return manage(res); +} + +isl::checked::set set::flatten() const +{ + auto res = isl_set_flatten(copy()); + return manage(res); +} + +stat set::foreach_basic_set(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_basic_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_set_foreach_basic_set(get(), fn_lambda, &fn_data); + return manage(res); +} + +stat set::foreach_point(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_point *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_set_foreach_point(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::space set::space() const +{ + auto res = isl_set_get_space(get()); + return manage(res); +} + +isl::checked::space set::get_space() const +{ + return space(); +} + +isl::checked::val set::stride(int pos) const +{ + auto res = isl_set_get_stride(get(), pos); + return manage(res); +} + +isl::checked::val set::get_stride(int pos) const +{ + return stride(pos); +} + +isl::checked::set set::gist(isl::checked::set context) const +{ + auto res = isl_set_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::map set::identity() const +{ + auto res = isl_set_identity(copy()); + return manage(res); +} + +isl::checked::set set::intersect(isl::checked::set set2) const +{ + auto res = isl_set_intersect(copy(), set2.release()); + return manage(res); +} + +isl::checked::set set::intersect_params(isl::checked::set params) const +{ + auto res = isl_set_intersect_params(copy(), params.release()); + return manage(res); +} + +boolean set::is_disjoint(const isl::checked::set &set2) const +{ + auto res = isl_set_is_disjoint(get(), set2.get()); + return manage(res); +} + +boolean set::is_empty() const +{ + auto res = isl_set_is_empty(get()); + return manage(res); +} + +boolean set::is_equal(const isl::checked::set &set2) const +{ + auto res = isl_set_is_equal(get(), set2.get()); + return manage(res); +} + +boolean set::is_singleton() const +{ + auto res = isl_set_is_singleton(get()); + return manage(res); +} + +boolean set::is_strict_subset(const isl::checked::set &set2) const +{ + auto res = isl_set_is_strict_subset(get(), set2.get()); + return manage(res); +} + +boolean set::is_subset(const isl::checked::set &set2) const +{ + auto res = isl_set_is_subset(get(), set2.get()); + return manage(res); +} + +boolean set::is_wrapping() const +{ + auto res = isl_set_is_wrapping(get()); + return manage(res); +} + +isl::checked::set set::lexmax() const +{ + auto res = isl_set_lexmax(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff set::lexmax_pw_multi_aff() const +{ + auto res = isl_set_lexmax_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::set set::lexmin() const +{ + auto res = isl_set_lexmin(copy()); + return manage(res); +} + +isl::checked::pw_multi_aff set::lexmin_pw_multi_aff() const +{ + auto res = isl_set_lexmin_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::val set::max_val(const isl::checked::aff &obj) const +{ + auto res = isl_set_max_val(get(), obj.get()); + return manage(res); +} + +isl::checked::val set::min_val(const isl::checked::aff &obj) const +{ + auto res = isl_set_min_val(get(), obj.get()); + return manage(res); +} + +isl::checked::set set::params() const +{ + auto res = isl_set_params(copy()); + return manage(res); +} + +isl::checked::basic_set set::polyhedral_hull() const +{ + auto res = isl_set_polyhedral_hull(copy()); + return manage(res); +} + +isl::checked::set set::preimage(isl::checked::multi_aff ma) const +{ + auto res = isl_set_preimage_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::set set::preimage(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_set_preimage_multi_pw_aff(copy(), mpa.release()); + return manage(res); +} + +isl::checked::set set::preimage(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_set_preimage_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::set set::product(isl::checked::set set2) const +{ + auto res = isl_set_product(copy(), set2.release()); + return manage(res); +} + +isl::checked::set set::project_out_all_params() const +{ + auto res = isl_set_project_out_all_params(copy()); + return manage(res); +} + +isl::checked::set set::project_out_param(isl::checked::id id) const +{ + auto res = isl_set_project_out_param_id(copy(), id.release()); + return manage(res); +} + +isl::checked::set set::project_out_param(const std::string &id) const +{ + return this->project_out_param(isl::checked::id(ctx(), id)); +} + +isl::checked::set set::project_out_param(isl::checked::id_list list) const +{ + auto res = isl_set_project_out_param_id_list(copy(), list.release()); + return manage(res); +} + +isl::checked::basic_set set::sample() const +{ + auto res = isl_set_sample(copy()); + return manage(res); +} + +isl::checked::point set::sample_point() const +{ + auto res = isl_set_sample_point(copy()); + return manage(res); +} + +isl::checked::set set::subtract(isl::checked::set set2) const +{ + auto res = isl_set_subtract(copy(), set2.release()); + return manage(res); +} + +isl::checked::set set::unbind_params(isl::checked::multi_id tuple) const +{ + auto res = isl_set_unbind_params(copy(), tuple.release()); + return manage(res); +} + +isl::checked::map set::unbind_params_insert_domain(isl::checked::multi_id domain) const +{ + auto res = isl_set_unbind_params_insert_domain(copy(), domain.release()); + return manage(res); +} + +isl::checked::set set::unite(isl::checked::set set2) const +{ + auto res = isl_set_union(copy(), set2.release()); + return manage(res); +} + +isl::checked::set set::universe(isl::checked::space space) +{ + auto res = isl_set_universe(space.release()); + return manage(res); +} + +isl::checked::basic_set set::unshifted_simple_hull() const +{ + auto res = isl_set_unshifted_simple_hull(copy()); + return manage(res); +} + +isl::checked::map set::unwrap() const +{ + auto res = isl_set_unwrap(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const set &obj) +{ + char *str = isl_set_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::space +space manage(__isl_take isl_space *ptr) { + return space(ptr); +} +space manage_copy(__isl_keep isl_space *ptr) { + ptr = isl_space_copy(ptr); + return space(ptr); +} + +space::space() + : ptr(nullptr) {} + +space::space(const space &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +space::space(__isl_take isl_space *ptr) + : ptr(ptr) {} + +space &space::operator=(space obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +space::~space() { + if (ptr) + isl_space_free(ptr); +} + +__isl_give isl_space *space::copy() const & { + return isl_space_copy(ptr); +} + +__isl_keep isl_space *space::get() const { + return ptr; +} + +__isl_give isl_space *space::release() { + isl_space *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool space::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx space::ctx() const { + return isl::checked::ctx(isl_space_get_ctx(ptr)); +} + +isl::checked::space space::add_named_tuple(isl::checked::id tuple_id, unsigned int dim) const +{ + auto res = isl_space_add_named_tuple_id_ui(copy(), tuple_id.release(), dim); + return manage(res); +} + +isl::checked::space space::add_named_tuple(const std::string &tuple_id, unsigned int dim) const +{ + return this->add_named_tuple(isl::checked::id(ctx(), tuple_id), dim); +} + +isl::checked::space space::add_unnamed_tuple(unsigned int dim) const +{ + auto res = isl_space_add_unnamed_tuple_ui(copy(), dim); + return manage(res); +} + +isl::checked::space space::domain() const +{ + auto res = isl_space_domain(copy()); + return manage(res); +} + +isl::checked::space space::flatten_domain() const +{ + auto res = isl_space_flatten_domain(copy()); + return manage(res); +} + +isl::checked::space space::flatten_range() const +{ + auto res = isl_space_flatten_range(copy()); + return manage(res); +} + +boolean space::is_equal(const isl::checked::space &space2) const +{ + auto res = isl_space_is_equal(get(), space2.get()); + return manage(res); +} + +boolean space::is_wrapping() const +{ + auto res = isl_space_is_wrapping(get()); + return manage(res); +} + +isl::checked::space space::map_from_set() const +{ + auto res = isl_space_map_from_set(copy()); + return manage(res); +} + +isl::checked::space space::params() const +{ + auto res = isl_space_params(copy()); + return manage(res); +} + +isl::checked::space space::range() const +{ + auto res = isl_space_range(copy()); + return manage(res); +} + +isl::checked::space space::unit(isl::checked::ctx ctx) +{ + auto res = isl_space_unit(ctx.release()); + return manage(res); +} + +isl::checked::space space::unwrap() const +{ + auto res = isl_space_unwrap(copy()); + return manage(res); +} + +isl::checked::space space::wrap() const +{ + auto res = isl_space_wrap(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const space &obj) +{ + char *str = isl_space_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_access_info +union_access_info manage(__isl_take isl_union_access_info *ptr) { + return union_access_info(ptr); +} +union_access_info manage_copy(__isl_keep isl_union_access_info *ptr) { + ptr = isl_union_access_info_copy(ptr); + return union_access_info(ptr); +} + +union_access_info::union_access_info() + : ptr(nullptr) {} + +union_access_info::union_access_info(const union_access_info &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_access_info::union_access_info(__isl_take isl_union_access_info *ptr) + : ptr(ptr) {} + +union_access_info::union_access_info(isl::checked::union_map sink) +{ + auto res = isl_union_access_info_from_sink(sink.release()); + ptr = res; +} + +union_access_info &union_access_info::operator=(union_access_info obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_access_info::~union_access_info() { + if (ptr) + isl_union_access_info_free(ptr); +} + +__isl_give isl_union_access_info *union_access_info::copy() const & { + return isl_union_access_info_copy(ptr); +} + +__isl_keep isl_union_access_info *union_access_info::get() const { + return ptr; +} + +__isl_give isl_union_access_info *union_access_info::release() { + isl_union_access_info *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_access_info::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_access_info::ctx() const { + return isl::checked::ctx(isl_union_access_info_get_ctx(ptr)); +} + +isl::checked::union_flow union_access_info::compute_flow() const +{ + auto res = isl_union_access_info_compute_flow(copy()); + return manage(res); +} + +isl::checked::union_access_info union_access_info::set_kill(isl::checked::union_map kill) const +{ + auto res = isl_union_access_info_set_kill(copy(), kill.release()); + return manage(res); +} + +isl::checked::union_access_info union_access_info::set_may_source(isl::checked::union_map may_source) const +{ + auto res = isl_union_access_info_set_may_source(copy(), may_source.release()); + return manage(res); +} + +isl::checked::union_access_info union_access_info::set_must_source(isl::checked::union_map must_source) const +{ + auto res = isl_union_access_info_set_must_source(copy(), must_source.release()); + return manage(res); +} + +isl::checked::union_access_info union_access_info::set_schedule(isl::checked::schedule schedule) const +{ + auto res = isl_union_access_info_set_schedule(copy(), schedule.release()); + return manage(res); +} + +isl::checked::union_access_info union_access_info::set_schedule_map(isl::checked::union_map schedule_map) const +{ + auto res = isl_union_access_info_set_schedule_map(copy(), schedule_map.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_access_info &obj) +{ + char *str = isl_union_access_info_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_flow +union_flow manage(__isl_take isl_union_flow *ptr) { + return union_flow(ptr); +} +union_flow manage_copy(__isl_keep isl_union_flow *ptr) { + ptr = isl_union_flow_copy(ptr); + return union_flow(ptr); +} + +union_flow::union_flow() + : ptr(nullptr) {} + +union_flow::union_flow(const union_flow &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_flow::union_flow(__isl_take isl_union_flow *ptr) + : ptr(ptr) {} + +union_flow &union_flow::operator=(union_flow obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_flow::~union_flow() { + if (ptr) + isl_union_flow_free(ptr); +} + +__isl_give isl_union_flow *union_flow::copy() const & { + return isl_union_flow_copy(ptr); +} + +__isl_keep isl_union_flow *union_flow::get() const { + return ptr; +} + +__isl_give isl_union_flow *union_flow::release() { + isl_union_flow *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_flow::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_flow::ctx() const { + return isl::checked::ctx(isl_union_flow_get_ctx(ptr)); +} + +isl::checked::union_map union_flow::full_may_dependence() const +{ + auto res = isl_union_flow_get_full_may_dependence(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_full_may_dependence() const +{ + return full_may_dependence(); +} + +isl::checked::union_map union_flow::full_must_dependence() const +{ + auto res = isl_union_flow_get_full_must_dependence(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_full_must_dependence() const +{ + return full_must_dependence(); +} + +isl::checked::union_map union_flow::may_dependence() const +{ + auto res = isl_union_flow_get_may_dependence(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_may_dependence() const +{ + return may_dependence(); +} + +isl::checked::union_map union_flow::may_no_source() const +{ + auto res = isl_union_flow_get_may_no_source(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_may_no_source() const +{ + return may_no_source(); +} + +isl::checked::union_map union_flow::must_dependence() const +{ + auto res = isl_union_flow_get_must_dependence(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_must_dependence() const +{ + return must_dependence(); +} + +isl::checked::union_map union_flow::must_no_source() const +{ + auto res = isl_union_flow_get_must_no_source(get()); + return manage(res); +} + +isl::checked::union_map union_flow::get_must_no_source() const +{ + return must_no_source(); +} + +inline std::ostream &operator<<(std::ostream &os, const union_flow &obj) +{ + char *str = isl_union_flow_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_map +union_map manage(__isl_take isl_union_map *ptr) { + return union_map(ptr); +} +union_map manage_copy(__isl_keep isl_union_map *ptr) { + ptr = isl_union_map_copy(ptr); + return union_map(ptr); +} + +union_map::union_map() + : ptr(nullptr) {} + +union_map::union_map(const union_map &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_map::union_map(__isl_take isl_union_map *ptr) + : ptr(ptr) {} + +union_map::union_map(isl::checked::basic_map bmap) +{ + auto res = isl_union_map_from_basic_map(bmap.release()); + ptr = res; +} + +union_map::union_map(isl::checked::map map) +{ + auto res = isl_union_map_from_map(map.release()); + ptr = res; +} + +union_map::union_map(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_union_map_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +union_map &union_map::operator=(union_map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_map::~union_map() { + if (ptr) + isl_union_map_free(ptr); +} + +__isl_give isl_union_map *union_map::copy() const & { + return isl_union_map_copy(ptr); +} + +__isl_keep isl_union_map *union_map::get() const { + return ptr; +} + +__isl_give isl_union_map *union_map::release() { + isl_union_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_map::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_map::ctx() const { + return isl::checked::ctx(isl_union_map_get_ctx(ptr)); +} + +isl::checked::union_map union_map::affine_hull() const +{ + auto res = isl_union_map_affine_hull(copy()); + return manage(res); +} + +isl::checked::union_map union_map::apply_domain(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_apply_domain(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::apply_range(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_apply_range(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_set union_map::bind_range(isl::checked::multi_id tuple) const +{ + auto res = isl_union_map_bind_range(copy(), tuple.release()); + return manage(res); +} + +isl::checked::union_map union_map::coalesce() const +{ + auto res = isl_union_map_coalesce(copy()); + return manage(res); +} + +isl::checked::union_map union_map::compute_divs() const +{ + auto res = isl_union_map_compute_divs(copy()); + return manage(res); +} + +isl::checked::union_map union_map::curry() const +{ + auto res = isl_union_map_curry(copy()); + return manage(res); +} + +isl::checked::union_set union_map::deltas() const +{ + auto res = isl_union_map_deltas(copy()); + return manage(res); +} + +isl::checked::union_map union_map::detect_equalities() const +{ + auto res = isl_union_map_detect_equalities(copy()); + return manage(res); +} + +isl::checked::union_set union_map::domain() const +{ + auto res = isl_union_map_domain(copy()); + return manage(res); +} + +isl::checked::union_map union_map::domain_factor_domain() const +{ + auto res = isl_union_map_domain_factor_domain(copy()); + return manage(res); +} + +isl::checked::union_map union_map::domain_factor_range() const +{ + auto res = isl_union_map_domain_factor_range(copy()); + return manage(res); +} + +isl::checked::union_map union_map::domain_map() const +{ + auto res = isl_union_map_domain_map(copy()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_map::domain_map_union_pw_multi_aff() const +{ + auto res = isl_union_map_domain_map_union_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::union_map union_map::domain_product(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_domain_product(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::empty(isl::checked::ctx ctx) +{ + auto res = isl_union_map_empty_ctx(ctx.release()); + return manage(res); +} + +isl::checked::union_map union_map::eq_at(isl::checked::multi_union_pw_aff mupa) const +{ + auto res = isl_union_map_eq_at_multi_union_pw_aff(copy(), mupa.release()); + return manage(res); +} + +boolean union_map::every_map(const std::function &test) const +{ + struct test_data { + std::function func; + } test_data = { test }; + auto test_lambda = [](isl_map *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage_copy(arg_0)); + return ret.release(); + }; + auto res = isl_union_map_every_map(get(), test_lambda, &test_data); + return manage(res); +} + +isl::checked::map union_map::extract_map(isl::checked::space dim) const +{ + auto res = isl_union_map_extract_map(get(), dim.release()); + return manage(res); +} + +isl::checked::union_map union_map::factor_domain() const +{ + auto res = isl_union_map_factor_domain(copy()); + return manage(res); +} + +isl::checked::union_map union_map::factor_range() const +{ + auto res = isl_union_map_factor_range(copy()); + return manage(res); +} + +isl::checked::union_map union_map::fixed_power(isl::checked::val exp) const +{ + auto res = isl_union_map_fixed_power_val(copy(), exp.release()); + return manage(res); +} + +isl::checked::union_map union_map::fixed_power(long exp) const +{ + return this->fixed_power(isl::checked::val(ctx(), exp)); +} + +stat union_map::foreach_map(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_map *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_union_map_foreach_map(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::union_map union_map::from(isl::checked::multi_union_pw_aff mupa) +{ + auto res = isl_union_map_from_multi_union_pw_aff(mupa.release()); + return manage(res); +} + +isl::checked::union_map union_map::from(isl::checked::union_pw_multi_aff upma) +{ + auto res = isl_union_map_from_union_pw_multi_aff(upma.release()); + return manage(res); +} + +isl::checked::union_map union_map::from_domain(isl::checked::union_set uset) +{ + auto res = isl_union_map_from_domain(uset.release()); + return manage(res); +} + +isl::checked::union_map union_map::from_domain_and_range(isl::checked::union_set domain, isl::checked::union_set range) +{ + auto res = isl_union_map_from_domain_and_range(domain.release(), range.release()); + return manage(res); +} + +isl::checked::union_map union_map::from_range(isl::checked::union_set uset) +{ + auto res = isl_union_map_from_range(uset.release()); + return manage(res); +} + +isl::checked::space union_map::space() const +{ + auto res = isl_union_map_get_space(get()); + return manage(res); +} + +isl::checked::space union_map::get_space() const +{ + return space(); +} + +isl::checked::union_map union_map::gist(isl::checked::union_map context) const +{ + auto res = isl_union_map_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::union_map union_map::gist_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_map_gist_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_map union_map::gist_params(isl::checked::set set) const +{ + auto res = isl_union_map_gist_params(copy(), set.release()); + return manage(res); +} + +isl::checked::union_map union_map::gist_range(isl::checked::union_set uset) const +{ + auto res = isl_union_map_gist_range(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_map union_map::intersect(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_intersect(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::intersect_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_map_intersect_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_map union_map::intersect_params(isl::checked::set set) const +{ + auto res = isl_union_map_intersect_params(copy(), set.release()); + return manage(res); +} + +isl::checked::union_map union_map::intersect_range(isl::checked::union_set uset) const +{ + auto res = isl_union_map_intersect_range(copy(), uset.release()); + return manage(res); +} + +boolean union_map::is_bijective() const +{ + auto res = isl_union_map_is_bijective(get()); + return manage(res); +} + +boolean union_map::is_disjoint(const isl::checked::union_map &umap2) const +{ + auto res = isl_union_map_is_disjoint(get(), umap2.get()); + return manage(res); +} + +boolean union_map::is_empty() const +{ + auto res = isl_union_map_is_empty(get()); + return manage(res); +} + +boolean union_map::is_equal(const isl::checked::union_map &umap2) const +{ + auto res = isl_union_map_is_equal(get(), umap2.get()); + return manage(res); +} + +boolean union_map::is_injective() const +{ + auto res = isl_union_map_is_injective(get()); + return manage(res); +} + +boolean union_map::is_single_valued() const +{ + auto res = isl_union_map_is_single_valued(get()); + return manage(res); +} + +boolean union_map::is_strict_subset(const isl::checked::union_map &umap2) const +{ + auto res = isl_union_map_is_strict_subset(get(), umap2.get()); + return manage(res); +} + +boolean union_map::is_subset(const isl::checked::union_map &umap2) const +{ + auto res = isl_union_map_is_subset(get(), umap2.get()); + return manage(res); +} + +boolean union_map::isa_map() const +{ + auto res = isl_union_map_isa_map(get()); + return manage(res); +} + +isl::checked::union_map union_map::lexmax() const +{ + auto res = isl_union_map_lexmax(copy()); + return manage(res); +} + +isl::checked::union_map union_map::lexmin() const +{ + auto res = isl_union_map_lexmin(copy()); + return manage(res); +} + +isl::checked::union_map union_map::polyhedral_hull() const +{ + auto res = isl_union_map_polyhedral_hull(copy()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_domain(isl::checked::multi_aff ma) const +{ + auto res = isl_union_map_preimage_domain_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_domain(isl::checked::multi_pw_aff mpa) const +{ + auto res = isl_union_map_preimage_domain_multi_pw_aff(copy(), mpa.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_domain(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_union_map_preimage_domain_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_domain(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_union_map_preimage_domain_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_range(isl::checked::multi_aff ma) const +{ + auto res = isl_union_map_preimage_range_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_range(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_union_map_preimage_range_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::union_map union_map::preimage_range(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_union_map_preimage_range_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +isl::checked::union_map union_map::product(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_product(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::project_out_all_params() const +{ + auto res = isl_union_map_project_out_all_params(copy()); + return manage(res); +} + +isl::checked::union_set union_map::range() const +{ + auto res = isl_union_map_range(copy()); + return manage(res); +} + +isl::checked::union_map union_map::range_factor_domain() const +{ + auto res = isl_union_map_range_factor_domain(copy()); + return manage(res); +} + +isl::checked::union_map union_map::range_factor_range() const +{ + auto res = isl_union_map_range_factor_range(copy()); + return manage(res); +} + +isl::checked::union_map union_map::range_map() const +{ + auto res = isl_union_map_range_map(copy()); + return manage(res); +} + +isl::checked::union_map union_map::range_product(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_range_product(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::reverse() const +{ + auto res = isl_union_map_reverse(copy()); + return manage(res); +} + +isl::checked::union_map union_map::subtract(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_subtract(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::subtract_domain(isl::checked::union_set dom) const +{ + auto res = isl_union_map_subtract_domain(copy(), dom.release()); + return manage(res); +} + +isl::checked::union_map union_map::subtract_range(isl::checked::union_set dom) const +{ + auto res = isl_union_map_subtract_range(copy(), dom.release()); + return manage(res); +} + +isl::checked::union_map union_map::uncurry() const +{ + auto res = isl_union_map_uncurry(copy()); + return manage(res); +} + +isl::checked::union_map union_map::unite(isl::checked::union_map umap2) const +{ + auto res = isl_union_map_union(copy(), umap2.release()); + return manage(res); +} + +isl::checked::union_map union_map::universe() const +{ + auto res = isl_union_map_universe(copy()); + return manage(res); +} + +isl::checked::union_set union_map::wrap() const +{ + auto res = isl_union_map_wrap(copy()); + return manage(res); +} + +isl::checked::union_map union_map::zip() const +{ + auto res = isl_union_map_zip(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_map &obj) +{ + char *str = isl_union_map_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_aff +union_pw_aff manage(__isl_take isl_union_pw_aff *ptr) { + return union_pw_aff(ptr); +} +union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr) { + ptr = isl_union_pw_aff_copy(ptr); + return union_pw_aff(ptr); +} + +union_pw_aff::union_pw_aff() + : ptr(nullptr) {} + +union_pw_aff::union_pw_aff(const union_pw_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_pw_aff::union_pw_aff(__isl_take isl_union_pw_aff *ptr) + : ptr(ptr) {} + +union_pw_aff::union_pw_aff(isl::checked::pw_aff pa) +{ + auto res = isl_union_pw_aff_from_pw_aff(pa.release()); + ptr = res; +} + +union_pw_aff::union_pw_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_union_pw_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +union_pw_aff &union_pw_aff::operator=(union_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_aff::~union_pw_aff() { + if (ptr) + isl_union_pw_aff_free(ptr); +} + +__isl_give isl_union_pw_aff *union_pw_aff::copy() const & { + return isl_union_pw_aff_copy(ptr); +} + +__isl_keep isl_union_pw_aff *union_pw_aff::get() const { + return ptr; +} + +__isl_give isl_union_pw_aff *union_pw_aff::release() { + isl_union_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_pw_aff::ctx() const { + return isl::checked::ctx(isl_union_pw_aff_get_ctx(ptr)); +} + +isl::checked::union_pw_aff union_pw_aff::add(isl::checked::union_pw_aff upa2) const +{ + auto res = isl_union_pw_aff_add(copy(), upa2.release()); + return manage(res); +} + +isl::checked::union_set union_pw_aff::bind(isl::checked::id id) const +{ + auto res = isl_union_pw_aff_bind_id(copy(), id.release()); + return manage(res); +} + +isl::checked::union_set union_pw_aff::bind(const std::string &id) const +{ + return this->bind(isl::checked::id(ctx(), id)); +} + +isl::checked::union_set union_pw_aff::domain() const +{ + auto res = isl_union_pw_aff_domain(copy()); + return manage(res); +} + +isl::checked::space union_pw_aff::space() const +{ + auto res = isl_union_pw_aff_get_space(get()); + return manage(res); +} + +isl::checked::space union_pw_aff::get_space() const +{ + return space(); +} + +isl::checked::union_pw_aff union_pw_aff::gist(isl::checked::union_set context) const +{ + auto res = isl_union_pw_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::intersect_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_aff_intersect_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::intersect_domain_wrapped_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_aff_intersect_domain_wrapped_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::intersect_domain_wrapped_range(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_aff_intersect_domain_wrapped_range(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::intersect_params(isl::checked::set set) const +{ + auto res = isl_union_pw_aff_intersect_params(copy(), set.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::pullback(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_union_pw_aff_pullback_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::sub(isl::checked::union_pw_aff upa2) const +{ + auto res = isl_union_pw_aff_sub(copy(), upa2.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::subtract_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_aff_subtract_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff::union_add(isl::checked::union_pw_aff upa2) const +{ + auto res = isl_union_pw_aff_union_add(copy(), upa2.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_aff &obj) +{ + char *str = isl_union_pw_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_aff_list +union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr) { + return union_pw_aff_list(ptr); +} +union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr) { + ptr = isl_union_pw_aff_list_copy(ptr); + return union_pw_aff_list(ptr); +} + +union_pw_aff_list::union_pw_aff_list() + : ptr(nullptr) {} + +union_pw_aff_list::union_pw_aff_list(const union_pw_aff_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_pw_aff_list::union_pw_aff_list(__isl_take isl_union_pw_aff_list *ptr) + : ptr(ptr) {} + +union_pw_aff_list::union_pw_aff_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_union_pw_aff_list_alloc(ctx.release(), n); + ptr = res; +} + +union_pw_aff_list::union_pw_aff_list(isl::checked::union_pw_aff el) +{ + auto res = isl_union_pw_aff_list_from_union_pw_aff(el.release()); + ptr = res; +} + +union_pw_aff_list &union_pw_aff_list::operator=(union_pw_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_aff_list::~union_pw_aff_list() { + if (ptr) + isl_union_pw_aff_list_free(ptr); +} + +__isl_give isl_union_pw_aff_list *union_pw_aff_list::copy() const & { + return isl_union_pw_aff_list_copy(ptr); +} + +__isl_keep isl_union_pw_aff_list *union_pw_aff_list::get() const { + return ptr; +} + +__isl_give isl_union_pw_aff_list *union_pw_aff_list::release() { + isl_union_pw_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_pw_aff_list::ctx() const { + return isl::checked::ctx(isl_union_pw_aff_list_get_ctx(ptr)); +} + +isl::checked::union_pw_aff_list union_pw_aff_list::add(isl::checked::union_pw_aff el) const +{ + auto res = isl_union_pw_aff_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::union_pw_aff_list union_pw_aff_list::clear() const +{ + auto res = isl_union_pw_aff_list_clear(copy()); + return manage(res); +} + +isl::checked::union_pw_aff_list union_pw_aff_list::concat(isl::checked::union_pw_aff_list list2) const +{ + auto res = isl_union_pw_aff_list_concat(copy(), list2.release()); + return manage(res); +} + +stat union_pw_aff_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_union_pw_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_union_pw_aff_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff_list::at(int index) const +{ + auto res = isl_union_pw_aff_list_get_at(get(), index); + return manage(res); +} + +isl::checked::union_pw_aff union_pw_aff_list::get_at(int index) const +{ + return at(index); +} + +class size union_pw_aff_list::size() const +{ + auto res = isl_union_pw_aff_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_aff_list &obj) +{ + char *str = isl_union_pw_aff_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_multi_aff +union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr) { + return union_pw_multi_aff(ptr); +} +union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr) { + ptr = isl_union_pw_multi_aff_copy(ptr); + return union_pw_multi_aff(ptr); +} + +union_pw_multi_aff::union_pw_multi_aff() + : ptr(nullptr) {} + +union_pw_multi_aff::union_pw_multi_aff(const union_pw_multi_aff &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_pw_multi_aff::union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *ptr) + : ptr(ptr) {} + +union_pw_multi_aff::union_pw_multi_aff(isl::checked::pw_multi_aff pma) +{ + auto res = isl_union_pw_multi_aff_from_pw_multi_aff(pma.release()); + ptr = res; +} + +union_pw_multi_aff::union_pw_multi_aff(isl::checked::union_pw_aff upa) +{ + auto res = isl_union_pw_multi_aff_from_union_pw_aff(upa.release()); + ptr = res; +} + +union_pw_multi_aff::union_pw_multi_aff(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_union_pw_multi_aff_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +union_pw_multi_aff &union_pw_multi_aff::operator=(union_pw_multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_multi_aff::~union_pw_multi_aff() { + if (ptr) + isl_union_pw_multi_aff_free(ptr); +} + +__isl_give isl_union_pw_multi_aff *union_pw_multi_aff::copy() const & { + return isl_union_pw_multi_aff_copy(ptr); +} + +__isl_keep isl_union_pw_multi_aff *union_pw_multi_aff::get() const { + return ptr; +} + +__isl_give isl_union_pw_multi_aff *union_pw_multi_aff::release() { + isl_union_pw_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_pw_multi_aff::ctx() const { + return isl::checked::ctx(isl_union_pw_multi_aff_get_ctx(ptr)); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::add(isl::checked::union_pw_multi_aff upma2) const +{ + auto res = isl_union_pw_multi_aff_add(copy(), upma2.release()); + return manage(res); +} + +isl::checked::pw_multi_aff union_pw_multi_aff::as_pw_multi_aff() const +{ + auto res = isl_union_pw_multi_aff_as_pw_multi_aff(copy()); + return manage(res); +} + +isl::checked::union_set union_pw_multi_aff::domain() const +{ + auto res = isl_union_pw_multi_aff_domain(copy()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::empty(isl::checked::ctx ctx) +{ + auto res = isl_union_pw_multi_aff_empty_ctx(ctx.release()); + return manage(res); +} + +isl::checked::pw_multi_aff union_pw_multi_aff::extract_pw_multi_aff(isl::checked::space space) const +{ + auto res = isl_union_pw_multi_aff_extract_pw_multi_aff(get(), space.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::flat_range_product(isl::checked::union_pw_multi_aff upma2) const +{ + auto res = isl_union_pw_multi_aff_flat_range_product(copy(), upma2.release()); + return manage(res); +} + +isl::checked::space union_pw_multi_aff::space() const +{ + auto res = isl_union_pw_multi_aff_get_space(get()); + return manage(res); +} + +isl::checked::space union_pw_multi_aff::get_space() const +{ + return space(); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::gist(isl::checked::union_set context) const +{ + auto res = isl_union_pw_multi_aff_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::intersect_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_multi_aff_intersect_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::intersect_domain_wrapped_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_multi_aff_intersect_domain_wrapped_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::intersect_domain_wrapped_range(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_multi_aff_intersect_domain_wrapped_range(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::intersect_params(isl::checked::set set) const +{ + auto res = isl_union_pw_multi_aff_intersect_params(copy(), set.release()); + return manage(res); +} + +boolean union_pw_multi_aff::isa_pw_multi_aff() const +{ + auto res = isl_union_pw_multi_aff_isa_pw_multi_aff(get()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::pullback(isl::checked::union_pw_multi_aff upma2) const +{ + auto res = isl_union_pw_multi_aff_pullback_union_pw_multi_aff(copy(), upma2.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::range_factor_domain() const +{ + auto res = isl_union_pw_multi_aff_range_factor_domain(copy()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::range_factor_range() const +{ + auto res = isl_union_pw_multi_aff_range_factor_range(copy()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::sub(isl::checked::union_pw_multi_aff upma2) const +{ + auto res = isl_union_pw_multi_aff_sub(copy(), upma2.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::subtract_domain(isl::checked::union_set uset) const +{ + auto res = isl_union_pw_multi_aff_subtract_domain(copy(), uset.release()); + return manage(res); +} + +isl::checked::union_pw_multi_aff union_pw_multi_aff::union_add(isl::checked::union_pw_multi_aff upma2) const +{ + auto res = isl_union_pw_multi_aff_union_add(copy(), upma2.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_multi_aff &obj) +{ + char *str = isl_union_pw_multi_aff_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_set +union_set manage(__isl_take isl_union_set *ptr) { + return union_set(ptr); +} +union_set manage_copy(__isl_keep isl_union_set *ptr) { + ptr = isl_union_set_copy(ptr); + return union_set(ptr); +} + +union_set::union_set() + : ptr(nullptr) {} + +union_set::union_set(const union_set &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_set::union_set(__isl_take isl_union_set *ptr) + : ptr(ptr) {} + +union_set::union_set(isl::checked::basic_set bset) +{ + auto res = isl_union_set_from_basic_set(bset.release()); + ptr = res; +} + +union_set::union_set(isl::checked::point pnt) +{ + auto res = isl_union_set_from_point(pnt.release()); + ptr = res; +} + +union_set::union_set(isl::checked::set set) +{ + auto res = isl_union_set_from_set(set.release()); + ptr = res; +} + +union_set::union_set(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_union_set_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +union_set &union_set::operator=(union_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_set::~union_set() { + if (ptr) + isl_union_set_free(ptr); +} + +__isl_give isl_union_set *union_set::copy() const & { + return isl_union_set_copy(ptr); +} + +__isl_keep isl_union_set *union_set::get() const { + return ptr; +} + +__isl_give isl_union_set *union_set::release() { + isl_union_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_set::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_set::ctx() const { + return isl::checked::ctx(isl_union_set_get_ctx(ptr)); +} + +isl::checked::union_set union_set::affine_hull() const +{ + auto res = isl_union_set_affine_hull(copy()); + return manage(res); +} + +isl::checked::union_set union_set::apply(isl::checked::union_map umap) const +{ + auto res = isl_union_set_apply(copy(), umap.release()); + return manage(res); +} + +isl::checked::union_set union_set::coalesce() const +{ + auto res = isl_union_set_coalesce(copy()); + return manage(res); +} + +isl::checked::union_set union_set::compute_divs() const +{ + auto res = isl_union_set_compute_divs(copy()); + return manage(res); +} + +isl::checked::union_set union_set::detect_equalities() const +{ + auto res = isl_union_set_detect_equalities(copy()); + return manage(res); +} + +isl::checked::union_set union_set::empty(isl::checked::ctx ctx) +{ + auto res = isl_union_set_empty_ctx(ctx.release()); + return manage(res); +} + +boolean union_set::every_set(const std::function &test) const +{ + struct test_data { + std::function func; + } test_data = { test }; + auto test_lambda = [](isl_set *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage_copy(arg_0)); + return ret.release(); + }; + auto res = isl_union_set_every_set(get(), test_lambda, &test_data); + return manage(res); +} + +isl::checked::set union_set::extract_set(isl::checked::space dim) const +{ + auto res = isl_union_set_extract_set(get(), dim.release()); + return manage(res); +} + +stat union_set::foreach_point(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_point *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_union_set_foreach_point(get(), fn_lambda, &fn_data); + return manage(res); +} + +stat union_set::foreach_set(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_union_set_foreach_set(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::space union_set::space() const +{ + auto res = isl_union_set_get_space(get()); + return manage(res); +} + +isl::checked::space union_set::get_space() const +{ + return space(); +} + +isl::checked::union_set union_set::gist(isl::checked::union_set context) const +{ + auto res = isl_union_set_gist(copy(), context.release()); + return manage(res); +} + +isl::checked::union_set union_set::gist_params(isl::checked::set set) const +{ + auto res = isl_union_set_gist_params(copy(), set.release()); + return manage(res); +} + +isl::checked::union_map union_set::identity() const +{ + auto res = isl_union_set_identity(copy()); + return manage(res); +} + +isl::checked::union_set union_set::intersect(isl::checked::union_set uset2) const +{ + auto res = isl_union_set_intersect(copy(), uset2.release()); + return manage(res); +} + +isl::checked::union_set union_set::intersect_params(isl::checked::set set) const +{ + auto res = isl_union_set_intersect_params(copy(), set.release()); + return manage(res); +} + +boolean union_set::is_disjoint(const isl::checked::union_set &uset2) const +{ + auto res = isl_union_set_is_disjoint(get(), uset2.get()); + return manage(res); +} + +boolean union_set::is_empty() const +{ + auto res = isl_union_set_is_empty(get()); + return manage(res); +} + +boolean union_set::is_equal(const isl::checked::union_set &uset2) const +{ + auto res = isl_union_set_is_equal(get(), uset2.get()); + return manage(res); +} + +boolean union_set::is_strict_subset(const isl::checked::union_set &uset2) const +{ + auto res = isl_union_set_is_strict_subset(get(), uset2.get()); + return manage(res); +} + +boolean union_set::is_subset(const isl::checked::union_set &uset2) const +{ + auto res = isl_union_set_is_subset(get(), uset2.get()); + return manage(res); +} + +boolean union_set::isa_set() const +{ + auto res = isl_union_set_isa_set(get()); + return manage(res); +} + +isl::checked::union_set union_set::lexmax() const +{ + auto res = isl_union_set_lexmax(copy()); + return manage(res); +} + +isl::checked::union_set union_set::lexmin() const +{ + auto res = isl_union_set_lexmin(copy()); + return manage(res); +} + +isl::checked::union_set union_set::polyhedral_hull() const +{ + auto res = isl_union_set_polyhedral_hull(copy()); + return manage(res); +} + +isl::checked::union_set union_set::preimage(isl::checked::multi_aff ma) const +{ + auto res = isl_union_set_preimage_multi_aff(copy(), ma.release()); + return manage(res); +} + +isl::checked::union_set union_set::preimage(isl::checked::pw_multi_aff pma) const +{ + auto res = isl_union_set_preimage_pw_multi_aff(copy(), pma.release()); + return manage(res); +} + +isl::checked::union_set union_set::preimage(isl::checked::union_pw_multi_aff upma) const +{ + auto res = isl_union_set_preimage_union_pw_multi_aff(copy(), upma.release()); + return manage(res); +} + +isl::checked::point union_set::sample_point() const +{ + auto res = isl_union_set_sample_point(copy()); + return manage(res); +} + +isl::checked::union_set union_set::subtract(isl::checked::union_set uset2) const +{ + auto res = isl_union_set_subtract(copy(), uset2.release()); + return manage(res); +} + +isl::checked::union_set union_set::unite(isl::checked::union_set uset2) const +{ + auto res = isl_union_set_union(copy(), uset2.release()); + return manage(res); +} + +isl::checked::union_set union_set::universe() const +{ + auto res = isl_union_set_universe(copy()); + return manage(res); +} + +isl::checked::union_map union_set::unwrap() const +{ + auto res = isl_union_set_unwrap(copy()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_set &obj) +{ + char *str = isl_union_set_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::union_set_list +union_set_list manage(__isl_take isl_union_set_list *ptr) { + return union_set_list(ptr); +} +union_set_list manage_copy(__isl_keep isl_union_set_list *ptr) { + ptr = isl_union_set_list_copy(ptr); + return union_set_list(ptr); +} + +union_set_list::union_set_list() + : ptr(nullptr) {} + +union_set_list::union_set_list(const union_set_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +union_set_list::union_set_list(__isl_take isl_union_set_list *ptr) + : ptr(ptr) {} + +union_set_list::union_set_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_union_set_list_alloc(ctx.release(), n); + ptr = res; +} + +union_set_list::union_set_list(isl::checked::union_set el) +{ + auto res = isl_union_set_list_from_union_set(el.release()); + ptr = res; +} + +union_set_list &union_set_list::operator=(union_set_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_set_list::~union_set_list() { + if (ptr) + isl_union_set_list_free(ptr); +} + +__isl_give isl_union_set_list *union_set_list::copy() const & { + return isl_union_set_list_copy(ptr); +} + +__isl_keep isl_union_set_list *union_set_list::get() const { + return ptr; +} + +__isl_give isl_union_set_list *union_set_list::release() { + isl_union_set_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_set_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx union_set_list::ctx() const { + return isl::checked::ctx(isl_union_set_list_get_ctx(ptr)); +} + +isl::checked::union_set_list union_set_list::add(isl::checked::union_set el) const +{ + auto res = isl_union_set_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::union_set_list union_set_list::clear() const +{ + auto res = isl_union_set_list_clear(copy()); + return manage(res); +} + +isl::checked::union_set_list union_set_list::concat(isl::checked::union_set_list list2) const +{ + auto res = isl_union_set_list_concat(copy(), list2.release()); + return manage(res); +} + +stat union_set_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_union_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_union_set_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::union_set union_set_list::at(int index) const +{ + auto res = isl_union_set_list_get_at(get(), index); + return manage(res); +} + +isl::checked::union_set union_set_list::get_at(int index) const +{ + return at(index); +} + +class size union_set_list::size() const +{ + auto res = isl_union_set_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_set_list &obj) +{ + char *str = isl_union_set_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::val +val manage(__isl_take isl_val *ptr) { + return val(ptr); +} +val manage_copy(__isl_keep isl_val *ptr) { + ptr = isl_val_copy(ptr); + return val(ptr); +} + +val::val() + : ptr(nullptr) {} + +val::val(const val &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +val::val(__isl_take isl_val *ptr) + : ptr(ptr) {} + +val::val(isl::checked::ctx ctx, long i) +{ + auto res = isl_val_int_from_si(ctx.release(), i); + ptr = res; +} + +val::val(isl::checked::ctx ctx, const std::string &str) +{ + auto res = isl_val_read_from_str(ctx.release(), str.c_str()); + ptr = res; +} + +val &val::operator=(val obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +val::~val() { + if (ptr) + isl_val_free(ptr); +} + +__isl_give isl_val *val::copy() const & { + return isl_val_copy(ptr); +} + +__isl_keep isl_val *val::get() const { + return ptr; +} + +__isl_give isl_val *val::release() { + isl_val *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool val::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx val::ctx() const { + return isl::checked::ctx(isl_val_get_ctx(ptr)); +} + +isl::checked::val val::abs() const +{ + auto res = isl_val_abs(copy()); + return manage(res); +} + +boolean val::abs_eq(const isl::checked::val &v2) const +{ + auto res = isl_val_abs_eq(get(), v2.get()); + return manage(res); +} + +boolean val::abs_eq(long v2) const +{ + return this->abs_eq(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::add(isl::checked::val v2) const +{ + auto res = isl_val_add(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::add(long v2) const +{ + return this->add(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::ceil() const +{ + auto res = isl_val_ceil(copy()); + return manage(res); +} + +int val::cmp_si(long i) const +{ + auto res = isl_val_cmp_si(get(), i); + return res; +} + +isl::checked::val val::div(isl::checked::val v2) const +{ + auto res = isl_val_div(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::div(long v2) const +{ + return this->div(isl::checked::val(ctx(), v2)); +} + +boolean val::eq(const isl::checked::val &v2) const +{ + auto res = isl_val_eq(get(), v2.get()); + return manage(res); +} + +boolean val::eq(long v2) const +{ + return this->eq(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::floor() const +{ + auto res = isl_val_floor(copy()); + return manage(res); +} + +isl::checked::val val::gcd(isl::checked::val v2) const +{ + auto res = isl_val_gcd(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::gcd(long v2) const +{ + return this->gcd(isl::checked::val(ctx(), v2)); +} + +boolean val::ge(const isl::checked::val &v2) const +{ + auto res = isl_val_ge(get(), v2.get()); + return manage(res); +} + +boolean val::ge(long v2) const +{ + return this->ge(isl::checked::val(ctx(), v2)); +} + +long val::den_si() const +{ + auto res = isl_val_get_den_si(get()); + return res; +} + +long val::get_den_si() const +{ + return den_si(); +} + +long val::num_si() const +{ + auto res = isl_val_get_num_si(get()); + return res; +} + +long val::get_num_si() const +{ + return num_si(); +} + +boolean val::gt(const isl::checked::val &v2) const +{ + auto res = isl_val_gt(get(), v2.get()); + return manage(res); +} + +boolean val::gt(long v2) const +{ + return this->gt(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::infty(isl::checked::ctx ctx) +{ + auto res = isl_val_infty(ctx.release()); + return manage(res); +} + +isl::checked::val val::inv() const +{ + auto res = isl_val_inv(copy()); + return manage(res); +} + +boolean val::is_divisible_by(const isl::checked::val &v2) const +{ + auto res = isl_val_is_divisible_by(get(), v2.get()); + return manage(res); +} + +boolean val::is_divisible_by(long v2) const +{ + return this->is_divisible_by(isl::checked::val(ctx(), v2)); +} + +boolean val::is_infty() const +{ + auto res = isl_val_is_infty(get()); + return manage(res); +} + +boolean val::is_int() const +{ + auto res = isl_val_is_int(get()); + return manage(res); +} + +boolean val::is_nan() const +{ + auto res = isl_val_is_nan(get()); + return manage(res); +} + +boolean val::is_neg() const +{ + auto res = isl_val_is_neg(get()); + return manage(res); +} + +boolean val::is_neginfty() const +{ + auto res = isl_val_is_neginfty(get()); + return manage(res); +} + +boolean val::is_negone() const +{ + auto res = isl_val_is_negone(get()); + return manage(res); +} + +boolean val::is_nonneg() const +{ + auto res = isl_val_is_nonneg(get()); + return manage(res); +} + +boolean val::is_nonpos() const +{ + auto res = isl_val_is_nonpos(get()); + return manage(res); +} + +boolean val::is_one() const +{ + auto res = isl_val_is_one(get()); + return manage(res); +} + +boolean val::is_pos() const +{ + auto res = isl_val_is_pos(get()); + return manage(res); +} + +boolean val::is_rat() const +{ + auto res = isl_val_is_rat(get()); + return manage(res); +} + +boolean val::is_zero() const +{ + auto res = isl_val_is_zero(get()); + return manage(res); +} + +boolean val::le(const isl::checked::val &v2) const +{ + auto res = isl_val_le(get(), v2.get()); + return manage(res); +} + +boolean val::le(long v2) const +{ + return this->le(isl::checked::val(ctx(), v2)); +} + +boolean val::lt(const isl::checked::val &v2) const +{ + auto res = isl_val_lt(get(), v2.get()); + return manage(res); +} + +boolean val::lt(long v2) const +{ + return this->lt(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::max(isl::checked::val v2) const +{ + auto res = isl_val_max(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::max(long v2) const +{ + return this->max(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::min(isl::checked::val v2) const +{ + auto res = isl_val_min(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::min(long v2) const +{ + return this->min(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::mod(isl::checked::val v2) const +{ + auto res = isl_val_mod(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::mod(long v2) const +{ + return this->mod(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::mul(isl::checked::val v2) const +{ + auto res = isl_val_mul(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::mul(long v2) const +{ + return this->mul(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::nan(isl::checked::ctx ctx) +{ + auto res = isl_val_nan(ctx.release()); + return manage(res); +} + +boolean val::ne(const isl::checked::val &v2) const +{ + auto res = isl_val_ne(get(), v2.get()); + return manage(res); +} + +boolean val::ne(long v2) const +{ + return this->ne(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::neg() const +{ + auto res = isl_val_neg(copy()); + return manage(res); +} + +isl::checked::val val::neginfty(isl::checked::ctx ctx) +{ + auto res = isl_val_neginfty(ctx.release()); + return manage(res); +} + +isl::checked::val val::negone(isl::checked::ctx ctx) +{ + auto res = isl_val_negone(ctx.release()); + return manage(res); +} + +isl::checked::val val::one(isl::checked::ctx ctx) +{ + auto res = isl_val_one(ctx.release()); + return manage(res); +} + +isl::checked::val val::pow2() const +{ + auto res = isl_val_pow2(copy()); + return manage(res); +} + +int val::sgn() const +{ + auto res = isl_val_sgn(get()); + return res; +} + +isl::checked::val val::sub(isl::checked::val v2) const +{ + auto res = isl_val_sub(copy(), v2.release()); + return manage(res); +} + +isl::checked::val val::sub(long v2) const +{ + return this->sub(isl::checked::val(ctx(), v2)); +} + +isl::checked::val val::trunc() const +{ + auto res = isl_val_trunc(copy()); + return manage(res); +} + +isl::checked::val val::zero(isl::checked::ctx ctx) +{ + auto res = isl_val_zero(ctx.release()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const val &obj) +{ + char *str = isl_val_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} + +// implementations for isl::val_list +val_list manage(__isl_take isl_val_list *ptr) { + return val_list(ptr); +} +val_list manage_copy(__isl_keep isl_val_list *ptr) { + ptr = isl_val_list_copy(ptr); + return val_list(ptr); +} + +val_list::val_list() + : ptr(nullptr) {} + +val_list::val_list(const val_list &obj) + : ptr(nullptr) +{ + ptr = obj.copy(); +} + +val_list::val_list(__isl_take isl_val_list *ptr) + : ptr(ptr) {} + +val_list::val_list(isl::checked::ctx ctx, int n) +{ + auto res = isl_val_list_alloc(ctx.release(), n); + ptr = res; +} + +val_list::val_list(isl::checked::val el) +{ + auto res = isl_val_list_from_val(el.release()); + ptr = res; +} + +val_list &val_list::operator=(val_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +val_list::~val_list() { + if (ptr) + isl_val_list_free(ptr); +} + +__isl_give isl_val_list *val_list::copy() const & { + return isl_val_list_copy(ptr); +} + +__isl_keep isl_val_list *val_list::get() const { + return ptr; +} + +__isl_give isl_val_list *val_list::release() { + isl_val_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool val_list::is_null() const { + return ptr == nullptr; +} + +isl::checked::ctx val_list::ctx() const { + return isl::checked::ctx(isl_val_list_get_ctx(ptr)); +} + +isl::checked::val_list val_list::add(isl::checked::val el) const +{ + auto res = isl_val_list_add(copy(), el.release()); + return manage(res); +} + +isl::checked::val_list val_list::add(long el) const +{ + return this->add(isl::checked::val(ctx(), el)); +} + +isl::checked::val_list val_list::clear() const +{ + auto res = isl_val_list_clear(copy()); + return manage(res); +} + +isl::checked::val_list val_list::concat(isl::checked::val_list list2) const +{ + auto res = isl_val_list_concat(copy(), list2.release()); + return manage(res); +} + +stat val_list::foreach(const std::function &fn) const +{ + struct fn_data { + std::function func; + } fn_data = { fn }; + auto fn_lambda = [](isl_val *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + }; + auto res = isl_val_list_foreach(get(), fn_lambda, &fn_data); + return manage(res); +} + +isl::checked::val val_list::at(int index) const +{ + auto res = isl_val_list_get_at(get(), index); + return manage(res); +} + +isl::checked::val val_list::get_at(int index) const +{ + return at(index); +} + +class size val_list::size() const +{ + auto res = isl_val_list_size(get()); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const val_list &obj) +{ + char *str = isl_val_list_to_str(obj.get()); + if (!str) { + os.setstate(std::ios_base::badbit); + return os; + } + os << str; + free(str); + return os; +} +} // namespace checked +} // namespace isl + +#endif /* ISL_CPP_CHECKED */ diff --git a/gcc/isl/include/isl/cpp.h b/gcc/isl/include/isl/cpp.h new file mode 100644 index 0000000..38068cb 100644 --- /dev/null +++ a/gcc/isl/include/isl/cpp.h @@ -1,0 +1,18118 @@ +/// These are automatically generated C++ bindings for isl. +/// +/// isl is a library for computing with integer sets and maps described by +/// Presburger formulas. On top of this, isl provides various tools for +/// polyhedral compilation, ranging from dependence analysis over scheduling +/// to AST generation. + +#ifndef ISL_CPP +#define ISL_CPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +/* ISL_USE_EXCEPTIONS should be defined to 1 if exceptions are available. + * gcc and clang define __cpp_exceptions; MSVC and xlC define _CPPUNWIND. + * Older versions of gcc (e.g., 4.9) only define __EXCEPTIONS. + * If exceptions are not available, any error condition will result + * in an abort. + */ +#ifndef ISL_USE_EXCEPTIONS +#if defined(__cpp_exceptions) || defined(_CPPUNWIND) || defined(__EXCEPTIONS) +#define ISL_USE_EXCEPTIONS 1 +#else +#define ISL_USE_EXCEPTIONS 0 +#endif +#endif + +namespace isl { + +class ctx { + isl_ctx *ptr; +public: + /* implicit */ ctx(isl_ctx *ctx) : ptr(ctx) {} + isl_ctx *release() { + auto tmp = ptr; + ptr = nullptr; + return tmp; + } + isl_ctx *get() { + return ptr; + } +}; + +/* Macros hiding try/catch. + * If exceptions are not available, then no exceptions will be thrown and + * there is nothing to catch. + */ +#if ISL_USE_EXCEPTIONS +#define ISL_CPP_TRY try +#define ISL_CPP_CATCH_ALL catch (...) +#else +#define ISL_CPP_TRY if (1) +#define ISL_CPP_CATCH_ALL if (0) +#endif + +#if ISL_USE_EXCEPTIONS + +/* Class capturing isl errors. + * + * The what() return value is stored in a reference counted string + * to ensure that the copy constructor and the assignment operator + * do not throw any exceptions. + */ +class exception : public std::exception { + std::shared_ptr what_str; + +protected: + inline exception(const char *what_arg, const char *msg, + const char *file, int line); +public: + exception() {} + exception(const char *what_arg) { + what_str = std::make_shared(what_arg); + } + static inline void throw_error(enum isl_error error, const char *msg, + const char *file, int line); + virtual const char *what() const noexcept { + return what_str->c_str(); + } + + /* Default behavior on error conditions that occur inside isl calls + * performed from inside the bindings. + * In the case exceptions are available, isl should continue + * without printing a warning since the warning message + * will be included in the exception thrown from inside the bindings. + */ + static constexpr auto on_error = ISL_ON_ERROR_CONTINUE; + /* Wrapper for throwing an exception with the given message. + */ + static void throw_invalid(const char *msg, const char *file, int line) { + throw_error(isl_error_invalid, msg, file, line); + } + static inline void throw_last_error(ctx ctx); +}; + +/* Create an exception of a type described by "what_arg", with + * error message "msg" in line "line" of file "file". + * + * Create a string holding the what() return value that + * corresponds to what isl would have printed. + * If no error message or no error file was set, then use "what_arg" instead. + */ +exception::exception(const char *what_arg, const char *msg, const char *file, + int line) +{ + if (!msg || !file) + what_str = std::make_shared(what_arg); + else + what_str = std::make_shared(std::string(file) + + ":" + std::to_string(line) + ": " + msg); +} + +class exception_abort : public exception { + friend exception; + exception_abort(const char *msg, const char *file, int line) : + exception("execution aborted", msg, file, line) {} +}; + +class exception_alloc : public exception { + friend exception; + exception_alloc(const char *msg, const char *file, int line) : + exception("memory allocation failure", msg, file, line) {} +}; + +class exception_unknown : public exception { + friend exception; + exception_unknown(const char *msg, const char *file, int line) : + exception("unknown failure", msg, file, line) {} +}; + +class exception_internal : public exception { + friend exception; + exception_internal(const char *msg, const char *file, int line) : + exception("internal error", msg, file, line) {} +}; + +class exception_invalid : public exception { + friend exception; + exception_invalid(const char *msg, const char *file, int line) : + exception("invalid argument", msg, file, line) {} +}; + +class exception_quota : public exception { + friend exception; + exception_quota(const char *msg, const char *file, int line) : + exception("quota exceeded", msg, file, line) {} +}; + +class exception_unsupported : public exception { + friend exception; + exception_unsupported(const char *msg, const char *file, int line) : + exception("unsupported operation", msg, file, line) {} +}; + +/* Throw an exception of the class that corresponds to "error", with + * error message "msg" in line "line" of file "file". + * + * isl_error_none is treated as an invalid error type. + */ +void exception::throw_error(enum isl_error error, const char *msg, + const char *file, int line) +{ + switch (error) { + case isl_error_none: + break; + case isl_error_abort: throw exception_abort(msg, file, line); + case isl_error_alloc: throw exception_alloc(msg, file, line); + case isl_error_unknown: throw exception_unknown(msg, file, line); + case isl_error_internal: throw exception_internal(msg, file, line); + case isl_error_invalid: throw exception_invalid(msg, file, line); + case isl_error_quota: throw exception_quota(msg, file, line); + case isl_error_unsupported: + throw exception_unsupported(msg, file, line); + } + + throw exception_invalid("invalid error type", file, line); +} + +/* Throw an exception corresponding to the last error on "ctx" and + * reset the error. + * + * If "ctx" is NULL or if it is not in an error state at the start, + * then an invalid argument exception is thrown. + */ +void exception::throw_last_error(ctx ctx) +{ + enum isl_error error; + const char *msg, *file; + int line; + + error = isl_ctx_last_error(ctx.get()); + msg = isl_ctx_last_error_msg(ctx.get()); + file = isl_ctx_last_error_file(ctx.get()); + line = isl_ctx_last_error_line(ctx.get()); + isl_ctx_reset_error(ctx.get()); + + throw_error(error, msg, file, line); +} + +#else + +#include +#include + +class exception { +public: + /* Default behavior on error conditions that occur inside isl calls + * performed from inside the bindings. + * In the case exceptions are not available, isl should abort. + */ + static constexpr auto on_error = ISL_ON_ERROR_ABORT; + /* Wrapper for throwing an exception with the given message. + * In the case exceptions are not available, print an error and abort. + */ + static void throw_invalid(const char *msg, const char *file, int line) { + fprintf(stderr, "%s:%d: %s\n", file, line, msg); + abort(); + } + /* Throw an exception corresponding to the last + * error on "ctx". + * isl should already abort when an error condition occurs, + * so this function should never be called. + */ + static void throw_last_error(ctx ctx) { + abort(); + } +}; + +#endif + +/* Helper class for setting the on_error and resetting the option + * to the original value when leaving the scope. + */ +class options_scoped_set_on_error { + isl_ctx *ctx; + int saved_on_error; +public: + options_scoped_set_on_error(class ctx ctx, int on_error) { + this->ctx = ctx.get(); + saved_on_error = isl_options_get_on_error(this->ctx); + isl_options_set_on_error(this->ctx, on_error); + } + ~options_scoped_set_on_error() { + isl_options_set_on_error(ctx, saved_on_error); + } +}; + +} // namespace isl + +namespace isl { + +// forward declarations +class aff; +class aff_list; +class ast_build; +class ast_expr; +class ast_expr_id; +class ast_expr_int; +class ast_expr_op; +class ast_expr_op_access; +class ast_expr_op_add; +class ast_expr_op_address_of; +class ast_expr_op_and; +class ast_expr_op_and_then; +class ast_expr_op_call; +class ast_expr_op_cond; +class ast_expr_op_div; +class ast_expr_op_eq; +class ast_expr_op_fdiv_q; +class ast_expr_op_ge; +class ast_expr_op_gt; +class ast_expr_op_le; +class ast_expr_op_lt; +class ast_expr_op_max; +class ast_expr_op_member; +class ast_expr_op_min; +class ast_expr_op_minus; +class ast_expr_op_mul; +class ast_expr_op_or; +class ast_expr_op_or_else; +class ast_expr_op_pdiv_q; +class ast_expr_op_pdiv_r; +class ast_expr_op_select; +class ast_expr_op_sub; +class ast_expr_op_zdiv_r; +class ast_node; +class ast_node_block; +class ast_node_for; +class ast_node_if; +class ast_node_list; +class ast_node_mark; +class ast_node_user; +class basic_map; +class basic_set; +class fixed_box; +class id; +class id_list; +class map; +class multi_aff; +class multi_id; +class multi_pw_aff; +class multi_union_pw_aff; +class multi_val; +class point; +class pw_aff; +class pw_aff_list; +class pw_multi_aff; +class pw_multi_aff_list; +class schedule; +class schedule_constraints; +class schedule_node; +class schedule_node_band; +class schedule_node_context; +class schedule_node_domain; +class schedule_node_expansion; +class schedule_node_extension; +class schedule_node_filter; +class schedule_node_guard; +class schedule_node_leaf; +class schedule_node_mark; +class schedule_node_sequence; +class schedule_node_set; +class set; +class space; +class union_access_info; +class union_flow; +class union_map; +class union_pw_aff; +class union_pw_aff_list; +class union_pw_multi_aff; +class union_set; +class union_set_list; +class val; +class val_list; + +// declarations for isl::aff +inline aff manage(__isl_take isl_aff *ptr); +inline aff manage_copy(__isl_keep isl_aff *ptr); + +class aff { + friend inline aff manage(__isl_take isl_aff *ptr); + friend inline aff manage_copy(__isl_keep isl_aff *ptr); + +protected: + isl_aff *ptr = nullptr; + + inline explicit aff(__isl_take isl_aff *ptr); + +public: + inline /* implicit */ aff(); + inline /* implicit */ aff(const aff &obj); + inline explicit aff(isl::ctx ctx, const std::string &str); + inline aff &operator=(aff obj); + inline ~aff(); + inline __isl_give isl_aff *copy() const &; + inline __isl_give isl_aff *copy() && = delete; + inline __isl_keep isl_aff *get() const; + inline __isl_give isl_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::aff add(isl::aff aff2) const; + inline isl::aff add_constant(isl::val v) const; + inline isl::aff add_constant(long v) const; + inline isl::basic_set bind(isl::id id) const; + inline isl::basic_set bind(const std::string &id) const; + inline isl::aff ceil() const; + inline isl::aff div(isl::aff aff2) const; + inline isl::set eq_set(isl::aff aff2) const; + inline isl::val eval(isl::point pnt) const; + inline isl::aff floor() const; + inline isl::set ge_set(isl::aff aff2) const; + inline isl::aff gist(isl::set context) const; + inline isl::set gt_set(isl::aff aff2) const; + inline isl::set le_set(isl::aff aff2) const; + inline isl::set lt_set(isl::aff aff2) const; + inline isl::aff mod(isl::val mod) const; + inline isl::aff mod(long mod) const; + inline isl::aff mul(isl::aff aff2) const; + inline isl::set ne_set(isl::aff aff2) const; + inline isl::aff neg() const; + inline isl::aff pullback(isl::multi_aff ma) const; + inline isl::aff scale(isl::val v) const; + inline isl::aff scale(long v) const; + inline isl::aff scale_down(isl::val v) const; + inline isl::aff scale_down(long v) const; + inline isl::aff sub(isl::aff aff2) const; + inline isl::aff unbind_params_insert_domain(isl::multi_id domain) const; +}; + +// declarations for isl::aff_list +inline aff_list manage(__isl_take isl_aff_list *ptr); +inline aff_list manage_copy(__isl_keep isl_aff_list *ptr); + +class aff_list { + friend inline aff_list manage(__isl_take isl_aff_list *ptr); + friend inline aff_list manage_copy(__isl_keep isl_aff_list *ptr); + +protected: + isl_aff_list *ptr = nullptr; + + inline explicit aff_list(__isl_take isl_aff_list *ptr); + +public: + inline /* implicit */ aff_list(); + inline /* implicit */ aff_list(const aff_list &obj); + inline explicit aff_list(isl::ctx ctx, int n); + inline explicit aff_list(isl::aff el); + inline aff_list &operator=(aff_list obj); + inline ~aff_list(); + inline __isl_give isl_aff_list *copy() const &; + inline __isl_give isl_aff_list *copy() && = delete; + inline __isl_keep isl_aff_list *get() const; + inline __isl_give isl_aff_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::aff_list add(isl::aff el) const; + inline isl::aff_list clear() const; + inline isl::aff_list concat(isl::aff_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::aff at(int index) const; + inline isl::aff get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::ast_build +inline ast_build manage(__isl_take isl_ast_build *ptr); +inline ast_build manage_copy(__isl_keep isl_ast_build *ptr); + +class ast_build { + friend inline ast_build manage(__isl_take isl_ast_build *ptr); + friend inline ast_build manage_copy(__isl_keep isl_ast_build *ptr); + +protected: + isl_ast_build *ptr = nullptr; + + inline explicit ast_build(__isl_take isl_ast_build *ptr); + +public: + inline /* implicit */ ast_build(); + inline /* implicit */ ast_build(const ast_build &obj); + inline explicit ast_build(isl::ctx ctx); + inline ast_build &operator=(ast_build obj); + inline ~ast_build(); + inline __isl_give isl_ast_build *copy() const &; + inline __isl_give isl_ast_build *copy() && = delete; + inline __isl_keep isl_ast_build *get() const; + inline __isl_give isl_ast_build *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + +private: + inline ast_build ©_callbacks(const ast_build &obj); + struct at_each_domain_data { + std::function func; + std::exception_ptr eptr; + }; + std::shared_ptr at_each_domain_data; + static inline isl_ast_node *at_each_domain(isl_ast_node *arg_0, isl_ast_build *arg_1, void *arg_2); + inline void set_at_each_domain_data(const std::function &fn); +public: + inline isl::ast_build set_at_each_domain(const std::function &fn) const; + inline isl::ast_expr access_from(isl::multi_pw_aff mpa) const; + inline isl::ast_expr access_from(isl::pw_multi_aff pma) const; + inline isl::ast_expr call_from(isl::multi_pw_aff mpa) const; + inline isl::ast_expr call_from(isl::pw_multi_aff pma) const; + inline isl::ast_expr expr_from(isl::pw_aff pa) const; + inline isl::ast_expr expr_from(isl::set set) const; + static inline isl::ast_build from_context(isl::set set); + inline isl::union_map schedule() const; + inline isl::union_map get_schedule() const; + inline isl::ast_node node_from(isl::schedule schedule) const; + inline isl::ast_node node_from_schedule_map(isl::union_map schedule) const; +}; + +// declarations for isl::ast_expr +inline ast_expr manage(__isl_take isl_ast_expr *ptr); +inline ast_expr manage_copy(__isl_keep isl_ast_expr *ptr); + +class ast_expr { + friend inline ast_expr manage(__isl_take isl_ast_expr *ptr); + friend inline ast_expr manage_copy(__isl_keep isl_ast_expr *ptr); + +protected: + isl_ast_expr *ptr = nullptr; + + inline explicit ast_expr(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr(); + inline /* implicit */ ast_expr(const ast_expr &obj); + inline ast_expr &operator=(ast_expr obj); + inline ~ast_expr(); + inline __isl_give isl_ast_expr *copy() const &; + inline __isl_give isl_ast_expr *copy() && = delete; + inline __isl_keep isl_ast_expr *get() const; + inline __isl_give isl_ast_expr *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline bool isa_type(T subtype) const; +public: + template inline bool isa() const; + template inline T as() const; + inline isl::ctx ctx() const; + + inline std::string to_C_str() const; +}; + +// declarations for isl::ast_expr_id + +class ast_expr_id : public ast_expr { + template + friend bool ast_expr::isa() const; + friend ast_expr_id ast_expr::as() const; + static const auto type = isl_ast_expr_id; + +protected: + inline explicit ast_expr_id(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_id(); + inline /* implicit */ ast_expr_id(const ast_expr_id &obj); + inline ast_expr_id &operator=(ast_expr_id obj); + inline isl::ctx ctx() const; + + inline isl::id id() const; + inline isl::id get_id() const; +}; + +// declarations for isl::ast_expr_int + +class ast_expr_int : public ast_expr { + template + friend bool ast_expr::isa() const; + friend ast_expr_int ast_expr::as() const; + static const auto type = isl_ast_expr_int; + +protected: + inline explicit ast_expr_int(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_int(); + inline /* implicit */ ast_expr_int(const ast_expr_int &obj); + inline ast_expr_int &operator=(ast_expr_int obj); + inline isl::ctx ctx() const; + + inline isl::val val() const; + inline isl::val get_val() const; +}; + +// declarations for isl::ast_expr_op + +class ast_expr_op : public ast_expr { + template + friend bool ast_expr::isa() const; + friend ast_expr_op ast_expr::as() const; + static const auto type = isl_ast_expr_op; + +protected: + inline explicit ast_expr_op(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op(); + inline /* implicit */ ast_expr_op(const ast_expr_op &obj); + inline ast_expr_op &operator=(ast_expr_op obj); +private: + template ::value>::type> + inline bool isa_type(T subtype) const; +public: + template inline bool isa() const; + template inline T as() const; + inline isl::ctx ctx() const; + + inline isl::ast_expr arg(int pos) const; + inline isl::ast_expr get_arg(int pos) const; + inline unsigned n_arg() const; + inline unsigned get_n_arg() const; +}; + +// declarations for isl::ast_expr_op_access + +class ast_expr_op_access : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_access ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_access; + +protected: + inline explicit ast_expr_op_access(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_access(); + inline /* implicit */ ast_expr_op_access(const ast_expr_op_access &obj); + inline ast_expr_op_access &operator=(ast_expr_op_access obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_add + +class ast_expr_op_add : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_add ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_add; + +protected: + inline explicit ast_expr_op_add(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_add(); + inline /* implicit */ ast_expr_op_add(const ast_expr_op_add &obj); + inline ast_expr_op_add &operator=(ast_expr_op_add obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_address_of + +class ast_expr_op_address_of : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_address_of ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_address_of; + +protected: + inline explicit ast_expr_op_address_of(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_address_of(); + inline /* implicit */ ast_expr_op_address_of(const ast_expr_op_address_of &obj); + inline ast_expr_op_address_of &operator=(ast_expr_op_address_of obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_and + +class ast_expr_op_and : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_and ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_and; + +protected: + inline explicit ast_expr_op_and(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_and(); + inline /* implicit */ ast_expr_op_and(const ast_expr_op_and &obj); + inline ast_expr_op_and &operator=(ast_expr_op_and obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_and_then + +class ast_expr_op_and_then : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_and_then ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_and_then; + +protected: + inline explicit ast_expr_op_and_then(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_and_then(); + inline /* implicit */ ast_expr_op_and_then(const ast_expr_op_and_then &obj); + inline ast_expr_op_and_then &operator=(ast_expr_op_and_then obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_call + +class ast_expr_op_call : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_call ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_call; + +protected: + inline explicit ast_expr_op_call(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_call(); + inline /* implicit */ ast_expr_op_call(const ast_expr_op_call &obj); + inline ast_expr_op_call &operator=(ast_expr_op_call obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_cond + +class ast_expr_op_cond : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_cond ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_cond; + +protected: + inline explicit ast_expr_op_cond(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_cond(); + inline /* implicit */ ast_expr_op_cond(const ast_expr_op_cond &obj); + inline ast_expr_op_cond &operator=(ast_expr_op_cond obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_div + +class ast_expr_op_div : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_div ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_div; + +protected: + inline explicit ast_expr_op_div(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_div(); + inline /* implicit */ ast_expr_op_div(const ast_expr_op_div &obj); + inline ast_expr_op_div &operator=(ast_expr_op_div obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_eq + +class ast_expr_op_eq : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_eq ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_eq; + +protected: + inline explicit ast_expr_op_eq(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_eq(); + inline /* implicit */ ast_expr_op_eq(const ast_expr_op_eq &obj); + inline ast_expr_op_eq &operator=(ast_expr_op_eq obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_fdiv_q + +class ast_expr_op_fdiv_q : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_fdiv_q ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_fdiv_q; + +protected: + inline explicit ast_expr_op_fdiv_q(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_fdiv_q(); + inline /* implicit */ ast_expr_op_fdiv_q(const ast_expr_op_fdiv_q &obj); + inline ast_expr_op_fdiv_q &operator=(ast_expr_op_fdiv_q obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_ge + +class ast_expr_op_ge : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_ge ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_ge; + +protected: + inline explicit ast_expr_op_ge(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_ge(); + inline /* implicit */ ast_expr_op_ge(const ast_expr_op_ge &obj); + inline ast_expr_op_ge &operator=(ast_expr_op_ge obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_gt + +class ast_expr_op_gt : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_gt ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_gt; + +protected: + inline explicit ast_expr_op_gt(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_gt(); + inline /* implicit */ ast_expr_op_gt(const ast_expr_op_gt &obj); + inline ast_expr_op_gt &operator=(ast_expr_op_gt obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_le + +class ast_expr_op_le : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_le ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_le; + +protected: + inline explicit ast_expr_op_le(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_le(); + inline /* implicit */ ast_expr_op_le(const ast_expr_op_le &obj); + inline ast_expr_op_le &operator=(ast_expr_op_le obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_lt + +class ast_expr_op_lt : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_lt ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_lt; + +protected: + inline explicit ast_expr_op_lt(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_lt(); + inline /* implicit */ ast_expr_op_lt(const ast_expr_op_lt &obj); + inline ast_expr_op_lt &operator=(ast_expr_op_lt obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_max + +class ast_expr_op_max : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_max ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_max; + +protected: + inline explicit ast_expr_op_max(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_max(); + inline /* implicit */ ast_expr_op_max(const ast_expr_op_max &obj); + inline ast_expr_op_max &operator=(ast_expr_op_max obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_member + +class ast_expr_op_member : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_member ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_member; + +protected: + inline explicit ast_expr_op_member(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_member(); + inline /* implicit */ ast_expr_op_member(const ast_expr_op_member &obj); + inline ast_expr_op_member &operator=(ast_expr_op_member obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_min + +class ast_expr_op_min : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_min ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_min; + +protected: + inline explicit ast_expr_op_min(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_min(); + inline /* implicit */ ast_expr_op_min(const ast_expr_op_min &obj); + inline ast_expr_op_min &operator=(ast_expr_op_min obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_minus + +class ast_expr_op_minus : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_minus ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_minus; + +protected: + inline explicit ast_expr_op_minus(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_minus(); + inline /* implicit */ ast_expr_op_minus(const ast_expr_op_minus &obj); + inline ast_expr_op_minus &operator=(ast_expr_op_minus obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_mul + +class ast_expr_op_mul : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_mul ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_mul; + +protected: + inline explicit ast_expr_op_mul(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_mul(); + inline /* implicit */ ast_expr_op_mul(const ast_expr_op_mul &obj); + inline ast_expr_op_mul &operator=(ast_expr_op_mul obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_or + +class ast_expr_op_or : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_or ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_or; + +protected: + inline explicit ast_expr_op_or(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_or(); + inline /* implicit */ ast_expr_op_or(const ast_expr_op_or &obj); + inline ast_expr_op_or &operator=(ast_expr_op_or obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_or_else + +class ast_expr_op_or_else : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_or_else ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_or_else; + +protected: + inline explicit ast_expr_op_or_else(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_or_else(); + inline /* implicit */ ast_expr_op_or_else(const ast_expr_op_or_else &obj); + inline ast_expr_op_or_else &operator=(ast_expr_op_or_else obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_pdiv_q + +class ast_expr_op_pdiv_q : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_pdiv_q ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_pdiv_q; + +protected: + inline explicit ast_expr_op_pdiv_q(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_pdiv_q(); + inline /* implicit */ ast_expr_op_pdiv_q(const ast_expr_op_pdiv_q &obj); + inline ast_expr_op_pdiv_q &operator=(ast_expr_op_pdiv_q obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_pdiv_r + +class ast_expr_op_pdiv_r : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_pdiv_r ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_pdiv_r; + +protected: + inline explicit ast_expr_op_pdiv_r(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_pdiv_r(); + inline /* implicit */ ast_expr_op_pdiv_r(const ast_expr_op_pdiv_r &obj); + inline ast_expr_op_pdiv_r &operator=(ast_expr_op_pdiv_r obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_select + +class ast_expr_op_select : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_select ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_select; + +protected: + inline explicit ast_expr_op_select(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_select(); + inline /* implicit */ ast_expr_op_select(const ast_expr_op_select &obj); + inline ast_expr_op_select &operator=(ast_expr_op_select obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_sub + +class ast_expr_op_sub : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_sub ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_sub; + +protected: + inline explicit ast_expr_op_sub(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_sub(); + inline /* implicit */ ast_expr_op_sub(const ast_expr_op_sub &obj); + inline ast_expr_op_sub &operator=(ast_expr_op_sub obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_expr_op_zdiv_r + +class ast_expr_op_zdiv_r : public ast_expr_op { + template + friend bool ast_expr_op::isa() const; + friend ast_expr_op_zdiv_r ast_expr_op::as() const; + static const auto type = isl_ast_expr_op_zdiv_r; + +protected: + inline explicit ast_expr_op_zdiv_r(__isl_take isl_ast_expr *ptr); + +public: + inline /* implicit */ ast_expr_op_zdiv_r(); + inline /* implicit */ ast_expr_op_zdiv_r(const ast_expr_op_zdiv_r &obj); + inline ast_expr_op_zdiv_r &operator=(ast_expr_op_zdiv_r obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::ast_node +inline ast_node manage(__isl_take isl_ast_node *ptr); +inline ast_node manage_copy(__isl_keep isl_ast_node *ptr); + +class ast_node { + friend inline ast_node manage(__isl_take isl_ast_node *ptr); + friend inline ast_node manage_copy(__isl_keep isl_ast_node *ptr); + +protected: + isl_ast_node *ptr = nullptr; + + inline explicit ast_node(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node(); + inline /* implicit */ ast_node(const ast_node &obj); + inline ast_node &operator=(ast_node obj); + inline ~ast_node(); + inline __isl_give isl_ast_node *copy() const &; + inline __isl_give isl_ast_node *copy() && = delete; + inline __isl_keep isl_ast_node *get() const; + inline __isl_give isl_ast_node *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline bool isa_type(T subtype) const; +public: + template inline bool isa() const; + template inline T as() const; + inline isl::ctx ctx() const; + + inline std::string to_C_str() const; +}; + +// declarations for isl::ast_node_block + +class ast_node_block : public ast_node { + template + friend bool ast_node::isa() const; + friend ast_node_block ast_node::as() const; + static const auto type = isl_ast_node_block; + +protected: + inline explicit ast_node_block(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_block(); + inline /* implicit */ ast_node_block(const ast_node_block &obj); + inline ast_node_block &operator=(ast_node_block obj); + inline isl::ctx ctx() const; + + inline isl::ast_node_list children() const; + inline isl::ast_node_list get_children() const; +}; + +// declarations for isl::ast_node_for + +class ast_node_for : public ast_node { + template + friend bool ast_node::isa() const; + friend ast_node_for ast_node::as() const; + static const auto type = isl_ast_node_for; + +protected: + inline explicit ast_node_for(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_for(); + inline /* implicit */ ast_node_for(const ast_node_for &obj); + inline ast_node_for &operator=(ast_node_for obj); + inline isl::ctx ctx() const; + + inline isl::ast_node body() const; + inline isl::ast_node get_body() const; + inline isl::ast_expr cond() const; + inline isl::ast_expr get_cond() const; + inline isl::ast_expr inc() const; + inline isl::ast_expr get_inc() const; + inline isl::ast_expr init() const; + inline isl::ast_expr get_init() const; + inline isl::ast_expr iterator() const; + inline isl::ast_expr get_iterator() const; + inline bool is_degenerate() const; +}; + +// declarations for isl::ast_node_if + +class ast_node_if : public ast_node { + template + friend bool ast_node::isa() const; + friend ast_node_if ast_node::as() const; + static const auto type = isl_ast_node_if; + +protected: + inline explicit ast_node_if(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_if(); + inline /* implicit */ ast_node_if(const ast_node_if &obj); + inline ast_node_if &operator=(ast_node_if obj); + inline isl::ctx ctx() const; + + inline isl::ast_expr cond() const; + inline isl::ast_expr get_cond() const; + inline isl::ast_node else_node() const; + inline isl::ast_node get_else_node() const; + inline isl::ast_node then_node() const; + inline isl::ast_node get_then_node() const; + inline bool has_else_node() const; +}; + +// declarations for isl::ast_node_list +inline ast_node_list manage(__isl_take isl_ast_node_list *ptr); +inline ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr); + +class ast_node_list { + friend inline ast_node_list manage(__isl_take isl_ast_node_list *ptr); + friend inline ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr); + +protected: + isl_ast_node_list *ptr = nullptr; + + inline explicit ast_node_list(__isl_take isl_ast_node_list *ptr); + +public: + inline /* implicit */ ast_node_list(); + inline /* implicit */ ast_node_list(const ast_node_list &obj); + inline explicit ast_node_list(isl::ctx ctx, int n); + inline explicit ast_node_list(isl::ast_node el); + inline ast_node_list &operator=(ast_node_list obj); + inline ~ast_node_list(); + inline __isl_give isl_ast_node_list *copy() const &; + inline __isl_give isl_ast_node_list *copy() && = delete; + inline __isl_keep isl_ast_node_list *get() const; + inline __isl_give isl_ast_node_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::ast_node_list add(isl::ast_node el) const; + inline isl::ast_node_list clear() const; + inline isl::ast_node_list concat(isl::ast_node_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::ast_node at(int index) const; + inline isl::ast_node get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::ast_node_mark + +class ast_node_mark : public ast_node { + template + friend bool ast_node::isa() const; + friend ast_node_mark ast_node::as() const; + static const auto type = isl_ast_node_mark; + +protected: + inline explicit ast_node_mark(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_mark(); + inline /* implicit */ ast_node_mark(const ast_node_mark &obj); + inline ast_node_mark &operator=(ast_node_mark obj); + inline isl::ctx ctx() const; + + inline isl::id id() const; + inline isl::id get_id() const; + inline isl::ast_node node() const; + inline isl::ast_node get_node() const; +}; + +// declarations for isl::ast_node_user + +class ast_node_user : public ast_node { + template + friend bool ast_node::isa() const; + friend ast_node_user ast_node::as() const; + static const auto type = isl_ast_node_user; + +protected: + inline explicit ast_node_user(__isl_take isl_ast_node *ptr); + +public: + inline /* implicit */ ast_node_user(); + inline /* implicit */ ast_node_user(const ast_node_user &obj); + inline ast_node_user &operator=(ast_node_user obj); + inline isl::ctx ctx() const; + + inline isl::ast_expr expr() const; + inline isl::ast_expr get_expr() const; +}; + +// declarations for isl::basic_map +inline basic_map manage(__isl_take isl_basic_map *ptr); +inline basic_map manage_copy(__isl_keep isl_basic_map *ptr); + +class basic_map { + friend inline basic_map manage(__isl_take isl_basic_map *ptr); + friend inline basic_map manage_copy(__isl_keep isl_basic_map *ptr); + +protected: + isl_basic_map *ptr = nullptr; + + inline explicit basic_map(__isl_take isl_basic_map *ptr); + +public: + inline /* implicit */ basic_map(); + inline /* implicit */ basic_map(const basic_map &obj); + inline explicit basic_map(isl::ctx ctx, const std::string &str); + inline basic_map &operator=(basic_map obj); + inline ~basic_map(); + inline __isl_give isl_basic_map *copy() const &; + inline __isl_give isl_basic_map *copy() && = delete; + inline __isl_keep isl_basic_map *get() const; + inline __isl_give isl_basic_map *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::basic_map affine_hull() const; + inline isl::basic_map apply_domain(isl::basic_map bmap2) const; + inline isl::basic_map apply_range(isl::basic_map bmap2) const; + inline isl::basic_set deltas() const; + inline isl::basic_map detect_equalities() const; + inline isl::basic_map flatten() const; + inline isl::basic_map flatten_domain() const; + inline isl::basic_map flatten_range() const; + inline isl::basic_map gist(isl::basic_map context) const; + inline isl::basic_map intersect(isl::basic_map bmap2) const; + inline isl::basic_map intersect_domain(isl::basic_set bset) const; + inline isl::basic_map intersect_range(isl::basic_set bset) const; + inline bool is_empty() const; + inline bool is_equal(const isl::basic_map &bmap2) const; + inline bool is_subset(const isl::basic_map &bmap2) const; + inline isl::map lexmax() const; + inline isl::map lexmin() const; + inline isl::basic_map reverse() const; + inline isl::basic_map sample() const; + inline isl::map unite(isl::basic_map bmap2) const; +}; + +// declarations for isl::basic_set +inline basic_set manage(__isl_take isl_basic_set *ptr); +inline basic_set manage_copy(__isl_keep isl_basic_set *ptr); + +class basic_set { + friend inline basic_set manage(__isl_take isl_basic_set *ptr); + friend inline basic_set manage_copy(__isl_keep isl_basic_set *ptr); + +protected: + isl_basic_set *ptr = nullptr; + + inline explicit basic_set(__isl_take isl_basic_set *ptr); + +public: + inline /* implicit */ basic_set(); + inline /* implicit */ basic_set(const basic_set &obj); + inline /* implicit */ basic_set(isl::point pnt); + inline explicit basic_set(isl::ctx ctx, const std::string &str); + inline basic_set &operator=(basic_set obj); + inline ~basic_set(); + inline __isl_give isl_basic_set *copy() const &; + inline __isl_give isl_basic_set *copy() && = delete; + inline __isl_keep isl_basic_set *get() const; + inline __isl_give isl_basic_set *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::basic_set affine_hull() const; + inline isl::basic_set apply(isl::basic_map bmap) const; + inline isl::basic_set detect_equalities() const; + inline isl::val dim_max_val(int pos) const; + inline isl::basic_set flatten() const; + inline isl::basic_set gist(isl::basic_set context) const; + inline isl::basic_set intersect(isl::basic_set bset2) const; + inline isl::basic_set intersect_params(isl::basic_set bset2) const; + inline bool is_empty() const; + inline bool is_equal(const isl::basic_set &bset2) const; + inline bool is_subset(const isl::basic_set &bset2) const; + inline bool is_wrapping() const; + inline isl::set lexmax() const; + inline isl::set lexmin() const; + inline isl::basic_set params() const; + inline isl::basic_set sample() const; + inline isl::point sample_point() const; + inline isl::set unite(isl::basic_set bset2) const; +}; + +// declarations for isl::fixed_box +inline fixed_box manage(__isl_take isl_fixed_box *ptr); +inline fixed_box manage_copy(__isl_keep isl_fixed_box *ptr); + +class fixed_box { + friend inline fixed_box manage(__isl_take isl_fixed_box *ptr); + friend inline fixed_box manage_copy(__isl_keep isl_fixed_box *ptr); + +protected: + isl_fixed_box *ptr = nullptr; + + inline explicit fixed_box(__isl_take isl_fixed_box *ptr); + +public: + inline /* implicit */ fixed_box(); + inline /* implicit */ fixed_box(const fixed_box &obj); + inline fixed_box &operator=(fixed_box obj); + inline ~fixed_box(); + inline __isl_give isl_fixed_box *copy() const &; + inline __isl_give isl_fixed_box *copy() && = delete; + inline __isl_keep isl_fixed_box *get() const; + inline __isl_give isl_fixed_box *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_aff offset() const; + inline isl::multi_aff get_offset() const; + inline isl::multi_val size() const; + inline isl::multi_val get_size() const; + inline isl::space space() const; + inline isl::space get_space() const; + inline bool is_valid() const; +}; + +// declarations for isl::id +inline id manage(__isl_take isl_id *ptr); +inline id manage_copy(__isl_keep isl_id *ptr); + +class id { + friend inline id manage(__isl_take isl_id *ptr); + friend inline id manage_copy(__isl_keep isl_id *ptr); + +protected: + isl_id *ptr = nullptr; + + inline explicit id(__isl_take isl_id *ptr); + +public: + inline /* implicit */ id(); + inline /* implicit */ id(const id &obj); + inline explicit id(isl::ctx ctx, const std::string &str); + inline id &operator=(id obj); + inline ~id(); + inline __isl_give isl_id *copy() const &; + inline __isl_give isl_id *copy() && = delete; + inline __isl_keep isl_id *get() const; + inline __isl_give isl_id *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline std::string name() const; + inline std::string get_name() const; +}; + +// declarations for isl::id_list +inline id_list manage(__isl_take isl_id_list *ptr); +inline id_list manage_copy(__isl_keep isl_id_list *ptr); + +class id_list { + friend inline id_list manage(__isl_take isl_id_list *ptr); + friend inline id_list manage_copy(__isl_keep isl_id_list *ptr); + +protected: + isl_id_list *ptr = nullptr; + + inline explicit id_list(__isl_take isl_id_list *ptr); + +public: + inline /* implicit */ id_list(); + inline /* implicit */ id_list(const id_list &obj); + inline explicit id_list(isl::ctx ctx, int n); + inline explicit id_list(isl::id el); + inline id_list &operator=(id_list obj); + inline ~id_list(); + inline __isl_give isl_id_list *copy() const &; + inline __isl_give isl_id_list *copy() && = delete; + inline __isl_keep isl_id_list *get() const; + inline __isl_give isl_id_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::id_list add(isl::id el) const; + inline isl::id_list add(const std::string &el) const; + inline isl::id_list clear() const; + inline isl::id_list concat(isl::id_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::id at(int index) const; + inline isl::id get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::map +inline map manage(__isl_take isl_map *ptr); +inline map manage_copy(__isl_keep isl_map *ptr); + +class map { + friend inline map manage(__isl_take isl_map *ptr); + friend inline map manage_copy(__isl_keep isl_map *ptr); + +protected: + isl_map *ptr = nullptr; + + inline explicit map(__isl_take isl_map *ptr); + +public: + inline /* implicit */ map(); + inline /* implicit */ map(const map &obj); + inline /* implicit */ map(isl::basic_map bmap); + inline explicit map(isl::ctx ctx, const std::string &str); + inline map &operator=(map obj); + inline ~map(); + inline __isl_give isl_map *copy() const &; + inline __isl_give isl_map *copy() && = delete; + inline __isl_keep isl_map *get() const; + inline __isl_give isl_map *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::basic_map affine_hull() const; + inline isl::map apply_domain(isl::map map2) const; + inline isl::map apply_range(isl::map map2) const; + inline isl::set bind_domain(isl::multi_id tuple) const; + inline isl::set bind_range(isl::multi_id tuple) const; + inline isl::map coalesce() const; + inline isl::map complement() const; + inline isl::map curry() const; + inline isl::set deltas() const; + inline isl::map detect_equalities() const; + inline isl::set domain() const; + inline isl::map domain_factor_domain() const; + inline isl::map domain_factor_range() const; + inline isl::map domain_product(isl::map map2) const; + static inline isl::map empty(isl::space space); + inline isl::map factor_domain() const; + inline isl::map factor_range() const; + inline isl::map flatten() const; + inline isl::map flatten_domain() const; + inline isl::map flatten_range() const; + inline void foreach_basic_map(const std::function &fn) const; + inline isl::fixed_box range_simple_fixed_box_hull() const; + inline isl::fixed_box get_range_simple_fixed_box_hull() const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::map gist(isl::map context) const; + inline isl::map gist_domain(isl::set context) const; + inline isl::map intersect(isl::map map2) const; + inline isl::map intersect_domain(isl::set set) const; + inline isl::map intersect_params(isl::set params) const; + inline isl::map intersect_range(isl::set set) const; + inline bool is_bijective() const; + inline bool is_disjoint(const isl::map &map2) const; + inline bool is_empty() const; + inline bool is_equal(const isl::map &map2) const; + inline bool is_injective() const; + inline bool is_single_valued() const; + inline bool is_strict_subset(const isl::map &map2) const; + inline bool is_subset(const isl::map &map2) const; + inline isl::map lexmax() const; + inline isl::pw_multi_aff lexmax_pw_multi_aff() const; + inline isl::map lexmin() const; + inline isl::pw_multi_aff lexmin_pw_multi_aff() const; + inline isl::basic_map polyhedral_hull() const; + inline isl::map preimage_domain(isl::multi_aff ma) const; + inline isl::map preimage_domain(isl::multi_pw_aff mpa) const; + inline isl::map preimage_domain(isl::pw_multi_aff pma) const; + inline isl::map preimage_range(isl::multi_aff ma) const; + inline isl::map preimage_range(isl::pw_multi_aff pma) const; + inline isl::map project_out_all_params() const; + inline isl::set range() const; + inline isl::map range_factor_domain() const; + inline isl::map range_factor_range() const; + inline isl::map range_product(isl::map map2) const; + inline isl::map reverse() const; + inline isl::basic_map sample() const; + inline isl::map subtract(isl::map map2) const; + inline isl::map uncurry() const; + inline isl::map unite(isl::map map2) const; + static inline isl::map universe(isl::space space); + inline isl::basic_map unshifted_simple_hull() const; + inline isl::set wrap() const; +}; + +// declarations for isl::multi_aff +inline multi_aff manage(__isl_take isl_multi_aff *ptr); +inline multi_aff manage_copy(__isl_keep isl_multi_aff *ptr); + +class multi_aff { + friend inline multi_aff manage(__isl_take isl_multi_aff *ptr); + friend inline multi_aff manage_copy(__isl_keep isl_multi_aff *ptr); + +protected: + isl_multi_aff *ptr = nullptr; + + inline explicit multi_aff(__isl_take isl_multi_aff *ptr); + +public: + inline /* implicit */ multi_aff(); + inline /* implicit */ multi_aff(const multi_aff &obj); + inline /* implicit */ multi_aff(isl::aff aff); + inline explicit multi_aff(isl::space space, isl::aff_list list); + inline explicit multi_aff(isl::ctx ctx, const std::string &str); + inline multi_aff &operator=(multi_aff obj); + inline ~multi_aff(); + inline __isl_give isl_multi_aff *copy() const &; + inline __isl_give isl_multi_aff *copy() && = delete; + inline __isl_keep isl_multi_aff *get() const; + inline __isl_give isl_multi_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_aff add(isl::multi_aff multi2) const; + inline isl::basic_set bind(isl::multi_id tuple) const; + inline isl::multi_aff bind_domain(isl::multi_id tuple) const; + inline isl::multi_aff bind_domain_wrapped_domain(isl::multi_id tuple) const; + static inline isl::multi_aff domain_map(isl::space space); + inline isl::multi_aff flat_range_product(isl::multi_aff multi2) const; + inline isl::multi_aff floor() const; + inline isl::aff at(int pos) const; + inline isl::aff get_at(int pos) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::multi_aff gist(isl::set context) const; + inline isl::multi_aff identity() const; + static inline isl::multi_aff identity_on_domain(isl::space space); + inline bool involves_locals() const; + inline isl::multi_aff neg() const; + inline bool plain_is_equal(const isl::multi_aff &multi2) const; + inline isl::multi_aff product(isl::multi_aff multi2) const; + inline isl::multi_aff pullback(isl::multi_aff ma2) const; + static inline isl::multi_aff range_map(isl::space space); + inline isl::multi_aff range_product(isl::multi_aff multi2) const; + inline isl::multi_aff scale(isl::multi_val mv) const; + inline isl::multi_aff scale(isl::val v) const; + inline isl::multi_aff scale(long v) const; + inline isl::multi_aff scale_down(isl::multi_val mv) const; + inline isl::multi_aff scale_down(isl::val v) const; + inline isl::multi_aff scale_down(long v) const; + inline isl::multi_aff set_at(int pos, isl::aff el) const; + inline unsigned size() const; + inline isl::multi_aff sub(isl::multi_aff multi2) const; + static inline isl::multi_aff zero(isl::space space); +}; + +// declarations for isl::multi_id +inline multi_id manage(__isl_take isl_multi_id *ptr); +inline multi_id manage_copy(__isl_keep isl_multi_id *ptr); + +class multi_id { + friend inline multi_id manage(__isl_take isl_multi_id *ptr); + friend inline multi_id manage_copy(__isl_keep isl_multi_id *ptr); + +protected: + isl_multi_id *ptr = nullptr; + + inline explicit multi_id(__isl_take isl_multi_id *ptr); + +public: + inline /* implicit */ multi_id(); + inline /* implicit */ multi_id(const multi_id &obj); + inline explicit multi_id(isl::space space, isl::id_list list); + inline explicit multi_id(isl::ctx ctx, const std::string &str); + inline multi_id &operator=(multi_id obj); + inline ~multi_id(); + inline __isl_give isl_multi_id *copy() const &; + inline __isl_give isl_multi_id *copy() && = delete; + inline __isl_keep isl_multi_id *get() const; + inline __isl_give isl_multi_id *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_id flat_range_product(isl::multi_id multi2) const; + inline isl::id at(int pos) const; + inline isl::id get_at(int pos) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline bool plain_is_equal(const isl::multi_id &multi2) const; + inline isl::multi_id range_product(isl::multi_id multi2) const; + inline isl::multi_id set_at(int pos, isl::id el) const; + inline isl::multi_id set_at(int pos, const std::string &el) const; + inline unsigned size() const; +}; + +// declarations for isl::multi_pw_aff +inline multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr); +inline multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr); + +class multi_pw_aff { + friend inline multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr); + friend inline multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr); + +protected: + isl_multi_pw_aff *ptr = nullptr; + + inline explicit multi_pw_aff(__isl_take isl_multi_pw_aff *ptr); + +public: + inline /* implicit */ multi_pw_aff(); + inline /* implicit */ multi_pw_aff(const multi_pw_aff &obj); + inline /* implicit */ multi_pw_aff(isl::multi_aff ma); + inline /* implicit */ multi_pw_aff(isl::pw_aff pa); + inline explicit multi_pw_aff(isl::space space, isl::pw_aff_list list); + inline /* implicit */ multi_pw_aff(isl::pw_multi_aff pma); + inline explicit multi_pw_aff(isl::ctx ctx, const std::string &str); + inline multi_pw_aff &operator=(multi_pw_aff obj); + inline ~multi_pw_aff(); + inline __isl_give isl_multi_pw_aff *copy() const &; + inline __isl_give isl_multi_pw_aff *copy() && = delete; + inline __isl_keep isl_multi_pw_aff *get() const; + inline __isl_give isl_multi_pw_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_pw_aff add(isl::multi_pw_aff multi2) const; + inline isl::set bind(isl::multi_id tuple) const; + inline isl::multi_pw_aff bind_domain(isl::multi_id tuple) const; + inline isl::multi_pw_aff bind_domain_wrapped_domain(isl::multi_id tuple) const; + inline isl::set domain() const; + inline isl::multi_pw_aff flat_range_product(isl::multi_pw_aff multi2) const; + inline isl::pw_aff at(int pos) const; + inline isl::pw_aff get_at(int pos) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::multi_pw_aff gist(isl::set set) const; + inline isl::multi_pw_aff identity() const; + static inline isl::multi_pw_aff identity_on_domain(isl::space space); + inline isl::multi_pw_aff intersect_domain(isl::set domain) const; + inline isl::multi_pw_aff intersect_params(isl::set set) const; + inline bool involves_param(const isl::id &id) const; + inline bool involves_param(const std::string &id) const; + inline bool involves_param(const isl::id_list &list) const; + inline isl::multi_pw_aff neg() const; + inline bool plain_is_equal(const isl::multi_pw_aff &multi2) const; + inline isl::multi_pw_aff product(isl::multi_pw_aff multi2) const; + inline isl::multi_pw_aff pullback(isl::multi_aff ma) const; + inline isl::multi_pw_aff pullback(isl::multi_pw_aff mpa2) const; + inline isl::multi_pw_aff pullback(isl::pw_multi_aff pma) const; + inline isl::multi_pw_aff range_product(isl::multi_pw_aff multi2) const; + inline isl::multi_pw_aff scale(isl::multi_val mv) const; + inline isl::multi_pw_aff scale(isl::val v) const; + inline isl::multi_pw_aff scale(long v) const; + inline isl::multi_pw_aff scale_down(isl::multi_val mv) const; + inline isl::multi_pw_aff scale_down(isl::val v) const; + inline isl::multi_pw_aff scale_down(long v) const; + inline isl::multi_pw_aff set_at(int pos, isl::pw_aff el) const; + inline unsigned size() const; + inline isl::multi_pw_aff sub(isl::multi_pw_aff multi2) const; + static inline isl::multi_pw_aff zero(isl::space space); +}; + +// declarations for isl::multi_union_pw_aff +inline multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr); +inline multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr); + +class multi_union_pw_aff { + friend inline multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr); + friend inline multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr); + +protected: + isl_multi_union_pw_aff *ptr = nullptr; + + inline explicit multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *ptr); + +public: + inline /* implicit */ multi_union_pw_aff(); + inline /* implicit */ multi_union_pw_aff(const multi_union_pw_aff &obj); + inline /* implicit */ multi_union_pw_aff(isl::multi_pw_aff mpa); + inline /* implicit */ multi_union_pw_aff(isl::union_pw_aff upa); + inline explicit multi_union_pw_aff(isl::space space, isl::union_pw_aff_list list); + inline explicit multi_union_pw_aff(isl::ctx ctx, const std::string &str); + inline multi_union_pw_aff &operator=(multi_union_pw_aff obj); + inline ~multi_union_pw_aff(); + inline __isl_give isl_multi_union_pw_aff *copy() const &; + inline __isl_give isl_multi_union_pw_aff *copy() && = delete; + inline __isl_keep isl_multi_union_pw_aff *get() const; + inline __isl_give isl_multi_union_pw_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_union_pw_aff add(isl::multi_union_pw_aff multi2) const; + inline isl::union_set bind(isl::multi_id tuple) const; + inline isl::union_set domain() const; + inline isl::multi_union_pw_aff flat_range_product(isl::multi_union_pw_aff multi2) const; + inline isl::union_pw_aff at(int pos) const; + inline isl::union_pw_aff get_at(int pos) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::multi_union_pw_aff gist(isl::union_set context) const; + inline isl::multi_union_pw_aff intersect_domain(isl::union_set uset) const; + inline isl::multi_union_pw_aff intersect_params(isl::set params) const; + inline isl::multi_union_pw_aff neg() const; + inline bool plain_is_equal(const isl::multi_union_pw_aff &multi2) const; + inline isl::multi_union_pw_aff pullback(isl::union_pw_multi_aff upma) const; + inline isl::multi_union_pw_aff range_product(isl::multi_union_pw_aff multi2) const; + inline isl::multi_union_pw_aff scale(isl::multi_val mv) const; + inline isl::multi_union_pw_aff scale(isl::val v) const; + inline isl::multi_union_pw_aff scale(long v) const; + inline isl::multi_union_pw_aff scale_down(isl::multi_val mv) const; + inline isl::multi_union_pw_aff scale_down(isl::val v) const; + inline isl::multi_union_pw_aff scale_down(long v) const; + inline isl::multi_union_pw_aff set_at(int pos, isl::union_pw_aff el) const; + inline unsigned size() const; + inline isl::multi_union_pw_aff sub(isl::multi_union_pw_aff multi2) const; + inline isl::multi_union_pw_aff union_add(isl::multi_union_pw_aff mupa2) const; + static inline isl::multi_union_pw_aff zero(isl::space space); +}; + +// declarations for isl::multi_val +inline multi_val manage(__isl_take isl_multi_val *ptr); +inline multi_val manage_copy(__isl_keep isl_multi_val *ptr); + +class multi_val { + friend inline multi_val manage(__isl_take isl_multi_val *ptr); + friend inline multi_val manage_copy(__isl_keep isl_multi_val *ptr); + +protected: + isl_multi_val *ptr = nullptr; + + inline explicit multi_val(__isl_take isl_multi_val *ptr); + +public: + inline /* implicit */ multi_val(); + inline /* implicit */ multi_val(const multi_val &obj); + inline explicit multi_val(isl::space space, isl::val_list list); + inline explicit multi_val(isl::ctx ctx, const std::string &str); + inline multi_val &operator=(multi_val obj); + inline ~multi_val(); + inline __isl_give isl_multi_val *copy() const &; + inline __isl_give isl_multi_val *copy() && = delete; + inline __isl_keep isl_multi_val *get() const; + inline __isl_give isl_multi_val *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::multi_val add(isl::multi_val multi2) const; + inline isl::multi_val add(isl::val v) const; + inline isl::multi_val add(long v) const; + inline isl::multi_val flat_range_product(isl::multi_val multi2) const; + inline isl::val at(int pos) const; + inline isl::val get_at(int pos) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::multi_val neg() const; + inline bool plain_is_equal(const isl::multi_val &multi2) const; + inline isl::multi_val product(isl::multi_val multi2) const; + inline isl::multi_val range_product(isl::multi_val multi2) const; + inline isl::multi_val scale(isl::multi_val mv) const; + inline isl::multi_val scale(isl::val v) const; + inline isl::multi_val scale(long v) const; + inline isl::multi_val scale_down(isl::multi_val mv) const; + inline isl::multi_val scale_down(isl::val v) const; + inline isl::multi_val scale_down(long v) const; + inline isl::multi_val set_at(int pos, isl::val el) const; + inline isl::multi_val set_at(int pos, long el) const; + inline unsigned size() const; + inline isl::multi_val sub(isl::multi_val multi2) const; + static inline isl::multi_val zero(isl::space space); +}; + +// declarations for isl::point +inline point manage(__isl_take isl_point *ptr); +inline point manage_copy(__isl_keep isl_point *ptr); + +class point { + friend inline point manage(__isl_take isl_point *ptr); + friend inline point manage_copy(__isl_keep isl_point *ptr); + +protected: + isl_point *ptr = nullptr; + + inline explicit point(__isl_take isl_point *ptr); + +public: + inline /* implicit */ point(); + inline /* implicit */ point(const point &obj); + inline point &operator=(point obj); + inline ~point(); + inline __isl_give isl_point *copy() const &; + inline __isl_give isl_point *copy() && = delete; + inline __isl_keep isl_point *get() const; + inline __isl_give isl_point *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + +}; + +// declarations for isl::pw_aff +inline pw_aff manage(__isl_take isl_pw_aff *ptr); +inline pw_aff manage_copy(__isl_keep isl_pw_aff *ptr); + +class pw_aff { + friend inline pw_aff manage(__isl_take isl_pw_aff *ptr); + friend inline pw_aff manage_copy(__isl_keep isl_pw_aff *ptr); + +protected: + isl_pw_aff *ptr = nullptr; + + inline explicit pw_aff(__isl_take isl_pw_aff *ptr); + +public: + inline /* implicit */ pw_aff(); + inline /* implicit */ pw_aff(const pw_aff &obj); + inline /* implicit */ pw_aff(isl::aff aff); + inline explicit pw_aff(isl::ctx ctx, const std::string &str); + inline pw_aff &operator=(pw_aff obj); + inline ~pw_aff(); + inline __isl_give isl_pw_aff *copy() const &; + inline __isl_give isl_pw_aff *copy() && = delete; + inline __isl_keep isl_pw_aff *get() const; + inline __isl_give isl_pw_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::pw_aff add(isl::pw_aff pwaff2) const; + inline isl::aff as_aff() const; + inline isl::set bind(isl::id id) const; + inline isl::set bind(const std::string &id) const; + inline isl::pw_aff bind_domain(isl::multi_id tuple) const; + inline isl::pw_aff bind_domain_wrapped_domain(isl::multi_id tuple) const; + inline isl::pw_aff ceil() const; + inline isl::pw_aff cond(isl::pw_aff pwaff_true, isl::pw_aff pwaff_false) const; + inline isl::pw_aff div(isl::pw_aff pa2) const; + inline isl::set domain() const; + inline isl::set eq_set(isl::pw_aff pwaff2) const; + inline isl::val eval(isl::point pnt) const; + inline isl::pw_aff floor() const; + inline isl::set ge_set(isl::pw_aff pwaff2) const; + inline isl::pw_aff gist(isl::set context) const; + inline isl::set gt_set(isl::pw_aff pwaff2) const; + inline isl::pw_aff intersect_domain(isl::set set) const; + inline isl::pw_aff intersect_params(isl::set set) const; + inline bool isa_aff() const; + inline isl::set le_set(isl::pw_aff pwaff2) const; + inline isl::set lt_set(isl::pw_aff pwaff2) const; + inline isl::pw_aff max(isl::pw_aff pwaff2) const; + inline isl::pw_aff min(isl::pw_aff pwaff2) const; + inline isl::pw_aff mod(isl::val mod) const; + inline isl::pw_aff mod(long mod) const; + inline isl::pw_aff mul(isl::pw_aff pwaff2) const; + inline isl::set ne_set(isl::pw_aff pwaff2) const; + inline isl::pw_aff neg() const; + static inline isl::pw_aff param_on_domain(isl::set domain, isl::id id); + inline isl::pw_aff pullback(isl::multi_aff ma) const; + inline isl::pw_aff pullback(isl::multi_pw_aff mpa) const; + inline isl::pw_aff pullback(isl::pw_multi_aff pma) const; + inline isl::pw_aff scale(isl::val v) const; + inline isl::pw_aff scale(long v) const; + inline isl::pw_aff scale_down(isl::val f) const; + inline isl::pw_aff scale_down(long f) const; + inline isl::pw_aff sub(isl::pw_aff pwaff2) const; + inline isl::pw_aff subtract_domain(isl::set set) const; + inline isl::pw_aff tdiv_q(isl::pw_aff pa2) const; + inline isl::pw_aff tdiv_r(isl::pw_aff pa2) const; + inline isl::pw_aff union_add(isl::pw_aff pwaff2) const; +}; + +// declarations for isl::pw_aff_list +inline pw_aff_list manage(__isl_take isl_pw_aff_list *ptr); +inline pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr); + +class pw_aff_list { + friend inline pw_aff_list manage(__isl_take isl_pw_aff_list *ptr); + friend inline pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr); + +protected: + isl_pw_aff_list *ptr = nullptr; + + inline explicit pw_aff_list(__isl_take isl_pw_aff_list *ptr); + +public: + inline /* implicit */ pw_aff_list(); + inline /* implicit */ pw_aff_list(const pw_aff_list &obj); + inline explicit pw_aff_list(isl::ctx ctx, int n); + inline explicit pw_aff_list(isl::pw_aff el); + inline pw_aff_list &operator=(pw_aff_list obj); + inline ~pw_aff_list(); + inline __isl_give isl_pw_aff_list *copy() const &; + inline __isl_give isl_pw_aff_list *copy() && = delete; + inline __isl_keep isl_pw_aff_list *get() const; + inline __isl_give isl_pw_aff_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::pw_aff_list add(isl::pw_aff el) const; + inline isl::pw_aff_list clear() const; + inline isl::pw_aff_list concat(isl::pw_aff_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::pw_aff at(int index) const; + inline isl::pw_aff get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::pw_multi_aff +inline pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr); +inline pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr); + +class pw_multi_aff { + friend inline pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr); + friend inline pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr); + +protected: + isl_pw_multi_aff *ptr = nullptr; + + inline explicit pw_multi_aff(__isl_take isl_pw_multi_aff *ptr); + +public: + inline /* implicit */ pw_multi_aff(); + inline /* implicit */ pw_multi_aff(const pw_multi_aff &obj); + inline /* implicit */ pw_multi_aff(isl::multi_aff ma); + inline /* implicit */ pw_multi_aff(isl::pw_aff pa); + inline explicit pw_multi_aff(isl::ctx ctx, const std::string &str); + inline pw_multi_aff &operator=(pw_multi_aff obj); + inline ~pw_multi_aff(); + inline __isl_give isl_pw_multi_aff *copy() const &; + inline __isl_give isl_pw_multi_aff *copy() && = delete; + inline __isl_keep isl_pw_multi_aff *get() const; + inline __isl_give isl_pw_multi_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::pw_multi_aff add(isl::pw_multi_aff pma2) const; + inline isl::multi_aff as_multi_aff() const; + inline isl::pw_multi_aff bind_domain(isl::multi_id tuple) const; + inline isl::pw_multi_aff bind_domain_wrapped_domain(isl::multi_id tuple) const; + inline isl::set domain() const; + inline isl::pw_multi_aff flat_range_product(isl::pw_multi_aff pma2) const; + inline void foreach_piece(const std::function &fn) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::pw_multi_aff gist(isl::set set) const; + inline isl::pw_multi_aff intersect_domain(isl::set set) const; + inline isl::pw_multi_aff intersect_params(isl::set set) const; + inline bool isa_multi_aff() const; + inline unsigned n_piece() const; + inline isl::pw_multi_aff product(isl::pw_multi_aff pma2) const; + inline isl::pw_multi_aff pullback(isl::multi_aff ma) const; + inline isl::pw_multi_aff pullback(isl::pw_multi_aff pma2) const; + inline isl::pw_multi_aff range_factor_domain() const; + inline isl::pw_multi_aff range_factor_range() const; + inline isl::pw_multi_aff range_product(isl::pw_multi_aff pma2) const; + inline isl::pw_multi_aff scale(isl::val v) const; + inline isl::pw_multi_aff scale(long v) const; + inline isl::pw_multi_aff scale_down(isl::val v) const; + inline isl::pw_multi_aff scale_down(long v) const; + inline isl::pw_multi_aff sub(isl::pw_multi_aff pma2) const; + inline isl::pw_multi_aff subtract_domain(isl::set set) const; + inline isl::pw_multi_aff union_add(isl::pw_multi_aff pma2) const; + static inline isl::pw_multi_aff zero(isl::space space); +}; + +// declarations for isl::pw_multi_aff_list +inline pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr); +inline pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr); + +class pw_multi_aff_list { + friend inline pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr); + friend inline pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr); + +protected: + isl_pw_multi_aff_list *ptr = nullptr; + + inline explicit pw_multi_aff_list(__isl_take isl_pw_multi_aff_list *ptr); + +public: + inline /* implicit */ pw_multi_aff_list(); + inline /* implicit */ pw_multi_aff_list(const pw_multi_aff_list &obj); + inline explicit pw_multi_aff_list(isl::ctx ctx, int n); + inline explicit pw_multi_aff_list(isl::pw_multi_aff el); + inline pw_multi_aff_list &operator=(pw_multi_aff_list obj); + inline ~pw_multi_aff_list(); + inline __isl_give isl_pw_multi_aff_list *copy() const &; + inline __isl_give isl_pw_multi_aff_list *copy() && = delete; + inline __isl_keep isl_pw_multi_aff_list *get() const; + inline __isl_give isl_pw_multi_aff_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::pw_multi_aff_list add(isl::pw_multi_aff el) const; + inline isl::pw_multi_aff_list clear() const; + inline isl::pw_multi_aff_list concat(isl::pw_multi_aff_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::pw_multi_aff at(int index) const; + inline isl::pw_multi_aff get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::schedule +inline schedule manage(__isl_take isl_schedule *ptr); +inline schedule manage_copy(__isl_keep isl_schedule *ptr); + +class schedule { + friend inline schedule manage(__isl_take isl_schedule *ptr); + friend inline schedule manage_copy(__isl_keep isl_schedule *ptr); + +protected: + isl_schedule *ptr = nullptr; + + inline explicit schedule(__isl_take isl_schedule *ptr); + +public: + inline /* implicit */ schedule(); + inline /* implicit */ schedule(const schedule &obj); + inline explicit schedule(isl::ctx ctx, const std::string &str); + inline schedule &operator=(schedule obj); + inline ~schedule(); + inline __isl_give isl_schedule *copy() const &; + inline __isl_give isl_schedule *copy() && = delete; + inline __isl_keep isl_schedule *get() const; + inline __isl_give isl_schedule *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + static inline isl::schedule from_domain(isl::union_set domain); + inline isl::union_map map() const; + inline isl::union_map get_map() const; + inline isl::schedule_node root() const; + inline isl::schedule_node get_root() const; + inline isl::schedule pullback(isl::union_pw_multi_aff upma) const; +}; + +// declarations for isl::schedule_constraints +inline schedule_constraints manage(__isl_take isl_schedule_constraints *ptr); +inline schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr); + +class schedule_constraints { + friend inline schedule_constraints manage(__isl_take isl_schedule_constraints *ptr); + friend inline schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr); + +protected: + isl_schedule_constraints *ptr = nullptr; + + inline explicit schedule_constraints(__isl_take isl_schedule_constraints *ptr); + +public: + inline /* implicit */ schedule_constraints(); + inline /* implicit */ schedule_constraints(const schedule_constraints &obj); + inline explicit schedule_constraints(isl::ctx ctx, const std::string &str); + inline schedule_constraints &operator=(schedule_constraints obj); + inline ~schedule_constraints(); + inline __isl_give isl_schedule_constraints *copy() const &; + inline __isl_give isl_schedule_constraints *copy() && = delete; + inline __isl_keep isl_schedule_constraints *get() const; + inline __isl_give isl_schedule_constraints *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::schedule compute_schedule() const; + inline isl::union_map coincidence() const; + inline isl::union_map get_coincidence() const; + inline isl::union_map conditional_validity() const; + inline isl::union_map get_conditional_validity() const; + inline isl::union_map conditional_validity_condition() const; + inline isl::union_map get_conditional_validity_condition() const; + inline isl::set context() const; + inline isl::set get_context() const; + inline isl::union_set domain() const; + inline isl::union_set get_domain() const; + inline isl::union_map proximity() const; + inline isl::union_map get_proximity() const; + inline isl::union_map validity() const; + inline isl::union_map get_validity() const; + static inline isl::schedule_constraints on_domain(isl::union_set domain); + inline isl::schedule_constraints set_coincidence(isl::union_map coincidence) const; + inline isl::schedule_constraints set_conditional_validity(isl::union_map condition, isl::union_map validity) const; + inline isl::schedule_constraints set_context(isl::set context) const; + inline isl::schedule_constraints set_proximity(isl::union_map proximity) const; + inline isl::schedule_constraints set_validity(isl::union_map validity) const; +}; + +// declarations for isl::schedule_node +inline schedule_node manage(__isl_take isl_schedule_node *ptr); +inline schedule_node manage_copy(__isl_keep isl_schedule_node *ptr); + +class schedule_node { + friend inline schedule_node manage(__isl_take isl_schedule_node *ptr); + friend inline schedule_node manage_copy(__isl_keep isl_schedule_node *ptr); + +protected: + isl_schedule_node *ptr = nullptr; + + inline explicit schedule_node(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node(); + inline /* implicit */ schedule_node(const schedule_node &obj); + inline schedule_node &operator=(schedule_node obj); + inline ~schedule_node(); + inline __isl_give isl_schedule_node *copy() const &; + inline __isl_give isl_schedule_node *copy() && = delete; + inline __isl_keep isl_schedule_node *get() const; + inline __isl_give isl_schedule_node *release(); + inline bool is_null() const; +private: + template ::value>::type> + inline bool isa_type(T subtype) const; +public: + template inline bool isa() const; + template inline T as() const; + inline isl::ctx ctx() const; + + inline isl::schedule_node ancestor(int generation) const; + inline isl::schedule_node child(int pos) const; + inline bool every_descendant(const std::function &test) const; + inline isl::schedule_node first_child() const; + inline void foreach_ancestor_top_down(const std::function &fn) const; + inline void foreach_descendant_top_down(const std::function &fn) const; + static inline isl::schedule_node from_domain(isl::union_set domain); + static inline isl::schedule_node from_extension(isl::union_map extension); + inline unsigned ancestor_child_position(const isl::schedule_node &ancestor) const; + inline unsigned get_ancestor_child_position(const isl::schedule_node &ancestor) const; + inline unsigned child_position() const; + inline unsigned get_child_position() const; + inline isl::multi_union_pw_aff prefix_schedule_multi_union_pw_aff() const; + inline isl::multi_union_pw_aff get_prefix_schedule_multi_union_pw_aff() const; + inline isl::union_map prefix_schedule_union_map() const; + inline isl::union_map get_prefix_schedule_union_map() const; + inline isl::union_pw_multi_aff prefix_schedule_union_pw_multi_aff() const; + inline isl::union_pw_multi_aff get_prefix_schedule_union_pw_multi_aff() const; + inline isl::schedule schedule() const; + inline isl::schedule get_schedule() const; + inline isl::schedule_node shared_ancestor(const isl::schedule_node &node2) const; + inline isl::schedule_node get_shared_ancestor(const isl::schedule_node &node2) const; + inline unsigned tree_depth() const; + inline unsigned get_tree_depth() const; + inline isl::schedule_node graft_after(isl::schedule_node graft) const; + inline isl::schedule_node graft_before(isl::schedule_node graft) const; + inline bool has_children() const; + inline bool has_next_sibling() const; + inline bool has_parent() const; + inline bool has_previous_sibling() const; + inline isl::schedule_node insert_context(isl::set context) const; + inline isl::schedule_node insert_filter(isl::union_set filter) const; + inline isl::schedule_node insert_guard(isl::set context) const; + inline isl::schedule_node insert_mark(isl::id mark) const; + inline isl::schedule_node insert_mark(const std::string &mark) const; + inline isl::schedule_node insert_partial_schedule(isl::multi_union_pw_aff schedule) const; + inline isl::schedule_node insert_sequence(isl::union_set_list filters) const; + inline isl::schedule_node insert_set(isl::union_set_list filters) const; + inline bool is_equal(const isl::schedule_node &node2) const; + inline bool is_subtree_anchored() const; + inline isl::schedule_node map_descendant_bottom_up(const std::function &fn) const; + inline unsigned n_children() const; + inline isl::schedule_node next_sibling() const; + inline isl::schedule_node order_after(isl::union_set filter) const; + inline isl::schedule_node order_before(isl::union_set filter) const; + inline isl::schedule_node parent() const; + inline isl::schedule_node previous_sibling() const; + inline isl::schedule_node root() const; +}; + +// declarations for isl::schedule_node_band + +class schedule_node_band : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_band schedule_node::as() const; + static const auto type = isl_schedule_node_band; + +protected: + inline explicit schedule_node_band(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_band(); + inline /* implicit */ schedule_node_band(const schedule_node_band &obj); + inline schedule_node_band &operator=(schedule_node_band obj); + inline isl::ctx ctx() const; + + inline isl::union_set ast_build_options() const; + inline isl::union_set get_ast_build_options() const; + inline isl::set ast_isolate_option() const; + inline isl::set get_ast_isolate_option() const; + inline isl::multi_union_pw_aff partial_schedule() const; + inline isl::multi_union_pw_aff get_partial_schedule() const; + inline bool permutable() const; + inline bool get_permutable() const; + inline bool member_get_coincident(int pos) const; + inline schedule_node_band member_set_coincident(int pos, int coincident) const; + inline schedule_node_band mod(isl::multi_val mv) const; + inline unsigned n_member() const; + inline schedule_node_band scale(isl::multi_val mv) const; + inline schedule_node_band scale_down(isl::multi_val mv) const; + inline schedule_node_band set_ast_build_options(isl::union_set options) const; + inline schedule_node_band set_permutable(int permutable) const; + inline schedule_node_band shift(isl::multi_union_pw_aff shift) const; + inline schedule_node_band split(int pos) const; + inline schedule_node_band tile(isl::multi_val sizes) const; + inline schedule_node_band member_set_ast_loop_default(int pos) const; + inline schedule_node_band member_set_ast_loop_atomic(int pos) const; + inline schedule_node_band member_set_ast_loop_unroll(int pos) const; + inline schedule_node_band member_set_ast_loop_separate(int pos) const; +}; + +// declarations for isl::schedule_node_context + +class schedule_node_context : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_context schedule_node::as() const; + static const auto type = isl_schedule_node_context; + +protected: + inline explicit schedule_node_context(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_context(); + inline /* implicit */ schedule_node_context(const schedule_node_context &obj); + inline schedule_node_context &operator=(schedule_node_context obj); + inline isl::ctx ctx() const; + + inline isl::set context() const; + inline isl::set get_context() const; +}; + +// declarations for isl::schedule_node_domain + +class schedule_node_domain : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_domain schedule_node::as() const; + static const auto type = isl_schedule_node_domain; + +protected: + inline explicit schedule_node_domain(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_domain(); + inline /* implicit */ schedule_node_domain(const schedule_node_domain &obj); + inline schedule_node_domain &operator=(schedule_node_domain obj); + inline isl::ctx ctx() const; + + inline isl::union_set domain() const; + inline isl::union_set get_domain() const; +}; + +// declarations for isl::schedule_node_expansion + +class schedule_node_expansion : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_expansion schedule_node::as() const; + static const auto type = isl_schedule_node_expansion; + +protected: + inline explicit schedule_node_expansion(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_expansion(); + inline /* implicit */ schedule_node_expansion(const schedule_node_expansion &obj); + inline schedule_node_expansion &operator=(schedule_node_expansion obj); + inline isl::ctx ctx() const; + + inline isl::union_pw_multi_aff contraction() const; + inline isl::union_pw_multi_aff get_contraction() const; + inline isl::union_map expansion() const; + inline isl::union_map get_expansion() const; +}; + +// declarations for isl::schedule_node_extension + +class schedule_node_extension : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_extension schedule_node::as() const; + static const auto type = isl_schedule_node_extension; + +protected: + inline explicit schedule_node_extension(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_extension(); + inline /* implicit */ schedule_node_extension(const schedule_node_extension &obj); + inline schedule_node_extension &operator=(schedule_node_extension obj); + inline isl::ctx ctx() const; + + inline isl::union_map extension() const; + inline isl::union_map get_extension() const; +}; + +// declarations for isl::schedule_node_filter + +class schedule_node_filter : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_filter schedule_node::as() const; + static const auto type = isl_schedule_node_filter; + +protected: + inline explicit schedule_node_filter(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_filter(); + inline /* implicit */ schedule_node_filter(const schedule_node_filter &obj); + inline schedule_node_filter &operator=(schedule_node_filter obj); + inline isl::ctx ctx() const; + + inline isl::union_set filter() const; + inline isl::union_set get_filter() const; +}; + +// declarations for isl::schedule_node_guard + +class schedule_node_guard : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_guard schedule_node::as() const; + static const auto type = isl_schedule_node_guard; + +protected: + inline explicit schedule_node_guard(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_guard(); + inline /* implicit */ schedule_node_guard(const schedule_node_guard &obj); + inline schedule_node_guard &operator=(schedule_node_guard obj); + inline isl::ctx ctx() const; + + inline isl::set guard() const; + inline isl::set get_guard() const; +}; + +// declarations for isl::schedule_node_leaf + +class schedule_node_leaf : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_leaf schedule_node::as() const; + static const auto type = isl_schedule_node_leaf; + +protected: + inline explicit schedule_node_leaf(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_leaf(); + inline /* implicit */ schedule_node_leaf(const schedule_node_leaf &obj); + inline schedule_node_leaf &operator=(schedule_node_leaf obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_mark + +class schedule_node_mark : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_mark schedule_node::as() const; + static const auto type = isl_schedule_node_mark; + +protected: + inline explicit schedule_node_mark(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_mark(); + inline /* implicit */ schedule_node_mark(const schedule_node_mark &obj); + inline schedule_node_mark &operator=(schedule_node_mark obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_sequence + +class schedule_node_sequence : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_sequence schedule_node::as() const; + static const auto type = isl_schedule_node_sequence; + +protected: + inline explicit schedule_node_sequence(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_sequence(); + inline /* implicit */ schedule_node_sequence(const schedule_node_sequence &obj); + inline schedule_node_sequence &operator=(schedule_node_sequence obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::schedule_node_set + +class schedule_node_set : public schedule_node { + template + friend bool schedule_node::isa() const; + friend schedule_node_set schedule_node::as() const; + static const auto type = isl_schedule_node_set; + +protected: + inline explicit schedule_node_set(__isl_take isl_schedule_node *ptr); + +public: + inline /* implicit */ schedule_node_set(); + inline /* implicit */ schedule_node_set(const schedule_node_set &obj); + inline schedule_node_set &operator=(schedule_node_set obj); + inline isl::ctx ctx() const; + +}; + +// declarations for isl::set +inline set manage(__isl_take isl_set *ptr); +inline set manage_copy(__isl_keep isl_set *ptr); + +class set { + friend inline set manage(__isl_take isl_set *ptr); + friend inline set manage_copy(__isl_keep isl_set *ptr); + +protected: + isl_set *ptr = nullptr; + + inline explicit set(__isl_take isl_set *ptr); + +public: + inline /* implicit */ set(); + inline /* implicit */ set(const set &obj); + inline /* implicit */ set(isl::basic_set bset); + inline /* implicit */ set(isl::point pnt); + inline explicit set(isl::ctx ctx, const std::string &str); + inline set &operator=(set obj); + inline ~set(); + inline __isl_give isl_set *copy() const &; + inline __isl_give isl_set *copy() && = delete; + inline __isl_keep isl_set *get() const; + inline __isl_give isl_set *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::basic_set affine_hull() const; + inline isl::set apply(isl::map map) const; + inline isl::set bind(isl::multi_id tuple) const; + inline isl::set coalesce() const; + inline isl::set complement() const; + inline isl::set detect_equalities() const; + static inline isl::set empty(isl::space space); + inline isl::set flatten() const; + inline void foreach_basic_set(const std::function &fn) const; + inline void foreach_point(const std::function &fn) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::val stride(int pos) const; + inline isl::val get_stride(int pos) const; + inline isl::set gist(isl::set context) const; + inline isl::map identity() const; + inline isl::set intersect(isl::set set2) const; + inline isl::set intersect_params(isl::set params) const; + inline bool is_disjoint(const isl::set &set2) const; + inline bool is_empty() const; + inline bool is_equal(const isl::set &set2) const; + inline bool is_singleton() const; + inline bool is_strict_subset(const isl::set &set2) const; + inline bool is_subset(const isl::set &set2) const; + inline bool is_wrapping() const; + inline isl::set lexmax() const; + inline isl::pw_multi_aff lexmax_pw_multi_aff() const; + inline isl::set lexmin() const; + inline isl::pw_multi_aff lexmin_pw_multi_aff() const; + inline isl::val max_val(const isl::aff &obj) const; + inline isl::val min_val(const isl::aff &obj) const; + inline isl::set params() const; + inline isl::basic_set polyhedral_hull() const; + inline isl::set preimage(isl::multi_aff ma) const; + inline isl::set preimage(isl::multi_pw_aff mpa) const; + inline isl::set preimage(isl::pw_multi_aff pma) const; + inline isl::set product(isl::set set2) const; + inline isl::set project_out_all_params() const; + inline isl::set project_out_param(isl::id id) const; + inline isl::set project_out_param(const std::string &id) const; + inline isl::set project_out_param(isl::id_list list) const; + inline isl::basic_set sample() const; + inline isl::point sample_point() const; + inline isl::set subtract(isl::set set2) const; + inline isl::set unbind_params(isl::multi_id tuple) const; + inline isl::map unbind_params_insert_domain(isl::multi_id domain) const; + inline isl::set unite(isl::set set2) const; + static inline isl::set universe(isl::space space); + inline isl::basic_set unshifted_simple_hull() const; + inline isl::map unwrap() const; +}; + +// declarations for isl::space +inline space manage(__isl_take isl_space *ptr); +inline space manage_copy(__isl_keep isl_space *ptr); + +class space { + friend inline space manage(__isl_take isl_space *ptr); + friend inline space manage_copy(__isl_keep isl_space *ptr); + +protected: + isl_space *ptr = nullptr; + + inline explicit space(__isl_take isl_space *ptr); + +public: + inline /* implicit */ space(); + inline /* implicit */ space(const space &obj); + inline space &operator=(space obj); + inline ~space(); + inline __isl_give isl_space *copy() const &; + inline __isl_give isl_space *copy() && = delete; + inline __isl_keep isl_space *get() const; + inline __isl_give isl_space *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::space add_named_tuple(isl::id tuple_id, unsigned int dim) const; + inline isl::space add_named_tuple(const std::string &tuple_id, unsigned int dim) const; + inline isl::space add_unnamed_tuple(unsigned int dim) const; + inline isl::space domain() const; + inline isl::space flatten_domain() const; + inline isl::space flatten_range() const; + inline bool is_equal(const isl::space &space2) const; + inline bool is_wrapping() const; + inline isl::space map_from_set() const; + inline isl::space params() const; + inline isl::space range() const; + static inline isl::space unit(isl::ctx ctx); + inline isl::space unwrap() const; + inline isl::space wrap() const; +}; + +// declarations for isl::union_access_info +inline union_access_info manage(__isl_take isl_union_access_info *ptr); +inline union_access_info manage_copy(__isl_keep isl_union_access_info *ptr); + +class union_access_info { + friend inline union_access_info manage(__isl_take isl_union_access_info *ptr); + friend inline union_access_info manage_copy(__isl_keep isl_union_access_info *ptr); + +protected: + isl_union_access_info *ptr = nullptr; + + inline explicit union_access_info(__isl_take isl_union_access_info *ptr); + +public: + inline /* implicit */ union_access_info(); + inline /* implicit */ union_access_info(const union_access_info &obj); + inline explicit union_access_info(isl::union_map sink); + inline union_access_info &operator=(union_access_info obj); + inline ~union_access_info(); + inline __isl_give isl_union_access_info *copy() const &; + inline __isl_give isl_union_access_info *copy() && = delete; + inline __isl_keep isl_union_access_info *get() const; + inline __isl_give isl_union_access_info *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_flow compute_flow() const; + inline isl::union_access_info set_kill(isl::union_map kill) const; + inline isl::union_access_info set_may_source(isl::union_map may_source) const; + inline isl::union_access_info set_must_source(isl::union_map must_source) const; + inline isl::union_access_info set_schedule(isl::schedule schedule) const; + inline isl::union_access_info set_schedule_map(isl::union_map schedule_map) const; +}; + +// declarations for isl::union_flow +inline union_flow manage(__isl_take isl_union_flow *ptr); +inline union_flow manage_copy(__isl_keep isl_union_flow *ptr); + +class union_flow { + friend inline union_flow manage(__isl_take isl_union_flow *ptr); + friend inline union_flow manage_copy(__isl_keep isl_union_flow *ptr); + +protected: + isl_union_flow *ptr = nullptr; + + inline explicit union_flow(__isl_take isl_union_flow *ptr); + +public: + inline /* implicit */ union_flow(); + inline /* implicit */ union_flow(const union_flow &obj); + inline union_flow &operator=(union_flow obj); + inline ~union_flow(); + inline __isl_give isl_union_flow *copy() const &; + inline __isl_give isl_union_flow *copy() && = delete; + inline __isl_keep isl_union_flow *get() const; + inline __isl_give isl_union_flow *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_map full_may_dependence() const; + inline isl::union_map get_full_may_dependence() const; + inline isl::union_map full_must_dependence() const; + inline isl::union_map get_full_must_dependence() const; + inline isl::union_map may_dependence() const; + inline isl::union_map get_may_dependence() const; + inline isl::union_map may_no_source() const; + inline isl::union_map get_may_no_source() const; + inline isl::union_map must_dependence() const; + inline isl::union_map get_must_dependence() const; + inline isl::union_map must_no_source() const; + inline isl::union_map get_must_no_source() const; +}; + +// declarations for isl::union_map +inline union_map manage(__isl_take isl_union_map *ptr); +inline union_map manage_copy(__isl_keep isl_union_map *ptr); + +class union_map { + friend inline union_map manage(__isl_take isl_union_map *ptr); + friend inline union_map manage_copy(__isl_keep isl_union_map *ptr); + +protected: + isl_union_map *ptr = nullptr; + + inline explicit union_map(__isl_take isl_union_map *ptr); + +public: + inline /* implicit */ union_map(); + inline /* implicit */ union_map(const union_map &obj); + inline /* implicit */ union_map(isl::basic_map bmap); + inline /* implicit */ union_map(isl::map map); + inline explicit union_map(isl::ctx ctx, const std::string &str); + inline union_map &operator=(union_map obj); + inline ~union_map(); + inline __isl_give isl_union_map *copy() const &; + inline __isl_give isl_union_map *copy() && = delete; + inline __isl_keep isl_union_map *get() const; + inline __isl_give isl_union_map *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_map affine_hull() const; + inline isl::union_map apply_domain(isl::union_map umap2) const; + inline isl::union_map apply_range(isl::union_map umap2) const; + inline isl::union_set bind_range(isl::multi_id tuple) const; + inline isl::union_map coalesce() const; + inline isl::union_map compute_divs() const; + inline isl::union_map curry() const; + inline isl::union_set deltas() const; + inline isl::union_map detect_equalities() const; + inline isl::union_set domain() const; + inline isl::union_map domain_factor_domain() const; + inline isl::union_map domain_factor_range() const; + inline isl::union_map domain_map() const; + inline isl::union_pw_multi_aff domain_map_union_pw_multi_aff() const; + inline isl::union_map domain_product(isl::union_map umap2) const; + static inline isl::union_map empty(isl::ctx ctx); + inline isl::union_map eq_at(isl::multi_union_pw_aff mupa) const; + inline bool every_map(const std::function &test) const; + inline isl::map extract_map(isl::space dim) const; + inline isl::union_map factor_domain() const; + inline isl::union_map factor_range() const; + inline isl::union_map fixed_power(isl::val exp) const; + inline isl::union_map fixed_power(long exp) const; + inline void foreach_map(const std::function &fn) const; + static inline isl::union_map from(isl::multi_union_pw_aff mupa); + static inline isl::union_map from(isl::union_pw_multi_aff upma); + static inline isl::union_map from_domain(isl::union_set uset); + static inline isl::union_map from_domain_and_range(isl::union_set domain, isl::union_set range); + static inline isl::union_map from_range(isl::union_set uset); + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::union_map gist(isl::union_map context) const; + inline isl::union_map gist_domain(isl::union_set uset) const; + inline isl::union_map gist_params(isl::set set) const; + inline isl::union_map gist_range(isl::union_set uset) const; + inline isl::union_map intersect(isl::union_map umap2) const; + inline isl::union_map intersect_domain(isl::union_set uset) const; + inline isl::union_map intersect_params(isl::set set) const; + inline isl::union_map intersect_range(isl::union_set uset) const; + inline bool is_bijective() const; + inline bool is_disjoint(const isl::union_map &umap2) const; + inline bool is_empty() const; + inline bool is_equal(const isl::union_map &umap2) const; + inline bool is_injective() const; + inline bool is_single_valued() const; + inline bool is_strict_subset(const isl::union_map &umap2) const; + inline bool is_subset(const isl::union_map &umap2) const; + inline bool isa_map() const; + inline isl::union_map lexmax() const; + inline isl::union_map lexmin() const; + inline isl::union_map polyhedral_hull() const; + inline isl::union_map preimage_domain(isl::multi_aff ma) const; + inline isl::union_map preimage_domain(isl::multi_pw_aff mpa) const; + inline isl::union_map preimage_domain(isl::pw_multi_aff pma) const; + inline isl::union_map preimage_domain(isl::union_pw_multi_aff upma) const; + inline isl::union_map preimage_range(isl::multi_aff ma) const; + inline isl::union_map preimage_range(isl::pw_multi_aff pma) const; + inline isl::union_map preimage_range(isl::union_pw_multi_aff upma) const; + inline isl::union_map product(isl::union_map umap2) const; + inline isl::union_map project_out_all_params() const; + inline isl::union_set range() const; + inline isl::union_map range_factor_domain() const; + inline isl::union_map range_factor_range() const; + inline isl::union_map range_map() const; + inline isl::union_map range_product(isl::union_map umap2) const; + inline isl::union_map reverse() const; + inline isl::union_map subtract(isl::union_map umap2) const; + inline isl::union_map subtract_domain(isl::union_set dom) const; + inline isl::union_map subtract_range(isl::union_set dom) const; + inline isl::union_map uncurry() const; + inline isl::union_map unite(isl::union_map umap2) const; + inline isl::union_map universe() const; + inline isl::union_set wrap() const; + inline isl::union_map zip() const; +}; + +// declarations for isl::union_pw_aff +inline union_pw_aff manage(__isl_take isl_union_pw_aff *ptr); +inline union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr); + +class union_pw_aff { + friend inline union_pw_aff manage(__isl_take isl_union_pw_aff *ptr); + friend inline union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr); + +protected: + isl_union_pw_aff *ptr = nullptr; + + inline explicit union_pw_aff(__isl_take isl_union_pw_aff *ptr); + +public: + inline /* implicit */ union_pw_aff(); + inline /* implicit */ union_pw_aff(const union_pw_aff &obj); + inline /* implicit */ union_pw_aff(isl::pw_aff pa); + inline explicit union_pw_aff(isl::ctx ctx, const std::string &str); + inline union_pw_aff &operator=(union_pw_aff obj); + inline ~union_pw_aff(); + inline __isl_give isl_union_pw_aff *copy() const &; + inline __isl_give isl_union_pw_aff *copy() && = delete; + inline __isl_keep isl_union_pw_aff *get() const; + inline __isl_give isl_union_pw_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_pw_aff add(isl::union_pw_aff upa2) const; + inline isl::union_set bind(isl::id id) const; + inline isl::union_set bind(const std::string &id) const; + inline isl::union_set domain() const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::union_pw_aff gist(isl::union_set context) const; + inline isl::union_pw_aff intersect_domain(isl::union_set uset) const; + inline isl::union_pw_aff intersect_domain_wrapped_domain(isl::union_set uset) const; + inline isl::union_pw_aff intersect_domain_wrapped_range(isl::union_set uset) const; + inline isl::union_pw_aff intersect_params(isl::set set) const; + inline isl::union_pw_aff pullback(isl::union_pw_multi_aff upma) const; + inline isl::union_pw_aff sub(isl::union_pw_aff upa2) const; + inline isl::union_pw_aff subtract_domain(isl::union_set uset) const; + inline isl::union_pw_aff union_add(isl::union_pw_aff upa2) const; +}; + +// declarations for isl::union_pw_aff_list +inline union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr); +inline union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr); + +class union_pw_aff_list { + friend inline union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr); + friend inline union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr); + +protected: + isl_union_pw_aff_list *ptr = nullptr; + + inline explicit union_pw_aff_list(__isl_take isl_union_pw_aff_list *ptr); + +public: + inline /* implicit */ union_pw_aff_list(); + inline /* implicit */ union_pw_aff_list(const union_pw_aff_list &obj); + inline explicit union_pw_aff_list(isl::ctx ctx, int n); + inline explicit union_pw_aff_list(isl::union_pw_aff el); + inline union_pw_aff_list &operator=(union_pw_aff_list obj); + inline ~union_pw_aff_list(); + inline __isl_give isl_union_pw_aff_list *copy() const &; + inline __isl_give isl_union_pw_aff_list *copy() && = delete; + inline __isl_keep isl_union_pw_aff_list *get() const; + inline __isl_give isl_union_pw_aff_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_pw_aff_list add(isl::union_pw_aff el) const; + inline isl::union_pw_aff_list clear() const; + inline isl::union_pw_aff_list concat(isl::union_pw_aff_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::union_pw_aff at(int index) const; + inline isl::union_pw_aff get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::union_pw_multi_aff +inline union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr); +inline union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr); + +class union_pw_multi_aff { + friend inline union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr); + friend inline union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr); + +protected: + isl_union_pw_multi_aff *ptr = nullptr; + + inline explicit union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *ptr); + +public: + inline /* implicit */ union_pw_multi_aff(); + inline /* implicit */ union_pw_multi_aff(const union_pw_multi_aff &obj); + inline /* implicit */ union_pw_multi_aff(isl::pw_multi_aff pma); + inline /* implicit */ union_pw_multi_aff(isl::union_pw_aff upa); + inline explicit union_pw_multi_aff(isl::ctx ctx, const std::string &str); + inline union_pw_multi_aff &operator=(union_pw_multi_aff obj); + inline ~union_pw_multi_aff(); + inline __isl_give isl_union_pw_multi_aff *copy() const &; + inline __isl_give isl_union_pw_multi_aff *copy() && = delete; + inline __isl_keep isl_union_pw_multi_aff *get() const; + inline __isl_give isl_union_pw_multi_aff *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_pw_multi_aff add(isl::union_pw_multi_aff upma2) const; + inline isl::pw_multi_aff as_pw_multi_aff() const; + inline isl::union_set domain() const; + static inline isl::union_pw_multi_aff empty(isl::ctx ctx); + inline isl::pw_multi_aff extract_pw_multi_aff(isl::space space) const; + inline isl::union_pw_multi_aff flat_range_product(isl::union_pw_multi_aff upma2) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::union_pw_multi_aff gist(isl::union_set context) const; + inline isl::union_pw_multi_aff intersect_domain(isl::union_set uset) const; + inline isl::union_pw_multi_aff intersect_domain_wrapped_domain(isl::union_set uset) const; + inline isl::union_pw_multi_aff intersect_domain_wrapped_range(isl::union_set uset) const; + inline isl::union_pw_multi_aff intersect_params(isl::set set) const; + inline bool isa_pw_multi_aff() const; + inline isl::union_pw_multi_aff pullback(isl::union_pw_multi_aff upma2) const; + inline isl::union_pw_multi_aff range_factor_domain() const; + inline isl::union_pw_multi_aff range_factor_range() const; + inline isl::union_pw_multi_aff sub(isl::union_pw_multi_aff upma2) const; + inline isl::union_pw_multi_aff subtract_domain(isl::union_set uset) const; + inline isl::union_pw_multi_aff union_add(isl::union_pw_multi_aff upma2) const; +}; + +// declarations for isl::union_set +inline union_set manage(__isl_take isl_union_set *ptr); +inline union_set manage_copy(__isl_keep isl_union_set *ptr); + +class union_set { + friend inline union_set manage(__isl_take isl_union_set *ptr); + friend inline union_set manage_copy(__isl_keep isl_union_set *ptr); + +protected: + isl_union_set *ptr = nullptr; + + inline explicit union_set(__isl_take isl_union_set *ptr); + +public: + inline /* implicit */ union_set(); + inline /* implicit */ union_set(const union_set &obj); + inline /* implicit */ union_set(isl::basic_set bset); + inline /* implicit */ union_set(isl::point pnt); + inline /* implicit */ union_set(isl::set set); + inline explicit union_set(isl::ctx ctx, const std::string &str); + inline union_set &operator=(union_set obj); + inline ~union_set(); + inline __isl_give isl_union_set *copy() const &; + inline __isl_give isl_union_set *copy() && = delete; + inline __isl_keep isl_union_set *get() const; + inline __isl_give isl_union_set *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_set affine_hull() const; + inline isl::union_set apply(isl::union_map umap) const; + inline isl::union_set coalesce() const; + inline isl::union_set compute_divs() const; + inline isl::union_set detect_equalities() const; + static inline isl::union_set empty(isl::ctx ctx); + inline bool every_set(const std::function &test) const; + inline isl::set extract_set(isl::space dim) const; + inline void foreach_point(const std::function &fn) const; + inline void foreach_set(const std::function &fn) const; + inline isl::space space() const; + inline isl::space get_space() const; + inline isl::union_set gist(isl::union_set context) const; + inline isl::union_set gist_params(isl::set set) const; + inline isl::union_map identity() const; + inline isl::union_set intersect(isl::union_set uset2) const; + inline isl::union_set intersect_params(isl::set set) const; + inline bool is_disjoint(const isl::union_set &uset2) const; + inline bool is_empty() const; + inline bool is_equal(const isl::union_set &uset2) const; + inline bool is_strict_subset(const isl::union_set &uset2) const; + inline bool is_subset(const isl::union_set &uset2) const; + inline bool isa_set() const; + inline isl::union_set lexmax() const; + inline isl::union_set lexmin() const; + inline isl::union_set polyhedral_hull() const; + inline isl::union_set preimage(isl::multi_aff ma) const; + inline isl::union_set preimage(isl::pw_multi_aff pma) const; + inline isl::union_set preimage(isl::union_pw_multi_aff upma) const; + inline isl::point sample_point() const; + inline isl::union_set subtract(isl::union_set uset2) const; + inline isl::union_set unite(isl::union_set uset2) const; + inline isl::union_set universe() const; + inline isl::union_map unwrap() const; +}; + +// declarations for isl::union_set_list +inline union_set_list manage(__isl_take isl_union_set_list *ptr); +inline union_set_list manage_copy(__isl_keep isl_union_set_list *ptr); + +class union_set_list { + friend inline union_set_list manage(__isl_take isl_union_set_list *ptr); + friend inline union_set_list manage_copy(__isl_keep isl_union_set_list *ptr); + +protected: + isl_union_set_list *ptr = nullptr; + + inline explicit union_set_list(__isl_take isl_union_set_list *ptr); + +public: + inline /* implicit */ union_set_list(); + inline /* implicit */ union_set_list(const union_set_list &obj); + inline explicit union_set_list(isl::ctx ctx, int n); + inline explicit union_set_list(isl::union_set el); + inline union_set_list &operator=(union_set_list obj); + inline ~union_set_list(); + inline __isl_give isl_union_set_list *copy() const &; + inline __isl_give isl_union_set_list *copy() && = delete; + inline __isl_keep isl_union_set_list *get() const; + inline __isl_give isl_union_set_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::union_set_list add(isl::union_set el) const; + inline isl::union_set_list clear() const; + inline isl::union_set_list concat(isl::union_set_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::union_set at(int index) const; + inline isl::union_set get_at(int index) const; + inline unsigned size() const; +}; + +// declarations for isl::val +inline val manage(__isl_take isl_val *ptr); +inline val manage_copy(__isl_keep isl_val *ptr); + +class val { + friend inline val manage(__isl_take isl_val *ptr); + friend inline val manage_copy(__isl_keep isl_val *ptr); + +protected: + isl_val *ptr = nullptr; + + inline explicit val(__isl_take isl_val *ptr); + +public: + inline /* implicit */ val(); + inline /* implicit */ val(const val &obj); + inline explicit val(isl::ctx ctx, long i); + inline explicit val(isl::ctx ctx, const std::string &str); + inline val &operator=(val obj); + inline ~val(); + inline __isl_give isl_val *copy() const &; + inline __isl_give isl_val *copy() && = delete; + inline __isl_keep isl_val *get() const; + inline __isl_give isl_val *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::val abs() const; + inline bool abs_eq(const isl::val &v2) const; + inline bool abs_eq(long v2) const; + inline isl::val add(isl::val v2) const; + inline isl::val add(long v2) const; + inline isl::val ceil() const; + inline int cmp_si(long i) const; + inline isl::val div(isl::val v2) const; + inline isl::val div(long v2) const; + inline bool eq(const isl::val &v2) const; + inline bool eq(long v2) const; + inline isl::val floor() const; + inline isl::val gcd(isl::val v2) const; + inline isl::val gcd(long v2) const; + inline bool ge(const isl::val &v2) const; + inline bool ge(long v2) const; + inline long den_si() const; + inline long get_den_si() const; + inline long num_si() const; + inline long get_num_si() const; + inline bool gt(const isl::val &v2) const; + inline bool gt(long v2) const; + static inline isl::val infty(isl::ctx ctx); + inline isl::val inv() const; + inline bool is_divisible_by(const isl::val &v2) const; + inline bool is_divisible_by(long v2) const; + inline bool is_infty() const; + inline bool is_int() const; + inline bool is_nan() const; + inline bool is_neg() const; + inline bool is_neginfty() const; + inline bool is_negone() const; + inline bool is_nonneg() const; + inline bool is_nonpos() const; + inline bool is_one() const; + inline bool is_pos() const; + inline bool is_rat() const; + inline bool is_zero() const; + inline bool le(const isl::val &v2) const; + inline bool le(long v2) const; + inline bool lt(const isl::val &v2) const; + inline bool lt(long v2) const; + inline isl::val max(isl::val v2) const; + inline isl::val max(long v2) const; + inline isl::val min(isl::val v2) const; + inline isl::val min(long v2) const; + inline isl::val mod(isl::val v2) const; + inline isl::val mod(long v2) const; + inline isl::val mul(isl::val v2) const; + inline isl::val mul(long v2) const; + static inline isl::val nan(isl::ctx ctx); + inline bool ne(const isl::val &v2) const; + inline bool ne(long v2) const; + inline isl::val neg() const; + static inline isl::val neginfty(isl::ctx ctx); + static inline isl::val negone(isl::ctx ctx); + static inline isl::val one(isl::ctx ctx); + inline isl::val pow2() const; + inline int sgn() const; + inline isl::val sub(isl::val v2) const; + inline isl::val sub(long v2) const; + inline isl::val trunc() const; + static inline isl::val zero(isl::ctx ctx); +}; + +// declarations for isl::val_list +inline val_list manage(__isl_take isl_val_list *ptr); +inline val_list manage_copy(__isl_keep isl_val_list *ptr); + +class val_list { + friend inline val_list manage(__isl_take isl_val_list *ptr); + friend inline val_list manage_copy(__isl_keep isl_val_list *ptr); + +protected: + isl_val_list *ptr = nullptr; + + inline explicit val_list(__isl_take isl_val_list *ptr); + +public: + inline /* implicit */ val_list(); + inline /* implicit */ val_list(const val_list &obj); + inline explicit val_list(isl::ctx ctx, int n); + inline explicit val_list(isl::val el); + inline val_list &operator=(val_list obj); + inline ~val_list(); + inline __isl_give isl_val_list *copy() const &; + inline __isl_give isl_val_list *copy() && = delete; + inline __isl_keep isl_val_list *get() const; + inline __isl_give isl_val_list *release(); + inline bool is_null() const; + inline isl::ctx ctx() const; + + inline isl::val_list add(isl::val el) const; + inline isl::val_list add(long el) const; + inline isl::val_list clear() const; + inline isl::val_list concat(isl::val_list list2) const; + inline void foreach(const std::function &fn) const; + inline isl::val at(int index) const; + inline isl::val get_at(int index) const; + inline unsigned size() const; +}; + +// implementations for isl::aff +aff manage(__isl_take isl_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return aff(ptr); +} +aff manage_copy(__isl_keep isl_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return aff(ptr); +} + +aff::aff() + : ptr(nullptr) {} + +aff::aff(const aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +aff::aff(__isl_take isl_aff *ptr) + : ptr(ptr) {} + +aff::aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +aff &aff::operator=(aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +aff::~aff() { + if (ptr) + isl_aff_free(ptr); +} + +__isl_give isl_aff *aff::copy() const & { + return isl_aff_copy(ptr); +} + +__isl_keep isl_aff *aff::get() const { + return ptr; +} + +__isl_give isl_aff *aff::release() { + isl_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx aff::ctx() const { + return isl::ctx(isl_aff_get_ctx(ptr)); +} + +isl::aff aff::add(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_add(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::add_constant(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_add_constant_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::add_constant(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add_constant(isl::val(ctx(), v)); +} + +isl::basic_set aff::bind(isl::id id) const +{ + if (!ptr || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_bind_id(copy(), id.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set aff::bind(const std::string &id) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->bind(isl::id(ctx(), id)); +} + +isl::aff aff::ceil() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_ceil(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::div(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_div(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::eq_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_eq_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val aff::eval(isl::point pnt) const +{ + if (!ptr || pnt.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_eval(copy(), pnt.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::floor() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_floor(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::ge_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_ge_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::gist(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::gt_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_gt_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::le_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_le_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::lt_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_lt_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::mod(isl::val mod) const +{ + if (!ptr || mod.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_mod_val(copy(), mod.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::mod(long mod) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->mod(isl::val(ctx(), mod)); +} + +isl::aff aff::mul(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_mul(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set aff::ne_set(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_ne_set(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::pullback(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_pullback_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::aff aff::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::aff aff::sub(isl::aff aff2) const +{ + if (!ptr || aff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_sub(copy(), aff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff::unbind_params_insert_domain(isl::multi_id domain) const +{ + if (!ptr || domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_unbind_params_insert_domain(copy(), domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::aff_list +aff_list manage(__isl_take isl_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return aff_list(ptr); +} +aff_list manage_copy(__isl_keep isl_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_aff_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return aff_list(ptr); +} + +aff_list::aff_list() + : ptr(nullptr) {} + +aff_list::aff_list(const aff_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +aff_list::aff_list(__isl_take isl_aff_list *ptr) + : ptr(ptr) {} + +aff_list::aff_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +aff_list::aff_list(isl::aff el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_from_aff(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +aff_list &aff_list::operator=(aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +aff_list::~aff_list() { + if (ptr) + isl_aff_list_free(ptr); +} + +__isl_give isl_aff_list *aff_list::copy() const & { + return isl_aff_list_copy(ptr); +} + +__isl_keep isl_aff_list *aff_list::get() const { + return ptr; +} + +__isl_give isl_aff_list *aff_list::release() { + isl_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool aff_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx aff_list::ctx() const { + return isl::ctx(isl_aff_list_get_ctx(ptr)); +} + +isl::aff_list aff_list::add(isl::aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff_list aff_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff_list aff_list::concat(isl::aff_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void aff_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_aff_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::aff aff_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff aff_list::get_at(int index) const +{ + return at(index); +} + +unsigned aff_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_aff_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const aff_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_aff_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_aff_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_build +ast_build manage(__isl_take isl_ast_build *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return ast_build(ptr); +} +ast_build manage_copy(__isl_keep isl_ast_build *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_build_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_ast_build_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return ast_build(ptr); +} + +ast_build::ast_build() + : ptr(nullptr) {} + +ast_build::ast_build(const ast_build &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_build_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + copy_callbacks(obj); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +ast_build::ast_build(__isl_take isl_ast_build *ptr) + : ptr(ptr) {} + +ast_build::ast_build(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_alloc(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +ast_build &ast_build::operator=(ast_build obj) { + std::swap(this->ptr, obj.ptr); + copy_callbacks(obj); + return *this; +} + +ast_build::~ast_build() { + if (ptr) + isl_ast_build_free(ptr); +} + +__isl_give isl_ast_build *ast_build::copy() const & { + return isl_ast_build_copy(ptr); +} + +__isl_keep isl_ast_build *ast_build::get() const { + return ptr; +} + +__isl_give isl_ast_build *ast_build::release() { + if (at_each_domain_data) + exception::throw_invalid("cannot release object with persistent callbacks", __FILE__, __LINE__); + isl_ast_build *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_build::is_null() const { + return ptr == nullptr; +} + +isl::ctx ast_build::ctx() const { + return isl::ctx(isl_ast_build_get_ctx(ptr)); +} + +ast_build &ast_build::copy_callbacks(const ast_build &obj) +{ + at_each_domain_data = obj.at_each_domain_data; + return *this; +} + +isl_ast_node *ast_build::at_each_domain(isl_ast_node *arg_0, isl_ast_build *arg_1, void *arg_2) +{ + auto *data = static_cast(arg_2); + ISL_CPP_TRY { + auto ret = (data->func)(manage(arg_0), manage_copy(arg_1)); + return ret.release(); + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return NULL; + } +} + +void ast_build::set_at_each_domain_data(const std::function &fn) +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_build_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + at_each_domain_data = std::make_shared(); + at_each_domain_data->func = fn; + ptr = isl_ast_build_set_at_each_domain(ptr, &at_each_domain, at_each_domain_data.get()); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +isl::ast_build ast_build::set_at_each_domain(const std::function &fn) const +{ + auto copy = *this; + copy.set_at_each_domain_data(fn); + return copy; +} + +isl::ast_expr ast_build::access_from(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_access_from_multi_pw_aff(get(), mpa.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_build::access_from(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_access_from_pw_multi_aff(get(), pma.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_build::call_from(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_call_from_multi_pw_aff(get(), mpa.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_build::call_from(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_call_from_pw_multi_aff(get(), pma.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_build::expr_from(isl::pw_aff pa) const +{ + if (!ptr || pa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_expr_from_pw_aff(get(), pa.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_build::expr_from(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_expr_from_set(get(), set.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_build ast_build::from_context(isl::set set) +{ + if (set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = set.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_from_context(set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map ast_build::schedule() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_get_schedule(get()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map ast_build::get_schedule() const +{ + return schedule(); +} + +isl::ast_node ast_build::node_from(isl::schedule schedule) const +{ + if (!ptr || schedule.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_node_from_schedule(get(), schedule.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_build::node_from_schedule_map(isl::union_map schedule) const +{ + if (!ptr || schedule.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_build_node_from_schedule_map(get(), schedule.release()); + if (at_each_domain_data && at_each_domain_data->eptr) { + std::exception_ptr eptr = at_each_domain_data->eptr; + at_each_domain_data->eptr = nullptr; + std::rethrow_exception(eptr); + } + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +// implementations for isl::ast_expr +ast_expr manage(__isl_take isl_ast_expr *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return ast_expr(ptr); +} +ast_expr manage_copy(__isl_keep isl_ast_expr *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_ast_expr_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return ast_expr(ptr); +} + +ast_expr::ast_expr() + : ptr(nullptr) {} + +ast_expr::ast_expr(const ast_expr &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +ast_expr::ast_expr(__isl_take isl_ast_expr *ptr) + : ptr(ptr) {} + +ast_expr &ast_expr::operator=(ast_expr obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_expr::~ast_expr() { + if (ptr) + isl_ast_expr_free(ptr); +} + +__isl_give isl_ast_expr *ast_expr::copy() const & { + return isl_ast_expr_copy(ptr); +} + +__isl_keep isl_ast_expr *ast_expr::get() const { + return ptr; +} + +__isl_give isl_ast_expr *ast_expr::release() { + isl_ast_expr *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_expr::is_null() const { + return ptr == nullptr; +} + +template +bool ast_expr::isa_type(T subtype) const +{ + if (is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return isl_ast_expr_get_type(get()) == subtype; +} +template +bool ast_expr::isa() const +{ + return isa_type(T::type); +} +template +T ast_expr::as() const +{ + if (!isa()) + exception::throw_invalid("not an object of the requested subtype", __FILE__, __LINE__); + return T(copy()); +} + +isl::ctx ast_expr::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +std::string ast_expr::to_C_str() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_expr_to_C_str(get()); + std::string tmp(res); + free(res); + return tmp; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_id +ast_expr_id::ast_expr_id() + : ast_expr() {} + +ast_expr_id::ast_expr_id(const ast_expr_id &obj) + : ast_expr(obj) +{ +} + +ast_expr_id::ast_expr_id(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_id &ast_expr_id::operator=(ast_expr_id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_id::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::id ast_expr_id::id() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_expr_id_get_id(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id ast_expr_id::get_id() const +{ + return id(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_id &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_int +ast_expr_int::ast_expr_int() + : ast_expr() {} + +ast_expr_int::ast_expr_int(const ast_expr_int &obj) + : ast_expr(obj) +{ +} + +ast_expr_int::ast_expr_int(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_int &ast_expr_int::operator=(ast_expr_int obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_int::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::val ast_expr_int::val() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_expr_int_get_val(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val ast_expr_int::get_val() const +{ + return val(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_int &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op +ast_expr_op::ast_expr_op() + : ast_expr() {} + +ast_expr_op::ast_expr_op(const ast_expr_op &obj) + : ast_expr(obj) +{ +} + +ast_expr_op::ast_expr_op(__isl_take isl_ast_expr *ptr) + : ast_expr(ptr) {} + +ast_expr_op &ast_expr_op::operator=(ast_expr_op obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +template +bool ast_expr_op::isa_type(T subtype) const +{ + if (is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return isl_ast_expr_op_get_type(get()) == subtype; +} +template +bool ast_expr_op::isa() const +{ + return isa_type(T::type); +} +template +T ast_expr_op::as() const +{ + if (!isa()) + exception::throw_invalid("not an object of the requested subtype", __FILE__, __LINE__); + return T(copy()); +} + +isl::ctx ast_expr_op::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +isl::ast_expr ast_expr_op::arg(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_expr_op_get_arg(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_expr_op::get_arg(int pos) const +{ + return arg(pos); +} + +unsigned ast_expr_op::n_arg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_expr_op_get_n_arg(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +unsigned ast_expr_op::get_n_arg() const +{ + return n_arg(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_access +ast_expr_op_access::ast_expr_op_access() + : ast_expr_op() {} + +ast_expr_op_access::ast_expr_op_access(const ast_expr_op_access &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_access::ast_expr_op_access(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_access &ast_expr_op_access::operator=(ast_expr_op_access obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_access::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_access &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_add +ast_expr_op_add::ast_expr_op_add() + : ast_expr_op() {} + +ast_expr_op_add::ast_expr_op_add(const ast_expr_op_add &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_add::ast_expr_op_add(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_add &ast_expr_op_add::operator=(ast_expr_op_add obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_add::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_add &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_address_of +ast_expr_op_address_of::ast_expr_op_address_of() + : ast_expr_op() {} + +ast_expr_op_address_of::ast_expr_op_address_of(const ast_expr_op_address_of &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_address_of::ast_expr_op_address_of(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_address_of &ast_expr_op_address_of::operator=(ast_expr_op_address_of obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_address_of::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_address_of &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_and +ast_expr_op_and::ast_expr_op_and() + : ast_expr_op() {} + +ast_expr_op_and::ast_expr_op_and(const ast_expr_op_and &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_and::ast_expr_op_and(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_and &ast_expr_op_and::operator=(ast_expr_op_and obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_and::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_and &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_and_then +ast_expr_op_and_then::ast_expr_op_and_then() + : ast_expr_op() {} + +ast_expr_op_and_then::ast_expr_op_and_then(const ast_expr_op_and_then &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_and_then::ast_expr_op_and_then(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_and_then &ast_expr_op_and_then::operator=(ast_expr_op_and_then obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_and_then::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_and_then &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_call +ast_expr_op_call::ast_expr_op_call() + : ast_expr_op() {} + +ast_expr_op_call::ast_expr_op_call(const ast_expr_op_call &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_call::ast_expr_op_call(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_call &ast_expr_op_call::operator=(ast_expr_op_call obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_call::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_call &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_cond +ast_expr_op_cond::ast_expr_op_cond() + : ast_expr_op() {} + +ast_expr_op_cond::ast_expr_op_cond(const ast_expr_op_cond &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_cond::ast_expr_op_cond(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_cond &ast_expr_op_cond::operator=(ast_expr_op_cond obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_cond::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_cond &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_div +ast_expr_op_div::ast_expr_op_div() + : ast_expr_op() {} + +ast_expr_op_div::ast_expr_op_div(const ast_expr_op_div &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_div::ast_expr_op_div(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_div &ast_expr_op_div::operator=(ast_expr_op_div obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_div::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_div &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_eq +ast_expr_op_eq::ast_expr_op_eq() + : ast_expr_op() {} + +ast_expr_op_eq::ast_expr_op_eq(const ast_expr_op_eq &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_eq::ast_expr_op_eq(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_eq &ast_expr_op_eq::operator=(ast_expr_op_eq obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_eq::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_eq &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_fdiv_q +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q() + : ast_expr_op() {} + +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q(const ast_expr_op_fdiv_q &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_fdiv_q::ast_expr_op_fdiv_q(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_fdiv_q &ast_expr_op_fdiv_q::operator=(ast_expr_op_fdiv_q obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_fdiv_q::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_fdiv_q &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_ge +ast_expr_op_ge::ast_expr_op_ge() + : ast_expr_op() {} + +ast_expr_op_ge::ast_expr_op_ge(const ast_expr_op_ge &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_ge::ast_expr_op_ge(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_ge &ast_expr_op_ge::operator=(ast_expr_op_ge obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_ge::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_ge &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_gt +ast_expr_op_gt::ast_expr_op_gt() + : ast_expr_op() {} + +ast_expr_op_gt::ast_expr_op_gt(const ast_expr_op_gt &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_gt::ast_expr_op_gt(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_gt &ast_expr_op_gt::operator=(ast_expr_op_gt obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_gt::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_gt &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_le +ast_expr_op_le::ast_expr_op_le() + : ast_expr_op() {} + +ast_expr_op_le::ast_expr_op_le(const ast_expr_op_le &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_le::ast_expr_op_le(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_le &ast_expr_op_le::operator=(ast_expr_op_le obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_le::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_le &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_lt +ast_expr_op_lt::ast_expr_op_lt() + : ast_expr_op() {} + +ast_expr_op_lt::ast_expr_op_lt(const ast_expr_op_lt &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_lt::ast_expr_op_lt(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_lt &ast_expr_op_lt::operator=(ast_expr_op_lt obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_lt::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_lt &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_max +ast_expr_op_max::ast_expr_op_max() + : ast_expr_op() {} + +ast_expr_op_max::ast_expr_op_max(const ast_expr_op_max &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_max::ast_expr_op_max(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_max &ast_expr_op_max::operator=(ast_expr_op_max obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_max::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_max &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_member +ast_expr_op_member::ast_expr_op_member() + : ast_expr_op() {} + +ast_expr_op_member::ast_expr_op_member(const ast_expr_op_member &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_member::ast_expr_op_member(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_member &ast_expr_op_member::operator=(ast_expr_op_member obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_member::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_member &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_min +ast_expr_op_min::ast_expr_op_min() + : ast_expr_op() {} + +ast_expr_op_min::ast_expr_op_min(const ast_expr_op_min &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_min::ast_expr_op_min(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_min &ast_expr_op_min::operator=(ast_expr_op_min obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_min::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_min &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_minus +ast_expr_op_minus::ast_expr_op_minus() + : ast_expr_op() {} + +ast_expr_op_minus::ast_expr_op_minus(const ast_expr_op_minus &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_minus::ast_expr_op_minus(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_minus &ast_expr_op_minus::operator=(ast_expr_op_minus obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_minus::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_minus &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_mul +ast_expr_op_mul::ast_expr_op_mul() + : ast_expr_op() {} + +ast_expr_op_mul::ast_expr_op_mul(const ast_expr_op_mul &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_mul::ast_expr_op_mul(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_mul &ast_expr_op_mul::operator=(ast_expr_op_mul obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_mul::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_mul &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_or +ast_expr_op_or::ast_expr_op_or() + : ast_expr_op() {} + +ast_expr_op_or::ast_expr_op_or(const ast_expr_op_or &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_or::ast_expr_op_or(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_or &ast_expr_op_or::operator=(ast_expr_op_or obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_or::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_or &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_or_else +ast_expr_op_or_else::ast_expr_op_or_else() + : ast_expr_op() {} + +ast_expr_op_or_else::ast_expr_op_or_else(const ast_expr_op_or_else &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_or_else::ast_expr_op_or_else(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_or_else &ast_expr_op_or_else::operator=(ast_expr_op_or_else obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_or_else::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_or_else &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_pdiv_q +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q() + : ast_expr_op() {} + +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q(const ast_expr_op_pdiv_q &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_pdiv_q::ast_expr_op_pdiv_q(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_pdiv_q &ast_expr_op_pdiv_q::operator=(ast_expr_op_pdiv_q obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_pdiv_q::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_pdiv_q &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_pdiv_r +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r() + : ast_expr_op() {} + +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r(const ast_expr_op_pdiv_r &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_pdiv_r::ast_expr_op_pdiv_r(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_pdiv_r &ast_expr_op_pdiv_r::operator=(ast_expr_op_pdiv_r obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_pdiv_r::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_pdiv_r &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_select +ast_expr_op_select::ast_expr_op_select() + : ast_expr_op() {} + +ast_expr_op_select::ast_expr_op_select(const ast_expr_op_select &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_select::ast_expr_op_select(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_select &ast_expr_op_select::operator=(ast_expr_op_select obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_select::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_select &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_sub +ast_expr_op_sub::ast_expr_op_sub() + : ast_expr_op() {} + +ast_expr_op_sub::ast_expr_op_sub(const ast_expr_op_sub &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_sub::ast_expr_op_sub(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_sub &ast_expr_op_sub::operator=(ast_expr_op_sub obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_sub::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_sub &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_expr_op_zdiv_r +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r() + : ast_expr_op() {} + +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r(const ast_expr_op_zdiv_r &obj) + : ast_expr_op(obj) +{ +} + +ast_expr_op_zdiv_r::ast_expr_op_zdiv_r(__isl_take isl_ast_expr *ptr) + : ast_expr_op(ptr) {} + +ast_expr_op_zdiv_r &ast_expr_op_zdiv_r::operator=(ast_expr_op_zdiv_r obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_expr_op_zdiv_r::ctx() const { + return isl::ctx(isl_ast_expr_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_expr_op_zdiv_r &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_expr_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_expr_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node +ast_node manage(__isl_take isl_ast_node *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return ast_node(ptr); +} +ast_node manage_copy(__isl_keep isl_ast_node *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_ast_node_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return ast_node(ptr); +} + +ast_node::ast_node() + : ptr(nullptr) {} + +ast_node::ast_node(const ast_node &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +ast_node::ast_node(__isl_take isl_ast_node *ptr) + : ptr(ptr) {} + +ast_node &ast_node::operator=(ast_node obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_node::~ast_node() { + if (ptr) + isl_ast_node_free(ptr); +} + +__isl_give isl_ast_node *ast_node::copy() const & { + return isl_ast_node_copy(ptr); +} + +__isl_keep isl_ast_node *ast_node::get() const { + return ptr; +} + +__isl_give isl_ast_node *ast_node::release() { + isl_ast_node *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_node::is_null() const { + return ptr == nullptr; +} + +template +bool ast_node::isa_type(T subtype) const +{ + if (is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return isl_ast_node_get_type(get()) == subtype; +} +template +bool ast_node::isa() const +{ + return isa_type(T::type); +} +template +T ast_node::as() const +{ + if (!isa()) + exception::throw_invalid("not an object of the requested subtype", __FILE__, __LINE__); + return T(copy()); +} + +isl::ctx ast_node::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +std::string ast_node::to_C_str() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_to_C_str(get()); + std::string tmp(res); + free(res); + return tmp; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_block +ast_node_block::ast_node_block() + : ast_node() {} + +ast_node_block::ast_node_block(const ast_node_block &obj) + : ast_node(obj) +{ +} + +ast_node_block::ast_node_block(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_block &ast_node_block::operator=(ast_node_block obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_node_block::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::ast_node_list ast_node_block::children() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_block_get_children(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node_list ast_node_block::get_children() const +{ + return children(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_block &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_for +ast_node_for::ast_node_for() + : ast_node() {} + +ast_node_for::ast_node_for(const ast_node_for &obj) + : ast_node(obj) +{ +} + +ast_node_for::ast_node_for(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_for &ast_node_for::operator=(ast_node_for obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_node_for::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::ast_node ast_node_for::body() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_get_body(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_node_for::get_body() const +{ + return body(); +} + +isl::ast_expr ast_node_for::cond() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_get_cond(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_for::get_cond() const +{ + return cond(); +} + +isl::ast_expr ast_node_for::inc() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_get_inc(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_for::get_inc() const +{ + return inc(); +} + +isl::ast_expr ast_node_for::init() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_get_init(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_for::get_init() const +{ + return init(); +} + +isl::ast_expr ast_node_for::iterator() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_get_iterator(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_for::get_iterator() const +{ + return iterator(); +} + +bool ast_node_for::is_degenerate() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_for_is_degenerate(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_for &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_if +ast_node_if::ast_node_if() + : ast_node() {} + +ast_node_if::ast_node_if(const ast_node_if &obj) + : ast_node(obj) +{ +} + +ast_node_if::ast_node_if(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_if &ast_node_if::operator=(ast_node_if obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_node_if::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::ast_expr ast_node_if::cond() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_if_get_cond(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_if::get_cond() const +{ + return cond(); +} + +isl::ast_node ast_node_if::else_node() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_if_get_else_node(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_node_if::get_else_node() const +{ + return else_node(); +} + +isl::ast_node ast_node_if::then_node() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_if_get_then_node(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_node_if::get_then_node() const +{ + return then_node(); +} + +bool ast_node_if::has_else_node() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_if_has_else_node(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_if &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_list +ast_node_list manage(__isl_take isl_ast_node_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return ast_node_list(ptr); +} +ast_node_list manage_copy(__isl_keep isl_ast_node_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_ast_node_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return ast_node_list(ptr); +} + +ast_node_list::ast_node_list() + : ptr(nullptr) {} + +ast_node_list::ast_node_list(const ast_node_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +ast_node_list::ast_node_list(__isl_take isl_ast_node_list *ptr) + : ptr(ptr) {} + +ast_node_list::ast_node_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +ast_node_list::ast_node_list(isl::ast_node el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_from_ast_node(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +ast_node_list &ast_node_list::operator=(ast_node_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +ast_node_list::~ast_node_list() { + if (ptr) + isl_ast_node_list_free(ptr); +} + +__isl_give isl_ast_node_list *ast_node_list::copy() const & { + return isl_ast_node_list_copy(ptr); +} + +__isl_keep isl_ast_node_list *ast_node_list::get() const { + return ptr; +} + +__isl_give isl_ast_node_list *ast_node_list::release() { + isl_ast_node_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool ast_node_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx ast_node_list::ctx() const { + return isl::ctx(isl_ast_node_list_get_ctx(ptr)); +} + +isl::ast_node_list ast_node_list::add(isl::ast_node el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node_list ast_node_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node_list ast_node_list::concat(isl::ast_node_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void ast_node_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_ast_node *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_ast_node_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::ast_node ast_node_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_node_list::get_at(int index) const +{ + return at(index); +} + +unsigned ast_node_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_mark +ast_node_mark::ast_node_mark() + : ast_node() {} + +ast_node_mark::ast_node_mark(const ast_node_mark &obj) + : ast_node(obj) +{ +} + +ast_node_mark::ast_node_mark(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_mark &ast_node_mark::operator=(ast_node_mark obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_node_mark::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::id ast_node_mark::id() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_mark_get_id(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id ast_node_mark::get_id() const +{ + return id(); +} + +isl::ast_node ast_node_mark::node() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_mark_get_node(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_node ast_node_mark::get_node() const +{ + return node(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_mark &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::ast_node_user +ast_node_user::ast_node_user() + : ast_node() {} + +ast_node_user::ast_node_user(const ast_node_user &obj) + : ast_node(obj) +{ +} + +ast_node_user::ast_node_user(__isl_take isl_ast_node *ptr) + : ast_node(ptr) {} + +ast_node_user &ast_node_user::operator=(ast_node_user obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx ast_node_user::ctx() const { + return isl::ctx(isl_ast_node_get_ctx(ptr)); +} + +isl::ast_expr ast_node_user::expr() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_ast_node_user_get_expr(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::ast_expr ast_node_user::get_expr() const +{ + return expr(); +} + +inline std::ostream &operator<<(std::ostream &os, const ast_node_user &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_ast_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_ast_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::basic_map +basic_map manage(__isl_take isl_basic_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return basic_map(ptr); +} +basic_map manage_copy(__isl_keep isl_basic_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_map_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_basic_map_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return basic_map(ptr); +} + +basic_map::basic_map() + : ptr(nullptr) {} + +basic_map::basic_map(const basic_map &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_map_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +basic_map::basic_map(__isl_take isl_basic_map *ptr) + : ptr(ptr) {} + +basic_map::basic_map(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +basic_map &basic_map::operator=(basic_map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +basic_map::~basic_map() { + if (ptr) + isl_basic_map_free(ptr); +} + +__isl_give isl_basic_map *basic_map::copy() const & { + return isl_basic_map_copy(ptr); +} + +__isl_keep isl_basic_map *basic_map::get() const { + return ptr; +} + +__isl_give isl_basic_map *basic_map::release() { + isl_basic_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool basic_map::is_null() const { + return ptr == nullptr; +} + +isl::ctx basic_map::ctx() const { + return isl::ctx(isl_basic_map_get_ctx(ptr)); +} + +isl::basic_map basic_map::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::apply_domain(isl::basic_map bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_apply_domain(copy(), bmap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::apply_range(isl::basic_map bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_apply_range(copy(), bmap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_map::deltas() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_deltas(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::flatten() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_flatten(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::flatten_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_flatten_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::flatten_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_flatten_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::gist(isl::basic_map context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::intersect(isl::basic_map bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_intersect(copy(), bmap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::intersect_domain(isl::basic_set bset) const +{ + if (!ptr || bset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_intersect_domain(copy(), bset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::intersect_range(isl::basic_set bset) const +{ + if (!ptr || bset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_intersect_range(copy(), bset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool basic_map::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool basic_map::is_equal(const isl::basic_map &bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_is_equal(get(), bmap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool basic_map::is_subset(const isl::basic_map &bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_is_subset(get(), bmap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::map basic_map::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map basic_map::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::reverse() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_reverse(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map basic_map::sample() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_sample(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map basic_map::unite(isl::basic_map bmap2) const +{ + if (!ptr || bmap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_map_union(copy(), bmap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const basic_map &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_map_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_basic_map_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::basic_set +basic_set manage(__isl_take isl_basic_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return basic_set(ptr); +} +basic_set manage_copy(__isl_keep isl_basic_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_set_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_basic_set_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return basic_set(ptr); +} + +basic_set::basic_set() + : ptr(nullptr) {} + +basic_set::basic_set(const basic_set &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_set_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +basic_set::basic_set(__isl_take isl_basic_set *ptr) + : ptr(ptr) {} + +basic_set::basic_set(isl::point pnt) +{ + if (pnt.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pnt.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_from_point(pnt.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +basic_set::basic_set(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +basic_set &basic_set::operator=(basic_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +basic_set::~basic_set() { + if (ptr) + isl_basic_set_free(ptr); +} + +__isl_give isl_basic_set *basic_set::copy() const & { + return isl_basic_set_copy(ptr); +} + +__isl_keep isl_basic_set *basic_set::get() const { + return ptr; +} + +__isl_give isl_basic_set *basic_set::release() { + isl_basic_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool basic_set::is_null() const { + return ptr == nullptr; +} + +isl::ctx basic_set::ctx() const { + return isl::ctx(isl_basic_set_get_ctx(ptr)); +} + +isl::basic_set basic_set::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::apply(isl::basic_map bmap) const +{ + if (!ptr || bmap.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_apply(copy(), bmap.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val basic_set::dim_max_val(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_dim_max_val(copy(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::flatten() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_flatten(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::gist(isl::basic_set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::intersect(isl::basic_set bset2) const +{ + if (!ptr || bset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_intersect(copy(), bset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::intersect_params(isl::basic_set bset2) const +{ + if (!ptr || bset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_intersect_params(copy(), bset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool basic_set::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool basic_set::is_equal(const isl::basic_set &bset2) const +{ + if (!ptr || bset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_is_equal(get(), bset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool basic_set::is_subset(const isl::basic_set &bset2) const +{ + if (!ptr || bset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_is_subset(get(), bset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool basic_set::is_wrapping() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_is_wrapping(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::set basic_set::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set basic_set::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set basic_set::sample() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_sample(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::point basic_set::sample_point() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_sample_point(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set basic_set::unite(isl::basic_set bset2) const +{ + if (!ptr || bset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_basic_set_union(copy(), bset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const basic_set &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_basic_set_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_basic_set_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::fixed_box +fixed_box manage(__isl_take isl_fixed_box *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return fixed_box(ptr); +} +fixed_box manage_copy(__isl_keep isl_fixed_box *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_fixed_box_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_fixed_box_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return fixed_box(ptr); +} + +fixed_box::fixed_box() + : ptr(nullptr) {} + +fixed_box::fixed_box(const fixed_box &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_fixed_box_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +fixed_box::fixed_box(__isl_take isl_fixed_box *ptr) + : ptr(ptr) {} + +fixed_box &fixed_box::operator=(fixed_box obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +fixed_box::~fixed_box() { + if (ptr) + isl_fixed_box_free(ptr); +} + +__isl_give isl_fixed_box *fixed_box::copy() const & { + return isl_fixed_box_copy(ptr); +} + +__isl_keep isl_fixed_box *fixed_box::get() const { + return ptr; +} + +__isl_give isl_fixed_box *fixed_box::release() { + isl_fixed_box *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool fixed_box::is_null() const { + return ptr == nullptr; +} + +isl::ctx fixed_box::ctx() const { + return isl::ctx(isl_fixed_box_get_ctx(ptr)); +} + +isl::multi_aff fixed_box::offset() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_fixed_box_get_offset(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff fixed_box::get_offset() const +{ + return offset(); +} + +isl::multi_val fixed_box::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_fixed_box_get_size(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val fixed_box::get_size() const +{ + return size(); +} + +isl::space fixed_box::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_fixed_box_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space fixed_box::get_space() const +{ + return space(); +} + +bool fixed_box::is_valid() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_fixed_box_is_valid(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const fixed_box &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_fixed_box_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_fixed_box_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::id +id manage(__isl_take isl_id *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return id(ptr); +} +id manage_copy(__isl_keep isl_id *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_id_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return id(ptr); +} + +id::id() + : ptr(nullptr) {} + +id::id(const id &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +id::id(__isl_take isl_id *ptr) + : ptr(ptr) {} + +id::id(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +id &id::operator=(id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +id::~id() { + if (ptr) + isl_id_free(ptr); +} + +__isl_give isl_id *id::copy() const & { + return isl_id_copy(ptr); +} + +__isl_keep isl_id *id::get() const { + return ptr; +} + +__isl_give isl_id *id::release() { + isl_id *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool id::is_null() const { + return ptr == nullptr; +} + +isl::ctx id::ctx() const { + return isl::ctx(isl_id_get_ctx(ptr)); +} + +std::string id::name() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_get_name(get()); + std::string tmp(res); + return tmp; +} + +std::string id::get_name() const +{ + return name(); +} + +inline std::ostream &operator<<(std::ostream &os, const id &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_id_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::id_list +id_list manage(__isl_take isl_id_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return id_list(ptr); +} +id_list manage_copy(__isl_keep isl_id_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_id_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return id_list(ptr); +} + +id_list::id_list() + : ptr(nullptr) {} + +id_list::id_list(const id_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +id_list::id_list(__isl_take isl_id_list *ptr) + : ptr(ptr) {} + +id_list::id_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +id_list::id_list(isl::id el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_from_id(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +id_list &id_list::operator=(id_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +id_list::~id_list() { + if (ptr) + isl_id_list_free(ptr); +} + +__isl_give isl_id_list *id_list::copy() const & { + return isl_id_list_copy(ptr); +} + +__isl_keep isl_id_list *id_list::get() const { + return ptr; +} + +__isl_give isl_id_list *id_list::release() { + isl_id_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool id_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx id_list::ctx() const { + return isl::ctx(isl_id_list_get_ctx(ptr)); +} + +isl::id_list id_list::add(isl::id el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id_list id_list::add(const std::string &el) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add(isl::id(ctx(), el)); +} + +isl::id_list id_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id_list id_list::concat(isl::id_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void id_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_id *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_id_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::id id_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id id_list::get_at(int index) const +{ + return at(index); +} + +unsigned id_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_id_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const id_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_id_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_id_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::map +map manage(__isl_take isl_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return map(ptr); +} +map manage_copy(__isl_keep isl_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_map_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_map_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return map(ptr); +} + +map::map() + : ptr(nullptr) {} + +map::map(const map &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_map_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +map::map(__isl_take isl_map *ptr) + : ptr(ptr) {} + +map::map(isl::basic_map bmap) +{ + if (bmap.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = bmap.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_from_basic_map(bmap.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +map::map(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +map &map::operator=(map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +map::~map() { + if (ptr) + isl_map_free(ptr); +} + +__isl_give isl_map *map::copy() const & { + return isl_map_copy(ptr); +} + +__isl_keep isl_map *map::get() const { + return ptr; +} + +__isl_give isl_map *map::release() { + isl_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool map::is_null() const { + return ptr == nullptr; +} + +isl::ctx map::ctx() const { + return isl::ctx(isl_map_get_ctx(ptr)); +} + +isl::basic_map map::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::apply_domain(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_apply_domain(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::apply_range(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_apply_range(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::bind_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_bind_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::bind_range(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_bind_range(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::coalesce() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_coalesce(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::complement() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_complement(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::curry() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_curry(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::deltas() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_deltas(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::domain_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_domain_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::domain_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_domain_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::domain_product(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_domain_product(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::empty(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_empty(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::flatten() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_flatten(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::flatten_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_flatten_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::flatten_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_flatten_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void map::foreach_basic_map(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_basic_map *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_map_foreach_basic_map(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::fixed_box map::range_simple_fixed_box_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_get_range_simple_fixed_box_hull(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::fixed_box map::get_range_simple_fixed_box_hull() const +{ + return range_simple_fixed_box_hull(); +} + +isl::space map::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space map::get_space() const +{ + return space(); +} + +isl::map map::gist(isl::map context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::gist_domain(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_gist_domain(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::intersect(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_intersect(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::intersect_domain(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_intersect_domain(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::intersect_params(isl::set params) const +{ + if (!ptr || params.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_intersect_params(copy(), params.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::intersect_range(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_intersect_range(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool map::is_bijective() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_bijective(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_disjoint(const isl::map &map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_disjoint(get(), map2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_equal(const isl::map &map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_equal(get(), map2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_injective() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_injective(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_single_valued() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_single_valued(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_strict_subset(const isl::map &map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_strict_subset(get(), map2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool map::is_subset(const isl::map &map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_is_subset(get(), map2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::map map::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff map::lexmax_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_lexmax_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff map::lexmin_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_lexmin_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map map::polyhedral_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_polyhedral_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::preimage_domain(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_preimage_domain_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::preimage_domain(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_preimage_domain_multi_pw_aff(copy(), mpa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::preimage_domain(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_preimage_domain_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::preimage_range(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_preimage_range_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::preimage_range(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_preimage_range_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::project_out_all_params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_project_out_all_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::range_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_range_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::range_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_range_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::range_product(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_range_product(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::reverse() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_reverse(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map map::sample() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_sample(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::subtract(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_subtract(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::uncurry() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_uncurry(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::unite(isl::map map2) const +{ + if (!ptr || map2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_union(copy(), map2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map map::universe(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_universe(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_map map::unshifted_simple_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_unshifted_simple_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set map::wrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_map_wrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const map &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_map_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_map_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::multi_aff +multi_aff manage(__isl_take isl_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return multi_aff(ptr); +} +multi_aff manage_copy(__isl_keep isl_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_multi_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return multi_aff(ptr); +} + +multi_aff::multi_aff() + : ptr(nullptr) {} + +multi_aff::multi_aff(const multi_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +multi_aff::multi_aff(__isl_take isl_multi_aff *ptr) + : ptr(ptr) {} + +multi_aff::multi_aff(isl::aff aff) +{ + if (aff.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = aff.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_from_aff(aff.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_aff::multi_aff(isl::space space, isl::aff_list list) +{ + if (space.is_null() || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_from_aff_list(space.release(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_aff::multi_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_aff &multi_aff::operator=(multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_aff::~multi_aff() { + if (ptr) + isl_multi_aff_free(ptr); +} + +__isl_give isl_multi_aff *multi_aff::copy() const & { + return isl_multi_aff_copy(ptr); +} + +__isl_keep isl_multi_aff *multi_aff::get() const { + return ptr; +} + +__isl_give isl_multi_aff *multi_aff::release() { + isl_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx multi_aff::ctx() const { + return isl::ctx(isl_multi_aff_get_ctx(ptr)); +} + +isl::multi_aff multi_aff::add(isl::multi_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_add(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set multi_aff::bind(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_bind(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::bind_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_bind_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::bind_domain_wrapped_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::domain_map(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_domain_map(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::flat_range_product(isl::multi_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_flat_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::floor() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_floor(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff multi_aff::at(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_get_at(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff multi_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::space multi_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space multi_aff::get_space() const +{ + return space(); +} + +isl::multi_aff multi_aff::gist(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::identity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_identity_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::identity_on_domain(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_identity_on_domain_space(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_aff::involves_locals() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_involves_locals(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_aff multi_aff::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_aff::plain_is_equal(const isl::multi_aff &multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_plain_is_equal(get(), multi2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_aff multi_aff::product(isl::multi_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::pullback(isl::multi_aff ma2) const +{ + if (!ptr || ma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_pullback_multi_aff(copy(), ma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::range_map(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_range_map(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::range_product(isl::multi_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::scale(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_scale_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::multi_aff multi_aff::scale_down(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_scale_down_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::multi_aff multi_aff::set_at(int pos, isl::aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_set_at(copy(), pos, el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +unsigned multi_aff::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_aff multi_aff::sub(isl::multi_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_sub(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff multi_aff::zero(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_aff_zero(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_multi_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::multi_id +multi_id manage(__isl_take isl_multi_id *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return multi_id(ptr); +} +multi_id manage_copy(__isl_keep isl_multi_id *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_id_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_multi_id_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return multi_id(ptr); +} + +multi_id::multi_id() + : ptr(nullptr) {} + +multi_id::multi_id(const multi_id &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_id_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +multi_id::multi_id(__isl_take isl_multi_id *ptr) + : ptr(ptr) {} + +multi_id::multi_id(isl::space space, isl::id_list list) +{ + if (space.is_null() || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_from_id_list(space.release(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_id::multi_id(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_id &multi_id::operator=(multi_id obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_id::~multi_id() { + if (ptr) + isl_multi_id_free(ptr); +} + +__isl_give isl_multi_id *multi_id::copy() const & { + return isl_multi_id_copy(ptr); +} + +__isl_keep isl_multi_id *multi_id::get() const { + return ptr; +} + +__isl_give isl_multi_id *multi_id::release() { + isl_multi_id *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_id::is_null() const { + return ptr == nullptr; +} + +isl::ctx multi_id::ctx() const { + return isl::ctx(isl_multi_id_get_ctx(ptr)); +} + +isl::multi_id multi_id::flat_range_product(isl::multi_id multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_flat_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id multi_id::at(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_get_at(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::id multi_id::get_at(int pos) const +{ + return at(pos); +} + +isl::space multi_id::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space multi_id::get_space() const +{ + return space(); +} + +bool multi_id::plain_is_equal(const isl::multi_id &multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_plain_is_equal(get(), multi2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_id multi_id::range_product(isl::multi_id multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_id multi_id::set_at(int pos, isl::id el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_set_at(copy(), pos, el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_id multi_id::set_at(int pos, const std::string &el) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->set_at(pos, isl::id(ctx(), el)); +} + +unsigned multi_id::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_id_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const multi_id &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_id_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_multi_id_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::multi_pw_aff +multi_pw_aff manage(__isl_take isl_multi_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return multi_pw_aff(ptr); +} +multi_pw_aff manage_copy(__isl_keep isl_multi_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_pw_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_multi_pw_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return multi_pw_aff(ptr); +} + +multi_pw_aff::multi_pw_aff() + : ptr(nullptr) {} + +multi_pw_aff::multi_pw_aff(const multi_pw_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_pw_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +multi_pw_aff::multi_pw_aff(__isl_take isl_multi_pw_aff *ptr) + : ptr(ptr) {} + +multi_pw_aff::multi_pw_aff(isl::multi_aff ma) +{ + if (ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ma.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_from_multi_aff(ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::pw_aff pa) +{ + if (pa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_from_pw_aff(pa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::space space, isl::pw_aff_list list) +{ + if (space.is_null() || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_from_pw_aff_list(space.release(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::pw_multi_aff pma) +{ + if (pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pma.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_from_pw_multi_aff(pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_pw_aff::multi_pw_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_pw_aff &multi_pw_aff::operator=(multi_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_pw_aff::~multi_pw_aff() { + if (ptr) + isl_multi_pw_aff_free(ptr); +} + +__isl_give isl_multi_pw_aff *multi_pw_aff::copy() const & { + return isl_multi_pw_aff_copy(ptr); +} + +__isl_keep isl_multi_pw_aff *multi_pw_aff::get() const { + return ptr; +} + +__isl_give isl_multi_pw_aff *multi_pw_aff::release() { + isl_multi_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx multi_pw_aff::ctx() const { + return isl::ctx(isl_multi_pw_aff_get_ctx(ptr)); +} + +isl::multi_pw_aff multi_pw_aff::add(isl::multi_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_add(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set multi_pw_aff::bind(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_bind(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::bind_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_bind_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::bind_domain_wrapped_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set multi_pw_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::flat_range_product(isl::multi_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_flat_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff multi_pw_aff::at(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_get_at(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff multi_pw_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::space multi_pw_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space multi_pw_aff::get_space() const +{ + return space(); +} + +isl::multi_pw_aff multi_pw_aff::gist(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_gist(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::identity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_identity_multi_pw_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::identity_on_domain(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_identity_on_domain_space(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::intersect_domain(isl::set domain) const +{ + if (!ptr || domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_intersect_domain(copy(), domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_pw_aff::involves_param(const isl::id &id) const +{ + if (!ptr || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_involves_param_id(get(), id.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool multi_pw_aff::involves_param(const std::string &id) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->involves_param(isl::id(ctx(), id)); +} + +bool multi_pw_aff::involves_param(const isl::id_list &list) const +{ + if (!ptr || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_involves_param_id_list(get(), list.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_pw_aff multi_pw_aff::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_pw_aff::plain_is_equal(const isl::multi_pw_aff &multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_plain_is_equal(get(), multi2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_pw_aff multi_pw_aff::product(isl::multi_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::pullback(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_pullback_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::pullback(isl::multi_pw_aff mpa2) const +{ + if (!ptr || mpa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_pullback_multi_pw_aff(copy(), mpa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::pullback(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_pullback_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::range_product(isl::multi_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::scale(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_scale_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::multi_pw_aff multi_pw_aff::scale_down(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_scale_down_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::multi_pw_aff multi_pw_aff::set_at(int pos, isl::pw_aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_set_at(copy(), pos, el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +unsigned multi_pw_aff::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_pw_aff multi_pw_aff::sub(isl::multi_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_sub(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_pw_aff multi_pw_aff::zero(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_pw_aff_zero(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_pw_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_pw_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_multi_pw_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::multi_union_pw_aff +multi_union_pw_aff manage(__isl_take isl_multi_union_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return multi_union_pw_aff(ptr); +} +multi_union_pw_aff manage_copy(__isl_keep isl_multi_union_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_union_pw_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_multi_union_pw_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return multi_union_pw_aff(ptr); +} + +multi_union_pw_aff::multi_union_pw_aff() + : ptr(nullptr) {} + +multi_union_pw_aff::multi_union_pw_aff(const multi_union_pw_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_union_pw_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +multi_union_pw_aff::multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *ptr) + : ptr(ptr) {} + +multi_union_pw_aff::multi_union_pw_aff(isl::multi_pw_aff mpa) +{ + if (mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = mpa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_from_multi_pw_aff(mpa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::union_pw_aff upa) +{ + if (upa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = upa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_from_union_pw_aff(upa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::space space, isl::union_pw_aff_list list) +{ + if (space.is_null() || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_from_union_pw_aff_list(space.release(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_union_pw_aff::multi_union_pw_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_union_pw_aff &multi_union_pw_aff::operator=(multi_union_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_union_pw_aff::~multi_union_pw_aff() { + if (ptr) + isl_multi_union_pw_aff_free(ptr); +} + +__isl_give isl_multi_union_pw_aff *multi_union_pw_aff::copy() const & { + return isl_multi_union_pw_aff_copy(ptr); +} + +__isl_keep isl_multi_union_pw_aff *multi_union_pw_aff::get() const { + return ptr; +} + +__isl_give isl_multi_union_pw_aff *multi_union_pw_aff::release() { + isl_multi_union_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_union_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx multi_union_pw_aff::ctx() const { + return isl::ctx(isl_multi_union_pw_aff_get_ctx(ptr)); +} + +isl::multi_union_pw_aff multi_union_pw_aff::add(isl::multi_union_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_add(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set multi_union_pw_aff::bind(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_bind(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set multi_union_pw_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::flat_range_product(isl::multi_union_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_flat_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff multi_union_pw_aff::at(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_get_at(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff multi_union_pw_aff::get_at(int pos) const +{ + return at(pos); +} + +isl::space multi_union_pw_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space multi_union_pw_aff::get_space() const +{ + return space(); +} + +isl::multi_union_pw_aff multi_union_pw_aff::gist(isl::union_set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::intersect_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_intersect_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::intersect_params(isl::set params) const +{ + if (!ptr || params.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_intersect_params(copy(), params.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_union_pw_aff::plain_is_equal(const isl::multi_union_pw_aff &multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_plain_is_equal(get(), multi2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_union_pw_aff multi_union_pw_aff::pullback(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_pullback_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::range_product(isl::multi_union_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_scale_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale_down(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_scale_down_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::multi_union_pw_aff multi_union_pw_aff::set_at(int pos, isl::union_pw_aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_set_at(copy(), pos, el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +unsigned multi_union_pw_aff::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_union_pw_aff multi_union_pw_aff::sub(isl::multi_union_pw_aff multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_sub(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::union_add(isl::multi_union_pw_aff mupa2) const +{ + if (!ptr || mupa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_union_add(copy(), mupa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff multi_union_pw_aff::zero(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_union_pw_aff_zero(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_union_pw_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_union_pw_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_multi_union_pw_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::multi_val +multi_val manage(__isl_take isl_multi_val *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return multi_val(ptr); +} +multi_val manage_copy(__isl_keep isl_multi_val *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_val_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_multi_val_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return multi_val(ptr); +} + +multi_val::multi_val() + : ptr(nullptr) {} + +multi_val::multi_val(const multi_val &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_val_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +multi_val::multi_val(__isl_take isl_multi_val *ptr) + : ptr(ptr) {} + +multi_val::multi_val(isl::space space, isl::val_list list) +{ + if (space.is_null() || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_from_val_list(space.release(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_val::multi_val(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +multi_val &multi_val::operator=(multi_val obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +multi_val::~multi_val() { + if (ptr) + isl_multi_val_free(ptr); +} + +__isl_give isl_multi_val *multi_val::copy() const & { + return isl_multi_val_copy(ptr); +} + +__isl_keep isl_multi_val *multi_val::get() const { + return ptr; +} + +__isl_give isl_multi_val *multi_val::release() { + isl_multi_val *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool multi_val::is_null() const { + return ptr == nullptr; +} + +isl::ctx multi_val::ctx() const { + return isl::ctx(isl_multi_val_get_ctx(ptr)); +} + +isl::multi_val multi_val::add(isl::multi_val multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_add(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::add(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_add_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::add(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add(isl::val(ctx(), v)); +} + +isl::multi_val multi_val::flat_range_product(isl::multi_val multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_flat_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val multi_val::at(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_get_at(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val multi_val::get_at(int pos) const +{ + return at(pos); +} + +isl::space multi_val::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space multi_val::get_space() const +{ + return space(); +} + +isl::multi_val multi_val::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool multi_val::plain_is_equal(const isl::multi_val &multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_plain_is_equal(get(), multi2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_val multi_val::product(isl::multi_val multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::range_product(isl::multi_val multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_range_product(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::scale(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_scale_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::multi_val multi_val::scale_down(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_scale_down_multi_val(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::multi_val multi_val::set_at(int pos, isl::val el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_set_at(copy(), pos, el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::set_at(int pos, long el) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->set_at(pos, isl::val(ctx(), el)); +} + +unsigned multi_val::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::multi_val multi_val::sub(isl::multi_val multi2) const +{ + if (!ptr || multi2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_sub(copy(), multi2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_val multi_val::zero(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_multi_val_zero(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const multi_val &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_multi_val_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_multi_val_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::point +point manage(__isl_take isl_point *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return point(ptr); +} +point manage_copy(__isl_keep isl_point *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_point_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_point_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return point(ptr); +} + +point::point() + : ptr(nullptr) {} + +point::point(const point &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_point_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +point::point(__isl_take isl_point *ptr) + : ptr(ptr) {} + +point &point::operator=(point obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +point::~point() { + if (ptr) + isl_point_free(ptr); +} + +__isl_give isl_point *point::copy() const & { + return isl_point_copy(ptr); +} + +__isl_keep isl_point *point::get() const { + return ptr; +} + +__isl_give isl_point *point::release() { + isl_point *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool point::is_null() const { + return ptr == nullptr; +} + +isl::ctx point::ctx() const { + return isl::ctx(isl_point_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const point &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_point_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_point_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::pw_aff +pw_aff manage(__isl_take isl_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return pw_aff(ptr); +} +pw_aff manage_copy(__isl_keep isl_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_pw_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return pw_aff(ptr); +} + +pw_aff::pw_aff() + : ptr(nullptr) {} + +pw_aff::pw_aff(const pw_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +pw_aff::pw_aff(__isl_take isl_pw_aff *ptr) + : ptr(ptr) {} + +pw_aff::pw_aff(isl::aff aff) +{ + if (aff.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = aff.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_from_aff(aff.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_aff::pw_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_aff &pw_aff::operator=(pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_aff::~pw_aff() { + if (ptr) + isl_pw_aff_free(ptr); +} + +__isl_give isl_pw_aff *pw_aff::copy() const & { + return isl_pw_aff_copy(ptr); +} + +__isl_keep isl_pw_aff *pw_aff::get() const { + return ptr; +} + +__isl_give isl_pw_aff *pw_aff::release() { + isl_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx pw_aff::ctx() const { + return isl::ctx(isl_pw_aff_get_ctx(ptr)); +} + +isl::pw_aff pw_aff::add(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_add(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::aff pw_aff::as_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_as_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::bind(isl::id id) const +{ + if (!ptr || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_bind_id(copy(), id.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::bind(const std::string &id) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->bind(isl::id(ctx(), id)); +} + +isl::pw_aff pw_aff::bind_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_bind_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::bind_domain_wrapped_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::ceil() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_ceil(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::cond(isl::pw_aff pwaff_true, isl::pw_aff pwaff_false) const +{ + if (!ptr || pwaff_true.is_null() || pwaff_false.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_cond(copy(), pwaff_true.release(), pwaff_false.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::div(isl::pw_aff pa2) const +{ + if (!ptr || pa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_div(copy(), pa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::eq_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_eq_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val pw_aff::eval(isl::point pnt) const +{ + if (!ptr || pnt.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_eval(copy(), pnt.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::floor() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_floor(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::ge_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_ge_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::gist(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::gt_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_gt_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::intersect_domain(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_intersect_domain(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool pw_aff::isa_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_isa_aff(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::set pw_aff::le_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_le_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::lt_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_lt_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::max(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_max(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::min(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_min(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::mod(isl::val mod) const +{ + if (!ptr || mod.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_mod_val(copy(), mod.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::mod(long mod) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->mod(isl::val(ctx(), mod)); +} + +isl::pw_aff pw_aff::mul(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_mul(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_aff::ne_set(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_ne_set(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::param_on_domain(isl::set domain, isl::id id) +{ + if (domain.is_null() || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = domain.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_param_on_domain_id(domain.release(), id.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::pullback(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_pullback_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::pullback(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_pullback_multi_pw_aff(copy(), mpa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::pullback(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_pullback_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::pw_aff pw_aff::scale_down(isl::val f) const +{ + if (!ptr || f.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_scale_down_val(copy(), f.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::scale_down(long f) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), f)); +} + +isl::pw_aff pw_aff::sub(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_sub(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::subtract_domain(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_subtract_domain(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::tdiv_q(isl::pw_aff pa2) const +{ + if (!ptr || pa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_tdiv_q(copy(), pa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::tdiv_r(isl::pw_aff pa2) const +{ + if (!ptr || pa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_tdiv_r(copy(), pa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff::union_add(isl::pw_aff pwaff2) const +{ + if (!ptr || pwaff2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_union_add(copy(), pwaff2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_pw_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::pw_aff_list +pw_aff_list manage(__isl_take isl_pw_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return pw_aff_list(ptr); +} +pw_aff_list manage_copy(__isl_keep isl_pw_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_pw_aff_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return pw_aff_list(ptr); +} + +pw_aff_list::pw_aff_list() + : ptr(nullptr) {} + +pw_aff_list::pw_aff_list(const pw_aff_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +pw_aff_list::pw_aff_list(__isl_take isl_pw_aff_list *ptr) + : ptr(ptr) {} + +pw_aff_list::pw_aff_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_aff_list::pw_aff_list(isl::pw_aff el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_from_pw_aff(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_aff_list &pw_aff_list::operator=(pw_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_aff_list::~pw_aff_list() { + if (ptr) + isl_pw_aff_list_free(ptr); +} + +__isl_give isl_pw_aff_list *pw_aff_list::copy() const & { + return isl_pw_aff_list_copy(ptr); +} + +__isl_keep isl_pw_aff_list *pw_aff_list::get() const { + return ptr; +} + +__isl_give isl_pw_aff_list *pw_aff_list::release() { + isl_pw_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx pw_aff_list::ctx() const { + return isl::ctx(isl_pw_aff_list_get_ctx(ptr)); +} + +isl::pw_aff_list pw_aff_list::add(isl::pw_aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff_list pw_aff_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff_list pw_aff_list::concat(isl::pw_aff_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void pw_aff_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_pw_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_pw_aff_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::pw_aff pw_aff_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_aff pw_aff_list::get_at(int index) const +{ + return at(index); +} + +unsigned pw_aff_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_aff_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const pw_aff_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_aff_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_pw_aff_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::pw_multi_aff +pw_multi_aff manage(__isl_take isl_pw_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return pw_multi_aff(ptr); +} +pw_multi_aff manage_copy(__isl_keep isl_pw_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_pw_multi_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return pw_multi_aff(ptr); +} + +pw_multi_aff::pw_multi_aff() + : ptr(nullptr) {} + +pw_multi_aff::pw_multi_aff(const pw_multi_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +pw_multi_aff::pw_multi_aff(__isl_take isl_pw_multi_aff *ptr) + : ptr(ptr) {} + +pw_multi_aff::pw_multi_aff(isl::multi_aff ma) +{ + if (ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ma.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_from_multi_aff(ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_multi_aff::pw_multi_aff(isl::pw_aff pa) +{ + if (pa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_from_pw_aff(pa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_multi_aff::pw_multi_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_multi_aff &pw_multi_aff::operator=(pw_multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_multi_aff::~pw_multi_aff() { + if (ptr) + isl_pw_multi_aff_free(ptr); +} + +__isl_give isl_pw_multi_aff *pw_multi_aff::copy() const & { + return isl_pw_multi_aff_copy(ptr); +} + +__isl_keep isl_pw_multi_aff *pw_multi_aff::get() const { + return ptr; +} + +__isl_give isl_pw_multi_aff *pw_multi_aff::release() { + isl_pw_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx pw_multi_aff::ctx() const { + return isl::ctx(isl_pw_multi_aff_get_ctx(ptr)); +} + +isl::pw_multi_aff pw_multi_aff::add(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_add(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_aff pw_multi_aff::as_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_as_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::bind_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_bind_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::bind_domain_wrapped_domain(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_bind_domain_wrapped_domain(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set pw_multi_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::flat_range_product(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_flat_range_product(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void pw_multi_aff::foreach_piece(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_set *arg_0, isl_multi_aff *arg_1, void *arg_2) -> isl_stat { + auto *data = static_cast(arg_2); + ISL_CPP_TRY { + (data->func)(manage(arg_0), manage(arg_1)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_pw_multi_aff_foreach_piece(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::space pw_multi_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space pw_multi_aff::get_space() const +{ + return space(); +} + +isl::pw_multi_aff pw_multi_aff::gist(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_gist(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::intersect_domain(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_intersect_domain(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool pw_multi_aff::isa_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_isa_multi_aff(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +unsigned pw_multi_aff::n_piece() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_n_piece(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::pw_multi_aff pw_multi_aff::product(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_product(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::pullback(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_pullback_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::pullback(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_pullback_pw_multi_aff(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::range_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_range_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::range_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_range_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::range_product(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_range_product(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::scale(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_scale_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::scale(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale(isl::val(ctx(), v)); +} + +isl::pw_multi_aff pw_multi_aff::scale_down(isl::val v) const +{ + if (!ptr || v.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_scale_down_val(copy(), v.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::scale_down(long v) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->scale_down(isl::val(ctx(), v)); +} + +isl::pw_multi_aff pw_multi_aff::sub(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_sub(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::subtract_domain(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_subtract_domain(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::union_add(isl::pw_multi_aff pma2) const +{ + if (!ptr || pma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_union_add(copy(), pma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff::zero(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_zero(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const pw_multi_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_pw_multi_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::pw_multi_aff_list +pw_multi_aff_list manage(__isl_take isl_pw_multi_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return pw_multi_aff_list(ptr); +} +pw_multi_aff_list manage_copy(__isl_keep isl_pw_multi_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_pw_multi_aff_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return pw_multi_aff_list(ptr); +} + +pw_multi_aff_list::pw_multi_aff_list() + : ptr(nullptr) {} + +pw_multi_aff_list::pw_multi_aff_list(const pw_multi_aff_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +pw_multi_aff_list::pw_multi_aff_list(__isl_take isl_pw_multi_aff_list *ptr) + : ptr(ptr) {} + +pw_multi_aff_list::pw_multi_aff_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_multi_aff_list::pw_multi_aff_list(isl::pw_multi_aff el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_from_pw_multi_aff(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +pw_multi_aff_list &pw_multi_aff_list::operator=(pw_multi_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +pw_multi_aff_list::~pw_multi_aff_list() { + if (ptr) + isl_pw_multi_aff_list_free(ptr); +} + +__isl_give isl_pw_multi_aff_list *pw_multi_aff_list::copy() const & { + return isl_pw_multi_aff_list_copy(ptr); +} + +__isl_keep isl_pw_multi_aff_list *pw_multi_aff_list::get() const { + return ptr; +} + +__isl_give isl_pw_multi_aff_list *pw_multi_aff_list::release() { + isl_pw_multi_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool pw_multi_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx pw_multi_aff_list::ctx() const { + return isl::ctx(isl_pw_multi_aff_list_get_ctx(ptr)); +} + +isl::pw_multi_aff_list pw_multi_aff_list::add(isl::pw_multi_aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff_list pw_multi_aff_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff_list pw_multi_aff_list::concat(isl::pw_multi_aff_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void pw_multi_aff_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_pw_multi_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_pw_multi_aff_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::pw_multi_aff pw_multi_aff_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff pw_multi_aff_list::get_at(int index) const +{ + return at(index); +} + +unsigned pw_multi_aff_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_pw_multi_aff_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const pw_multi_aff_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_pw_multi_aff_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_pw_multi_aff_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule +schedule manage(__isl_take isl_schedule *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return schedule(ptr); +} +schedule manage_copy(__isl_keep isl_schedule *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_schedule_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return schedule(ptr); +} + +schedule::schedule() + : ptr(nullptr) {} + +schedule::schedule(const schedule &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +schedule::schedule(__isl_take isl_schedule *ptr) + : ptr(ptr) {} + +schedule::schedule(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +schedule &schedule::operator=(schedule obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule::~schedule() { + if (ptr) + isl_schedule_free(ptr); +} + +__isl_give isl_schedule *schedule::copy() const & { + return isl_schedule_copy(ptr); +} + +__isl_keep isl_schedule *schedule::get() const { + return ptr; +} + +__isl_give isl_schedule *schedule::release() { + isl_schedule *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule::is_null() const { + return ptr == nullptr; +} + +isl::ctx schedule::ctx() const { + return isl::ctx(isl_schedule_get_ctx(ptr)); +} + +isl::schedule schedule::from_domain(isl::union_set domain) +{ + if (domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = domain.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_from_domain(domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule::map() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_get_map(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule::get_map() const +{ + return map(); +} + +isl::schedule_node schedule::root() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_get_root(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule::get_root() const +{ + return root(); +} + +isl::schedule schedule::pullback(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_pullback_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_constraints +schedule_constraints manage(__isl_take isl_schedule_constraints *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return schedule_constraints(ptr); +} +schedule_constraints manage_copy(__isl_keep isl_schedule_constraints *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_constraints_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_schedule_constraints_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return schedule_constraints(ptr); +} + +schedule_constraints::schedule_constraints() + : ptr(nullptr) {} + +schedule_constraints::schedule_constraints(const schedule_constraints &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_constraints_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +schedule_constraints::schedule_constraints(__isl_take isl_schedule_constraints *ptr) + : ptr(ptr) {} + +schedule_constraints::schedule_constraints(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +schedule_constraints &schedule_constraints::operator=(schedule_constraints obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule_constraints::~schedule_constraints() { + if (ptr) + isl_schedule_constraints_free(ptr); +} + +__isl_give isl_schedule_constraints *schedule_constraints::copy() const & { + return isl_schedule_constraints_copy(ptr); +} + +__isl_keep isl_schedule_constraints *schedule_constraints::get() const { + return ptr; +} + +__isl_give isl_schedule_constraints *schedule_constraints::release() { + isl_schedule_constraints *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule_constraints::is_null() const { + return ptr == nullptr; +} + +isl::ctx schedule_constraints::ctx() const { + return isl::ctx(isl_schedule_constraints_get_ctx(ptr)); +} + +isl::schedule schedule_constraints::compute_schedule() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_compute_schedule(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::coincidence() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_coincidence(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::get_coincidence() const +{ + return coincidence(); +} + +isl::union_map schedule_constraints::conditional_validity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_conditional_validity(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::get_conditional_validity() const +{ + return conditional_validity(); +} + +isl::union_map schedule_constraints::conditional_validity_condition() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_conditional_validity_condition(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::get_conditional_validity_condition() const +{ + return conditional_validity_condition(); +} + +isl::set schedule_constraints::context() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_context(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set schedule_constraints::get_context() const +{ + return context(); +} + +isl::union_set schedule_constraints::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_domain(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set schedule_constraints::get_domain() const +{ + return domain(); +} + +isl::union_map schedule_constraints::proximity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_proximity(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::get_proximity() const +{ + return proximity(); +} + +isl::union_map schedule_constraints::validity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_get_validity(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_constraints::get_validity() const +{ + return validity(); +} + +isl::schedule_constraints schedule_constraints::on_domain(isl::union_set domain) +{ + if (domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = domain.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_on_domain(domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_constraints schedule_constraints::set_coincidence(isl::union_map coincidence) const +{ + if (!ptr || coincidence.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_set_coincidence(copy(), coincidence.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_constraints schedule_constraints::set_conditional_validity(isl::union_map condition, isl::union_map validity) const +{ + if (!ptr || condition.is_null() || validity.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_set_conditional_validity(copy(), condition.release(), validity.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_constraints schedule_constraints::set_context(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_set_context(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_constraints schedule_constraints::set_proximity(isl::union_map proximity) const +{ + if (!ptr || proximity.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_set_proximity(copy(), proximity.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_constraints schedule_constraints::set_validity(isl::union_map validity) const +{ + if (!ptr || validity.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_constraints_set_validity(copy(), validity.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_constraints &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_constraints_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_constraints_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node +schedule_node manage(__isl_take isl_schedule_node *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return schedule_node(ptr); +} +schedule_node manage_copy(__isl_keep isl_schedule_node *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_schedule_node_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return schedule_node(ptr); +} + +schedule_node::schedule_node() + : ptr(nullptr) {} + +schedule_node::schedule_node(const schedule_node &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +schedule_node::schedule_node(__isl_take isl_schedule_node *ptr) + : ptr(ptr) {} + +schedule_node &schedule_node::operator=(schedule_node obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +schedule_node::~schedule_node() { + if (ptr) + isl_schedule_node_free(ptr); +} + +__isl_give isl_schedule_node *schedule_node::copy() const & { + return isl_schedule_node_copy(ptr); +} + +__isl_keep isl_schedule_node *schedule_node::get() const { + return ptr; +} + +__isl_give isl_schedule_node *schedule_node::release() { + isl_schedule_node *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool schedule_node::is_null() const { + return ptr == nullptr; +} + +template +bool schedule_node::isa_type(T subtype) const +{ + if (is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return isl_schedule_node_get_type(get()) == subtype; +} +template +bool schedule_node::isa() const +{ + return isa_type(T::type); +} +template +T schedule_node::as() const +{ + if (!isa()) + exception::throw_invalid("not an object of the requested subtype", __FILE__, __LINE__); + return T(copy()); +} + +isl::ctx schedule_node::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::schedule_node schedule_node::ancestor(int generation) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_ancestor(copy(), generation); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::child(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_child(copy(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool schedule_node::every_descendant(const std::function &test) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct test_data { + std::function func; + std::exception_ptr eptr; + } test_data = { test }; + auto test_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + auto ret = (data->func)(manage_copy(arg_0)); + return ret ? isl_bool_true : isl_bool_false; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_bool_error; + } + }; + auto res = isl_schedule_node_every_descendant(get(), test_lambda, &test_data); + if (test_data.eptr) + std::rethrow_exception(test_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::schedule_node schedule_node::first_child() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_first_child(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void schedule_node::foreach_ancestor_top_down(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage_copy(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_schedule_node_foreach_ancestor_top_down(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +void schedule_node::foreach_descendant_top_down(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + auto ret = (data->func)(manage_copy(arg_0)); + return ret ? isl_bool_true : isl_bool_false; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_bool_error; + } + }; + auto res = isl_schedule_node_foreach_descendant_top_down(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::schedule_node schedule_node::from_domain(isl::union_set domain) +{ + if (domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = domain.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_from_domain(domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::from_extension(isl::union_map extension) +{ + if (extension.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = extension.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_from_extension(extension.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +unsigned schedule_node::ancestor_child_position(const isl::schedule_node &ancestor) const +{ + if (!ptr || ancestor.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_ancestor_child_position(get(), ancestor.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +unsigned schedule_node::get_ancestor_child_position(const isl::schedule_node &ancestor) const +{ + return ancestor_child_position(ancestor); +} + +unsigned schedule_node::child_position() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_child_position(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +unsigned schedule_node::get_child_position() const +{ + return child_position(); +} + +isl::multi_union_pw_aff schedule_node::prefix_schedule_multi_union_pw_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_prefix_schedule_multi_union_pw_aff(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff schedule_node::get_prefix_schedule_multi_union_pw_aff() const +{ + return prefix_schedule_multi_union_pw_aff(); +} + +isl::union_map schedule_node::prefix_schedule_union_map() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_prefix_schedule_union_map(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_node::get_prefix_schedule_union_map() const +{ + return prefix_schedule_union_map(); +} + +isl::union_pw_multi_aff schedule_node::prefix_schedule_union_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_prefix_schedule_union_pw_multi_aff(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff schedule_node::get_prefix_schedule_union_pw_multi_aff() const +{ + return prefix_schedule_union_pw_multi_aff(); +} + +isl::schedule schedule_node::schedule() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_schedule(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule schedule_node::get_schedule() const +{ + return schedule(); +} + +isl::schedule_node schedule_node::shared_ancestor(const isl::schedule_node &node2) const +{ + if (!ptr || node2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_shared_ancestor(get(), node2.get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::get_shared_ancestor(const isl::schedule_node &node2) const +{ + return shared_ancestor(node2); +} + +unsigned schedule_node::tree_depth() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_get_tree_depth(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +unsigned schedule_node::get_tree_depth() const +{ + return tree_depth(); +} + +isl::schedule_node schedule_node::graft_after(isl::schedule_node graft) const +{ + if (!ptr || graft.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_graft_after(copy(), graft.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::graft_before(isl::schedule_node graft) const +{ + if (!ptr || graft.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_graft_before(copy(), graft.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool schedule_node::has_children() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_has_children(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool schedule_node::has_next_sibling() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_has_next_sibling(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool schedule_node::has_parent() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_has_parent(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool schedule_node::has_previous_sibling() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_has_previous_sibling(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::schedule_node schedule_node::insert_context(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_context(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_filter(isl::union_set filter) const +{ + if (!ptr || filter.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_filter(copy(), filter.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_guard(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_guard(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_mark(isl::id mark) const +{ + if (!ptr || mark.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_mark(copy(), mark.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_mark(const std::string &mark) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->insert_mark(isl::id(ctx(), mark)); +} + +isl::schedule_node schedule_node::insert_partial_schedule(isl::multi_union_pw_aff schedule) const +{ + if (!ptr || schedule.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_partial_schedule(copy(), schedule.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_sequence(isl::union_set_list filters) const +{ + if (!ptr || filters.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_sequence(copy(), filters.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::insert_set(isl::union_set_list filters) const +{ + if (!ptr || filters.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_insert_set(copy(), filters.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool schedule_node::is_equal(const isl::schedule_node &node2) const +{ + if (!ptr || node2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_is_equal(get(), node2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool schedule_node::is_subtree_anchored() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_is_subtree_anchored(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::schedule_node schedule_node::map_descendant_bottom_up(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_schedule_node *arg_0, void *arg_1) -> isl_schedule_node * { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + auto ret = (data->func)(manage(arg_0)); + return ret.release(); + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return NULL; + } + }; + auto res = isl_schedule_node_map_descendant_bottom_up(copy(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +unsigned schedule_node::n_children() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_n_children(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::schedule_node schedule_node::next_sibling() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_next_sibling(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::order_after(isl::union_set filter) const +{ + if (!ptr || filter.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_order_after(copy(), filter.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::order_before(isl::union_set filter) const +{ + if (!ptr || filter.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_order_before(copy(), filter.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::parent() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_parent(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::previous_sibling() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_previous_sibling(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::schedule_node schedule_node::root() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_root(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_band +schedule_node_band::schedule_node_band() + : schedule_node() {} + +schedule_node_band::schedule_node_band(const schedule_node_band &obj) + : schedule_node(obj) +{ +} + +schedule_node_band::schedule_node_band(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_band &schedule_node_band::operator=(schedule_node_band obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_band::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::union_set schedule_node_band::ast_build_options() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_get_ast_build_options(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set schedule_node_band::get_ast_build_options() const +{ + return ast_build_options(); +} + +isl::set schedule_node_band::ast_isolate_option() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_get_ast_isolate_option(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set schedule_node_band::get_ast_isolate_option() const +{ + return ast_isolate_option(); +} + +isl::multi_union_pw_aff schedule_node_band::partial_schedule() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_get_partial_schedule(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::multi_union_pw_aff schedule_node_band::get_partial_schedule() const +{ + return partial_schedule(); +} + +bool schedule_node_band::permutable() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_get_permutable(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool schedule_node_band::get_permutable() const +{ + return permutable(); +} + +bool schedule_node_band::member_get_coincident(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_get_coincident(get(), pos); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +schedule_node_band schedule_node_band::member_set_coincident(int pos, int coincident) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_set_coincident(copy(), pos, coincident); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::mod(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_mod(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +unsigned schedule_node_band::n_member() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_n_member(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +schedule_node_band schedule_node_band::scale(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_scale(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::scale_down(isl::multi_val mv) const +{ + if (!ptr || mv.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_scale_down(copy(), mv.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::set_ast_build_options(isl::union_set options) const +{ + if (!ptr || options.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_set_ast_build_options(copy(), options.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::set_permutable(int permutable) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_set_permutable(copy(), permutable); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::shift(isl::multi_union_pw_aff shift) const +{ + if (!ptr || shift.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_shift(copy(), shift.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::split(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_split(copy(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +schedule_node_band schedule_node_band::tile(isl::multi_val sizes) const +{ + if (!ptr || sizes.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_tile(copy(), sizes.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_default(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_default); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_atomic(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_atomic); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_unroll(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_unroll); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + + +schedule_node_band schedule_node_band::member_set_ast_loop_separate(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_band_member_set_ast_loop_type(copy(), pos, isl_ast_loop_separate); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res).as(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_band &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_context +schedule_node_context::schedule_node_context() + : schedule_node() {} + +schedule_node_context::schedule_node_context(const schedule_node_context &obj) + : schedule_node(obj) +{ +} + +schedule_node_context::schedule_node_context(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_context &schedule_node_context::operator=(schedule_node_context obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_context::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::set schedule_node_context::context() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_context_get_context(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set schedule_node_context::get_context() const +{ + return context(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_context &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_domain +schedule_node_domain::schedule_node_domain() + : schedule_node() {} + +schedule_node_domain::schedule_node_domain(const schedule_node_domain &obj) + : schedule_node(obj) +{ +} + +schedule_node_domain::schedule_node_domain(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_domain &schedule_node_domain::operator=(schedule_node_domain obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_domain::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::union_set schedule_node_domain::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_domain_get_domain(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set schedule_node_domain::get_domain() const +{ + return domain(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_domain &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_expansion +schedule_node_expansion::schedule_node_expansion() + : schedule_node() {} + +schedule_node_expansion::schedule_node_expansion(const schedule_node_expansion &obj) + : schedule_node(obj) +{ +} + +schedule_node_expansion::schedule_node_expansion(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_expansion &schedule_node_expansion::operator=(schedule_node_expansion obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_expansion::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::union_pw_multi_aff schedule_node_expansion::contraction() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_expansion_get_contraction(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff schedule_node_expansion::get_contraction() const +{ + return contraction(); +} + +isl::union_map schedule_node_expansion::expansion() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_expansion_get_expansion(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_node_expansion::get_expansion() const +{ + return expansion(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_expansion &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_extension +schedule_node_extension::schedule_node_extension() + : schedule_node() {} + +schedule_node_extension::schedule_node_extension(const schedule_node_extension &obj) + : schedule_node(obj) +{ +} + +schedule_node_extension::schedule_node_extension(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_extension &schedule_node_extension::operator=(schedule_node_extension obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_extension::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::union_map schedule_node_extension::extension() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_extension_get_extension(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map schedule_node_extension::get_extension() const +{ + return extension(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_extension &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_filter +schedule_node_filter::schedule_node_filter() + : schedule_node() {} + +schedule_node_filter::schedule_node_filter(const schedule_node_filter &obj) + : schedule_node(obj) +{ +} + +schedule_node_filter::schedule_node_filter(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_filter &schedule_node_filter::operator=(schedule_node_filter obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_filter::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::union_set schedule_node_filter::filter() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_filter_get_filter(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set schedule_node_filter::get_filter() const +{ + return filter(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_filter &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_guard +schedule_node_guard::schedule_node_guard() + : schedule_node() {} + +schedule_node_guard::schedule_node_guard(const schedule_node_guard &obj) + : schedule_node(obj) +{ +} + +schedule_node_guard::schedule_node_guard(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_guard &schedule_node_guard::operator=(schedule_node_guard obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_guard::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +isl::set schedule_node_guard::guard() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_schedule_node_guard_get_guard(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set schedule_node_guard::get_guard() const +{ + return guard(); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_guard &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_leaf +schedule_node_leaf::schedule_node_leaf() + : schedule_node() {} + +schedule_node_leaf::schedule_node_leaf(const schedule_node_leaf &obj) + : schedule_node(obj) +{ +} + +schedule_node_leaf::schedule_node_leaf(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_leaf &schedule_node_leaf::operator=(schedule_node_leaf obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_leaf::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_leaf &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_mark +schedule_node_mark::schedule_node_mark() + : schedule_node() {} + +schedule_node_mark::schedule_node_mark(const schedule_node_mark &obj) + : schedule_node(obj) +{ +} + +schedule_node_mark::schedule_node_mark(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_mark &schedule_node_mark::operator=(schedule_node_mark obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_mark::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_mark &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_sequence +schedule_node_sequence::schedule_node_sequence() + : schedule_node() {} + +schedule_node_sequence::schedule_node_sequence(const schedule_node_sequence &obj) + : schedule_node(obj) +{ +} + +schedule_node_sequence::schedule_node_sequence(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_sequence &schedule_node_sequence::operator=(schedule_node_sequence obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_sequence::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_sequence &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::schedule_node_set +schedule_node_set::schedule_node_set() + : schedule_node() {} + +schedule_node_set::schedule_node_set(const schedule_node_set &obj) + : schedule_node(obj) +{ +} + +schedule_node_set::schedule_node_set(__isl_take isl_schedule_node *ptr) + : schedule_node(ptr) {} + +schedule_node_set &schedule_node_set::operator=(schedule_node_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +isl::ctx schedule_node_set::ctx() const { + return isl::ctx(isl_schedule_node_get_ctx(ptr)); +} + +inline std::ostream &operator<<(std::ostream &os, const schedule_node_set &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_schedule_node_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_schedule_node_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::set +set manage(__isl_take isl_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return set(ptr); +} +set manage_copy(__isl_keep isl_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_set_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_set_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return set(ptr); +} + +set::set() + : ptr(nullptr) {} + +set::set(const set &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_set_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +set::set(__isl_take isl_set *ptr) + : ptr(ptr) {} + +set::set(isl::basic_set bset) +{ + if (bset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = bset.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_from_basic_set(bset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +set::set(isl::point pnt) +{ + if (pnt.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pnt.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_from_point(pnt.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +set::set(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +set &set::operator=(set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +set::~set() { + if (ptr) + isl_set_free(ptr); +} + +__isl_give isl_set *set::copy() const & { + return isl_set_copy(ptr); +} + +__isl_keep isl_set *set::get() const { + return ptr; +} + +__isl_give isl_set *set::release() { + isl_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool set::is_null() const { + return ptr == nullptr; +} + +isl::ctx set::ctx() const { + return isl::ctx(isl_set_get_ctx(ptr)); +} + +isl::basic_set set::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::apply(isl::map map) const +{ + if (!ptr || map.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_apply(copy(), map.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::bind(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_bind(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::coalesce() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_coalesce(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::complement() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_complement(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::empty(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_empty(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::flatten() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_flatten(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void set::foreach_basic_set(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_basic_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_set_foreach_basic_set(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +void set::foreach_point(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_point *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_set_foreach_point(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::space set::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space set::get_space() const +{ + return space(); +} + +isl::val set::stride(int pos) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_get_stride(get(), pos); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val set::get_stride(int pos) const +{ + return stride(pos); +} + +isl::set set::gist(isl::set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map set::identity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_identity(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::intersect(isl::set set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_intersect(copy(), set2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::intersect_params(isl::set params) const +{ + if (!ptr || params.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_intersect_params(copy(), params.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool set::is_disjoint(const isl::set &set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_disjoint(get(), set2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_equal(const isl::set &set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_equal(get(), set2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_singleton() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_singleton(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_strict_subset(const isl::set &set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_strict_subset(get(), set2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_subset(const isl::set &set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_subset(get(), set2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool set::is_wrapping() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_is_wrapping(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::set set::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff set::lexmax_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_lexmax_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff set::lexmin_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_lexmin_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val set::max_val(const isl::aff &obj) const +{ + if (!ptr || obj.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_max_val(get(), obj.get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val set::min_val(const isl::aff &obj) const +{ + if (!ptr || obj.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_min_val(get(), obj.get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set set::polyhedral_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_polyhedral_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::preimage(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_preimage_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::preimage(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_preimage_multi_pw_aff(copy(), mpa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::preimage(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_preimage_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::product(isl::set set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_product(copy(), set2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::project_out_all_params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_project_out_all_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::project_out_param(isl::id id) const +{ + if (!ptr || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_project_out_param_id(copy(), id.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::project_out_param(const std::string &id) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->project_out_param(isl::id(ctx(), id)); +} + +isl::set set::project_out_param(isl::id_list list) const +{ + if (!ptr || list.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_project_out_param_id_list(copy(), list.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set set::sample() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_sample(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::point set::sample_point() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_sample_point(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::subtract(isl::set set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_subtract(copy(), set2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::unbind_params(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_unbind_params(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map set::unbind_params_insert_domain(isl::multi_id domain) const +{ + if (!ptr || domain.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_unbind_params_insert_domain(copy(), domain.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::unite(isl::set set2) const +{ + if (!ptr || set2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_union(copy(), set2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::set set::universe(isl::space space) +{ + if (space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = space.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_universe(space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::basic_set set::unshifted_simple_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_unshifted_simple_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::map set::unwrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_set_unwrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const set &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_set_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_set_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::space +space manage(__isl_take isl_space *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return space(ptr); +} +space manage_copy(__isl_keep isl_space *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_space_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_space_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return space(ptr); +} + +space::space() + : ptr(nullptr) {} + +space::space(const space &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_space_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +space::space(__isl_take isl_space *ptr) + : ptr(ptr) {} + +space &space::operator=(space obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +space::~space() { + if (ptr) + isl_space_free(ptr); +} + +__isl_give isl_space *space::copy() const & { + return isl_space_copy(ptr); +} + +__isl_keep isl_space *space::get() const { + return ptr; +} + +__isl_give isl_space *space::release() { + isl_space *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool space::is_null() const { + return ptr == nullptr; +} + +isl::ctx space::ctx() const { + return isl::ctx(isl_space_get_ctx(ptr)); +} + +isl::space space::add_named_tuple(isl::id tuple_id, unsigned int dim) const +{ + if (!ptr || tuple_id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_add_named_tuple_id_ui(copy(), tuple_id.release(), dim); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::add_named_tuple(const std::string &tuple_id, unsigned int dim) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add_named_tuple(isl::id(ctx(), tuple_id), dim); +} + +isl::space space::add_unnamed_tuple(unsigned int dim) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_add_unnamed_tuple_ui(copy(), dim); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::flatten_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_flatten_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::flatten_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_flatten_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool space::is_equal(const isl::space &space2) const +{ + if (!ptr || space2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_is_equal(get(), space2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool space::is_wrapping() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_is_wrapping(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::space space::map_from_set() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_map_from_set(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::unit(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_unit(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::unwrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_unwrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space space::wrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_space_wrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const space &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_space_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_space_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_access_info +union_access_info manage(__isl_take isl_union_access_info *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_access_info(ptr); +} +union_access_info manage_copy(__isl_keep isl_union_access_info *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_access_info_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_access_info_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_access_info(ptr); +} + +union_access_info::union_access_info() + : ptr(nullptr) {} + +union_access_info::union_access_info(const union_access_info &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_access_info_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_access_info::union_access_info(__isl_take isl_union_access_info *ptr) + : ptr(ptr) {} + +union_access_info::union_access_info(isl::union_map sink) +{ + if (sink.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = sink.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_from_sink(sink.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_access_info &union_access_info::operator=(union_access_info obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_access_info::~union_access_info() { + if (ptr) + isl_union_access_info_free(ptr); +} + +__isl_give isl_union_access_info *union_access_info::copy() const & { + return isl_union_access_info_copy(ptr); +} + +__isl_keep isl_union_access_info *union_access_info::get() const { + return ptr; +} + +__isl_give isl_union_access_info *union_access_info::release() { + isl_union_access_info *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_access_info::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_access_info::ctx() const { + return isl::ctx(isl_union_access_info_get_ctx(ptr)); +} + +isl::union_flow union_access_info::compute_flow() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_compute_flow(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_access_info union_access_info::set_kill(isl::union_map kill) const +{ + if (!ptr || kill.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_set_kill(copy(), kill.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_access_info union_access_info::set_may_source(isl::union_map may_source) const +{ + if (!ptr || may_source.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_set_may_source(copy(), may_source.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_access_info union_access_info::set_must_source(isl::union_map must_source) const +{ + if (!ptr || must_source.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_set_must_source(copy(), must_source.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_access_info union_access_info::set_schedule(isl::schedule schedule) const +{ + if (!ptr || schedule.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_set_schedule(copy(), schedule.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_access_info union_access_info::set_schedule_map(isl::union_map schedule_map) const +{ + if (!ptr || schedule_map.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_access_info_set_schedule_map(copy(), schedule_map.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_access_info &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_access_info_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_access_info_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_flow +union_flow manage(__isl_take isl_union_flow *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_flow(ptr); +} +union_flow manage_copy(__isl_keep isl_union_flow *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_flow_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_flow_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_flow(ptr); +} + +union_flow::union_flow() + : ptr(nullptr) {} + +union_flow::union_flow(const union_flow &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_flow_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_flow::union_flow(__isl_take isl_union_flow *ptr) + : ptr(ptr) {} + +union_flow &union_flow::operator=(union_flow obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_flow::~union_flow() { + if (ptr) + isl_union_flow_free(ptr); +} + +__isl_give isl_union_flow *union_flow::copy() const & { + return isl_union_flow_copy(ptr); +} + +__isl_keep isl_union_flow *union_flow::get() const { + return ptr; +} + +__isl_give isl_union_flow *union_flow::release() { + isl_union_flow *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_flow::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_flow::ctx() const { + return isl::ctx(isl_union_flow_get_ctx(ptr)); +} + +isl::union_map union_flow::full_may_dependence() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_full_may_dependence(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_full_may_dependence() const +{ + return full_may_dependence(); +} + +isl::union_map union_flow::full_must_dependence() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_full_must_dependence(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_full_must_dependence() const +{ + return full_must_dependence(); +} + +isl::union_map union_flow::may_dependence() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_may_dependence(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_may_dependence() const +{ + return may_dependence(); +} + +isl::union_map union_flow::may_no_source() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_may_no_source(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_may_no_source() const +{ + return may_no_source(); +} + +isl::union_map union_flow::must_dependence() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_must_dependence(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_must_dependence() const +{ + return must_dependence(); +} + +isl::union_map union_flow::must_no_source() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_flow_get_must_no_source(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_flow::get_must_no_source() const +{ + return must_no_source(); +} + +inline std::ostream &operator<<(std::ostream &os, const union_flow &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_flow_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_flow_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_map +union_map manage(__isl_take isl_union_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_map(ptr); +} +union_map manage_copy(__isl_keep isl_union_map *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_map_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_map_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_map(ptr); +} + +union_map::union_map() + : ptr(nullptr) {} + +union_map::union_map(const union_map &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_map_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_map::union_map(__isl_take isl_union_map *ptr) + : ptr(ptr) {} + +union_map::union_map(isl::basic_map bmap) +{ + if (bmap.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = bmap.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_basic_map(bmap.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_map::union_map(isl::map map) +{ + if (map.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = map.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_map(map.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_map::union_map(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_map &union_map::operator=(union_map obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_map::~union_map() { + if (ptr) + isl_union_map_free(ptr); +} + +__isl_give isl_union_map *union_map::copy() const & { + return isl_union_map_copy(ptr); +} + +__isl_keep isl_union_map *union_map::get() const { + return ptr; +} + +__isl_give isl_union_map *union_map::release() { + isl_union_map *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_map::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_map::ctx() const { + return isl::ctx(isl_union_map_get_ctx(ptr)); +} + +isl::union_map union_map::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::apply_domain(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_apply_domain(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::apply_range(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_apply_range(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_map::bind_range(isl::multi_id tuple) const +{ + if (!ptr || tuple.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_bind_range(copy(), tuple.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::coalesce() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_coalesce(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::compute_divs() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_compute_divs(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::curry() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_curry(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_map::deltas() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_deltas(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_map::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::domain_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::domain_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::domain_map() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain_map(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_map::domain_map_union_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain_map_union_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::domain_product(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_domain_product(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::empty(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_empty_ctx(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::eq_at(isl::multi_union_pw_aff mupa) const +{ + if (!ptr || mupa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_eq_at_multi_union_pw_aff(copy(), mupa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool union_map::every_map(const std::function &test) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct test_data { + std::function func; + std::exception_ptr eptr; + } test_data = { test }; + auto test_lambda = [](isl_map *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + auto ret = (data->func)(manage_copy(arg_0)); + return ret ? isl_bool_true : isl_bool_false; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_bool_error; + } + }; + auto res = isl_union_map_every_map(get(), test_lambda, &test_data); + if (test_data.eptr) + std::rethrow_exception(test_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::map union_map::extract_map(isl::space dim) const +{ + if (!ptr || dim.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_extract_map(get(), dim.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::fixed_power(isl::val exp) const +{ + if (!ptr || exp.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_fixed_power_val(copy(), exp.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::fixed_power(long exp) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->fixed_power(isl::val(ctx(), exp)); +} + +void union_map::foreach_map(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_map *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_union_map_foreach_map(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::union_map union_map::from(isl::multi_union_pw_aff mupa) +{ + if (mupa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = mupa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_multi_union_pw_aff(mupa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::from(isl::union_pw_multi_aff upma) +{ + if (upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = upma.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_union_pw_multi_aff(upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::from_domain(isl::union_set uset) +{ + if (uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = uset.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_domain(uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::from_domain_and_range(isl::union_set domain, isl::union_set range) +{ + if (domain.is_null() || range.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = domain.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_domain_and_range(domain.release(), range.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::from_range(isl::union_set uset) +{ + if (uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = uset.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_from_range(uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_map::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_map::get_space() const +{ + return space(); +} + +isl::union_map union_map::gist(isl::union_map context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::gist_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_gist_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::gist_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_gist_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::gist_range(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_gist_range(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::intersect(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_intersect(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::intersect_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_intersect_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::intersect_range(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_intersect_range(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool union_map::is_bijective() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_bijective(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_disjoint(const isl::union_map &umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_disjoint(get(), umap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_equal(const isl::union_map &umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_equal(get(), umap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_injective() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_injective(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_single_valued() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_single_valued(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_strict_subset(const isl::union_map &umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_strict_subset(get(), umap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::is_subset(const isl::union_map &umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_is_subset(get(), umap2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_map::isa_map() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_isa_map(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::union_map union_map::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::polyhedral_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_polyhedral_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_domain(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_domain_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_domain(isl::multi_pw_aff mpa) const +{ + if (!ptr || mpa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_domain_multi_pw_aff(copy(), mpa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_domain(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_domain_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_domain(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_domain_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_range(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_range_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_range(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_range_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::preimage_range(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_preimage_range_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::product(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_product(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::project_out_all_params() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_project_out_all_params(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_map::range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::range_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_range_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::range_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_range_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::range_map() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_range_map(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::range_product(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_range_product(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::reverse() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_reverse(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::subtract(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_subtract(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::subtract_domain(isl::union_set dom) const +{ + if (!ptr || dom.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_subtract_domain(copy(), dom.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::subtract_range(isl::union_set dom) const +{ + if (!ptr || dom.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_subtract_range(copy(), dom.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::uncurry() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_uncurry(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::unite(isl::union_map umap2) const +{ + if (!ptr || umap2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_union(copy(), umap2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::universe() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_universe(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_map::wrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_wrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_map::zip() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_map_zip(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_map &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_map_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_map_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_aff +union_pw_aff manage(__isl_take isl_union_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_pw_aff(ptr); +} +union_pw_aff manage_copy(__isl_keep isl_union_pw_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_pw_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_pw_aff(ptr); +} + +union_pw_aff::union_pw_aff() + : ptr(nullptr) {} + +union_pw_aff::union_pw_aff(const union_pw_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_pw_aff::union_pw_aff(__isl_take isl_union_pw_aff *ptr) + : ptr(ptr) {} + +union_pw_aff::union_pw_aff(isl::pw_aff pa) +{ + if (pa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_from_pw_aff(pa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_aff::union_pw_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_aff &union_pw_aff::operator=(union_pw_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_aff::~union_pw_aff() { + if (ptr) + isl_union_pw_aff_free(ptr); +} + +__isl_give isl_union_pw_aff *union_pw_aff::copy() const & { + return isl_union_pw_aff_copy(ptr); +} + +__isl_keep isl_union_pw_aff *union_pw_aff::get() const { + return ptr; +} + +__isl_give isl_union_pw_aff *union_pw_aff::release() { + isl_union_pw_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_pw_aff::ctx() const { + return isl::ctx(isl_union_pw_aff_get_ctx(ptr)); +} + +isl::union_pw_aff union_pw_aff::add(isl::union_pw_aff upa2) const +{ + if (!ptr || upa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_add(copy(), upa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_pw_aff::bind(isl::id id) const +{ + if (!ptr || id.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_bind_id(copy(), id.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_pw_aff::bind(const std::string &id) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->bind(isl::id(ctx(), id)); +} + +isl::union_set union_pw_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_pw_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_pw_aff::get_space() const +{ + return space(); +} + +isl::union_pw_aff union_pw_aff::gist(isl::union_set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::intersect_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_intersect_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::intersect_domain_wrapped_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_intersect_domain_wrapped_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::intersect_domain_wrapped_range(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_intersect_domain_wrapped_range(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::pullback(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_pullback_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::sub(isl::union_pw_aff upa2) const +{ + if (!ptr || upa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_sub(copy(), upa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::subtract_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_subtract_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff::union_add(isl::union_pw_aff upa2) const +{ + if (!ptr || upa2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_union_add(copy(), upa2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_pw_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_aff_list +union_pw_aff_list manage(__isl_take isl_union_pw_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_pw_aff_list(ptr); +} +union_pw_aff_list manage_copy(__isl_keep isl_union_pw_aff_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_pw_aff_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_pw_aff_list(ptr); +} + +union_pw_aff_list::union_pw_aff_list() + : ptr(nullptr) {} + +union_pw_aff_list::union_pw_aff_list(const union_pw_aff_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_pw_aff_list::union_pw_aff_list(__isl_take isl_union_pw_aff_list *ptr) + : ptr(ptr) {} + +union_pw_aff_list::union_pw_aff_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_aff_list::union_pw_aff_list(isl::union_pw_aff el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_from_union_pw_aff(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_aff_list &union_pw_aff_list::operator=(union_pw_aff_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_aff_list::~union_pw_aff_list() { + if (ptr) + isl_union_pw_aff_list_free(ptr); +} + +__isl_give isl_union_pw_aff_list *union_pw_aff_list::copy() const & { + return isl_union_pw_aff_list_copy(ptr); +} + +__isl_keep isl_union_pw_aff_list *union_pw_aff_list::get() const { + return ptr; +} + +__isl_give isl_union_pw_aff_list *union_pw_aff_list::release() { + isl_union_pw_aff_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_aff_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_pw_aff_list::ctx() const { + return isl::ctx(isl_union_pw_aff_list_get_ctx(ptr)); +} + +isl::union_pw_aff_list union_pw_aff_list::add(isl::union_pw_aff el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff_list union_pw_aff_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff_list union_pw_aff_list::concat(isl::union_pw_aff_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void union_pw_aff_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_union_pw_aff *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_union_pw_aff_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::union_pw_aff union_pw_aff_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_aff union_pw_aff_list::get_at(int index) const +{ + return at(index); +} + +unsigned union_pw_aff_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_aff_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_aff_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_aff_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_pw_aff_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_pw_multi_aff +union_pw_multi_aff manage(__isl_take isl_union_pw_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_pw_multi_aff(ptr); +} +union_pw_multi_aff manage_copy(__isl_keep isl_union_pw_multi_aff *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_multi_aff_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_pw_multi_aff_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_pw_multi_aff(ptr); +} + +union_pw_multi_aff::union_pw_multi_aff() + : ptr(nullptr) {} + +union_pw_multi_aff::union_pw_multi_aff(const union_pw_multi_aff &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_multi_aff_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_pw_multi_aff::union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *ptr) + : ptr(ptr) {} + +union_pw_multi_aff::union_pw_multi_aff(isl::pw_multi_aff pma) +{ + if (pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pma.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_from_pw_multi_aff(pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_multi_aff::union_pw_multi_aff(isl::union_pw_aff upa) +{ + if (upa.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = upa.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_from_union_pw_aff(upa.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_multi_aff::union_pw_multi_aff(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_pw_multi_aff &union_pw_multi_aff::operator=(union_pw_multi_aff obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_pw_multi_aff::~union_pw_multi_aff() { + if (ptr) + isl_union_pw_multi_aff_free(ptr); +} + +__isl_give isl_union_pw_multi_aff *union_pw_multi_aff::copy() const & { + return isl_union_pw_multi_aff_copy(ptr); +} + +__isl_keep isl_union_pw_multi_aff *union_pw_multi_aff::get() const { + return ptr; +} + +__isl_give isl_union_pw_multi_aff *union_pw_multi_aff::release() { + isl_union_pw_multi_aff *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_pw_multi_aff::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_pw_multi_aff::ctx() const { + return isl::ctx(isl_union_pw_multi_aff_get_ctx(ptr)); +} + +isl::union_pw_multi_aff union_pw_multi_aff::add(isl::union_pw_multi_aff upma2) const +{ + if (!ptr || upma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_add(copy(), upma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff union_pw_multi_aff::as_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_as_pw_multi_aff(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_pw_multi_aff::domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::empty(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_empty_ctx(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::pw_multi_aff union_pw_multi_aff::extract_pw_multi_aff(isl::space space) const +{ + if (!ptr || space.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_extract_pw_multi_aff(get(), space.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::flat_range_product(isl::union_pw_multi_aff upma2) const +{ + if (!ptr || upma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_flat_range_product(copy(), upma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_pw_multi_aff::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_pw_multi_aff::get_space() const +{ + return space(); +} + +isl::union_pw_multi_aff union_pw_multi_aff::gist(isl::union_set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::intersect_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_intersect_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::intersect_domain_wrapped_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_intersect_domain_wrapped_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::intersect_domain_wrapped_range(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_intersect_domain_wrapped_range(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool union_pw_multi_aff::isa_pw_multi_aff() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_isa_pw_multi_aff(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::union_pw_multi_aff union_pw_multi_aff::pullback(isl::union_pw_multi_aff upma2) const +{ + if (!ptr || upma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_pullback_union_pw_multi_aff(copy(), upma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::range_factor_domain() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_range_factor_domain(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::range_factor_range() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_range_factor_range(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::sub(isl::union_pw_multi_aff upma2) const +{ + if (!ptr || upma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_sub(copy(), upma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::subtract_domain(isl::union_set uset) const +{ + if (!ptr || uset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_subtract_domain(copy(), uset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_pw_multi_aff union_pw_multi_aff::union_add(isl::union_pw_multi_aff upma2) const +{ + if (!ptr || upma2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_pw_multi_aff_union_add(copy(), upma2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_pw_multi_aff &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_pw_multi_aff_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_pw_multi_aff_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_set +union_set manage(__isl_take isl_union_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_set(ptr); +} +union_set manage_copy(__isl_keep isl_union_set *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_set_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_set(ptr); +} + +union_set::union_set() + : ptr(nullptr) {} + +union_set::union_set(const union_set &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_set::union_set(__isl_take isl_union_set *ptr) + : ptr(ptr) {} + +union_set::union_set(isl::basic_set bset) +{ + if (bset.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = bset.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_from_basic_set(bset.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set::union_set(isl::point pnt) +{ + if (pnt.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = pnt.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_from_point(pnt.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set::union_set(isl::set set) +{ + if (set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = set.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_from_set(set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set::union_set(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set &union_set::operator=(union_set obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_set::~union_set() { + if (ptr) + isl_union_set_free(ptr); +} + +__isl_give isl_union_set *union_set::copy() const & { + return isl_union_set_copy(ptr); +} + +__isl_keep isl_union_set *union_set::get() const { + return ptr; +} + +__isl_give isl_union_set *union_set::release() { + isl_union_set *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_set::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_set::ctx() const { + return isl::ctx(isl_union_set_get_ctx(ptr)); +} + +isl::union_set union_set::affine_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_affine_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::apply(isl::union_map umap) const +{ + if (!ptr || umap.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_apply(copy(), umap.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::coalesce() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_coalesce(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::compute_divs() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_compute_divs(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::detect_equalities() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_detect_equalities(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::empty(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_empty_ctx(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool union_set::every_set(const std::function &test) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct test_data { + std::function func; + std::exception_ptr eptr; + } test_data = { test }; + auto test_lambda = [](isl_set *arg_0, void *arg_1) -> isl_bool { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + auto ret = (data->func)(manage_copy(arg_0)); + return ret ? isl_bool_true : isl_bool_false; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_bool_error; + } + }; + auto res = isl_union_set_every_set(get(), test_lambda, &test_data); + if (test_data.eptr) + std::rethrow_exception(test_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::set union_set::extract_set(isl::space dim) const +{ + if (!ptr || dim.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_extract_set(get(), dim.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void union_set::foreach_point(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_point *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_union_set_foreach_point(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +void union_set::foreach_set(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_union_set_foreach_set(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::space union_set::space() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_get_space(get()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::space union_set::get_space() const +{ + return space(); +} + +isl::union_set union_set::gist(isl::union_set context) const +{ + if (!ptr || context.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_gist(copy(), context.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::gist_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_gist_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_set::identity() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_identity(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::intersect(isl::union_set uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_intersect(copy(), uset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::intersect_params(isl::set set) const +{ + if (!ptr || set.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_intersect_params(copy(), set.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool union_set::is_disjoint(const isl::union_set &uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_is_disjoint(get(), uset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_set::is_empty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_is_empty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_set::is_equal(const isl::union_set &uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_is_equal(get(), uset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_set::is_strict_subset(const isl::union_set &uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_is_strict_subset(get(), uset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_set::is_subset(const isl::union_set &uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_is_subset(get(), uset2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool union_set::isa_set() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_isa_set(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +isl::union_set union_set::lexmax() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_lexmax(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::lexmin() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_lexmin(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::polyhedral_hull() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_polyhedral_hull(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::preimage(isl::multi_aff ma) const +{ + if (!ptr || ma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_preimage_multi_aff(copy(), ma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::preimage(isl::pw_multi_aff pma) const +{ + if (!ptr || pma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_preimage_pw_multi_aff(copy(), pma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::preimage(isl::union_pw_multi_aff upma) const +{ + if (!ptr || upma.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_preimage_union_pw_multi_aff(copy(), upma.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::point union_set::sample_point() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_sample_point(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::subtract(isl::union_set uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_subtract(copy(), uset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::unite(isl::union_set uset2) const +{ + if (!ptr || uset2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_union(copy(), uset2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set::universe() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_universe(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_map union_set::unwrap() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_unwrap(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const union_set &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_set_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::union_set_list +union_set_list manage(__isl_take isl_union_set_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return union_set_list(ptr); +} +union_set_list manage_copy(__isl_keep isl_union_set_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_union_set_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return union_set_list(ptr); +} + +union_set_list::union_set_list() + : ptr(nullptr) {} + +union_set_list::union_set_list(const union_set_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +union_set_list::union_set_list(__isl_take isl_union_set_list *ptr) + : ptr(ptr) {} + +union_set_list::union_set_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set_list::union_set_list(isl::union_set el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_from_union_set(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +union_set_list &union_set_list::operator=(union_set_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +union_set_list::~union_set_list() { + if (ptr) + isl_union_set_list_free(ptr); +} + +__isl_give isl_union_set_list *union_set_list::copy() const & { + return isl_union_set_list_copy(ptr); +} + +__isl_keep isl_union_set_list *union_set_list::get() const { + return ptr; +} + +__isl_give isl_union_set_list *union_set_list::release() { + isl_union_set_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool union_set_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx union_set_list::ctx() const { + return isl::ctx(isl_union_set_list_get_ctx(ptr)); +} + +isl::union_set_list union_set_list::add(isl::union_set el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set_list union_set_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set_list union_set_list::concat(isl::union_set_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void union_set_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_union_set *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_union_set_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::union_set union_set_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::union_set union_set_list::get_at(int index) const +{ + return at(index); +} + +unsigned union_set_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_union_set_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const union_set_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_union_set_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_union_set_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::val +val manage(__isl_take isl_val *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return val(ptr); +} +val manage_copy(__isl_keep isl_val *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_val_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return val(ptr); +} + +val::val() + : ptr(nullptr) {} + +val::val(const val &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +val::val(__isl_take isl_val *ptr) + : ptr(ptr) {} + +val::val(isl::ctx ctx, long i) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_int_from_si(ctx.release(), i); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +val::val(isl::ctx ctx, const std::string &str) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_read_from_str(ctx.release(), str.c_str()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +val &val::operator=(val obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +val::~val() { + if (ptr) + isl_val_free(ptr); +} + +__isl_give isl_val *val::copy() const & { + return isl_val_copy(ptr); +} + +__isl_keep isl_val *val::get() const { + return ptr; +} + +__isl_give isl_val *val::release() { + isl_val *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool val::is_null() const { + return ptr == nullptr; +} + +isl::ctx val::ctx() const { + return isl::ctx(isl_val_get_ctx(ptr)); +} + +isl::val val::abs() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_abs(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool val::abs_eq(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_abs_eq(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::abs_eq(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->abs_eq(isl::val(ctx(), v2)); +} + +isl::val val::add(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_add(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::add(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add(isl::val(ctx(), v2)); +} + +isl::val val::ceil() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_ceil(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +int val::cmp_si(long i) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_cmp_si(get(), i); + return res; +} + +isl::val val::div(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_div(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::div(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->div(isl::val(ctx(), v2)); +} + +bool val::eq(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_eq(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::eq(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->eq(isl::val(ctx(), v2)); +} + +isl::val val::floor() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_floor(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::gcd(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_gcd(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::gcd(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->gcd(isl::val(ctx(), v2)); +} + +bool val::ge(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_ge(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::ge(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->ge(isl::val(ctx(), v2)); +} + +long val::den_si() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_get_den_si(get()); + return res; +} + +long val::get_den_si() const +{ + return den_si(); +} + +long val::num_si() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_get_num_si(get()); + return res; +} + +long val::get_num_si() const +{ + return num_si(); +} + +bool val::gt(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_gt(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::gt(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->gt(isl::val(ctx(), v2)); +} + +isl::val val::infty(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_infty(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::inv() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_inv(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool val::is_divisible_by(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_divisible_by(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_divisible_by(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->is_divisible_by(isl::val(ctx(), v2)); +} + +bool val::is_infty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_infty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_int() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_int(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_nan() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_nan(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_neg(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_neginfty() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_neginfty(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_negone() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_negone(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_nonneg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_nonneg(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_nonpos() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_nonpos(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_one() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_one(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_pos() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_pos(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_rat() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_rat(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::is_zero() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_is_zero(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::le(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_le(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::le(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->le(isl::val(ctx(), v2)); +} + +bool val::lt(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_lt(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::lt(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->lt(isl::val(ctx(), v2)); +} + +isl::val val::max(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_max(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::max(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->max(isl::val(ctx(), v2)); +} + +isl::val val::min(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_min(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::min(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->min(isl::val(ctx(), v2)); +} + +isl::val val::mod(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_mod(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::mod(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->mod(isl::val(ctx(), v2)); +} + +isl::val val::mul(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_mul(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::mul(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->mul(isl::val(ctx(), v2)); +} + +isl::val val::nan(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_nan(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +bool val::ne(const isl::val &v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_ne(get(), v2.get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +bool val::ne(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->ne(isl::val(ctx(), v2)); +} + +isl::val val::neg() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_neg(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::neginfty(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_neginfty(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::negone(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_negone(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::one(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_one(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::pow2() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_pow2(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +int val::sgn() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_sgn(get()); + return res; +} + +isl::val val::sub(isl::val v2) const +{ + if (!ptr || v2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_sub(copy(), v2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::sub(long v2) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->sub(isl::val(ctx(), v2)); +} + +isl::val val::trunc() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_trunc(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val::zero(isl::ctx ctx) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_zero(ctx.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +inline std::ostream &operator<<(std::ostream &os, const val &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_val_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} + +// implementations for isl::val_list +val_list manage(__isl_take isl_val_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return val_list(ptr); +} +val_list manage_copy(__isl_keep isl_val_list *ptr) { + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_list_get_ctx(ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = isl_val_list_copy(ptr); + if (!ptr) + exception::throw_last_error(saved_ctx); + return val_list(ptr); +} + +val_list::val_list() + : ptr(nullptr) {} + +val_list::val_list(const val_list &obj) + : ptr(nullptr) +{ + if (!obj.ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_list_get_ctx(obj.ptr); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + ptr = obj.copy(); + if (!ptr) + exception::throw_last_error(saved_ctx); +} + +val_list::val_list(__isl_take isl_val_list *ptr) + : ptr(ptr) {} + +val_list::val_list(isl::ctx ctx, int n) +{ + auto saved_ctx = ctx; + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_alloc(ctx.release(), n); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +val_list::val_list(isl::val el) +{ + if (el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = el.ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_from_val(el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + ptr = res; +} + +val_list &val_list::operator=(val_list obj) { + std::swap(this->ptr, obj.ptr); + return *this; +} + +val_list::~val_list() { + if (ptr) + isl_val_list_free(ptr); +} + +__isl_give isl_val_list *val_list::copy() const & { + return isl_val_list_copy(ptr); +} + +__isl_keep isl_val_list *val_list::get() const { + return ptr; +} + +__isl_give isl_val_list *val_list::release() { + isl_val_list *tmp = ptr; + ptr = nullptr; + return tmp; +} + +bool val_list::is_null() const { + return ptr == nullptr; +} + +isl::ctx val_list::ctx() const { + return isl::ctx(isl_val_list_get_ctx(ptr)); +} + +isl::val_list val_list::add(isl::val el) const +{ + if (!ptr || el.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_add(copy(), el.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val_list val_list::add(long el) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + return this->add(isl::val(ctx(), el)); +} + +isl::val_list val_list::clear() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_clear(copy()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val_list val_list::concat(isl::val_list list2) const +{ + if (!ptr || list2.is_null()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_concat(copy(), list2.release()); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +void val_list::foreach(const std::function &fn) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + struct fn_data { + std::function func; + std::exception_ptr eptr; + } fn_data = { fn }; + auto fn_lambda = [](isl_val *arg_0, void *arg_1) -> isl_stat { + auto *data = static_cast(arg_1); + ISL_CPP_TRY { + (data->func)(manage(arg_0)); + return isl_stat_ok; + } ISL_CPP_CATCH_ALL { + data->eptr = std::current_exception(); + return isl_stat_error; + } + }; + auto res = isl_val_list_foreach(get(), fn_lambda, &fn_data); + if (fn_data.eptr) + std::rethrow_exception(fn_data.eptr); + if (res < 0) + exception::throw_last_error(saved_ctx); + return; +} + +isl::val val_list::at(int index) const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_get_at(get(), index); + if (!res) + exception::throw_last_error(saved_ctx); + return manage(res); +} + +isl::val val_list::get_at(int index) const +{ + return at(index); +} + +unsigned val_list::size() const +{ + if (!ptr) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = ctx(); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + auto res = isl_val_list_size(get()); + if (res < 0) + exception::throw_last_error(saved_ctx); + return res; +} + +inline std::ostream &operator<<(std::ostream &os, const val_list &obj) +{ + if (!obj.get()) + exception::throw_invalid("NULL input", __FILE__, __LINE__); + auto saved_ctx = isl_val_list_get_ctx(obj.get()); + options_scoped_set_on_error saved_on_error(saved_ctx, exception::on_error); + char *str = isl_val_list_to_str(obj.get()); + if (!str) + exception::throw_last_error(saved_ctx); + os << str; + free(str); + return os; +} +} // namespace isl + +#endif /* ISL_CPP */ diff --git a/gcc/isl/include/isl/fixed_box.h b/gcc/isl/include/isl/fixed_box.h new file mode 100644 index 0000000..d8c78e3 100644 --- /dev/null +++ a/gcc/isl/include/isl/fixed_box.h @@ -1,0 +1,43 @@ +/* + * Use of this software is governed by the MIT license + */ + +#ifndef ISL_FIXED_BOX_H +#define ISL_FIXED_BOX_H + +#include +#include +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +struct __isl_export isl_fixed_box; +typedef struct isl_fixed_box isl_fixed_box; + +isl_ctx *isl_fixed_box_get_ctx(__isl_keep isl_fixed_box *box); +__isl_export +__isl_give isl_space *isl_fixed_box_get_space(__isl_keep isl_fixed_box *box); +__isl_export +isl_bool isl_fixed_box_is_valid(__isl_keep isl_fixed_box *box); +__isl_export +__isl_give isl_multi_aff *isl_fixed_box_get_offset( + __isl_keep isl_fixed_box *box); +__isl_export +__isl_give isl_multi_val *isl_fixed_box_get_size(__isl_keep isl_fixed_box *box); + +__isl_give isl_fixed_box *isl_fixed_box_copy(__isl_keep isl_fixed_box *box); +__isl_null isl_fixed_box *isl_fixed_box_free(__isl_take isl_fixed_box *box); + +__isl_give isl_printer *isl_printer_print_fixed_box( + __isl_take isl_printer *p, __isl_keep isl_fixed_box *box); +__isl_give char *isl_fixed_box_to_str(__isl_keep isl_fixed_box *box); +void isl_fixed_box_dump(__isl_keep isl_fixed_box *box); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/gcc/isl/include/isl/id_type.h b/gcc/isl/include/isl/id_type.h new file mode 100644 index 0000000..0cb3c1c 100644 --- /dev/null +++ a/gcc/isl/include/isl/id_type.h @@ -1,0 +1,22 @@ +#ifndef ISL_ID_TYPE_H +#define ISL_ID_TYPE_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +struct __isl_export isl_id; +typedef struct isl_id isl_id; + +ISL_DECLARE_EXPORTED_LIST_TYPE(id) + +struct __isl_export isl_multi_id; +typedef struct isl_multi_id isl_multi_id; + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/gcc/isl/include/isl/space_type.h b/gcc/isl/include/isl/space_type.h new file mode 100644 index 0000000..60c31b0 100644 --- /dev/null +++ a/gcc/isl/include/isl/space_type.h @@ -1,0 +1,27 @@ +#ifndef ISL_SPACE_TYPE_H +#define ISL_SPACE_TYPE_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +struct __isl_export isl_space; +typedef struct isl_space isl_space; + +enum isl_dim_type { + isl_dim_cst, + isl_dim_param, + isl_dim_in, + isl_dim_out, + isl_dim_set = isl_dim_out, + isl_dim_div, + isl_dim_all +}; + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/gcc/isl/include/isl/stride_info.h b/gcc/isl/include/isl/stride_info.h new file mode 100644 index 0000000..7a4e0dc 100644 --- /dev/null +++ a/gcc/isl/include/isl/stride_info.h @@ -1,0 +1,30 @@ +/* + * Use of this software is governed by the MIT license + */ + +#ifndef ISL_STRIDE_INFO_H +#define ISL_STRIDE_INFO_H + +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +struct isl_stride_info; +typedef struct isl_stride_info isl_stride_info; + +isl_ctx *isl_stride_info_get_ctx(__isl_keep isl_stride_info *si); +__isl_give isl_val *isl_stride_info_get_stride(__isl_keep isl_stride_info *si); +__isl_give isl_aff *isl_stride_info_get_offset(__isl_keep isl_stride_info *si); +__isl_null isl_stride_info *isl_stride_info_free( + __isl_take isl_stride_info *si); +__isl_give isl_stride_info *isl_stride_info_copy( + __isl_keep isl_stride_info *si); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/gcc/isl/include/isl/val_type.h b/gcc/isl/include/isl/val_type.h new file mode 100644 index 0000000..ede6401 100644 --- /dev/null +++ a/gcc/isl/include/isl/val_type.h @@ -1,0 +1,22 @@ +#ifndef ISL_VAL_TYPE_H +#define ISL_VAL_TYPE_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +struct __isl_export isl_val; +typedef struct isl_val isl_val; + +ISL_DECLARE_EXPORTED_LIST_TYPE(val) + +struct __isl_export isl_multi_val; +typedef struct isl_multi_val isl_multi_val; + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/gcc/isl/test_inputs/codegen/bilinear.c b/gcc/isl/test_inputs/codegen/bilinear.c new file mode 100644 index 0000000..8b123e1 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/bilinear.c @@ -1,0 +1,9 @@ +if (d <= -1) { + for (int c0 = 0; c0 < -(-d % 2) - d + w; c0 += 1) { + A(c0); + B(c0); + } +} else { + for (int c0 = 0; c0 < (d % 2) - d + w; c0 += 1) + A(c0); +} diff --git a/gcc/isl/test_inputs/codegen/bilinear.st b/gcc/isl/test_inputs/codegen/bilinear.st new file mode 100644 index 0000000..00704b5 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/bilinear.st @@ -1,0 +1,9 @@ +# Check that the generated code does not contain a loop upper bound +# that depends on the loop iterator. +domain: "[d, w] -> { A[i0] : i0 >= 0 and ((d < 0 and 2*floor((1 + d)/2) < w - i0) or (d >= 0 and 2*floor((d)/2) < w - i0)); B[i0] : i0 >= 0 and d < 0 and 2*floor((d)/2) > 2d - w + i0 }" +child: + schedule: "[d, w] -> [{ A[i0] -> [(i0)]; B[i0] -> [(i0)] }]" + child: + sequence: + - filter: "{ A[x] }" + - filter: "{ B[x] }" diff --git a/gcc/isl/test_inputs/codegen/component7.c b/gcc/isl/test_inputs/codegen/component7.c new file mode 100644 index 0000000..ca0a0de 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/component7.c @@ -1,0 +1,6 @@ +{ + S(); + for (int c0 = 0; c0 < K; c0 += 32) + for (int c1 = c0; c1 <= min(K - 1, c0 + 31); c1 += 1) + T(c1); +} diff --git a/gcc/isl/test_inputs/codegen/component7.st b/gcc/isl/test_inputs/codegen/component7.st new file mode 100644 index 0000000..c692567 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/component7.st @@ -1,0 +1,11 @@ +# Check that component detection is not confused by values +# of the schedule dimension that do not correspond to any statement instances. +domain: "[K] -> { S[]; T[i] : 0 <= i < K }" +child: + context: "[K] -> { [] : K > 0 }" + child: + schedule: "[K] -> [{ S[] -> [(0)]; T[i] -> [(32*floor((i)/32))] }]" + child: + sequence: + - filter: "[K] -> { S[] }" + - filter: "[K] -> { T[i] }" diff --git a/gcc/isl/test_inputs/codegen/group.c b/gcc/isl/test_inputs/codegen/group.c new file mode 100644 index 0000000..ff65b13 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/group.c @@ -1,0 +1,7 @@ +{ + if (N == 0) { + C(); + A(); + } + B(); +} diff --git a/gcc/isl/test_inputs/codegen/group.st b/gcc/isl/test_inputs/codegen/group.st new file mode 100644 index 0000000..04d8ad7 100644 --- /dev/null +++ a/gcc/isl/test_inputs/codegen/group.st @@ -1,0 +1,2 @@ +# Check that the condition "N == 0" is only generated once. +domain: "[N] -> { A[] : N = 0; B[]; C[] : N = 0 }" diff --git a/gcc/isl/test_inputs/schedule/bounded_coefficients.sc b/gcc/isl/test_inputs/schedule/bounded_coefficients.sc new file mode 100644 index 0000000..dd839e9 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/bounded_coefficients.sc @@ -1,0 +1,12 @@ +# Check that the bounds on the coefficients are respected. +# This function checks for a particular output schedule, +# but the exact output is not important, only that it does +# not contain any coefficients greater than 4. +# It is, however, easier to check for a particular output. +# This test uses the whole component scheduler +# because the incremental scheduler has no reason to fuse anything. +# OPTIONS: --schedule-whole-component --schedule-max-coefficient=4 --schedule-max-constant-term=10 +domain: { S_4[i, j, k] : 0 <= i < j <= 10 and 0 <= k <= 100; + S_2[i, j] : 0 <= i < j <= 10; S_6[i, j] : 0 <= i < j <= 10 } +validity: { S_2[0, j] -> S_4[0, j, 0] : 0 < j <= 10; + S_4[0, j, 100] -> S_6[0, j] : 0 < j <= 10 } diff --git a/gcc/isl/test_inputs/schedule/bounded_coefficients.st b/gcc/isl/test_inputs/schedule/bounded_coefficients.st new file mode 100644 index 0000000..6ce339c 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/bounded_coefficients.st @@ -1,0 +1,5 @@ +domain: "{ S_6[i, j] : i >= 0 and i < j <= 10; S_4[i, j, k] : i >= 0 and i < j <= 10 and 0 <= k <= 100; S_2[i, j] : i >= 0 and i < j <= 10 }" +child: + schedule: "[{ S_6[i, j] -> [(0)]; S_4[i, j, k] -> [(i)]; S_2[i, j] -> [(0)] }, { S_6[i, j] -> [(10 + i)]; S_4[i, j, k] -> [(j)]; S_2[i, j] -> [(i)] }, { S_6[i, j] -> [(j)]; S_4[i, j, k] -> [(10 - k)]; S_2[i, j] -> [(j)] }]" + permutable: 1 + coincident: [ 1, 1, 1 ] diff --git a/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.sc b/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.sc new file mode 100644 index 0000000..70037c0 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.sc @@ -1,0 +1,19 @@ +# Check that the dependence carrying step is not confused by +# a bound on the coefficient size. +# In particular, force the scheduler to move to a dependence carrying +# step by demanding outer coincidence and bound the size of +# the coefficients. Earlier versions of isl would take this +# bound into account while carrying dependences, breaking +# fundamental assumptions. +# On the other hand, the dependence carrying step now tries +# to prevent loop coalescing by default, so check that indeed +# no loop coalescing occurs by comparing the computed schedule +# to the expected non-coalescing schedule. +# OPTIONS: --schedule-outer-coincidence --schedule-max-coefficient=20 +domain: { C[i0, i1] : 2 <= i0 <= 3999 and 0 <= i1 <= -1 + i0 } +validity: { C[i0, i1] -> C[i0, 1 + i1] : i0 <= 3999 and i1 >= 0 and + i1 <= -2 + i0; + C[i0, -1 + i0] -> C[1 + i0, 0] : i0 <= 3998 and i0 >= 1 } +coincidence: { C[i0, i1] -> C[i0, 1 + i1] : i0 <= 3999 and i1 >= 0 and + i1 <= -2 + i0; + C[i0, -1 + i0] -> C[1 + i0, 0] : i0 <= 3998 and i0 >= 1 } diff --git a/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.st b/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.st new file mode 100644 index 0000000..cdcf12c 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/carry_bounded_coefficients.st @@ -1,0 +1,5 @@ +domain: "{ C[i0, i1] : 2 <= i0 <= 3999 and 0 <= i1 < i0 }" +child: + schedule: "[{ C[i0, i1] -> [(i0)] }]" + child: + schedule: "[{ C[i0, i1] -> [(i1)] }]" diff --git a/gcc/isl/test_inputs/schedule/flat1.sc b/gcc/isl/test_inputs/schedule/flat1.sc new file mode 100644 index 0000000..f3cb57f 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat1.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: [M] -> { S[a, b] : 0 <= a <= 99 and M <= 2b <= 1 + M } diff --git a/gcc/isl/test_inputs/schedule/flat1.st b/gcc/isl/test_inputs/schedule/flat1.st new file mode 100644 index 0000000..6b0b54f 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat1.st @@ -1,0 +1,5 @@ +domain: "[M] -> { S[a, b] : 0 <= a <= 99 and M <= 2b <= 1 + M }" +child: + schedule: "[M] -> [{ S[a, b] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/flat2.sc b/gcc/isl/test_inputs/schedule/flat2.sc new file mode 100644 index 0000000..bf5042c 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat2.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: { S[a, floor(a/2)] : 0 <= a <= 9 } diff --git a/gcc/isl/test_inputs/schedule/flat2.st b/gcc/isl/test_inputs/schedule/flat2.st new file mode 100644 index 0000000..83f0838 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat2.st @@ -1,0 +1,5 @@ +domain: "{ S[a, i1] : 0 <= a <= 9 and -1 + a <= 2i1 <= a }" +child: + schedule: "[{ S[a, i1] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/flat3.sc b/gcc/isl/test_inputs/schedule/flat3.sc new file mode 100644 index 0000000..86e296e 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat3.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: { S[a, floor(a/2), floor(a/4)] : 0 <= a <= 9 } diff --git a/gcc/isl/test_inputs/schedule/flat3.st b/gcc/isl/test_inputs/schedule/flat3.st new file mode 100644 index 0000000..eea2ea4 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat3.st @@ -1,0 +1,5 @@ +domain: "{ S[a, i1, i2] : 0 <= a <= 9 and -1 + a <= 2i1 <= a and -3 + a <= 4i2 <= a }" +child: + schedule: "[{ S[a, i1, i2] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/flat4.sc b/gcc/isl/test_inputs/schedule/flat4.sc new file mode 100644 index 0000000..3c094b0 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat4.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: { S[0, a, floor(a/2), floor(a/4)] : 0 <= a <= 9 } diff --git a/gcc/isl/test_inputs/schedule/flat4.st b/gcc/isl/test_inputs/schedule/flat4.st new file mode 100644 index 0000000..bef33ca 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat4.st @@ -1,0 +1,5 @@ +domain: "{ S[0, a, i2, i3] : 0 <= a <= 9 and -1 + a <= 2i2 <= a and -3 + a <= 4i3 <= a }" +child: + schedule: "[{ S[i0, a, i2, i3] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/flat5.sc b/gcc/isl/test_inputs/schedule/flat5.sc new file mode 100644 index 0000000..fdee69a 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat5.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: { S[a, b] : b >= 0 and a -10b >= 0 and -a + b + 9 >= 0 } diff --git a/gcc/isl/test_inputs/schedule/flat5.st b/gcc/isl/test_inputs/schedule/flat5.st new file mode 100644 index 0000000..de01551 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat5.st @@ -1,0 +1,5 @@ +domain: "{ S[a, b] : b >= -9 + a and b >= 0 and 10b <= a }" +child: + schedule: "[{ S[a, b] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/flat6.sc b/gcc/isl/test_inputs/schedule/flat6.sc new file mode 100644 index 0000000..c78919c 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat6.sc @@ -1,0 +1,3 @@ +# Check that a fixed value of one dimension in terms of the others +# does not cause loop coalescing avoidance to break down. +domain: { S[a, b] : -b >= 0 and a + 10b >= 0 and -a - b + 9 >= 0 } diff --git a/gcc/isl/test_inputs/schedule/flat6.st b/gcc/isl/test_inputs/schedule/flat6.st new file mode 100644 index 0000000..9ee1027 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/flat6.st @@ -1,0 +1,5 @@ +domain: "{ S[a, b] : b <= 9 - a and b <= 0 and 10b >= -a }" +child: + schedule: "[{ S[a, b] -> [(a)] }]" + permutable: 1 + coincident: [ 1 ] diff --git a/gcc/isl/test_inputs/schedule/max_coincidence.sc b/gcc/isl/test_inputs/schedule/max_coincidence.sc new file mode 100644 index 0000000..cabe9b4 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/max_coincidence.sc @@ -1,0 +1,7 @@ +# Check that nodes are not fused when maximizing coincidence. +# This option is only effective for the incremental scheduler. +# OPTIONS: --no-schedule-whole-component --schedule-maximize-coincidence +domain: [n] -> { A[i,j,k] : 0 <= i,j,k < n; B[i,j,k] : 0 <= i,j,k < n } +validity: { A[i,j,k] -> B[i,k,j] } +proximity: { A[i,j,k] -> B[i,k,j] } +coincidence: { A[i,j,k] -> A[i,j,k+1]; B[i,j,k] -> B[i,j,k+1] } diff --git a/gcc/isl/test_inputs/schedule/max_coincidence.st b/gcc/isl/test_inputs/schedule/max_coincidence.st new file mode 100644 index 0000000..2b29baf 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/max_coincidence.st @@ -1,0 +1,13 @@ +domain: "[n] -> { A[i, j, k] : 0 <= i < n and 0 <= j < n and 0 <= k < n; B[i, j, k] : 0 <= i < n and 0 <= j < n and 0 <= k < n }" +child: + sequence: + - filter: "[n] -> { A[i, j, k] }" + child: + schedule: "[n] -> [{ A[i, j, k] -> [(i)] }, { A[i, j, k] -> [(j)] }, { A[i, j, k] -> [(k)] }]" + permutable: 1 + coincident: [ 1, 1, 0 ] + - filter: "[n] -> { B[i, j, k] }" + child: + schedule: "[n] -> [{ B[i, j, k] -> [(i)] }, { B[i, j, k] -> [(j)] }, { B[i, j, k] -> [(k)] }]" + permutable: 1 + coincident: [ 1, 1, 0 ] diff --git a/gcc/isl/test_inputs/schedule/nomax_coincidence.sc b/gcc/isl/test_inputs/schedule/nomax_coincidence.sc new file mode 100644 index 0000000..c37ad5b 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/nomax_coincidence.sc @@ -1,0 +1,7 @@ +# Check that nodes are fused when not maximizing coincidence. +# This option is only effective for the incremental scheduler. +# OPTIONS: --no-schedule-whole-component --no-schedule-maximize-coincidence +domain: [n] -> { A[i,j,k] : 0 <= i,j,k < n; B[i,j,k] : 0 <= i,j,k < n } +validity: { A[i,j,k] -> B[i,k,j] } +proximity: { A[i,j,k] -> A[i,j,k+1]; A[i,j,k] -> B[i,k,j] } +coincidence: { A[i,j,k] -> A[i,j,k+1]; B[i,j,k] -> B[i,j,k+1] } diff --git a/gcc/isl/test_inputs/schedule/nomax_coincidence.st b/gcc/isl/test_inputs/schedule/nomax_coincidence.st new file mode 100644 index 0000000..3d3af70 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/nomax_coincidence.st @@ -1,0 +1,9 @@ +domain: "[n] -> { A[i, j, k] : 0 <= i < n and 0 <= j < n and 0 <= k < n; B[i, j, k] : 0 <= i < n and 0 <= j < n and 0 <= k < n }" +child: + schedule: "[n] -> [{ A[i, j, k] -> [(i)]; B[i, j, k] -> [(i)] }, { A[i, j, k] -> [(j)]; B[i, j, k] -> [(k)] }, { A[i, j, k] -> [(k)]; B[i, j, k] -> [(j)] }]" + permutable: 1 + coincident: [ 1, 0, 0 ] + child: + sequence: + - filter: "[n] -> { A[i, j, k] }" + - filter: "[n] -> { B[i, j, k] }" diff --git a/gcc/isl/test_inputs/schedule/poliwoda.sc b/gcc/isl/test_inputs/schedule/poliwoda.sc new file mode 100644 index 0000000..cd669fa 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/poliwoda.sc @@ -1,0 +1,47 @@ +# In earlier versions of isl, this test case would cause +# the loop coalescing avoidance to break down because one of the dimensions +# (Id2 in S_1) has a fixed value in terms of the other dimensions. +# Check that this no longer happens. +# The actual schedule that is produced is not that important, +# but it is different depending on whether the whole-component scheduler +# is being used, so pick a particular setting. +# OPTIONS: --schedule-whole-component +domain: [_PB_M, _PB_N] -> { S_0[Id1, Id2, Id3] : _PB_M >= 2 and Id1 >= +0 and 4Id1 < _PB_N and 2Id2 >= -_PB_M and 4Id2 <= -_PB_M and Id3 <= +0 and 4Id3 >= -3 + _PB_M + 4Id2 and 4Id3 >= -1 - _PB_M; S_1[Id1, Id2, +Id3] : _PB_M >= 2 and Id1 >= 0 and 4Id1 < _PB_N and -_PB_M <= 2Id2 <= +1 - _PB_M and Id3 <= 0 and 4Id3 >= -1 - _PB_M } +validity: [_PB_M, _PB_N] -> { S_0[Id1, Id2, Id3] -> S_0[Id1' = Id1, Id2', +Id3'] : Id1 >= 0 and 4Id1 < _PB_N and Id3 <= 0 and 4Id3 >= -3 + _PB_M + +4Id2 and Id2' <= Id2 and 2Id2' >= -_PB_M and Id3' < 0 and Id3' <= Id3 +and Id3' < Id2 + Id3 - Id2' and 4Id3' >= -4 + _PB_M + 4Id2 and 4Id3' >= +-3 + _PB_M + 3Id2 + Id2' and -1 - _PB_M <= 4Id3' <= 2 + _PB_M + 4Id2; +S_0[Id1, Id2, Id3] -> S_0[Id1' = Id1, Id2', Id3' = Id3] : Id1 >= 0 and +4Id1 < _PB_N and 4Id2 <= -_PB_M and Id3 <= 0 and 4Id3 >= -3 + _PB_M + +4Id2 and Id2' < Id2 and 2Id2' >= -_PB_M; S_0[Id1, Id2, Id3] -> S_1[Id1' += Id1, Id2', Id3'] : Id1 >= 0 and 4Id1 < _PB_N and Id3 <= 0 and 4Id3 >= +-3 + _PB_M + 4Id2 and Id2' < Id2 and -_PB_M <= 2Id2' <= 1 - _PB_M and +Id3' < 0 and Id3' <= Id3 and -4 + _PB_M + 4Id2 <= 4Id3' <= 2 + _PB_M + +4Id2; S_0[Id1, Id2, Id3] -> S_1[Id1' = Id1, Id2' = Id2, Id3'] : Id1 >= +0 and 4Id1 < _PB_N and -_PB_M <= 2Id2 <= 1 - _PB_M and Id3 <= 0 and Id3' +< Id3 and -1 - _PB_M <= 4Id3' <= 2 + _PB_M + 4Id2; S_0[Id1, Id2, Id3] +-> S_1[Id1' = Id1, Id2', Id3' = Id3] : Id1 >= 0 and 4Id1 < _PB_N and +4Id2 <= -_PB_M and Id3 <= 0 and 4Id3 >= -3 + _PB_M + 4Id2 and Id2' < +Id2 and -_PB_M <= 2Id2' <= 1 - _PB_M } +proximity: [_PB_M, _PB_N] -> { S_0[Id1, Id2, Id3] -> S_0[Id1' = Id1, Id2', +Id3'] : Id1 >= 0 and 4Id1 < _PB_N and Id3 <= 0 and 4Id3 >= -3 + _PB_M + +4Id2 and Id2' <= Id2 and 2Id2' >= -_PB_M and Id3' < 0 and Id3' <= Id3 +and Id3' < Id2 + Id3 - Id2' and 4Id3' >= -4 + _PB_M + 4Id2 and 4Id3' >= +-3 + _PB_M + 3Id2 + Id2' and -1 - _PB_M <= 4Id3' <= 2 + _PB_M + 4Id2; +S_0[Id1, Id2, Id3] -> S_0[Id1' = Id1, Id2', Id3' = Id3] : Id1 >= 0 and +4Id1 < _PB_N and 4Id2 <= -_PB_M and Id3 <= 0 and 4Id3 >= -3 + _PB_M + +4Id2 and Id2' < Id2 and 2Id2' >= -_PB_M; S_0[Id1, Id2, Id3] -> S_1[Id1' += Id1, Id2', Id3'] : Id1 >= 0 and 4Id1 < _PB_N and Id3 <= 0 and 4Id3 >= +-3 + _PB_M + 4Id2 and Id2' < Id2 and -_PB_M <= 2Id2' <= 1 - _PB_M and +Id3' < 0 and Id3' <= Id3 and -4 + _PB_M + 4Id2 <= 4Id3' <= 2 + _PB_M + +4Id2; S_0[Id1, Id2, Id3] -> S_1[Id1' = Id1, Id2' = Id2, Id3'] : Id1 >= +0 and 4Id1 < _PB_N and -_PB_M <= 2Id2 <= 1 - _PB_M and Id3 <= 0 and Id3' +< Id3 and -1 - _PB_M <= 4Id3' <= 2 + _PB_M + 4Id2; S_0[Id1, Id2, Id3] +-> S_1[Id1' = Id1, Id2', Id3' = Id3] : Id1 >= 0 and 4Id1 < _PB_N and +4Id2 <= -_PB_M and Id3 <= 0 and 4Id3 >= -3 + _PB_M + 4Id2 and Id2' < +Id2 and -_PB_M <= 2Id2' <= 1 - _PB_M } diff --git a/gcc/isl/test_inputs/schedule/poliwoda.st b/gcc/isl/test_inputs/schedule/poliwoda.st new file mode 100644 index 0000000..d9a07a6 100644 --- /dev/null +++ a/gcc/isl/test_inputs/schedule/poliwoda.st @@ -1,0 +1,5 @@ +domain: "[_PB_M, _PB_N] -> { S_0[Id1, Id2, Id3] : _PB_M >= 2 and Id1 >= 0 and 4Id1 < _PB_N and 2Id2 >= -_PB_M and 4Id2 <= -_PB_M and Id3 <= 0 and 4Id3 >= -3 + _PB_M + 4Id2 and 4Id3 >= -1 - _PB_M; S_1[Id1, Id2, Id3] : _PB_M >= 2 and Id1 >= 0 and 4Id1 < _PB_N and -_PB_M <= 2Id2 <= 1 - _PB_M and Id3 <= 0 and 4Id3 >= -1 - _PB_M }" +child: + schedule: "[_PB_M, _PB_N] -> [{ S_0[Id1, Id2, Id3] -> [(Id1)]; S_1[Id1, Id2, Id3] -> [(Id1)] }, { S_0[Id1, Id2, Id3] -> [(-Id2)]; S_1[Id1, Id2, Id3] -> [(_PB_M)] }, { S_0[Id1, Id2, Id3] -> [(-Id3)]; S_1[Id1, Id2, Id3] -> [(-Id3)] }]" + permutable: 1 + coincident: [ 1, 1, 1 ] -- gitore 0.2.1