/* * Copyright 2011 INRIA Saclay * Copyright 2011 Sven Verdoolaege * Copyright 2012-2014 Ecole Normale Superieure * Copyright 2014 INRIA Rocquencourt * Copyright 2016 Sven Verdoolaege * Copyright 2018,2020 Cerebras Systems * Copyright 2021 Sven Verdoolaege * Copyright 2022 Cerebras Systems * * 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 * and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt, * B.P. 105 - 78153 Le Chesnay, France * and Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA * and Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA */ #include <isl_ctx_private.h> #include <isl_map_private.h> #include <isl_union_map_private.h> #include <isl_aff_private.h> #include <isl_space_private.h> #include <isl_local_space_private.h> #include <isl_vec_private.h> #include <isl_mat_private.h> #include <isl_id_private.h> #include <isl/constraint.h> #include <isl_seq.h> #include <isl/set.h> #include <isl_val_private.h> #include <isl_point_private.h> #include <isl_config.h> #undef EL_BASE #define EL_BASE … #include <isl_list_templ.c> #include <isl_list_read_templ.c> #undef EL_BASE #define EL_BASE … #include <isl_list_templ.c> #include <isl_list_read_templ.c> #undef EL_BASE #define EL_BASE … #include <isl_list_templ.c> #include <isl_list_read_templ.c> #undef EL_BASE #define EL_BASE … #include <isl_list_templ.c> #include <isl_list_read_templ.c> #undef EL_BASE #define EL_BASE … #include <isl_list_templ.c> /* Construct an isl_aff from the given domain local space "ls" and * coefficients "v", where the local space is known to be valid * for an affine expression. */ static __isl_give isl_aff *isl_aff_alloc_vec_validated( __isl_take isl_local_space *ls, __isl_take isl_vec *v) { … } /* Construct an isl_aff from the given domain local space "ls" and * coefficients "v". * * First check that "ls" is a valid domain local space * for an affine expression. */ __isl_give isl_aff *isl_aff_alloc_vec(__isl_take isl_local_space *ls, __isl_take isl_vec *v) { … } __isl_give isl_aff *isl_aff_alloc(__isl_take isl_local_space *ls) { … } __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff) { … } __isl_give isl_aff *isl_aff_dup(__isl_keep isl_aff *aff) { … } __isl_give isl_aff *isl_aff_cow(__isl_take isl_aff *aff) { … } __isl_give isl_aff *isl_aff_zero_on_domain(__isl_take isl_local_space *ls) { … } /* Return an affine expression that is equal to zero on domain space "space". */ __isl_give isl_aff *isl_aff_zero_on_domain_space(__isl_take isl_space *space) { … } /* This function performs the same operation as isl_aff_zero_on_domain_space, * but is considered as a function on an isl_space when exported. */ __isl_give isl_aff *isl_space_zero_aff_on_domain(__isl_take isl_space *space) { … } /* Return a piecewise affine expression defined on the specified domain * that is equal to zero. */ __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(__isl_take isl_local_space *ls) { … } /* Change "aff" into a NaN. * * Note that this function gets called from isl_aff_nan_on_domain, * so "aff" may not have been initialized yet. */ static __isl_give isl_aff *isl_aff_set_nan(__isl_take isl_aff *aff) { … } /* Return an affine expression defined on the specified domain * that represents NaN. */ __isl_give isl_aff *isl_aff_nan_on_domain(__isl_take isl_local_space *ls) { … } /* Return an affine expression defined on the specified domain space * that represents NaN. */ __isl_give isl_aff *isl_aff_nan_on_domain_space(__isl_take isl_space *space) { … } /* Return a piecewise affine expression defined on the specified domain space * that represents NaN. */ __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain_space( __isl_take isl_space *space) { … } /* Return a piecewise affine expression defined on the specified domain * that represents NaN. */ __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain(__isl_take isl_local_space *ls) { … } /* Return an affine expression that is equal to "val" on * domain local space "ls". * * Note that the encoding for the special value NaN * is the same in isl_val and isl_aff, so this does not need * to be treated in any special way. */ __isl_give isl_aff *isl_aff_val_on_domain(__isl_take isl_local_space *ls, __isl_take isl_val *val) { … } /* Return an affine expression that is equal to "val" on domain space "space". */ __isl_give isl_aff *isl_aff_val_on_domain_space(__isl_take isl_space *space, __isl_take isl_val *val) { … } /* Return an affine expression that is equal to the specified dimension * in "ls". */ __isl_give isl_aff *isl_aff_var_on_domain(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos) { … } /* Return a piecewise affine expression that is equal to * the specified dimension in "ls". */ __isl_give isl_pw_aff *isl_pw_aff_var_on_domain(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos) { … } /* Return an affine expression that is equal to the parameter * in the domain space "space" with identifier "id". */ __isl_give isl_aff *isl_aff_param_on_domain_space_id( __isl_take isl_space *space, __isl_take isl_id *id) { … } /* This function performs the same operation as * isl_aff_param_on_domain_space_id, * but is considered as a function on an isl_space when exported. */ __isl_give isl_aff *isl_space_param_aff_on_domain_id( __isl_take isl_space *space, __isl_take isl_id *id) { … } __isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff) { … } isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff) { … } /* Return a hash value that digests "aff". */ uint32_t isl_aff_get_hash(__isl_keep isl_aff *aff) { … } /* Return the domain local space of "aff". */ static __isl_keep isl_local_space *isl_aff_peek_domain_local_space( __isl_keep isl_aff *aff) { … } /* Return the number of variables of the given type in the domain of "aff". */ isl_size isl_aff_domain_dim(__isl_keep isl_aff *aff, enum isl_dim_type type) { … } /* Externally, an isl_aff has a map space, but internally, the * ls field corresponds to the domain of that space. */ isl_size isl_aff_dim(__isl_keep isl_aff *aff, enum isl_dim_type type) { … } /* Return the offset of the first coefficient of type "type" in * the domain of "aff". */ isl_size isl_aff_domain_offset(__isl_keep isl_aff *aff, enum isl_dim_type type) { … } /* Return the position of the dimension of the given type and name * in "aff". * Return -1 if no such dimension can be found. */ int isl_aff_find_dim_by_name(__isl_keep isl_aff *aff, enum isl_dim_type type, const char *name) { … } /* Return the domain space of "aff". */ static __isl_keep isl_space *isl_aff_peek_domain_space(__isl_keep isl_aff *aff) { … } __isl_give isl_space *isl_aff_get_domain_space(__isl_keep isl_aff *aff) { … } __isl_give isl_space *isl_aff_get_space(__isl_keep isl_aff *aff) { … } /* Return a copy of the domain space of "aff". */ __isl_give isl_local_space *isl_aff_get_domain_local_space( __isl_keep isl_aff *aff) { … } __isl_give isl_local_space *isl_aff_get_local_space(__isl_keep isl_aff *aff) { … } /* Return the local space of the domain of "aff". * This may be either a copy or the local space itself * if there is only one reference to "aff". * This allows the local space to be modified inplace * if both the expression and its local space have only a single reference. * The caller is not allowed to modify "aff" between this call and * a subsequent call to isl_aff_restore_domain_local_space. * The only exception is that isl_aff_free can be called instead. */ __isl_give isl_local_space *isl_aff_take_domain_local_space( __isl_keep isl_aff *aff) { … } /* Set the local space of the domain of "aff" to "ls", * where the local space of "aff" may be missing * due to a preceding call to isl_aff_take_domain_local_space. * However, in this case, "aff" only has a single reference and * then the call to isl_aff_cow has no effect. */ __isl_give isl_aff *isl_aff_restore_domain_local_space( __isl_keep isl_aff *aff, __isl_take isl_local_space *ls) { … } /* Externally, an isl_aff has a map space, but internally, the * ls field corresponds to the domain of that space. */ const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff, enum isl_dim_type type, unsigned pos) { … } __isl_give isl_aff *isl_aff_reset_domain_space(__isl_take isl_aff *aff, __isl_take isl_space *space) { … } /* Reset the space of "aff". This function is called from isl_pw_templ.c * and doesn't know if the space of an element object is represented * directly or through its domain. It therefore passes along both. */ __isl_give isl_aff *isl_aff_reset_space_and_domain(__isl_take isl_aff *aff, __isl_take isl_space *space, __isl_take isl_space *domain) { … } /* Reorder the dimensions of the domain of "aff" according * to the given reordering. */ __isl_give isl_aff *isl_aff_realign_domain(__isl_take isl_aff *aff, __isl_take isl_reordering *r) { … } __isl_give isl_aff *isl_aff_align_params(__isl_take isl_aff *aff, __isl_take isl_space *model) { … } #undef TYPE #define TYPE … #include "isl_unbind_params_templ.c" /* Is "aff" obviously equal to zero? * * If the denominator is zero, then "aff" is not equal to zero. */ isl_bool isl_aff_plain_is_zero(__isl_keep isl_aff *aff) { … } /* Does "aff" represent NaN? */ isl_bool isl_aff_is_nan(__isl_keep isl_aff *aff) { … } /* Are "aff1" and "aff2" obviously equal? * * NaN is not equal to anything, not even to another NaN. */ isl_bool isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2) { … } /* Return the common denominator of "aff" in "v". * * We cannot return anything meaningful in case of a NaN. */ isl_stat isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v) { … } /* Return the common denominator of "aff". */ __isl_give isl_val *isl_aff_get_denominator_val(__isl_keep isl_aff *aff) { … } /* Return the constant term of "aff". */ __isl_give isl_val *isl_aff_get_constant_val(__isl_keep isl_aff *aff) { … } /* Return the coefficient of the variable of type "type" at position "pos" * of "aff". */ __isl_give isl_val *isl_aff_get_coefficient_val(__isl_keep isl_aff *aff, enum isl_dim_type type, int pos) { … } /* Return the sign of the coefficient of the variable of type "type" * at position "pos" of "aff". */ int isl_aff_coefficient_sgn(__isl_keep isl_aff *aff, enum isl_dim_type type, int pos) { … } /* Replace the numerator of the constant term of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_constant(__isl_take isl_aff *aff, isl_int v) { … } /* Replace the constant term of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } /* Add "v" to the constant term of "aff". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_add_constant(__isl_take isl_aff *aff, isl_int v) { … } /* Add "v" to the constant term of "aff", * in case "aff" is a rational expression. */ static __isl_give isl_aff *isl_aff_add_rat_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } /* Return the first argument and free the second. */ static __isl_give isl_aff *pick_free(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } /* Replace the first argument by NaN and free the second argument. */ static __isl_give isl_aff *set_nan_free_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } /* Add "v" to the constant term of "aff". * * A NaN is unaffected by this operation. * Conversely, adding a NaN turns "aff" into a NaN. */ __isl_give isl_aff *isl_aff_add_constant_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } __isl_give isl_aff *isl_aff_add_constant_si(__isl_take isl_aff *aff, int v) { … } /* Add "v" to the numerator of the constant term of "aff". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_add_constant_num(__isl_take isl_aff *aff, isl_int v) { … } /* Add "v" to the numerator of the constant term of "aff". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_add_constant_num_si(__isl_take isl_aff *aff, int v) { … } /* Replace the numerator of the constant term of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_constant_si(__isl_take isl_aff *aff, int v) { … } /* Replace the numerator of the coefficient of the variable of type "type" * at position "pos" of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_coefficient(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, isl_int v) { … } /* Replace the numerator of the coefficient of the variable of type "type" * at position "pos" of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v) { … } /* Replace the coefficient of the variable of type "type" at position "pos" * of "aff" by "v". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_set_coefficient_val(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, __isl_take isl_val *v) { … } /* Add "v" to the coefficient of the variable of type "type" * at position "pos" of "aff". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_add_coefficient(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, isl_int v) { … } /* Add "v" to the coefficient of the variable of type "type" * at position "pos" of "aff". * * A NaN is unaffected by this operation. */ __isl_give isl_aff *isl_aff_add_coefficient_val(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, __isl_take isl_val *v) { … } __isl_give isl_aff *isl_aff_add_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v) { … } __isl_give isl_aff *isl_aff_get_div(__isl_keep isl_aff *aff, int pos) { … } /* Return the negation of "aff". * * As a special case, -NaN = NaN. */ __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff) { … } /* Remove divs from the local space that do not appear in the affine * expression. * We currently only remove divs at the end. * Some intermediate divs may also not appear directly in the affine * expression, but we would also need to check that no other divs are * defined in terms of them. */ __isl_give isl_aff *isl_aff_remove_unused_divs(__isl_take isl_aff *aff) { … } /* Look for any divs in the aff->ls with a denominator equal to one * and plug them into the affine expression and any subsequent divs * that may reference the div. */ static __isl_give isl_aff *plug_in_integral_divs(__isl_take isl_aff *aff) { … } /* Look for any divs j that appear with a unit coefficient inside * the definitions of other divs i and plug them into the definitions * of the divs i. * * In particular, an expression of the form * * floor((f(..) + floor(g(..)/n))/m) * * is simplified to * * floor((n * f(..) + g(..))/(n * m)) * * This simplification is correct because we can move the expression * f(..) into the inner floor in the original expression to obtain * * floor(floor((n * f(..) + g(..))/n)/m) * * from which we can derive the simplified expression. */ static __isl_give isl_aff *plug_in_unit_divs(__isl_take isl_aff *aff) { … } /* Swap divs "a" and "b" in "aff", which is assumed to be non-NULL. * * Even though this function is only called on isl_affs with a single * reference, we are careful to only change aff->v and aff->ls together. */ static __isl_give isl_aff *swap_div(__isl_take isl_aff *aff, int a, int b) { … } /* Merge divs "a" and "b" in "aff", which is assumed to be non-NULL. * * We currently do not actually remove div "b", but simply add its * coefficient to that of "a" and then zero it out. */ static __isl_give isl_aff *merge_divs(__isl_take isl_aff *aff, int a, int b) { … } /* Sort the divs in the local space of "aff" according to * the comparison function "cmp_row" in isl_local_space.c, * combining the coefficients of identical divs. * * Reordering divs does not change the semantics of "aff", * so there is no need to call isl_aff_cow. * Moreover, this function is currently only called on isl_affs * with a single reference. */ static __isl_give isl_aff *sort_divs(__isl_take isl_aff *aff) { … } /* Normalize the representation of "aff". * * This function should only be called on "new" isl_affs, i.e., * with only a single reference. We therefore do not need to * worry about affecting other instances. */ __isl_give isl_aff *isl_aff_normalize(__isl_take isl_aff *aff) { … } /* Given f, return floor(f). * If f is an integer expression, then just return f. * If f is a constant, then return the constant floor(f). * Otherwise, if f = g/m, write g = q m + r, * create a new div d = [r/m] and return the expression q + d. * The coefficients in r are taken to lie between -m/2 and m/2. * * reduce_div_coefficients performs the same normalization. * * As a special case, floor(NaN) = NaN. */ __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff) { … } /* Compute * * aff mod m = aff - m * floor(aff/m) * * with m an integer value. */ __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff, __isl_take isl_val *m) { … } /* Compute * * pwaff mod m = pwaff - m * floor(pwaff/m) */ __isl_give isl_pw_aff *isl_pw_aff_mod(__isl_take isl_pw_aff *pwaff, isl_int m) { … } /* Compute * * pa mod m = pa - m * floor(pa/m) * * with m an integer value. */ __isl_give isl_pw_aff *isl_pw_aff_mod_val(__isl_take isl_pw_aff *pa, __isl_take isl_val *m) { … } /* Given f, return ceil(f). * If f is an integer expression, then just return f. * Otherwise, let f be the expression * * e/m * * then return * * floor((e + m - 1)/m) * * As a special case, ceil(NaN) = NaN. */ __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff) { … } /* Apply the expansion computed by isl_merge_divs. * The expansion itself is given by "exp" while the resulting * list of divs is given by "div". */ __isl_give isl_aff *isl_aff_expand_divs(__isl_take isl_aff *aff, __isl_take isl_mat *div, int *exp) { … } /* Add two affine expressions that live in the same local space. */ static __isl_give isl_aff *add_expanded(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Replace one of the arguments by a NaN and free the other one. */ static __isl_give isl_aff *set_nan_free(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return the sum of "aff1" and "aff2". * * If either of the two is NaN, then the result is NaN. */ __isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } __isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return the result of scaling "aff" by a factor of "f". * * As a special case, f * NaN = NaN. */ __isl_give isl_aff *isl_aff_scale(__isl_take isl_aff *aff, isl_int f) { … } /* Multiple "aff" by "v". */ __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } /* Return the result of scaling "aff" down by a factor of "f". * * As a special case, NaN/f = NaN. */ __isl_give isl_aff *isl_aff_scale_down(__isl_take isl_aff *aff, isl_int f) { … } /* Divide "aff" by "v". */ __isl_give isl_aff *isl_aff_scale_down_val(__isl_take isl_aff *aff, __isl_take isl_val *v) { … } __isl_give isl_aff *isl_aff_scale_down_ui(__isl_take isl_aff *aff, unsigned f) { … } __isl_give isl_aff *isl_aff_set_dim_name(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, const char *s) { … } __isl_give isl_aff *isl_aff_set_dim_id(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, __isl_take isl_id *id) { … } /* Replace the identifier of the input tuple of "aff" by "id". * type is currently required to be equal to isl_dim_in */ __isl_give isl_aff *isl_aff_set_tuple_id(__isl_take isl_aff *aff, enum isl_dim_type type, __isl_take isl_id *id) { … } /* Exploit the equalities in "eq" to simplify the affine expression * and the expressions of the integer divisions in the local space. * The integer divisions in this local space are assumed to appear * as regular dimensions in "eq". */ static __isl_give isl_aff *isl_aff_substitute_equalities_lifted( __isl_take isl_aff *aff, __isl_take isl_basic_set *eq) { … } /* Exploit the equalities in "eq" to simplify the affine expression * and the expressions of the integer divisions in the local space. */ __isl_give isl_aff *isl_aff_substitute_equalities(__isl_take isl_aff *aff, __isl_take isl_basic_set *eq) { … } /* Look for equalities among the variables shared by context and aff * and the integer divisions of aff, if any. * The equalities are then used to eliminate coefficients and/or integer * divisions from aff. */ __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff, __isl_take isl_set *context) { … } __isl_give isl_aff *isl_aff_gist_params(__isl_take isl_aff *aff, __isl_take isl_set *context) { … } /* Return a basic set containing those elements in the space * of aff where it is positive. "rational" should not be set. * * If "aff" is NaN, then it is not positive. */ static __isl_give isl_basic_set *aff_pos_basic_set(__isl_take isl_aff *aff, int rational, void *user) { … } /* Return a basic set containing those elements in the space * of aff where it is non-negative. * If "rational" is set, then return a rational basic set. * * If "aff" is NaN, then it is not non-negative (it's not negative either). */ static __isl_give isl_basic_set *aff_nonneg_basic_set( __isl_take isl_aff *aff, int rational, void *user) { … } /* Return a basic set containing those elements in the space * of aff where it is non-negative. */ __isl_give isl_basic_set *isl_aff_nonneg_basic_set(__isl_take isl_aff *aff) { … } /* Return a basic set containing those elements in the domain space * of "aff" where it is positive. */ __isl_give isl_basic_set *isl_aff_pos_basic_set(__isl_take isl_aff *aff) { … } /* Return a basic set containing those elements in the domain space * of aff where it is negative. */ __isl_give isl_basic_set *isl_aff_neg_basic_set(__isl_take isl_aff *aff) { … } /* Return a basic set containing those elements in the space * of aff where it is zero. * If "rational" is set, then return a rational basic set. * * If "aff" is NaN, then it is not zero. */ static __isl_give isl_basic_set *aff_zero_basic_set(__isl_take isl_aff *aff, int rational, void *user) { … } /* Return a basic set containing those elements in the space * of aff where it is zero. */ __isl_give isl_basic_set *isl_aff_zero_basic_set(__isl_take isl_aff *aff) { … } /* Return a basic set containing those elements in the shared space * of aff1 and aff2 where aff1 is greater than or equal to aff2. */ __isl_give isl_basic_set *isl_aff_ge_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a basic set containing those elements in the shared domain space * of "aff1" and "aff2" where "aff1" is greater than "aff2". */ __isl_give isl_basic_set *isl_aff_gt_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared space * of aff1 and aff2 where aff1 is greater than or equal to aff2. */ __isl_give isl_set *isl_aff_ge_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared domain space * of aff1 and aff2 where aff1 is greater than aff2. * * If either of the two inputs is NaN, then the result is empty, * as comparisons with NaN always return false. */ __isl_give isl_set *isl_aff_gt_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a basic set containing those elements in the shared space * of aff1 and aff2 where aff1 is smaller than or equal to aff2. */ __isl_give isl_basic_set *isl_aff_le_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a basic set containing those elements in the shared domain space * of "aff1" and "aff2" where "aff1" is smaller than "aff2". */ __isl_give isl_basic_set *isl_aff_lt_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared space * of aff1 and aff2 where aff1 is smaller than or equal to aff2. */ __isl_give isl_set *isl_aff_le_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared domain space * of "aff1" and "aff2" where "aff1" is smaller than "aff2". */ __isl_give isl_set *isl_aff_lt_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a basic set containing those elements in the shared space * of aff1 and aff2 where aff1 and aff2 are equal. */ __isl_give isl_basic_set *isl_aff_eq_basic_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared space * of aff1 and aff2 where aff1 and aff2 are equal. */ __isl_give isl_set *isl_aff_eq_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Return a set containing those elements in the shared domain space * of aff1 and aff2 where aff1 and aff2 are not equal. * * If either of the two inputs is NaN, then the result is empty, * as comparisons with NaN always return false. */ __isl_give isl_set *isl_aff_ne_set(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } __isl_give isl_aff *isl_aff_add_on_domain(__isl_keep isl_set *dom, __isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } isl_bool isl_aff_is_empty(__isl_keep isl_aff *aff) { … } #undef TYPE #define TYPE … static #include "check_type_range_templ.c" /* Check whether the given affine expression has non-zero coefficient * 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 in the affine expression. */ isl_bool isl_aff_involves_dims(__isl_keep isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n) { … } /* Does "aff" involve any local variables, i.e., integer divisions? */ isl_bool isl_aff_involves_locals(__isl_keep isl_aff *aff) { … } __isl_give isl_aff *isl_aff_drop_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n) { … } /* Is the domain of "aff" a product? */ static isl_bool isl_aff_domain_is_product(__isl_keep isl_aff *aff) { … } #undef TYPE #define TYPE … #include <isl_domain_factor_templ.c> /* Project the domain of the affine expression onto its parameter space. * The affine expression may not involve any of the domain dimensions. */ __isl_give isl_aff *isl_aff_project_domain_on_params(__isl_take isl_aff *aff) { … } /* Convert an affine expression defined over a parameter domain * into one that is defined over a zero-dimensional set. */ __isl_give isl_aff *isl_aff_from_range(__isl_take isl_aff *aff) { … } __isl_give isl_aff *isl_aff_insert_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned first, unsigned n) { … } __isl_give isl_aff *isl_aff_add_dims(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned n) { … } /* Move the "n" dimensions of "src_type" starting at "src_pos" of "aff" * to dimensions of "dst_type" at "dst_pos". * * We only support moving input dimensions to parameters and vice versa. */ __isl_give isl_aff *isl_aff_move_dims(__isl_take isl_aff *aff, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n) { … } /* Return a zero isl_aff in the given space. * * This is a helper function for isl_pw_*_as_* that ensures a uniform * interface over all piecewise types. */ static __isl_give isl_aff *isl_aff_zero_in_space(__isl_take isl_space *space) { … } #define isl_aff_involves_nan … #undef PW #define PW … #undef BASE #define BASE … #undef EL_IS_ZERO #define EL_IS_ZERO … #undef ZERO #define ZERO … #undef IS_ZERO #define IS_ZERO … #undef FIELD #define FIELD … #undef DEFAULT_IS_ZERO #define DEFAULT_IS_ZERO … #include <isl_pw_templ.c> #include <isl_pw_un_op_templ.c> #include <isl_pw_add_constant_val_templ.c> #include <isl_pw_add_disjoint_templ.c> #include <isl_pw_bind_domain_templ.c> #include <isl_pw_eval.c> #include <isl_pw_hash.c> #include <isl_pw_fix_templ.c> #include <isl_pw_from_range_templ.c> #include <isl_pw_insert_dims_templ.c> #include <isl_pw_insert_domain_templ.c> #include <isl_pw_move_dims_templ.c> #include <isl_pw_neg_templ.c> #include <isl_pw_pullback_templ.c> #include <isl_pw_scale_templ.c> #include <isl_pw_sub_templ.c> #include <isl_pw_union_opt.c> #undef BASE #define BASE … #include <isl_union_single.c> #include <isl_union_neg.c> #include <isl_union_sub_templ.c> #undef BASE #define BASE … #include <isl_union_pw_templ.c> /* Compute a piecewise quasi-affine expression with a domain that * is the union of those of pwaff1 and pwaff2 and such that on each * cell, the quasi-affine expression is the maximum of those of pwaff1 * and pwaff2. If only one of pwaff1 or pwaff2 is defined on a given * cell, then the associated expression is the defined one. */ __isl_give isl_pw_aff *isl_pw_aff_union_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Compute a piecewise quasi-affine expression with a domain that * is the union of those of pwaff1 and pwaff2 and such that on each * cell, the quasi-affine expression is the minimum of those of pwaff1 * and pwaff2. If only one of pwaff1 or pwaff2 is defined on a given * cell, then the associated expression is the defined one. */ __isl_give isl_pw_aff *isl_pw_aff_union_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } __isl_give isl_pw_aff *isl_pw_aff_union_opt(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2, int max) { … } /* Is the domain of "pa" a product? */ static isl_bool isl_pw_aff_domain_is_product(__isl_keep isl_pw_aff *pa) { … } #undef TYPE #define TYPE … #include <isl_domain_factor_templ.c> /* Return a set containing those elements in the domain * of "pwaff" where it satisfies "fn" (if complement is 0) or * does not satisfy "fn" (if complement is 1). * * The pieces with a NaN never belong to the result since * NaN does not satisfy any property. */ static __isl_give isl_set *pw_aff_locus(__isl_take isl_pw_aff *pwaff, __isl_give isl_basic_set *(*fn)(__isl_take isl_aff *aff, int rational, void *user), int complement, void *user) { … } /* Return a set containing those elements in the domain * of "pa" where it is positive. */ __isl_give isl_set *isl_pw_aff_pos_set(__isl_take isl_pw_aff *pa) { … } /* Return a set containing those elements in the domain * of pwaff where it is non-negative. */ __isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff) { … } /* Return a set containing those elements in the domain * of pwaff where it is zero. */ __isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff) { … } /* Return a set containing those elements in the domain * of pwaff where it is not zero. */ __isl_give isl_set *isl_pw_aff_non_zero_set(__isl_take isl_pw_aff *pwaff) { … } /* Bind the affine function "aff" to the parameter "id", * returning the elements in the domain where the affine expression * is equal to the parameter. */ __isl_give isl_basic_set *isl_aff_bind_id(__isl_take isl_aff *aff, __isl_take isl_id *id) { … } /* Wrapper around isl_aff_bind_id for use as pw_aff_locus callback. * "rational" should not be set. */ static __isl_give isl_basic_set *aff_bind_id(__isl_take isl_aff *aff, int rational, void *user) { … } /* Bind the piecewise affine function "pa" to the parameter "id", * returning the elements in the domain where the expression * is equal to the parameter. */ __isl_give isl_set *isl_pw_aff_bind_id(__isl_take isl_pw_aff *pa, __isl_take isl_id *id) { … } /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is greater than (or equal) to pwaff2. * * We compute the difference on the shared domain and then construct * the set of values where this difference is non-negative. * If strict is set, we first subtract 1 from the difference. * If equal is set, we only return the elements where pwaff1 and pwaff2 * are equal. */ static __isl_give isl_set *pw_aff_gte_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2, int strict, int equal) { … } /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is equal to pwaff2. */ __isl_give isl_set *isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is greater than or equal to pwaff2. */ __isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is strictly greater than pwaff2. */ __isl_give isl_set *isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } __isl_give isl_set *isl_pw_aff_le_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } __isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function values are ordered in the same way as "order", * which returns a set in the shared domain of its two arguments. * * Let "pa1" and "pa2" be defined on domains A and B respectively. * We first pull back the two functions such that they are defined on * the domain [A -> B]. Then we apply "order", resulting in a set * in the space [A -> B]. Finally, we unwrap this set to obtain * a map in the space A -> B. */ static __isl_give isl_map *isl_pw_aff_order_map( __isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2, __isl_give isl_set *(*order)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2)) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function values are equal. */ __isl_give isl_map *isl_pw_aff_eq_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function value of "pa1" is less than or equal to * the function value of "pa2". */ __isl_give isl_map *isl_pw_aff_le_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function value of "pa1" is less than the function value of "pa2". */ __isl_give isl_map *isl_pw_aff_lt_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function value of "pa1" is greater than or equal to * the function value of "pa2". */ __isl_give isl_map *isl_pw_aff_ge_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Return a map containing pairs of elements in the domains of "pa1" and "pa2" * where the function value of "pa1" is greater than the function value * of "pa2". */ __isl_give isl_map *isl_pw_aff_gt_map(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Return a set containing those elements in the shared domain * of the elements of list1 and list2 where each element in list1 * has the relation specified by "fn" with each element in list2. */ static __isl_give isl_set *pw_aff_list_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2, __isl_give isl_set *(*fn)(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)) { … } /* Return a set containing those elements in the shared domain * of the elements of list1 and list2 where each element in list1 * is equal to each element in list2. */ __isl_give isl_set *isl_pw_aff_list_eq_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } __isl_give isl_set *isl_pw_aff_list_ne_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } /* Return a set containing those elements in the shared domain * of the elements of list1 and list2 where each element in list1 * is less than or equal to each element in list2. */ __isl_give isl_set *isl_pw_aff_list_le_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } __isl_give isl_set *isl_pw_aff_list_lt_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } __isl_give isl_set *isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } __isl_give isl_set *isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1, __isl_take isl_pw_aff_list *list2) { … } /* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is not equal to pwaff2. */ __isl_give isl_set *isl_pw_aff_ne_set(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } __isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff, isl_int v) { … } __isl_give isl_pw_aff *isl_pw_aff_floor(__isl_take isl_pw_aff *pwaff) { … } __isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff) { … } /* Assuming that "cond1" and "cond2" are disjoint, * return an affine expression that is equal to pwaff1 on cond1 * and to pwaff2 on cond2. */ static __isl_give isl_pw_aff *isl_pw_aff_select( __isl_take isl_set *cond1, __isl_take isl_pw_aff *pwaff1, __isl_take isl_set *cond2, __isl_take isl_pw_aff *pwaff2) { … } /* Return an affine expression that is equal to pwaff_true for elements * where "cond" is non-zero and to pwaff_false for elements where "cond" * is zero. * That is, return cond ? pwaff_true : pwaff_false; * * If "cond" involves and NaN, then we conservatively return a NaN * on its entire domain. In principle, we could consider the pieces * where it is NaN separately from those where it is not. * * If "pwaff_true" and "pwaff_false" are obviously equal to each other, * then only use the domain of "cond" to restrict the domain. */ __isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_pw_aff *cond, __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false) { … } isl_bool isl_aff_is_cst(__isl_keep isl_aff *aff) { … } /* Check whether pwaff is a piecewise constant. */ isl_bool isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff) { … } /* Return the product of "aff1" and "aff2". * * If either of the two is NaN, then the result is NaN. * * Otherwise, at least one of "aff1" or "aff2" needs to be a constant. */ __isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Divide "aff1" by "aff2", assuming "aff2" is a constant. * * If either of the two is NaN, then the result is NaN. * A division by zero also results in NaN. */ __isl_give isl_aff *isl_aff_div(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } __isl_give isl_pw_aff *isl_pw_aff_add(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } __isl_give isl_pw_aff *isl_pw_aff_mul(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Divide "pa1" by "pa2", assuming "pa2" is a piecewise constant. */ __isl_give isl_pw_aff *isl_pw_aff_div(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Compute the quotient of the integer division of "pa1" by "pa2" * with rounding towards zero. * "pa2" is assumed to be a piecewise constant. * * In particular, return * * pa1 >= 0 ? floor(pa1/pa2) : ceil(pa1/pa2) * */ __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Compute the remainder of the integer division of "pa1" by "pa2" * with rounding towards zero. * "pa2" is assumed to be a piecewise constant. * * In particular, return * * pa1 - pa2 * (pa1 >= 0 ? floor(pa1/pa2) : ceil(pa1/pa2)) * */ __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } /* Does either of "pa1" or "pa2" involve any NaN? */ static isl_bool either_involves_nan(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2) { … } /* Return a piecewise affine expression defined on the specified domain * that represents NaN. */ static __isl_give isl_pw_aff *nan_on_domain_set(__isl_take isl_set *dom) { … } /* Replace "pa1" and "pa2" (at least one of which involves a NaN) * by a NaN on their shared domain. * * In principle, the result could be refined to only being NaN * on the parts of this domain where at least one of "pa1" or "pa2" is NaN. */ static __isl_give isl_pw_aff *replace_by_nan(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2) { … } static __isl_give isl_pw_aff *pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } static __isl_give isl_pw_aff *pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Return an expression for the minimum (if "max" is not set) or * the maximum (if "max" is set) of "pa1" and "pa2". * If either expression involves any NaN, then return a NaN * on the shared domain as result. */ static __isl_give isl_pw_aff *pw_aff_min_max(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2, int max) { … } /* Return an expression for the minimum of "pwaff1" and "pwaff2". */ __isl_give isl_pw_aff *isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Return an expression for the maximum of "pwaff1" and "pwaff2". */ __isl_give isl_pw_aff *isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2) { … } /* Does "pa" not involve any NaN? */ static isl_bool pw_aff_no_nan(__isl_keep isl_pw_aff *pa, void *user) { … } /* Does any element of "list" involve any NaN? * * That is, is it not the case that every element does not involve any NaN? */ static isl_bool isl_pw_aff_list_involves_nan(__isl_keep isl_pw_aff_list *list) { … } /* Replace "list" (consisting of "n" elements, of which * at least one element involves a NaN) * by a NaN on the shared domain of the elements. * * In principle, the result could be refined to only being NaN * on the parts of this domain where at least one of the elements is NaN. */ static __isl_give isl_pw_aff *replace_list_by_nan( __isl_take isl_pw_aff_list *list, int n) { … } /* Return the set where the element at "pos1" of "list" is less than or * equal to the element at "pos2". * Equality is only allowed if "pos1" is smaller than "pos2". */ static __isl_give isl_set *less(__isl_keep isl_pw_aff_list *list, int pos1, int pos2) { … } /* Return an isl_pw_aff that maps each element in the intersection of the * domains of the piecewise affine expressions in "list" * to the maximal (if "max" is set) or minimal (if "max" is not set) * expression in "list" at that element. * If any expression involves any NaN, then return a NaN * on the shared domain as result. * * If "list" has n elements, then the result consists of n pieces, * where, in the case of a minimum, each piece has as value expression * the value expression of one of the elements and as domain * the set of elements where that value expression * is less than (or equal) to the other value expressions. * In the case of a maximum, the condition is * that all the other value expressions are less than (or equal) * to the given value expression. * * In order to produce disjoint pieces, a pair of elements * in the original domain is only allowed to be equal to each other * on exactly one of the two pieces corresponding to the two elements. * The position in the list is used to break ties. * In particular, in the case of a minimum, * in the piece corresponding to a given element, * this element is allowed to be equal to any later element in the list, * but not to any earlier element in the list. */ static __isl_give isl_pw_aff *isl_pw_aff_list_opt( __isl_take isl_pw_aff_list *list, int max) { … } /* Return an isl_pw_aff that maps each element in the intersection of the * domains of the elements of list to the minimal corresponding affine * expression. */ __isl_give isl_pw_aff *isl_pw_aff_list_min(__isl_take isl_pw_aff_list *list) { … } /* Return an isl_pw_aff that maps each element in the intersection of the * domains of the elements of list to the maximal corresponding affine * expression. */ __isl_give isl_pw_aff *isl_pw_aff_list_max(__isl_take isl_pw_aff_list *list) { … } /* Mark the domains of "pwaff" as rational. */ __isl_give isl_pw_aff *isl_pw_aff_set_rational(__isl_take isl_pw_aff *pwaff) { … } /* Mark the domains of the elements of "list" as rational. */ __isl_give isl_pw_aff_list *isl_pw_aff_list_set_rational( __isl_take isl_pw_aff_list *list) { … } /* Do the parameters of "aff" match those of "space"? */ isl_bool isl_aff_matching_params(__isl_keep isl_aff *aff, __isl_keep isl_space *space) { … } /* Check that the domain space of "aff" matches "space". */ isl_stat isl_aff_check_match_domain_space(__isl_keep isl_aff *aff, __isl_keep isl_space *space) { … } /* Return the shared (universe) domain of the elements of "ma". * * Since an isl_multi_aff (and an isl_aff) is always total, * the domain is always the universe set in its domain space. * This is a helper function for use in the generic isl_multi_*_bind. */ static __isl_give isl_basic_set *isl_multi_aff_domain( __isl_take isl_multi_aff *ma) { … } #undef BASE #define BASE … #include <isl_multi_no_explicit_domain.c> #include <isl_multi_templ.c> #include <isl_multi_un_op_templ.c> #include <isl_multi_bin_val_templ.c> #include <isl_multi_add_constant_templ.c> #include <isl_multi_apply_set.c> #include <isl_multi_arith_templ.c> #include <isl_multi_bind_domain_templ.c> #include <isl_multi_cmp.c> #include <isl_multi_dim_id_templ.c> #include <isl_multi_dims.c> #include <isl_multi_floor.c> #include <isl_multi_from_base_templ.c> #include <isl_multi_identity_templ.c> #include <isl_multi_insert_domain_templ.c> #include <isl_multi_locals_templ.c> #include <isl_multi_move_dims_templ.c> #include <isl_multi_nan_templ.c> #include <isl_multi_product_templ.c> #include <isl_multi_splice_templ.c> #include <isl_multi_tuple_id_templ.c> #include <isl_multi_unbind_params_templ.c> #include <isl_multi_zero_templ.c> #undef DOMBASE #define DOMBASE … #include <isl_multi_gist.c> #undef DOMBASE #define DOMBASE … #include <isl_multi_bind_templ.c> /* Construct an isl_multi_aff living in "space" that corresponds * to the affine transformation matrix "mat". */ __isl_give isl_multi_aff *isl_multi_aff_from_aff_mat( __isl_take isl_space *space, __isl_take isl_mat *mat) { … } /* Return the constant terms of the affine expressions of "ma". */ __isl_give isl_multi_val *isl_multi_aff_get_constant_multi_val( __isl_keep isl_multi_aff *ma) { … } /* Remove any internal structure of the domain of "ma". * If there is any such internal structure in the input, * then the name of the corresponding space is also removed. */ __isl_give isl_multi_aff *isl_multi_aff_flatten_domain( __isl_take isl_multi_aff *ma) { … } /* Given a map space, return an isl_multi_aff that maps a wrapped copy * of the space to its domain. */ __isl_give isl_multi_aff *isl_multi_aff_domain_map(__isl_take isl_space *space) { … } /* This function performs the same operation as isl_multi_aff_domain_map, * but is considered as a function on an isl_space when exported. */ __isl_give isl_multi_aff *isl_space_domain_map_multi_aff( __isl_take isl_space *space) { … } /* Given a map space, return an isl_multi_aff that maps a wrapped copy * of the space to its range. */ __isl_give isl_multi_aff *isl_multi_aff_range_map(__isl_take isl_space *space) { … } /* This function performs the same operation as isl_multi_aff_range_map, * but is considered as a function on an isl_space when exported. */ __isl_give isl_multi_aff *isl_space_range_map_multi_aff( __isl_take isl_space *space) { … } /* Given a map space, return an isl_pw_multi_aff that maps a wrapped copy * of the space to its domain. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_domain_map( __isl_take isl_space *space) { … } /* This function performs the same operation as isl_pw_multi_aff_domain_map, * but is considered as a function on an isl_space when exported. */ __isl_give isl_pw_multi_aff *isl_space_domain_map_pw_multi_aff( __isl_take isl_space *space) { … } /* Given a map space, return an isl_pw_multi_aff that maps a wrapped copy * of the space to its range. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_range_map( __isl_take isl_space *space) { … } /* This function performs the same operation as isl_pw_multi_aff_range_map, * but is considered as a function on an isl_space when exported. */ __isl_give isl_pw_multi_aff *isl_space_range_map_pw_multi_aff( __isl_take isl_space *space) { … } /* Given the space of a set and a range of set dimensions, * construct an isl_multi_aff that projects out those dimensions. */ __isl_give isl_multi_aff *isl_multi_aff_project_out_map( __isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned n) { … } /* Given the space of a set and a range of set dimensions, * construct an isl_pw_multi_aff that projects out those dimensions. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_project_out_map( __isl_take isl_space *space, enum isl_dim_type type, unsigned first, unsigned n) { … } /* This function performs the same operation as isl_pw_multi_aff_from_multi_aff, * but is considered as a function on an isl_multi_aff when exported. */ __isl_give isl_pw_multi_aff *isl_multi_aff_to_pw_multi_aff( __isl_take isl_multi_aff *ma) { … } /* Create a piecewise multi-affine expression in the given space that maps each * input dimension to the corresponding output dimension. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity( __isl_take isl_space *space) { … } /* Create a piecewise multi expression that maps elements in the given space * to themselves. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity_on_domain_space( __isl_take isl_space *space) { … } /* This function performs the same operation as * isl_pw_multi_aff_identity_on_domain_space, * but is considered as a function on an isl_space when exported. */ __isl_give isl_pw_multi_aff *isl_space_identity_pw_multi_aff_on_domain( __isl_take isl_space *space) { … } /* Exploit the equalities in "eq" to simplify the affine expressions. */ static __isl_give isl_multi_aff *isl_multi_aff_substitute_equalities( __isl_take isl_multi_aff *maff, __isl_take isl_basic_set *eq) { … } __isl_give isl_multi_aff *isl_multi_aff_scale(__isl_take isl_multi_aff *maff, isl_int f) { … } __isl_give isl_multi_aff *isl_multi_aff_add_on_domain(__isl_keep isl_set *dom, __isl_take isl_multi_aff *maff1, __isl_take isl_multi_aff *maff2) { … } isl_bool isl_multi_aff_is_empty(__isl_keep isl_multi_aff *maff) { … } /* Return the set of domain elements where "ma1" is lexicographically * smaller than or equal to "ma2". */ __isl_give isl_set *isl_multi_aff_lex_le_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2) { … } /* Return the set of domain elements where "ma1" is lexicographically * smaller than "ma2". */ __isl_give isl_set *isl_multi_aff_lex_lt_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2) { … } /* Return the set of domain elements where "ma1" is lexicographically * greater than to "ma2". If "equal" is set, then include the domain * elements where they are equal. * Do this for the case where there are no entries. * In this case, "ma1" cannot be greater than "ma2", * but it is (greater than or) equal to "ma2". */ static __isl_give isl_set *isl_multi_aff_lex_gte_set_0d( __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2, int equal) { … } /* Return the set where entry "i" of "ma1" and "ma2" * satisfy the relation prescribed by "cmp". */ static __isl_give isl_set *isl_multi_aff_order_at(__isl_keep isl_multi_aff *ma1, __isl_keep isl_multi_aff *ma2, int i, __isl_give isl_set *(*cmp)(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)) { … } /* Return the set of domain elements where "ma1" is lexicographically * greater than to "ma2". If "equal" is set, then include the domain * elements where they are equal. * * In particular, for all but the final entry, * include the set of elements where this entry is strictly greater in "ma1" * and all previous entries are equal. * The final entry is also allowed to be equal in the two functions * if "equal" is set. * * The case where there are no entries is handled separately. */ static __isl_give isl_set *isl_multi_aff_lex_gte_set( __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2, int equal) { … } /* Return the set of domain elements where "ma1" is lexicographically * greater than or equal to "ma2". */ __isl_give isl_set *isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2) { … } /* Return the set of domain elements where "ma1" is lexicographically * greater than "ma2". */ __isl_give isl_set *isl_multi_aff_lex_gt_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2) { … } #define isl_multi_aff_zero_in_space … #undef PW #define PW … #undef BASE #define BASE … #undef EL_IS_ZERO #define EL_IS_ZERO … #undef ZERO #define ZERO … #undef IS_ZERO #define IS_ZERO … #undef FIELD #define FIELD … #undef DEFAULT_IS_ZERO #define DEFAULT_IS_ZERO … #include <isl_pw_templ.c> #include <isl_pw_un_op_templ.c> #include <isl_pw_add_constant_multi_val_templ.c> #include <isl_pw_add_constant_val_templ.c> #include <isl_pw_add_disjoint_templ.c> #include <isl_pw_bind_domain_templ.c> #include <isl_pw_fix_templ.c> #include <isl_pw_from_range_templ.c> #include <isl_pw_insert_dims_templ.c> #include <isl_pw_insert_domain_templ.c> #include <isl_pw_locals_templ.c> #include <isl_pw_move_dims_templ.c> #include <isl_pw_neg_templ.c> #include <isl_pw_pullback_templ.c> #include <isl_pw_range_tuple_id_templ.c> #include <isl_pw_union_opt.c> #undef BASE #define BASE … #include <isl_union_multi.c> #include "isl_union_locals_templ.c" #include <isl_union_neg.c> #include <isl_union_sub_templ.c> #undef BASE #define BASE … #include <isl_union_pw_templ.c> /* Generic function for extracting a factor from a product "pma". * "check_space" checks that the space is that of the right kind of product. * "space_factor" extracts the factor from the space. * "multi_aff_factor" extracts the factor from the constituent functions. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_factor( __isl_take isl_pw_multi_aff *pma, isl_stat (*check_space)(__isl_keep isl_pw_multi_aff *pma), __isl_give isl_space *(*space_factor)(__isl_take isl_space *space), __isl_give isl_multi_aff *(*multi_aff_factor)( __isl_take isl_multi_aff *ma)) { … } /* Is the range of "pma" a wrapped relation? */ static isl_bool isl_pw_multi_aff_range_is_wrapping( __isl_keep isl_pw_multi_aff *pma) { … } /* Check that the range of "pma" is a product. */ static isl_stat pw_multi_aff_check_range_product( __isl_keep isl_pw_multi_aff *pma) { … } /* Given a function A -> [B -> C], extract the function A -> B. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_range_factor_domain( __isl_take isl_pw_multi_aff *pma) { … } /* Given a function A -> [B -> C], extract the function A -> C. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_range_factor_range( __isl_take isl_pw_multi_aff *pma) { … } /* Given two piecewise multi affine expressions, return a piecewise * multi-affine expression defined on the union of the definition domains * of the inputs that is equal to the lexicographic maximum of the two * inputs on each cell. If only one of the two inputs is defined on * a given cell, then it is considered to be the maximum. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* Given two piecewise multi affine expressions, return a piecewise * multi-affine expression defined on the union of the definition domains * of the inputs that is equal to the lexicographic minimum of the two * inputs on each cell. If only one of the two inputs is defined on * a given cell, then it is considered to be the minimum. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* Subtract "pma2" from "pma1" and return the result. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* Given two piecewise multi-affine expressions A -> B and C -> D, * construct a piecewise multi-affine expression [A -> C] -> [B -> D]. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* Subtract the initial "n" elements in "ma" with coefficients in "c" and * denominator "denom". * "denom" is allowed to be negative, in which case the actual denominator * is -denom and the expressions are added instead. */ static __isl_give isl_aff *subtract_initial(__isl_take isl_aff *aff, __isl_keep isl_multi_aff *ma, int n, isl_int *c, isl_int denom) { … } /* Extract an affine expression that expresses the output dimension "pos" * of "bmap" in terms of the parameters and input dimensions from * equality "eq". * Note that this expression may involve integer divisions defined * in terms of parameters and input dimensions. * The equality may also involve references to earlier (but not later) * output dimensions. These are replaced by the corresponding elements * in "ma". * * If the equality is of the form * * f(i) + h(j) + a x + g(i) = 0, * * with f(i) a linear combinations of the parameters and input dimensions, * g(i) a linear combination of integer divisions defined in terms of the same * and h(j) a linear combinations of earlier output dimensions, * then the affine expression is * * (-f(i) - g(i))/a - h(j)/a * * If the equality is of the form * * f(i) + h(j) - a x + g(i) = 0, * * then the affine expression is * * (f(i) + g(i))/a - h(j)/(-a) * * * If "div" refers to an integer division (i.e., it is smaller than * the number of integer divisions), then the equality constraint * does involve an integer division (the one at position "div") that * is defined in terms of output dimensions. However, this integer * division can be eliminated by exploiting a pair of constraints * x >= l and x <= l + n, with n smaller than the coefficient of "div" * in the equality constraint. "ineq" refers to inequality x >= l, i.e., * -l + x >= 0. * In particular, let * * x = e(i) + m floor(...) * * with e(i) the expression derived above and floor(...) the integer * division involving output dimensions. * From * * l <= x <= l + n, * * we have * * 0 <= x - l <= n * * This means * * e(i) + m floor(...) - l = (e(i) + m floor(...) - l) mod m * = (e(i) - l) mod m * * Therefore, * * x - l = (e(i) - l) mod m * * or * * x = ((e(i) - l) mod m) + l * * The variable "shift" below contains the expression -l, which may * also involve a linear combination of earlier output dimensions. */ static __isl_give isl_aff *extract_aff_from_equality( __isl_keep isl_basic_map *bmap, int pos, int eq, int div, int ineq, __isl_keep isl_multi_aff *ma) { … } /* Given a basic map with output dimensions defined * in terms of the parameters input dimensions and earlier * output dimensions using an equality (and possibly a pair on inequalities), * extract an isl_aff that expresses output dimension "pos" in terms * of the parameters and input dimensions. * Note that this expression may involve integer divisions defined * in terms of parameters and input dimensions. * "ma" contains the expressions corresponding to earlier output dimensions. * * This function shares some similarities with * isl_basic_map_has_defining_equality and isl_constraint_get_bound. */ static __isl_give isl_aff *extract_isl_aff_from_basic_map( __isl_keep isl_basic_map *bmap, int pos, __isl_keep isl_multi_aff *ma) { … } /* Given a basic map where each output dimension is defined * in terms of the parameters and input dimensions using an equality, * extract an isl_multi_aff that expresses the output dimensions in terms * of the parameters and input dimensions. */ static __isl_give isl_multi_aff *extract_isl_multi_aff_from_basic_map( __isl_take isl_basic_map *bmap) { … } /* Given a basic set where each set dimension is defined * in terms of the parameters using an equality, * extract an isl_multi_aff that expresses the set dimensions in terms * of the parameters. */ __isl_give isl_multi_aff *isl_multi_aff_from_basic_set_equalities( __isl_take isl_basic_set *bset) { … } /* Create an isl_pw_multi_aff that is equivalent to * isl_map_intersect_domain(isl_map_from_basic_map(bmap), domain). * The given basic map is such that each output dimension is defined * in terms of the parameters and input dimensions using an equality. * * Since some applications expect the result of isl_pw_multi_aff_from_map * to only contain integer affine expressions, we compute the floor * of the expression before returning. * * Remove all constraints involving local variables without * an explicit representation (resulting in the removal of those * local variables) prior to the actual extraction to ensure * that the local spaces in which the resulting affine expressions * are created do not contain any unknown local variables. * Removing such constraints is safe because constraints involving * unknown local variables are not used to determine whether * a basic map is obviously single-valued. */ static __isl_give isl_pw_multi_aff *plain_pw_multi_aff_from_map( __isl_take isl_set *domain, __isl_take isl_basic_map *bmap) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map. * This obviously only works if the input "map" is single-valued. * If so, we compute the lexicographic minimum of the image in the form * of an isl_pw_multi_aff. Since the image is unique, it is equal * to its lexicographic minimum. * If the input is not single-valued, we produce an error. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_from_map_base( __isl_take isl_map *map) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map, * taking into account that the output dimension at position "d" * can be represented as * * x = floor((e(...) + c1) / m) * * given that constraint "i" is of the form * * e(...) + c1 - m x >= 0 * * * Let "map" be of the form * * A -> B * * We construct a mapping * * A -> [A -> x = floor(...)] * * apply that to the map, obtaining * * [A -> x = floor(...)] -> B * * and equate dimension "d" to x. * We then compute a isl_pw_multi_aff representation of the resulting map * and plug in the mapping above. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_from_map_div( __isl_take isl_map *map, __isl_take isl_basic_map *hull, int d, int i) { … } /* Is constraint "c" of the form * * e(...) + c1 - m x >= 0 * * or * * -e(...) + c2 + m x >= 0 * * where m > 1 and e only depends on parameters and input dimensions? * * "offset" is the offset of the output dimensions * "pos" is the position of output dimension x. */ static int is_potential_div_constraint(isl_int *c, int offset, int d, int total) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map. * * As a special case, we first check if there is any pair of constraints, * shared by all the basic maps in "map" that force a given dimension * to be equal to the floor of some affine combination of the input dimensions. * * In particular, if we can find two constraints * * e(...) + c1 - m x >= 0 i.e., m x <= e(...) + c1 * * and * * -e(...) + c2 + m x >= 0 i.e., m x >= e(...) - c2 * * where m > 1 and e only depends on parameters and input dimensions, * and such that * * c1 + c2 < m i.e., -c2 >= c1 - (m - 1) * * then we know that we can take * * x = floor((e(...) + c1) / m) * * without having to perform any computation. * * Note that we know that * * c1 + c2 >= 1 * * If c1 + c2 were 0, then we would have detected an equality during * simplification. If c1 + c2 were negative, then we would have detected * a contradiction. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_from_map_check_div( __isl_take isl_map *map) { … } /* Given an affine expression * * [A -> B] -> f(A,B) * * construct an isl_multi_aff * * [A -> B] -> B' * * such that dimension "d" in B' is set to "aff" and the remaining * dimensions are set equal to the corresponding dimensions in B. * "n_in" is the dimension of the space A. * "n_out" is the dimension of the space B. * * If "is_set" is set, then the affine expression is of the form * * [B] -> f(B) * * and we construct an isl_multi_aff * * B -> B' */ static __isl_give isl_multi_aff *range_map(__isl_take isl_aff *aff, int d, unsigned n_in, unsigned n_out, int is_set) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map, * taking into account that the dimension at position "d" can be written as * * x = m a + f(..) (1) * * where m is equal to "gcd". * "i" is the index of the equality in "hull" that defines f(..). * In particular, the equality is of the form * * f(..) - x + m g(existentials) = 0 * * or * * -f(..) + x + m g(existentials) = 0 * * We basically plug (1) into "map", resulting in a map with "a" * in the range instead of "x". The corresponding isl_pw_multi_aff * defining "a" is then plugged back into (1) to obtain a definition for "x". * * Specifically, given the input map * * A -> B * * We first wrap it into a set * * [A -> B] * * and define (1) on top of the corresponding space, resulting in "aff". * We use this to create an isl_multi_aff that maps the output position "d" * from "a" to "x", leaving all other (intput and output) dimensions unchanged. * We plug this into the wrapped map, unwrap the result and compute the * corresponding isl_pw_multi_aff. * The result is an expression * * A -> T(A) * * We adjust that to * * A -> [A -> T(A)] * * so that we can plug that into "aff", after extending the latter to * a mapping * * [A -> B] -> B' * * * If "map" is actually a set, then there is no "A" space, meaning * that we do not need to perform any wrapping, and that the result * of the recursive call is of the form * * [T] * * which is plugged into a mapping of the form * * B -> B' */ static __isl_give isl_pw_multi_aff *pw_multi_aff_from_map_stride( __isl_take isl_map *map, __isl_take isl_basic_map *hull, int d, int i, isl_int gcd) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map. * "hull" contains the equalities valid for "map". * * Check if any of the output dimensions is "strided". * That is, we check if it can be written as * * x = m a + f(..) * * with m greater than 1, a some combination of existentially quantified * variables and f an expression in the parameters and input dimensions. * If so, we remove the stride in pw_multi_aff_from_map_stride. * * Otherwise, we continue with pw_multi_aff_from_map_check_div for a further * special case. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_from_map_check_strides( __isl_take isl_map *map, __isl_take isl_basic_map *hull) { … } /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map. * * As a special case, we first check if all output dimensions are uniquely * defined in terms of the parameters and input dimensions over the entire * domain. If so, we extract the desired isl_pw_multi_aff directly * from the affine hull of "map" and its domain. * * Otherwise, continue with pw_multi_aff_from_map_check_strides for more * special cases. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(__isl_take isl_map *map) { … } /* This function performs the same operation as isl_pw_multi_aff_from_map, * but is considered as a function on an isl_map when exported. */ __isl_give isl_pw_multi_aff *isl_map_as_pw_multi_aff(__isl_take isl_map *map) { … } __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(__isl_take isl_set *set) { … } /* This function performs the same operation as isl_pw_multi_aff_from_set, * but is considered as a function on an isl_set when exported. */ __isl_give isl_pw_multi_aff *isl_set_as_pw_multi_aff(__isl_take isl_set *set) { … } /* Convert "map" into an isl_pw_multi_aff (if possible) and * add it to *user. */ static isl_stat pw_multi_aff_from_map(__isl_take isl_map *map, void *user) { … } /* Create an isl_union_pw_multi_aff with the given isl_aff on a universe * domain. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_aff( __isl_take isl_aff *aff) { … } /* Try and create an isl_union_pw_multi_aff that is equivalent * to the given isl_union_map. * The isl_union_map is required to be single-valued in each space. * Otherwise, an error is produced. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_union_map( __isl_take isl_union_map *umap) { … } /* This function performs the same operation as * isl_union_pw_multi_aff_from_union_map, * but is considered as a function on an isl_union_map when exported. */ __isl_give isl_union_pw_multi_aff *isl_union_map_as_union_pw_multi_aff( __isl_take isl_union_map *umap) { … } /* Try and create an isl_union_pw_multi_aff that is equivalent * to the given isl_union_set. * The isl_union_set is required to be a singleton in each space. * Otherwise, an error is produced. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_union_set( __isl_take isl_union_set *uset) { … } /* Return the piecewise affine expression "set ? 1 : 0". */ __isl_give isl_pw_aff *isl_set_indicator_function(__isl_take isl_set *set) { … } /* Plug in "subs" for dimension "type", "pos" of "aff". * * Let i be the dimension to replace and let "subs" be of the form * * f/d * * and "aff" of the form * * (a i + g)/m * * The result is * * (a f + d g')/(m d) * * where g' is the result of plugging in "subs" in each of the integer * divisions in g. */ __isl_give isl_aff *isl_aff_substitute(__isl_take isl_aff *aff, enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs) { … } /* Plug in "subs" for dimension "type", "pos" in each of the affine * expressions in "maff". */ __isl_give isl_multi_aff *isl_multi_aff_substitute( __isl_take isl_multi_aff *maff, enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs) { … } /* Plug in "subs" for input dimension "pos" of "pma". * * pma is of the form * * A_i(v) -> M_i(v) * * while subs is of the form * * v' = B_j(v) -> S_j * * Each pair i,j such that C_ij = A_i \cap B_i is non-empty * has a contribution in the result, in particular * * C_ij(S_j) -> M_i(S_j) * * Note that plugging in S_j in C_ij may also result in an empty set * and this contribution should simply be discarded. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_substitute( __isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_keep isl_pw_aff *subs) { … } /* Compute the preimage of a range of dimensions in the affine expression "src" * under "ma" and put the result in "dst". The number of dimensions in "src" * that precede the range is given by "n_before". The number of dimensions * in the range is given by the number of output dimensions of "ma". * The number of dimensions that follow the range is given by "n_after". * If "has_denom" is set (to one), * then "src" and "dst" have an extra initial denominator. * "n_div_ma" is the number of existentials in "ma" * "n_div_bset" is the number of existentials in "src" * The resulting "dst" (which is assumed to have been allocated by * the caller) contains coefficients for both sets of existentials, * first those in "ma" and then those in "src". * f, c1, c2 and g are temporary objects that have been initialized * by the caller. * * Let src represent the expression * * (a(p) + f_u u + b v + f_w w + c(divs))/d * * and let ma represent the expressions * * v_i = (r_i(p) + s_i(y) + t_i(divs'))/m_i * * We start out with the following expression for dst: * * (a(p) + f_u u + 0 y + f_w w + 0 divs' + c(divs) + f \sum_i b_i v_i)/d * * with the multiplication factor f initially equal to 1 * and f \sum_i b_i v_i kept separately. * For each x_i that we substitute, we multiply the numerator * (and denominator) of dst by c_1 = m_i and add the numerator * of the x_i expression multiplied by c_2 = f b_i, * after removing the common factors of c_1 and c_2. * The multiplication factor f also needs to be multiplied by c_1 * for the next x_j, j > i. */ isl_stat isl_seq_preimage(isl_int *dst, isl_int *src, __isl_keep isl_multi_aff *ma, int n_before, int n_after, int n_div_ma, int n_div_bmap, isl_int f, isl_int c1, isl_int c2, isl_int g, int has_denom) { … } /* Compute the pullback of "aff" by the function represented by "ma". * In other words, plug in "ma" in "aff". The result is an affine expression * defined over the domain space of "ma". * * If "aff" is represented by * * (a(p) + b x + c(divs))/d * * and ma is represented by * * x = D(p) + F(y) + G(divs') * * then the result is * * (a(p) + b D(p) + b F(y) + b G(divs') + c(divs))/d * * The divs in the local space of the input are similarly adjusted * through a call to isl_local_space_preimage_multi_aff. */ __isl_give isl_aff *isl_aff_pullback_multi_aff(__isl_take isl_aff *aff, __isl_take isl_multi_aff *ma) { … } /* Compute the pullback of "aff1" by the function represented by "aff2". * In other words, plug in "aff2" in "aff1". The result is an affine expression * defined over the domain space of "aff1". * * The domain of "aff1" should match the range of "aff2", which means * that it should be single-dimensional. */ __isl_give isl_aff *isl_aff_pullback_aff(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2) { … } /* Compute the pullback of "ma1" by the function represented by "ma2". * In other words, plug in "ma2" in "ma1". */ __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff( __isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2) { … } /* Extend the local space of "dst" to include the divs * in the local space of "src". * * If "src" does not have any divs or if the local spaces of "dst" and * "src" are the same, then no extension is required. */ __isl_give isl_aff *isl_aff_align_divs(__isl_take isl_aff *dst, __isl_keep isl_aff *src) { … } /* Adjust the local spaces of the affine expressions in "maff" * such that they all have the save divs. */ __isl_give isl_multi_aff *isl_multi_aff_align_divs( __isl_take isl_multi_aff *maff) { … } __isl_give isl_aff *isl_aff_lift(__isl_take isl_aff *aff) { … } /* Lift "maff" to a space with extra dimensions such that the result * has no more existentially quantified variables. * If "ls" is not NULL, then *ls is assigned the local space that lies * at the basis of the lifting applied to "maff". */ __isl_give isl_multi_aff *isl_multi_aff_lift(__isl_take isl_multi_aff *maff, __isl_give isl_local_space **ls) { … } #undef TYPE #define TYPE … static #include "check_type_range_templ.c" /* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma". */ __isl_give isl_pw_aff *isl_pw_multi_aff_get_at( __isl_keep isl_pw_multi_aff *pma, int pos) { … } /* This is an alternative name for the function above. */ __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff( __isl_keep isl_pw_multi_aff *pma, int pos) { … } /* Return an isl_pw_multi_aff with the given "set" as domain and * an unnamed zero-dimensional range. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain( __isl_take isl_set *set) { … } /* Add an isl_pw_multi_aff with the given "set" as domain and * an unnamed zero-dimensional range to *user. */ static isl_stat add_pw_multi_aff_from_domain(__isl_take isl_set *set, void *user) { … } /* Return an isl_union_pw_multi_aff with the given "uset" as domain and * an unnamed zero-dimensional range. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_domain( __isl_take isl_union_set *uset) { … } /* Local data for bin_entry and the callback "fn". */ struct isl_union_pw_multi_aff_bin_data { … }; /* Given an isl_pw_multi_aff from upma1, store it in data->pma * and call data->fn for each isl_pw_multi_aff in data->upma2. */ static isl_stat bin_entry(__isl_take isl_pw_multi_aff *pma, void *user) { … } /* Call "fn" on each pair of isl_pw_multi_affs in "upma1" and "upma2". * The isl_pw_multi_aff from upma1 is stored in data->pma (where data is * passed as user field) and the isl_pw_multi_aff from upma2 is available * as *entry. The callback should adjust data->res if desired. */ static __isl_give isl_union_pw_multi_aff *bin_op( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2, isl_stat (*fn)(__isl_take isl_pw_multi_aff *pma, void *user)) { … } /* Given two isl_pw_multi_affs A -> B and C -> D, * construct an isl_pw_multi_aff (A * C) -> [B -> D]. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_range_product( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* Given two isl_pw_multi_affs A -> B and C -> D, * construct an isl_pw_multi_aff (A * C) -> (B, D). */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_flat_range_product( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* If data->pma and "pma2" have the same domain space, then use "range_product" * to compute some form of range product and add the result to data->res. */ static isl_stat gen_range_product_entry(__isl_take isl_pw_multi_aff *pma2, __isl_give isl_pw_multi_aff *(*range_product)( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2), void *user) { … } /* If data->pma and "pma2" have the same domain space, then compute * their flat range product and add the result to data->res. */ static isl_stat flat_range_product_entry(__isl_take isl_pw_multi_aff *pma2, void *user) { … } /* Given two isl_union_pw_multi_affs A -> B and C -> D, * construct an isl_union_pw_multi_aff (A * C) -> (B, D). */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_flat_range_product( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2) { … } /* If data->pma and "pma2" have the same domain space, then compute * their range product and add the result to data->res. */ static isl_stat range_product_entry(__isl_take isl_pw_multi_aff *pma2, void *user) { … } /* Given two isl_union_pw_multi_affs A -> B and C -> D, * construct an isl_union_pw_multi_aff (A * C) -> [B -> D]. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_range_product( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2) { … } /* Replace the affine expressions at position "pos" in "pma" by "pa". * The parameters are assumed to have been aligned. * * The implementation essentially performs an isl_pw_*_on_shared_domain, * except that it works on two different isl_pw_* types. */ static __isl_give isl_pw_multi_aff *pw_multi_aff_set_pw_aff( __isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_take isl_pw_aff *pa) { … } /* Replace the affine expressions at position "pos" in "pma" by "pa". */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff( __isl_take isl_pw_multi_aff *pma, unsigned pos, __isl_take isl_pw_aff *pa) { … } /* Do the parameters of "pa" match those of "space"? */ isl_bool isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa, __isl_keep isl_space *space) { … } /* Check that the domain space of "pa" matches "space". */ isl_stat isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa, __isl_keep isl_space *space) { … } #undef BASE #define BASE … #undef DOMBASE #define DOMBASE … #include <isl_multi_explicit_domain.c> #include <isl_multi_pw_aff_explicit_domain.c> #include <isl_multi_templ.c> #include <isl_multi_un_op_templ.c> #include <isl_multi_bin_val_templ.c> #include <isl_multi_add_constant_templ.c> #include <isl_multi_apply_set.c> #include <isl_multi_arith_templ.c> #include <isl_multi_bind_templ.c> #include <isl_multi_bind_domain_templ.c> #include <isl_multi_coalesce.c> #include <isl_multi_domain_templ.c> #include <isl_multi_dim_id_templ.c> #include <isl_multi_dims.c> #include <isl_multi_from_base_templ.c> #include <isl_multi_gist.c> #include <isl_multi_hash.c> #include <isl_multi_identity_templ.c> #include <isl_multi_align_set.c> #include <isl_multi_insert_domain_templ.c> #include <isl_multi_intersect.c> #include <isl_multi_min_max_templ.c> #include <isl_multi_move_dims_templ.c> #include <isl_multi_nan_templ.c> #include <isl_multi_param_templ.c> #include <isl_multi_product_templ.c> #include <isl_multi_splice_templ.c> #include <isl_multi_tuple_id_templ.c> #include <isl_multi_union_add_templ.c> #include <isl_multi_zero_templ.c> #include <isl_multi_unbind_params_templ.c> /* Is every element of "mpa" defined over a single universe domain? */ isl_bool isl_multi_pw_aff_isa_multi_aff(__isl_keep isl_multi_pw_aff *mpa) { … } /* Given that every element of "mpa" is defined over a single universe domain, * return the corresponding base expressions. */ __isl_give isl_multi_aff *isl_multi_pw_aff_as_multi_aff( __isl_take isl_multi_pw_aff *mpa) { … } /* If "mpa" has an explicit domain, then intersect the domain of "map" * with this explicit domain. */ __isl_give isl_map *isl_map_intersect_multi_pw_aff_explicit_domain( __isl_take isl_map *map, __isl_keep isl_multi_pw_aff *mpa) { … } /* Are all elements of "mpa" piecewise constants? */ isl_bool isl_multi_pw_aff_is_cst(__isl_keep isl_multi_pw_aff *mpa) { … } /* Does "mpa" have a non-trivial explicit domain? * * The explicit domain, if present, is trivial if it represents * an (obviously) universe set. */ isl_bool isl_multi_pw_aff_has_non_trivial_domain( __isl_keep isl_multi_pw_aff *mpa) { … } #undef BASE #define BASE … #include "isl_opt_mpa_templ.c" /* Compute the minima of the set dimensions as a function of the * parameters, but independently of the other set dimensions. */ __isl_give isl_multi_pw_aff *isl_set_min_multi_pw_aff(__isl_take isl_set *set) { … } /* Compute the maxima of the set dimensions as a function of the * parameters, but independently of the other set dimensions. */ __isl_give isl_multi_pw_aff *isl_set_max_multi_pw_aff(__isl_take isl_set *set) { … } #undef BASE #define BASE … #include "isl_opt_mpa_templ.c" /* Compute the minima of the output dimensions as a function of the * parameters and input dimensions, but independently of * the other output dimensions. */ __isl_give isl_multi_pw_aff *isl_map_min_multi_pw_aff(__isl_take isl_map *map) { … } /* Compute the maxima of the output dimensions as a function of the * parameters and input dimensions, but independently of * the other output dimensions. */ __isl_give isl_multi_pw_aff *isl_map_max_multi_pw_aff(__isl_take isl_map *map) { … } #undef TYPE #define TYPE … #include "isl_type_check_match_range_multi_val.c" /* Apply "fn" to the base expressions of "pma" and "mv". */ static __isl_give isl_pw_multi_aff *isl_pw_multi_aff_op_multi_val( __isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv, __isl_give isl_multi_aff *(*fn)(__isl_take isl_multi_aff *ma, __isl_take isl_multi_val *mv)) { … } /* Scale the elements of "pma" by the corresponding elements of "mv". */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_multi_val( __isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv) { … } /* Scale the elements of "pma" down by the corresponding elements of "mv". */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_down_multi_val( __isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_val *mv) { … } /* This function is called for each entry of an isl_union_pw_multi_aff. * If the space of the entry matches that of data->mv, * then apply isl_pw_multi_aff_scale_multi_val and return the result. * Otherwise, return an empty isl_pw_multi_aff. */ static __isl_give isl_pw_multi_aff *union_pw_multi_aff_scale_multi_val_entry( __isl_take isl_pw_multi_aff *pma, void *user) { … } /* Scale the elements of "upma" by the corresponding elements of "mv", * for those entries that match the space of "mv". */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_scale_multi_val( __isl_take isl_union_pw_multi_aff *upma, __isl_take isl_multi_val *mv) { … } /* Construct and return a piecewise multi affine expression * in the given space with value zero in each of the output dimensions and * a universe domain. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_zero(__isl_take isl_space *space) { … } /* Construct and return a piecewise multi affine expression * that is equal to the given piecewise affine expression. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_pw_aff( __isl_take isl_pw_aff *pa) { … } /* Construct and return a piecewise multi affine expression * that is equal to the given multi piecewise affine expression * on the shared domain of the piecewise affine expressions, * in the special case of a 0D multi piecewise affine expression. * * Create a piecewise multi affine expression with the explicit domain of * the 0D multi piecewise affine expression as domain. */ static __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_multi_pw_aff_0D( __isl_take isl_multi_pw_aff *mpa) { … } /* Construct and return a piecewise multi affine expression * that is equal to the given multi piecewise affine expression * on the shared domain of the piecewise affine expressions. */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_multi_pw_aff( __isl_take isl_multi_pw_aff *mpa) { … } /* Convenience function that constructs an isl_multi_pw_aff * directly from an isl_aff. */ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_aff(__isl_take isl_aff *aff) { … } /* Construct and return a multi piecewise affine expression * that is equal to the given multi affine expression. */ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_multi_aff( __isl_take isl_multi_aff *ma) { … } /* This function performs the same operation as isl_multi_pw_aff_from_multi_aff, * but is considered as a function on an isl_multi_aff when exported. */ __isl_give isl_multi_pw_aff *isl_multi_aff_to_multi_pw_aff( __isl_take isl_multi_aff *ma) { … } /* Construct and return a multi piecewise affine expression * that is equal to the given piecewise multi affine expression. * * If the resulting multi piecewise affine expression has * an explicit domain, then assign it the domain of the input. * In other cases, the domain is stored in the individual elements. */ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_multi_aff( __isl_take isl_pw_multi_aff *pma) { … } /* This function performs the same operation as * isl_multi_pw_aff_from_pw_multi_aff, * but is considered as a function on an isl_pw_multi_aff when exported. */ __isl_give isl_multi_pw_aff *isl_pw_multi_aff_to_multi_pw_aff( __isl_take isl_pw_multi_aff *pma) { … } /* Do "pa1" and "pa2" represent the same function? * * We first check if they are obviously equal. * If not, we convert them to maps and check if those are equal. * * If "pa1" or "pa2" contain any NaNs, then they are considered * not to be the same. A NaN is not equal to anything, not even * to another NaN. */ isl_bool isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2) { … } /* Do "mpa1" and "mpa2" represent the same function? * * Note that we cannot convert the entire isl_multi_pw_aff * to a map because the domains of the piecewise affine expressions * may not be the same. */ isl_bool isl_multi_pw_aff_is_equal(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2) { … } /* Do "pma1" and "pma2" represent the same function? * * First check if they are obviously equal. * If not, then convert them to maps and check if those are equal. * * If "pa1" or "pa2" contain any NaNs, then they are considered * not to be the same. A NaN is not equal to anything, not even * to another NaN. */ isl_bool isl_pw_multi_aff_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2) { … } #undef BASE #define BASE … #include "isl_multi_pw_aff_pullback_templ.c" #undef BASE #define BASE … #include "isl_multi_pw_aff_pullback_templ.c" /* Apply "aff" to "mpa". The range of "mpa" needs to be compatible * with the domain of "aff". The domain of the result is the same * as that of "mpa". * "mpa" and "aff" are assumed to have been aligned. * * We first extract the parametric constant from "aff", defined * over the correct domain. * Then we add the appropriate combinations of the members of "mpa". * Finally, we add the integer divisions through recursive calls. */ static __isl_give isl_pw_aff *isl_multi_pw_aff_apply_aff_aligned( __isl_take isl_multi_pw_aff *mpa, __isl_take isl_aff *aff) { … } /* Apply "aff" to "mpa". The range of "mpa" needs to be compatible * with the domain of "aff". The domain of the result is the same * as that of "mpa". */ __isl_give isl_pw_aff *isl_multi_pw_aff_apply_aff( __isl_take isl_multi_pw_aff *mpa, __isl_take isl_aff *aff) { … } /* Apply "pa" to "mpa". The range of "mpa" needs to be compatible * with the domain of "pa". The domain of the result is the same * as that of "mpa". * "mpa" and "pa" are assumed to have been aligned. * * We consider each piece in turn. Note that the domains of the * pieces are assumed to be disjoint and they remain disjoint * after taking the preimage (over the same function). */ static __isl_give isl_pw_aff *isl_multi_pw_aff_apply_pw_aff_aligned( __isl_take isl_multi_pw_aff *mpa, __isl_take isl_pw_aff *pa) { … } /* Apply "pa" to "mpa". The range of "mpa" needs to be compatible * with the domain of "pa". The domain of the result is the same * as that of "mpa". */ __isl_give isl_pw_aff *isl_multi_pw_aff_apply_pw_aff( __isl_take isl_multi_pw_aff *mpa, __isl_take isl_pw_aff *pa) { … } /* Compute the pullback of "pa" by the function represented by "mpa". * In other words, plug in "mpa" in "pa". * * The pullback is computed by applying "pa" to "mpa". */ __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff( __isl_take isl_pw_aff *pa, __isl_take isl_multi_pw_aff *mpa) { … } #undef BASE #define BASE … #include "isl_multi_pw_aff_pullback_templ.c" /* Align the parameters of "mpa1" and "mpa2", check that the ranges * of "mpa1" and "mpa2" live in the same space, construct map space * between the domain spaces of "mpa1" and "mpa2" and call "order" * with this map space as extract argument. */ static __isl_give isl_map *isl_multi_pw_aff_order_map( __isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2, __isl_give isl_map *(*order)(__isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_take isl_space *space)) { … } /* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2" * where the function values are equal. "space" is the space of the result. * The parameters of "mpa1" and "mpa2" are assumed to have been aligned. * * "mpa1" and "mpa2" are equal when each of the pairs of elements * in the sequences are equal. */ static __isl_give isl_map *isl_multi_pw_aff_eq_map_on_space( __isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_take isl_space *space) { … } /* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2" * where the function values are equal. */ __isl_give isl_map *isl_multi_pw_aff_eq_map(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2) { … } /* Intersect "map" with the result of applying "order" * on two copies of "mpa". */ static __isl_give isl_map *isl_map_order_at_multi_pw_aff( __isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa, __isl_give isl_map *(*order)(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2)) { … } /* Return the subset of "map" where the domain and the range * have equal "mpa" values. */ __isl_give isl_map *isl_map_eq_at_multi_pw_aff(__isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa) { … } /* Return a map containing pairs of elements in the domains of "mpa1" and "mpa2" * where the function values of "mpa1" lexicographically satisfies * "strict_base"/"base" compared to that of "mpa2". * "space" is the space of the result. * The parameters of "mpa1" and "mpa2" are assumed to have been aligned. * * "mpa1" lexicographically satisfies "strict_base"/"base" compared to "mpa2" * if, for some i, the i-th element of "mpa1" satisfies "strict_base"/"base" * when compared to the i-th element of "mpa2" while all previous elements are * pairwise equal. * In particular, if i corresponds to the final elements * then they need to satisfy "base", while "strict_base" needs to be satisfied * for other values of i. * If "base" is a strict order, then "base" and "strict_base" are the same. */ static __isl_give isl_map *isl_multi_pw_aff_lex_map_on_space( __isl_keep isl_multi_pw_aff *mpa1, __isl_keep isl_multi_pw_aff *mpa2, __isl_give isl_map *(*strict_base)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2), __isl_give isl_map *(*base)(__isl_take isl_pw_aff *pa1, __isl_take isl_pw_aff *pa2), __isl_take isl_space *space) { … } #undef ORDER #define ORDER … #undef STRICT_ORDER #define STRICT_ORDER … #include "isl_aff_lex_templ.c" #undef ORDER #define ORDER … #undef STRICT_ORDER #define STRICT_ORDER … #include "isl_aff_lex_templ.c" #undef ORDER #define ORDER … #undef STRICT_ORDER #define STRICT_ORDER … #include "isl_aff_lex_templ.c" #undef ORDER #define ORDER … #undef STRICT_ORDER #define STRICT_ORDER … #include "isl_aff_lex_templ.c" /* Compare two isl_affs. * * Return -1 if "aff1" is "smaller" than "aff2", 1 if "aff1" is "greater" * than "aff2" and 0 if they are equal. * * The order is fairly arbitrary. We do consider expressions that only involve * earlier dimensions as "smaller". */ int isl_aff_plain_cmp(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2) { … } /* Compare two isl_pw_affs. * * Return -1 if "pa1" is "smaller" than "pa2", 1 if "pa1" is "greater" * than "pa2" and 0 if they are equal. * * The order is fairly arbitrary. We do consider expressions that only involve * earlier dimensions as "smaller". */ int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2) { … } /* Return a piecewise affine expression that is equal to "v" on "domain". */ __isl_give isl_pw_aff *isl_pw_aff_val_on_domain(__isl_take isl_set *domain, __isl_take isl_val *v) { … } /* This function performs the same operation as isl_pw_aff_val_on_domain, * but is considered as a function on an isl_set when exported. */ __isl_give isl_pw_aff *isl_set_pw_aff_on_domain_val(__isl_take isl_set *domain, __isl_take isl_val *v) { … } /* Return a piecewise affine expression that is equal to the parameter * with identifier "id" on "domain". */ __isl_give isl_pw_aff *isl_pw_aff_param_on_domain_id( __isl_take isl_set *domain, __isl_take isl_id *id) { … } /* This function performs the same operation as * isl_pw_aff_param_on_domain_id, * but is considered as a function on an isl_set when exported. */ __isl_give isl_pw_aff *isl_set_param_pw_aff_on_domain_id( __isl_take isl_set *domain, __isl_take isl_id *id) { … } /* Return a multi affine expression that is equal to "mv" on domain * space "space". */ __isl_give isl_multi_aff *isl_multi_aff_multi_val_on_domain_space( __isl_take isl_space *space, __isl_take isl_multi_val *mv) { … } /* This is an alternative name for the function above. */ __isl_give isl_multi_aff *isl_multi_aff_multi_val_on_space( __isl_take isl_space *space, __isl_take isl_multi_val *mv) { … } /* This function performs the same operation as * isl_multi_aff_multi_val_on_domain_space, * but is considered as a function on an isl_space when exported. */ __isl_give isl_multi_aff *isl_space_multi_aff_on_domain_multi_val( __isl_take isl_space *space, __isl_take isl_multi_val *mv) { … } /* Return a piecewise multi-affine expression * that is equal to "mv" on "domain". */ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_multi_val_on_domain( __isl_take isl_set *domain, __isl_take isl_multi_val *mv) { … } /* This function performs the same operation as * isl_pw_multi_aff_multi_val_on_domain, * but is considered as a function on an isl_set when exported. */ __isl_give isl_pw_multi_aff *isl_set_pw_multi_aff_on_domain_multi_val( __isl_take isl_set *domain, __isl_take isl_multi_val *mv) { … } /* Internal data structure for isl_union_pw_multi_aff_multi_val_on_domain. * mv is the value that should be attained on each domain set * res collects the results */ struct isl_union_pw_multi_aff_multi_val_on_domain_data { … }; /* Create an isl_pw_multi_aff equal to data->mv on "domain" * and add it to data->res. */ static isl_stat pw_multi_aff_multi_val_on_domain(__isl_take isl_set *domain, void *user) { … } /* Return a union piecewise multi-affine expression * that is equal to "mv" on "domain". */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_multi_val_on_domain( __isl_take isl_union_set *domain, __isl_take isl_multi_val *mv) { … } /* Compute the pullback of data->pma by the function represented by "pma2", * provided the spaces match, and add the results to data->res. */ static isl_stat pullback_entry(__isl_take isl_pw_multi_aff *pma2, void *user) { … } /* Compute the pullback of "upma1" by the function represented by "upma2". */ __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_pullback_union_pw_multi_aff( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2) { … } /* Apply "upma2" to "upma1". * * That is, compute the pullback of "upma2" by "upma1". */ __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_apply_union_pw_multi_aff( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2) { … } #undef TYPE #define TYPE … static #include "isl_copy_tuple_id_templ.c" /* Given a function "pma1" of the form A[B -> C] -> D and * a function "pma2" of the form E -> B, * replace the domain of the wrapped relation inside the domain of "pma1" * by the preimage with respect to "pma2". * In other words, plug in "pma2" in this nested domain. * The result is of the form A[E -> C] -> D. * * In particular, extend E -> B to A[E -> C] -> A[B -> C] and * plug that into "pma1". */ __isl_give isl_pw_multi_aff * isl_pw_multi_aff_preimage_domain_wrapped_domain_pw_multi_aff( __isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2) { … } /* If data->pma and "pma2" are such that * data->pma is of the form A[B -> C] -> D and * "pma2" is of the form E -> B, * then replace the domain of the wrapped relation * inside the domain of data->pma by the preimage with respect to "pma2" and * add the result to data->res. */ static isl_stat preimage_domain_wrapped_domain_entry( __isl_take isl_pw_multi_aff *pma2, void *user) { … } /* For each pair of functions A[B -> C] -> D in "upma1" and * E -> B in "upma2", * replace the domain of the wrapped relation inside the domain of the first * by the preimage with respect to the second and collect the results. * In other words, plug in the second function in this nested domain. * The results are of the form A[E -> C] -> D. */ __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_preimage_domain_wrapped_domain_union_pw_multi_aff( __isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2) { … } /* Check that the domain space of "upa" matches "space". * * This function is called from isl_multi_union_pw_aff_set_union_pw_aff and * can in principle never fail since the space "space" is that * of the isl_multi_union_pw_aff and is a set space such that * there is no domain space to match. * * We check the parameters and double-check that "space" is * indeed that of a set. */ static isl_stat isl_union_pw_aff_check_match_domain_space( __isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space) { … } /* Do the parameters of "upa" match those of "space"? */ static isl_bool isl_union_pw_aff_matching_params( __isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space) { … } /* Internal data structure for isl_union_pw_aff_reset_domain_space. * space represents the new parameters. * res collects the results. */ struct isl_union_pw_aff_reset_params_data { … }; /* Replace the parameters of "pa" by data->space and * add the result to data->res. */ static isl_stat reset_params(__isl_take isl_pw_aff *pa, void *user) { … } /* Replace the domain space of "upa" by "space". * Since a union expression does not have a (single) domain space, * "space" is necessarily a parameter space. * * Since the order and the names of the parameters determine * the hash value, we need to create a new hash table. */ static __isl_give isl_union_pw_aff *isl_union_pw_aff_reset_domain_space( __isl_take isl_union_pw_aff *upa, __isl_take isl_space *space) { … } /* Return the floor of "pa". */ static __isl_give isl_pw_aff *floor_entry(__isl_take isl_pw_aff *pa, void *user) { … } /* Given f, return floor(f). */ __isl_give isl_union_pw_aff *isl_union_pw_aff_floor( __isl_take isl_union_pw_aff *upa) { … } /* Compute * * upa mod m = upa - m * floor(upa/m) * * with m an integer value. */ __isl_give isl_union_pw_aff *isl_union_pw_aff_mod_val( __isl_take isl_union_pw_aff *upa, __isl_take isl_val *m) { … } /* Internal data structure for isl_union_pw_multi_aff_get_union_pw_aff. * pos is the output position that needs to be extracted. * res collects the results. */ struct isl_union_pw_multi_aff_get_union_pw_aff_data { … }; /* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma" * (assuming it has such a dimension) and add it to data->res. */ static isl_stat get_union_pw_aff(__isl_take isl_pw_multi_aff *pma, void *user) { … } /* Extract an isl_union_pw_aff corresponding to * output dimension "pos" of "upma". */ __isl_give isl_union_pw_aff *isl_union_pw_multi_aff_get_union_pw_aff( __isl_keep isl_union_pw_multi_aff *upma, int pos) { … } /* Return a union piecewise affine expression * that is equal to "aff" on "domain". */ __isl_give isl_union_pw_aff *isl_union_pw_aff_aff_on_domain( __isl_take isl_union_set *domain, __isl_take isl_aff *aff) { … } /* Return a union piecewise affine expression * that is equal to the parameter identified by "id" on "domain". * * Make sure the parameter appears in the space passed to * isl_aff_param_on_domain_space_id. */ __isl_give isl_union_pw_aff *isl_union_pw_aff_param_on_domain_id( __isl_take isl_union_set *domain, __isl_take isl_id *id) { … } /* Internal data structure for isl_union_pw_aff_pw_aff_on_domain. * "pa" is the piecewise symbolic value that the resulting isl_union_pw_aff * needs to attain. * "res" collects the results. */ struct isl_union_pw_aff_pw_aff_on_domain_data { … }; /* Construct a piecewise affine expression that is equal to data->pa * on "domain" and add the result to data->res. */ static isl_stat pw_aff_on_domain(__isl_take isl_set *domain, void *user) { … } /* Return a union piecewise affine expression * that is equal to "pa" on "domain", assuming "domain" and "pa" * have been aligned. * * Construct an isl_pw_aff on each of the sets in "domain" and * collect the results. */ static __isl_give isl_union_pw_aff *isl_union_pw_aff_pw_aff_on_domain_aligned( __isl_take isl_union_set *domain, __isl_take isl_pw_aff *pa) { … } /* Return a union piecewise affine expression * that is equal to "pa" on "domain". * * Check that "pa" is a parametric expression, * align the parameters if needed and call * isl_union_pw_aff_pw_aff_on_domain_aligned. */ __isl_give isl_union_pw_aff *isl_union_pw_aff_pw_aff_on_domain( __isl_take isl_union_set *domain, __isl_take isl_pw_aff *pa) { … } /* Internal data structure for isl_union_pw_aff_val_on_domain. * "v" is the value that the resulting isl_union_pw_aff needs to attain. * "res" collects the results. */ struct isl_union_pw_aff_val_on_domain_data { … }; /* Construct a piecewise affine expression that is equal to data->v * on "domain" and add the result to data->res. */ static isl_stat pw_aff_val_on_domain(__isl_take isl_set *domain, void *user) { … } /* Return a union piecewise affine expression * that is equal to "v" on "domain". * * Construct an isl_pw_aff on each of the sets in "domain" and * collect the results. */ __isl_give isl_union_pw_aff *isl_union_pw_aff_val_on_domain( __isl_take isl_union_set *domain, __isl_take isl_val *v) { … } /* Construct a piecewise multi affine expression * that is equal to "pa" and add it to upma. */ static isl_stat pw_multi_aff_from_pw_aff_entry(__isl_take isl_pw_aff *pa, void *user) { … } /* Construct and return a union piecewise multi affine expression * that is equal to the given union piecewise affine expression. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_union_pw_aff( __isl_take isl_union_pw_aff *upa) { … } /* Compute the set of elements in the domain of "pa" where it is zero and * add this set to "uset". */ static isl_stat zero_union_set(__isl_take isl_pw_aff *pa, void *user) { … } /* Return a union set containing those elements in the domain * of "upa" where it is zero. */ __isl_give isl_union_set *isl_union_pw_aff_zero_union_set( __isl_take isl_union_pw_aff *upa) { … } /* Internal data structure for isl_union_pw_aff_bind_id, * storing the parameter that needs to be bound and * the accumulated results. */ struct isl_bind_id_data { … }; /* Bind the piecewise affine function "pa" to the parameter data->id, * adding the resulting elements in the domain where the expression * is equal to the parameter to data->bound. */ static isl_stat bind_id(__isl_take isl_pw_aff *pa, void *user) { … } /* Bind the union piecewise affine function "upa" to the parameter "id", * returning the elements in the domain where the expression * is equal to the parameter. */ __isl_give isl_union_set *isl_union_pw_aff_bind_id( __isl_take isl_union_pw_aff *upa, __isl_take isl_id *id) { … } /* Internal data structure for isl_union_pw_aff_pullback_union_pw_multi_aff. * upma is the function that is plugged in. * pa is the current part of the function in which upma is plugged in. * res collects the results. */ struct isl_union_pw_aff_pullback_upma_data { … }; /* Check if "pma" can be plugged into data->pa. * If so, perform the pullback and add the result to data->res. */ static isl_stat pa_pb_pma(__isl_take isl_pw_multi_aff *pma, void *user) { … } /* Check if any of the elements of data->upma can be plugged into pa, * add if so add the result to data->res. */ static isl_stat upa_pb_upma(__isl_take isl_pw_aff *pa, void *user) { … } /* Compute the pullback of "upa" by the function represented by "upma". * In other words, plug in "upma" in "upa". The result contains * expressions defined over the domain space of "upma". * * Run over all pairs of elements in "upa" and "upma", perform * the pullback when appropriate and collect the results. * If the hash value were based on the domain space rather than * the function space, then we could run through all elements * of "upma" and directly pick out the corresponding element of "upa". */ __isl_give isl_union_pw_aff *isl_union_pw_aff_pullback_union_pw_multi_aff( __isl_take isl_union_pw_aff *upa, __isl_take isl_union_pw_multi_aff *upma) { … } #undef BASE #define BASE … #undef DOMBASE #define DOMBASE … #include <isl_multi_explicit_domain.c> #include <isl_multi_union_pw_aff_explicit_domain.c> #include <isl_multi_templ.c> #include <isl_multi_un_op_templ.c> #include <isl_multi_bin_val_templ.c> #include <isl_multi_apply_set.c> #include <isl_multi_apply_union_set.c> #include <isl_multi_arith_templ.c> #include <isl_multi_bind_templ.c> #include <isl_multi_coalesce.c> #include <isl_multi_dim_id_templ.c> #include <isl_multi_floor.c> #include <isl_multi_from_base_templ.c> #include <isl_multi_gist.c> #include <isl_multi_align_set.c> #include <isl_multi_align_union_set.c> #include <isl_multi_intersect.c> #include <isl_multi_nan_templ.c> #include <isl_multi_tuple_id_templ.c> #include <isl_multi_union_add_templ.c> #include <isl_multi_zero_space_templ.c> /* Does "mupa" have a non-trivial explicit domain? * * The explicit domain, if present, is trivial if it represents * an (obviously) universe parameter set. */ isl_bool isl_multi_union_pw_aff_has_non_trivial_domain( __isl_keep isl_multi_union_pw_aff *mupa) { … } /* Construct a multiple union piecewise affine expression * in the given space with value zero in each of the output dimensions. * * Since there is no canonical zero value for * a union piecewise affine expression, we can only construct * a zero-dimensional "zero" value. */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_zero( __isl_take isl_space *space) { … } /* Construct and return a multi union piecewise affine expression * that is equal to the given multi affine expression. */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_from_multi_aff( __isl_take isl_multi_aff *ma) { … } /* This function performs the same operation as * isl_multi_union_pw_aff_from_multi_aff, but is considered as a function on an * isl_multi_aff when exported. */ __isl_give isl_multi_union_pw_aff *isl_multi_aff_to_multi_union_pw_aff( __isl_take isl_multi_aff *ma) { … } /* Construct and return a multi union piecewise affine expression * that is equal to the given multi piecewise affine expression. * * If the resulting multi union piecewise affine expression has * an explicit domain, then assign it the domain of the input. * In other cases, the domain is stored in the individual elements. */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_from_multi_pw_aff( __isl_take isl_multi_pw_aff *mpa) { … } /* Extract the range space of "pma" and assign it to *space. * If *space has already been set (through a previous call to this function), * then check that the range space is the same. */ static isl_stat extract_space(__isl_take isl_pw_multi_aff *pma, void *user) { … } /* Construct and return a multi union piecewise affine expression * that is equal to the given union piecewise multi affine expression. * * In order to be able to perform the conversion, the input * needs to be non-empty and may only involve a single range space. * * If the resulting multi union piecewise affine expression has * an explicit domain, then assign it the domain of the input. * In other cases, the domain is stored in the individual elements. */ __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_union_pw_multi_aff( __isl_take isl_union_pw_multi_aff *upma) { … } /* This function performs the same operation as * isl_multi_union_pw_aff_from_union_pw_multi_aff, * but is considered as a function on an isl_union_pw_multi_aff when exported. */ __isl_give isl_multi_union_pw_aff * isl_union_pw_multi_aff_as_multi_union_pw_aff( __isl_take isl_union_pw_multi_aff *upma) { … } /* Try and create an isl_multi_union_pw_aff that is equivalent * to the given isl_union_map. * The isl_union_map is required to be single-valued in each space. * Moreover, it cannot be empty and all range spaces need to be the same. * Otherwise, an error is produced. */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_from_union_map( __isl_take isl_union_map *umap) { … } /* This function performs the same operation as * isl_multi_union_pw_aff_from_union_map, * but is considered as a function on an isl_union_map when exported. */ __isl_give isl_multi_union_pw_aff *isl_union_map_as_multi_union_pw_aff( __isl_take isl_union_map *umap) { … } /* Return a multiple union piecewise affine expression * that is equal to "mv" on "domain", assuming "domain" and "mv" * have been aligned. * * If the resulting multi union piecewise affine expression has * an explicit domain, then assign it the input domain. * In other cases, the domain is stored in the individual elements. */ static __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_multi_val_on_domain_aligned( __isl_take isl_union_set *domain, __isl_take isl_multi_val *mv) { … } /* Return a multiple union piecewise affine expression * that is equal to "mv" on "domain". */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_multi_val_on_domain( __isl_take isl_union_set *domain, __isl_take isl_multi_val *mv) { … } /* Return a multiple union piecewise affine expression * that is equal to "ma" on "domain". */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_multi_aff_on_domain( __isl_take isl_union_set *domain, __isl_take isl_multi_aff *ma) { … } /* Return a multiple union piecewise affine expression * that is equal to "pma" on "domain", assuming "domain" and "pma" * have been aligned. * * If the resulting multi union piecewise affine expression has * an explicit domain, then assign it the input domain. * In other cases, the domain is stored in the individual elements. */ static __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pw_multi_aff_on_domain_aligned( __isl_take isl_union_set *domain, __isl_take isl_pw_multi_aff *pma) { … } /* Return a multiple union piecewise affine expression * that is equal to "pma" on "domain". */ __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pw_multi_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_pw_multi_aff *pma) { … } /* Return a union set containing those elements in the domains * of the elements of "mupa" where they are all zero. * * If there are no elements, then simply return the entire domain. */ __isl_give isl_union_set *isl_multi_union_pw_aff_zero_union_set( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Construct a union map mapping the shared domain * of the union piecewise affine expressions to the range of "mupa" * in the special case of a 0D multi union piecewise affine expression. * * Construct a map between the explicit domain of "mupa" and * the range space. * Note that this assumes that the domain consists of explicit elements. */ static __isl_give isl_union_map *isl_union_map_from_multi_union_pw_aff_0D( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Construct a union map mapping the shared domain * of the union piecewise affine expressions to the range of "mupa" * with each dimension in the range equated to the * corresponding union piecewise affine expression. * * If the input is zero-dimensional, then construct a mapping * from its explicit domain. */ __isl_give isl_union_map *isl_union_map_from_multi_union_pw_aff( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Internal data structure for isl_union_pw_multi_aff_reset_range_space. * "range" is the space from which to set the range space. * "res" collects the results. */ struct isl_union_pw_multi_aff_reset_range_space_data { … }; /* Replace the range space of "pma" by the range space of data->range and * add the result to data->res. */ static isl_stat reset_range_space(__isl_take isl_pw_multi_aff *pma, void *user) { … } /* Replace the range space of all the piecewise affine expressions in "upma" by * the range space of "space". * * This assumes that all these expressions have the same output dimension. * * Since the spaces of the expressions change, so do their hash values. * We therefore need to create a new isl_union_pw_multi_aff. * Note that the hash value is currently computed based on the entire * space even though there can only be a single expression with a given * domain space. */ static __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_reset_range_space( __isl_take isl_union_pw_multi_aff *upma, __isl_take isl_space *space) { … } /* Construct and return a union piecewise multi affine expression * that is equal to the given multi union piecewise affine expression, * in the special case of a 0D multi union piecewise affine expression. * * Construct a union piecewise multi affine expression * on top of the explicit domain of the input. */ __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_multi_union_pw_aff_0D( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Construct and return a union piecewise multi affine expression * that is equal to the given multi union piecewise affine expression. * * If the input is zero-dimensional, then * construct a union piecewise multi affine expression * on top of the explicit domain of the input. */ __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_from_multi_union_pw_aff( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Intersect the range of "mupa" with "range", * in the special case where "mupa" is 0D. * * Intersect the domain of "mupa" with the constraints on the parameters * of "range". */ static __isl_give isl_multi_union_pw_aff *mupa_intersect_range_0D( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *range) { … } /* Intersect the range of "mupa" with "range". * That is, keep only those domain elements that have a function value * in "range". */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_intersect_range( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *range) { … } /* Return the shared domain of the elements of "mupa", * in the special case where "mupa" is zero-dimensional. * * Return the explicit domain of "mupa". * Note that this domain may be a parameter set, either * because "mupa" is meant to live in a set space or * because no explicit domain has been set. */ __isl_give isl_union_set *isl_multi_union_pw_aff_domain_0D( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Return the shared domain of the elements of "mupa". * * If "mupa" is zero-dimensional, then return its explicit domain. */ __isl_give isl_union_set *isl_multi_union_pw_aff_domain( __isl_take isl_multi_union_pw_aff *mupa) { … } /* Apply "aff" to "mupa". The space of "mupa" is equal to the domain of "aff". * In particular, the spaces have been aligned. * The result is defined over the shared domain of the elements of "mupa" * * We first extract the parametric constant part of "aff" and * define that over the shared domain. * Then we iterate over all input dimensions of "aff" and add the corresponding * multiples of the elements of "mupa". * Finally, we consider the integer divisions, calling the function * recursively to obtain an isl_union_pw_aff corresponding to the * integer division argument. */ static __isl_give isl_union_pw_aff *multi_union_pw_aff_apply_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_aff *aff) { … } /* Apply "aff" to "mupa". The space of "mupa" needs to be compatible * with the domain of "aff". * Furthermore, the dimension of this space needs to be greater than zero. * The result is defined over the shared domain of the elements of "mupa" * * We perform these checks and then hand over control to * multi_union_pw_aff_apply_aff. */ __isl_give isl_union_pw_aff *isl_multi_union_pw_aff_apply_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_aff *aff) { … } /* Apply "ma" to "mupa", in the special case where "mupa" is 0D. * The space of "mupa" is known to be compatible with the domain of "ma". * * Construct an isl_multi_union_pw_aff that is equal to "ma" * on the domain of "mupa". */ static __isl_give isl_multi_union_pw_aff *mupa_apply_multi_aff_0D( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_aff *ma) { … } /* Apply "ma" to "mupa". The space of "mupa" needs to be compatible * with the domain of "ma". * The result is defined over the shared domain of the elements of "mupa" */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_apply_multi_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_aff *ma) { … } /* Apply "pa" to "mupa", in the special case where "mupa" is 0D. * The space of "mupa" is known to be compatible with the domain of "pa". * * Construct an isl_multi_union_pw_aff that is equal to "pa" * on the domain of "mupa". */ static __isl_give isl_union_pw_aff *isl_multi_union_pw_aff_apply_pw_aff_0D( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_aff *pa) { … } /* Apply "pa" to "mupa". The space of "mupa" needs to be compatible * with the domain of "pa". * Furthermore, the dimension of this space needs to be greater than zero. * The result is defined over the shared domain of the elements of "mupa" */ __isl_give isl_union_pw_aff *isl_multi_union_pw_aff_apply_pw_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_aff *pa) { … } /* Apply "pma" to "mupa", in the special case where "mupa" is 0D. * The space of "mupa" is known to be compatible with the domain of "pma". * * Construct an isl_multi_union_pw_aff that is equal to "pma" * on the domain of "mupa". */ static __isl_give isl_multi_union_pw_aff *mupa_apply_pw_multi_aff_0D( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_multi_aff *pma) { … } /* Apply "pma" to "mupa". The space of "mupa" needs to be compatible * with the domain of "pma". * The result is defined over the shared domain of the elements of "mupa" */ __isl_give isl_multi_union_pw_aff *isl_multi_union_pw_aff_apply_pw_multi_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_multi_aff *pma) { … } /* Replace the explicit domain of "mupa" by its preimage under "upma". * If the explicit domain only keeps track of constraints on the parameters, * then only update those constraints. */ static __isl_give isl_multi_union_pw_aff *preimage_explicit_domain( __isl_take isl_multi_union_pw_aff *mupa, __isl_keep isl_union_pw_multi_aff *upma) { … } /* Compute the pullback of "mupa" by the function represented by "upma". * In other words, plug in "upma" in "mupa". The result contains * expressions defined over the domain space of "upma". * * Run over all elements of "mupa" and plug in "upma" in each of them. * * If "mupa" has an explicit domain, then it is this domain * that needs to undergo a pullback instead, i.e., a preimage. */ __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pullback_union_pw_multi_aff( __isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_union_pw_multi_aff *upma) { … } /* Extract the sequence of elements in "mupa" with domain space "space" * (ignoring parameters). * * For the elements of "mupa" that are not defined on the specified space, * the corresponding element in the result is empty. */ __isl_give isl_multi_pw_aff *isl_multi_union_pw_aff_extract_multi_pw_aff( __isl_keep isl_multi_union_pw_aff *mupa, __isl_take isl_space *space) { … } /* Data structure that specifies how isl_union_pw_multi_aff_un_op * should modify the base expressions in the input. * * If "filter" is not NULL, then only the base expressions that satisfy "filter" * are taken into account. * "fn" is applied to each entry in the input. */ struct isl_union_pw_multi_aff_un_op_control { … }; /* Wrapper for isl_union_pw_multi_aff_un_op filter functions (which do not take * a second argument) for use as an isl_union_pw_multi_aff_transform * filter function (which does take a second argument). * Simply call control->filter without the second argument. */ static isl_bool isl_union_pw_multi_aff_un_op_filter_drop_user( __isl_take isl_pw_multi_aff *pma, void *user) { … } /* Wrapper for isl_union_pw_multi_aff_un_op base functions (which do not take * a second argument) for use as an isl_union_pw_multi_aff_transform * base function (which does take a second argument). * Simply call control->fn without the second argument. */ static __isl_give isl_pw_multi_aff *isl_union_pw_multi_aff_un_op_drop_user( __isl_take isl_pw_multi_aff *pma, void *user) { … } /* Construct an isl_union_pw_multi_aff that is obtained by * modifying "upma" according to "control". * * isl_union_pw_multi_aff_transform performs essentially * the same operation, but takes a filter and a callback function * of a different form (with an extra argument). * Call isl_union_pw_multi_aff_transform with wrappers * that remove this extra argument. */ static __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_un_op( __isl_take isl_union_pw_multi_aff *upma, struct isl_union_pw_multi_aff_un_op_control *control) { … } /* For each function in "upma" of the form A -> [B -> C], * extract the function A -> B and collect the results. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_range_factor_domain( __isl_take isl_union_pw_multi_aff *upma) { … } /* For each function in "upma" of the form A -> [B -> C], * extract the function A -> C and collect the results. */ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_range_factor_range( __isl_take isl_union_pw_multi_aff *upma) { … } /* Evaluate the affine function "aff" in the void point "pnt". * In particular, return the value NaN. */ static __isl_give isl_val *eval_void(__isl_take isl_aff *aff, __isl_take isl_point *pnt) { … } /* Evaluate the affine expression "aff" * in the coordinates (with denominator) "pnt". */ static __isl_give isl_val *eval(__isl_keep isl_vec *aff, __isl_keep isl_vec *pnt) { … } /* Check that the domain space of "aff" is equal to "space". */ static isl_stat isl_aff_check_has_domain_space(__isl_keep isl_aff *aff, __isl_keep isl_space *space) { … } /* Evaluate the affine function "aff" in "pnt". */ __isl_give isl_val *isl_aff_eval(__isl_take isl_aff *aff, __isl_take isl_point *pnt) { … }