/* * Copyright 2012-2013 Ecole Normale Superieure * Copyright 2014 INRIA Rocquencourt * * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, * 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 */ #include <isl/id.h> #include <isl/val.h> #include <isl/space.h> #include <isl/map.h> #include <isl/aff.h> #include <isl/constraint.h> #include <isl/map.h> #include <isl/union_set.h> #include <isl/union_map.h> #include <isl_ast_build_private.h> #include <isl_ast_private.h> #include <isl_config.h> /* Construct a map that isolates the current dimension. * * Essentially, the current dimension of "set" is moved to the single output * dimension in the result, with the current dimension in the domain replaced * by an unconstrained variable. */ __isl_give isl_map *isl_ast_build_map_to_iterator( __isl_keep isl_ast_build *build, __isl_take isl_set *set) { … } /* Initialize the information derived during the AST generation to default * values for a schedule domain in "space". * * We also check that the remaining fields are not NULL so that * the calling functions don't have to perform this test. */ static __isl_give isl_ast_build *isl_ast_build_init_derived( __isl_take isl_ast_build *build, __isl_take isl_space *space) { … } /* Return an isl_id called "c%d", with "%d" set to "i". * If an isl_id with such a name already appears among the parameters * in build->domain, then adjust the name to "c%d_%d". */ static __isl_give isl_id *generate_name(isl_ctx *ctx, int i, __isl_keep isl_ast_build *build) { … } /* Create an isl_ast_build with "set" as domain. * * The input set is usually a parameter domain, but we currently allow it to * be any kind of set. We set the domain of the returned isl_ast_build * to "set" and initialize all the other fields to default values. */ __isl_give isl_ast_build *isl_ast_build_from_context(__isl_take isl_set *set) { … } /* Create an isl_ast_build with a universe (parametric) context. */ __isl_give isl_ast_build *isl_ast_build_alloc(isl_ctx *ctx) { … } __isl_give isl_ast_build *isl_ast_build_copy(__isl_keep isl_ast_build *build) { … } __isl_give isl_ast_build *isl_ast_build_dup(__isl_keep isl_ast_build *build) { … } /* Align the parameters of "build" to those of "model", introducing * additional parameters if needed. */ __isl_give isl_ast_build *isl_ast_build_align_params( __isl_take isl_ast_build *build, __isl_take isl_space *model) { … } __isl_give isl_ast_build *isl_ast_build_cow(__isl_take isl_ast_build *build) { … } __isl_null isl_ast_build *isl_ast_build_free( __isl_take isl_ast_build *build) { … } isl_ctx *isl_ast_build_get_ctx(__isl_keep isl_ast_build *build) { … } /* Replace build->options by "options". */ __isl_give isl_ast_build *isl_ast_build_set_options( __isl_take isl_ast_build *build, __isl_take isl_union_map *options) { … } /* Set the iterators for the next code generation. * * If we still have some iterators left from the previous code generation * (if any) or if iterators have already been set by a previous * call to this function, then we remove them first. */ __isl_give isl_ast_build *isl_ast_build_set_iterators( __isl_take isl_ast_build *build, __isl_take isl_id_list *iterators) { … } /* Set the "at_each_domain" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_at_each_domain( __isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user), void *user) { … } /* Set the "before_each_for" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_before_each_for( __isl_take isl_ast_build *build, __isl_give isl_id *(*fn)(__isl_keep isl_ast_build *build, void *user), void *user) { … } /* Set the "after_each_for" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_after_each_for( __isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user), void *user) { … } /* Set the "before_each_mark" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_before_each_mark( __isl_take isl_ast_build *build, isl_stat (*fn)(__isl_keep isl_id *mark, __isl_keep isl_ast_build *build, void *user), void *user) { … } /* Set the "after_each_mark" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_after_each_mark( __isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user), void *user) { … } /* Set the "create_leaf" callback of "build" to "fn". */ __isl_give isl_ast_build *isl_ast_build_set_create_leaf( __isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_build *build, void *user), void *user) { … } /* Clear all information that is specific to this code generation * and that is (probably) not meaningful to any nested code generation. */ __isl_give isl_ast_build *isl_ast_build_clear_local_info( __isl_take isl_ast_build *build) { … } /* Have any loops been eliminated? * That is, do any of the original schedule dimensions have a fixed * value that has been substituted? */ static int any_eliminated(isl_ast_build *build) { … } /* Clear build->schedule_map. * This function should be called whenever anything that might affect * the result of isl_ast_build_get_schedule_map_multi_aff changes. * In particular, it should be called when the depth is changed or * when an iterator is determined to have a fixed value. */ static void isl_ast_build_reset_schedule_map(__isl_keep isl_ast_build *build) { … } /* Do we need a (non-trivial) schedule map? * That is, is the internal schedule space different from * the external schedule space? * * The internal and external schedule spaces are only the same * if code has been generated for the entire schedule and if none * of the loops have been eliminated. */ isl_bool isl_ast_build_need_schedule_map(__isl_keep isl_ast_build *build) { … } /* Return a mapping from the internal schedule space to the external * schedule space in the form of an isl_multi_aff. * The internal schedule space originally corresponds to that of the * input schedule. This may change during the code generation if * if isl_ast_build_insert_dim is ever called. * The external schedule space corresponds to the * loops that have been generated. * * Currently, the only difference between the internal schedule domain * and the external schedule domain is that some dimensions are projected * out in the external schedule domain. In particular, the dimensions * for which no code has been generated yet and the dimensions that correspond * to eliminated loops. * * We cache a copy of the schedule_map in build->schedule_map. * The cache is cleared through isl_ast_build_reset_schedule_map * whenever anything changes that might affect the result of this function. */ __isl_give isl_multi_aff *isl_ast_build_get_schedule_map_multi_aff( __isl_keep isl_ast_build *build) { … } /* Return a mapping from the internal schedule space to the external * schedule space in the form of an isl_map. */ __isl_give isl_map *isl_ast_build_get_schedule_map( __isl_keep isl_ast_build *build) { … } /* Return the position of the dimension in build->domain for which * an AST node is currently being generated. */ isl_size isl_ast_build_get_depth(__isl_keep isl_ast_build *build) { … } /* Prepare for generating code for the next level. * In particular, increase the depth and reset any information * that is local to the current depth. */ __isl_give isl_ast_build *isl_ast_build_increase_depth( __isl_take isl_ast_build *build) { … } void isl_ast_build_dump(__isl_keep isl_ast_build *build) { … } /* Initialize "build" for AST construction in schedule space "space" * in the case that build->domain is a parameter set. * * build->iterators is assumed to have been updated already. */ static __isl_give isl_ast_build *isl_ast_build_init( __isl_take isl_ast_build *build, __isl_take isl_space *space) { … } /* Assign "aff" to *user and return -1, effectively extracting * the first (and presumably only) affine expression in the isl_pw_aff * on which this function is used. */ static isl_stat extract_single_piece(__isl_take isl_set *set, __isl_take isl_aff *aff, void *user) { … } /* Intersect "set" with the stride constraint of "build", if any. */ static __isl_give isl_set *intersect_stride_constraint(__isl_take isl_set *set, __isl_keep isl_ast_build *build) { … } /* Check if the given bounds on the current dimension (together with * the stride constraint, if any) imply that * this current dimension attains only a single value (in terms of * parameters and outer dimensions). * If so, we record it in build->value. * If, moreover, this value can be represented as a single affine expression, * then we also update build->values, effectively marking the current * dimension as "eliminated". * * When computing the gist of the fixed value that can be represented * as a single affine expression, it is important to only take into * account the domain constraints in the original AST build and * not the domain of the affine expression itself. * Otherwise, a [i/3] is changed into a i/3 because we know that i * is a multiple of 3, but then we end up not expressing anywhere * in the context that i is a multiple of 3. */ static __isl_give isl_ast_build *update_values( __isl_take isl_ast_build *build, __isl_take isl_basic_set *bounds) { … } /* Update the AST build based on the given loop bounds for * the current dimension and the stride information available in the build. * * We first make sure that the bounds do not refer to any iterators * that have already been eliminated. * Then, we check if the bounds imply that the current iterator * has a fixed value. * If they do and if this fixed value can be expressed as a single * affine expression, we eliminate the iterators from the bounds. * Note that we cannot simply plug in this single value using * isl_basic_set_preimage_multi_aff as the single value may only * be defined on a subset of the domain. Plugging in the value * would restrict the build domain to this subset, while this * restriction may not be reflected in the generated code. * Finally, we intersect build->domain with the updated bounds. * We also add the stride constraint unless we have been able * to find a fixed value expressed as a single affine expression. * * Note that the check for a fixed value in update_values requires * us to intersect the bounds with the current build domain. * When we intersect build->domain with the updated bounds in * the final step, we make sure that these updated bounds have * not been intersected with the old build->domain. * Otherwise, we would indirectly intersect the build domain with itself, * which can lead to inefficiencies, in particular if the build domain * contains any unknown divs. * * The pending and generated sets are not updated by this function to * match the updated domain. * The caller still needs to call isl_ast_build_set_pending_generated. */ __isl_give isl_ast_build *isl_ast_build_set_loop_bounds( __isl_take isl_ast_build *build, __isl_take isl_basic_set *bounds) { … } /* Update the pending and generated sets of "build" according to "bounds". * If the build has an affine value at the current depth, * then isl_ast_build_set_loop_bounds has already set the pending set. * Otherwise, do it here. */ __isl_give isl_ast_build *isl_ast_build_set_pending_generated( __isl_take isl_ast_build *build, __isl_take isl_basic_set *bounds) { … } /* Intersect build->domain with "set", where "set" is specified * in terms of the internal schedule domain. */ static __isl_give isl_ast_build *isl_ast_build_restrict_internal( __isl_take isl_ast_build *build, __isl_take isl_set *set) { … } /* Intersect build->generated and build->domain with "set", * where "set" is specified in terms of the internal schedule domain. */ __isl_give isl_ast_build *isl_ast_build_restrict_generated( __isl_take isl_ast_build *build, __isl_take isl_set *set) { … } /* Replace the set of pending constraints by "guard", which is then * no longer considered as pending. * That is, add "guard" to the generated constraints and clear all pending * constraints, making the domain equal to the generated constraints. */ __isl_give isl_ast_build *isl_ast_build_replace_pending_by_guard( __isl_take isl_ast_build *build, __isl_take isl_set *guard) { … } /* Intersect build->domain with "set", where "set" is specified * in terms of the external schedule domain. */ __isl_give isl_ast_build *isl_ast_build_restrict( __isl_take isl_ast_build *build, __isl_take isl_set *set) { … } /* Replace build->executed by "executed". */ __isl_give isl_ast_build *isl_ast_build_set_executed( __isl_take isl_ast_build *build, __isl_take isl_union_map *executed) { … } /* Does "build" point to a band node? * That is, are we currently handling a band node inside a schedule tree? */ int isl_ast_build_has_schedule_node(__isl_keep isl_ast_build *build) { … } /* Return a copy of the band node that "build" refers to. */ __isl_give isl_schedule_node *isl_ast_build_get_schedule_node( __isl_keep isl_ast_build *build) { … } /* Extract the loop AST generation types for the members of build->node * and store them in build->loop_type. */ static __isl_give isl_ast_build *extract_loop_types( __isl_take isl_ast_build *build) { … } /* Replace the band node that "build" refers to by "node" and * extract the corresponding loop AST generation types. */ __isl_give isl_ast_build *isl_ast_build_set_schedule_node( __isl_take isl_ast_build *build, __isl_take isl_schedule_node *node) { … } /* Remove any reference to a band node from "build". */ __isl_give isl_ast_build *isl_ast_build_reset_schedule_node( __isl_take isl_ast_build *build) { … } /* Return a copy of the current schedule domain. */ __isl_give isl_set *isl_ast_build_get_domain(__isl_keep isl_ast_build *build) { … } /* Return a copy of the set of pending constraints. */ __isl_give isl_set *isl_ast_build_get_pending( __isl_keep isl_ast_build *build) { … } /* Return a copy of the set of generated constraints. */ __isl_give isl_set *isl_ast_build_get_generated( __isl_keep isl_ast_build *build) { … } /* Return a copy of the map from the internal schedule domain * to the original input schedule domain. */ __isl_give isl_multi_aff *isl_ast_build_get_internal2input( __isl_keep isl_ast_build *build) { … } /* Return the number of variables of the given type * in the (internal) schedule space. */ isl_size isl_ast_build_dim(__isl_keep isl_ast_build *build, enum isl_dim_type type) { … } /* Return the (schedule) space of "build". * * If "internal" is set, then this space is the space of the internal * representation of the entire schedule, including those parts for * which no code has been generated yet. * * If "internal" is not set, then this space is the external representation * of the loops generated so far. */ __isl_give isl_space *isl_ast_build_get_space(__isl_keep isl_ast_build *build, int internal) { … } /* Return the external representation of the schedule space of "build", * i.e., a space with a dimension for each loop generated so far, * with the names of the dimensions set to the loop iterators. */ __isl_give isl_space *isl_ast_build_get_schedule_space( __isl_keep isl_ast_build *build) { … } /* Return the current schedule, as stored in build->executed, in terms * of the external schedule domain. */ __isl_give isl_union_map *isl_ast_build_get_schedule( __isl_keep isl_ast_build *build) { … } /* Return the iterator attached to the internal schedule dimension "pos". */ __isl_give isl_id *isl_ast_build_get_iterator_id( __isl_keep isl_ast_build *build, int pos) { … } /* Set the stride and offset of the current dimension to the given * value and expression. */ static __isl_give isl_ast_build *set_stride(__isl_take isl_ast_build *build, __isl_take isl_val *stride, __isl_take isl_aff *offset) { … } /* Return a set expressing the stride constraint at the current depth. * * In particular, if the current iterator (i) is known to attain values * * f + s a * * where f is the offset and s is the stride, then the returned set * expresses the constraint * * (f - i) mod s = 0 */ __isl_give isl_set *isl_ast_build_get_stride_constraint( __isl_keep isl_ast_build *build) { … } /* Return the expansion implied by the stride and offset at the current * depth. * * That is, return the mapping * * [i_0, ..., i_{d-1}, i_d, i_{d+1}, ...] * -> [i_0, ..., i_{d-1}, s * i_d + offset(i), i_{d+1}, ...] * * where s is the stride at the current depth d and offset(i) is * the corresponding offset. */ __isl_give isl_multi_aff *isl_ast_build_get_stride_expansion( __isl_keep isl_ast_build *build) { … } /* Add constraints corresponding to any previously detected * stride on the current dimension to build->domain. */ __isl_give isl_ast_build *isl_ast_build_include_stride( __isl_take isl_ast_build *build) { … } /* Check if the constraints in "set" imply any stride on the current * dimension and, if so, record the stride information in "build" * and return the updated "build". * * We assume that inner dimensions have been eliminated from "set" * by the caller. This is needed because the common stride * may be imposed by different inner dimensions on different parts of * the domain. * The assumption ensures that the lower bound does not depend * on inner dimensions. */ __isl_give isl_ast_build *isl_ast_build_detect_strides( __isl_take isl_ast_build *build, __isl_take isl_set *set) { … } /* Does "map" not involve the input dimension data->depth? */ static isl_bool free_of_depth(__isl_keep isl_map *map, void *user) { … } /* Do any options depend on the value of the dimension at the current depth? */ int isl_ast_build_options_involve_depth(__isl_keep isl_ast_build *build) { … } /* Construct the map * * { [i] -> [i] : i < pos; [i] -> [i + 1] : i >= pos } * * with "space" the parameter space of the constructed map. */ static __isl_give isl_map *construct_insertion_map(__isl_take isl_space *space, int pos) { … } static const char *option_str[] = …; /* Update the "options" to reflect the insertion of a dimension * at position "pos" in the schedule domain space. * "space" is the original domain space before the insertion and * may be named and/or structured. * * The (relevant) input options all have "space" as domain, which * has to be mapped to the extended space. * The values of the ranges also refer to the schedule domain positions * and they therefore also need to be adjusted. In particular, values * smaller than pos do not need to change, while values greater than or * equal to pos need to be incremented. * That is, we need to apply the following map. * * { atomic[i] -> atomic[i] : i < pos; [i] -> [i + 1] : i >= pos; * unroll[i] -> unroll[i] : i < pos; [i] -> [i + 1] : i >= pos; * separate[i] -> separate[i] : i < pos; [i] -> [i + 1] : i >= pos; * separation_class[[i] -> [c]] * -> separation_class[[i] -> [c]] : i < pos; * separation_class[[i] -> [c]] * -> separation_class[[i + 1] -> [c]] : i >= pos } */ static __isl_give isl_union_map *options_insert_dim( __isl_take isl_union_map *options, __isl_take isl_space *space, int pos) { … } /* If we are generating an AST from a schedule tree (build->node is set), * then update the loop AST generation types * to reflect the insertion of a dimension at (global) position "pos" * in the schedule domain space. * We do not need to adjust any isolate option since we would not be inserting * any dimensions if there were any isolate option. */ static __isl_give isl_ast_build *node_insert_dim( __isl_take isl_ast_build *build, int pos) { … } /* Insert a single dimension in the schedule domain at position "pos". * The new dimension is given an isl_id with the empty string as name. * * The main difficulty is updating build->options to reflect the * extra dimension. This is handled in options_insert_dim. * * Note that because of the dimension manipulations, the resulting * schedule domain space will always be unnamed and unstructured. * However, the original schedule domain space may be named and/or * structured, so we have to take this possibility into account * while performing the transformations. * * Since the inserted schedule dimension is used by the caller * to differentiate between different domain spaces, there is * no longer a uniform mapping from the internal schedule space * to the input schedule space. The internal2input mapping is * therefore removed. */ __isl_give isl_ast_build *isl_ast_build_insert_dim( __isl_take isl_ast_build *build, int pos) { … } /* Scale down the current dimension by a factor of "m". * "umap" is an isl_union_map that implements the scaling down. * That is, it is of the form * * { [.... i ....] -> [.... i' ....] : i = m i' } * * This function is called right after the strides have been * detected, but before any constraints on the current dimension * have been included in build->domain. * We therefore only need to update stride, offset, the options and * the mapping from internal schedule space to the original schedule * space, if we are still keeping track of such a mapping. * The latter mapping is updated by plugging in * { [... i ...] -> [... m i ... ] }. */ __isl_give isl_ast_build *isl_ast_build_scale_down( __isl_take isl_ast_build *build, __isl_take isl_val *m, __isl_take isl_union_map *umap) { … } /* Return a list of "n" isl_ids called "c%d", with "%d" starting at "first". * If an isl_id with such a name already appears among the parameters * in build->domain, then adjust the name to "c%d_%d". */ static __isl_give isl_id_list *generate_names(isl_ctx *ctx, int n, int first, __isl_keep isl_ast_build *build) { … } /* Embed "options" into the given isl_ast_build space. * * This function is called from within a nested call to * isl_ast_build_node_from_schedule_map. * "options" refers to the additional schedule, * while space refers to both the space of the outer isl_ast_build and * that of the additional schedule. * Specifically, space is of the form * * [I -> S] * * while options lives in the space(s) * * S -> * * * We compute * * [I -> S] -> S * * and compose this with options, to obtain the new options * living in the space(s) * * [I -> S] -> * */ static __isl_give isl_union_map *embed_options( __isl_take isl_union_map *options, __isl_take isl_space *space) { … } /* Update "build" for use in a (possibly nested) code generation. That is, * extend "build" from an AST build on some domain O to an AST build * on domain [O -> S], with S corresponding to "space". * If the original domain is a parameter domain, then the new domain is * simply S. * "iterators" is a list of iterators for S, but the number of elements * may be smaller or greater than the number of set dimensions of S. * If "keep_iterators" is set, then any extra ids in build->iterators * are reused for S. Otherwise, these extra ids are dropped. * * We first update build->outer_pos to the current depth. * This depth is zero in case this is the outermost code generation. * * We then add additional ids such that the number of iterators is at least * equal to the dimension of the new build domain. * * If the original domain is parametric, then we are constructing * an isl_ast_build for the outer code generation and we pass control * to isl_ast_build_init. * * Otherwise, we adjust the fields of "build" to include "space". */ __isl_give isl_ast_build *isl_ast_build_product( __isl_take isl_ast_build *build, __isl_take isl_space *space) { … } /* Does "aff" only attain non-negative values over build->domain? * That is, does it not attain any negative values? */ isl_bool isl_ast_build_aff_is_nonneg(__isl_keep isl_ast_build *build, __isl_keep isl_aff *aff) { … } /* Does the dimension at (internal) position "pos" have a non-trivial stride? */ isl_bool isl_ast_build_has_stride(__isl_keep isl_ast_build *build, int pos) { … } /* Given that the dimension at position "pos" takes on values * * f + s a * * with a an integer, return s. */ __isl_give isl_val *isl_ast_build_get_stride(__isl_keep isl_ast_build *build, int pos) { … } /* Given that the dimension at position "pos" takes on values * * f + s a * * with a an integer, return f. */ __isl_give isl_aff *isl_ast_build_get_offset( __isl_keep isl_ast_build *build, int pos) { … } /* Is the dimension at position "pos" known to attain only a single * value that, moreover, can be described by a single affine expression * in terms of the outer dimensions and parameters? * * If not, then the corresponding affine expression in build->values * is set to be equal to the same input dimension. * Otherwise, it is set to the requested expression in terms of * outer dimensions and parameters. */ isl_bool isl_ast_build_has_affine_value(__isl_keep isl_ast_build *build, int pos) { … } /* Plug in the known values (fixed affine expressions in terms of * parameters and outer loop iterators) of all loop iterators * in the domain of "umap". * * We simply precompose "umap" with build->values. */ __isl_give isl_union_map *isl_ast_build_substitute_values_union_map_domain( __isl_keep isl_ast_build *build, __isl_take isl_union_map *umap) { … } /* Is the current dimension known to attain only a single value? */ int isl_ast_build_has_value(__isl_keep isl_ast_build *build) { … } /* Simplify the basic set "bset" based on what we know about * the iterators of already generated loops. * * "bset" is assumed to live in the (internal) schedule domain. */ __isl_give isl_basic_set *isl_ast_build_compute_gist_basic_set( __isl_keep isl_ast_build *build, __isl_take isl_basic_set *bset) { … } /* Simplify the set "set" based on what we know about * the iterators of already generated loops. * * "set" is assumed to live in the (internal) schedule domain. */ __isl_give isl_set *isl_ast_build_compute_gist( __isl_keep isl_ast_build *build, __isl_take isl_set *set) { … } /* Include information about what we know about the iterators of * already generated loops to "set". * * We currently only plug in the known affine values of outer loop * iterators. * In principle we could also introduce equalities or even other * constraints implied by the intersection of "set" and build->domain. */ __isl_give isl_set *isl_ast_build_specialize(__isl_keep isl_ast_build *build, __isl_take isl_set *set) { … } /* Plug in the known affine values of outer loop iterators in "bset". */ __isl_give isl_basic_set *isl_ast_build_specialize_basic_set( __isl_keep isl_ast_build *build, __isl_take isl_basic_set *bset) { … } /* Simplify the map "map" based on what we know about * the iterators of already generated loops. * * The domain of "map" is assumed to live in the (internal) schedule domain. */ __isl_give isl_map *isl_ast_build_compute_gist_map_domain( __isl_keep isl_ast_build *build, __isl_take isl_map *map) { … } /* Simplify the affine expression "aff" based on what we know about * the iterators of already generated loops. * * The domain of "aff" is assumed to live in the (internal) schedule domain. */ __isl_give isl_aff *isl_ast_build_compute_gist_aff( __isl_keep isl_ast_build *build, __isl_take isl_aff *aff) { … } /* Simplify the piecewise affine expression "aff" based on what we know about * the iterators of already generated loops. * * The domain of "pa" is assumed to live in the (internal) schedule domain. */ __isl_give isl_pw_aff *isl_ast_build_compute_gist_pw_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa) { … } /* Simplify the piecewise multi-affine expression "aff" based on what * we know about the iterators of already generated loops. * * The domain of "pma" is assumed to live in the (internal) schedule domain. */ __isl_give isl_pw_multi_aff *isl_ast_build_compute_gist_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma) { … } /* Extract the schedule domain of the given type from build->options * at the current depth. * * In particular, find the subset of build->options that is of * the following form * * schedule_domain -> type[depth] * * and return the corresponding domain, after eliminating inner dimensions * and divs that depend on the current dimension. * * Note that the domain of build->options has been reformulated * in terms of the internal build space in embed_options, * but the position is still that within the current code generation. */ __isl_give isl_set *isl_ast_build_get_option_domain( __isl_keep isl_ast_build *build, enum isl_ast_loop_type type) { … } /* How does the user want the current schedule dimension to be generated? * These choices have been extracted from the schedule node * in extract_loop_types and stored in build->loop_type. * They have been updated to reflect any dimension insertion in * node_insert_dim. * Return isl_ast_domain_error on error. * * If "isolated" is set, then we get the loop AST generation type * directly from the band node since node_insert_dim cannot have been * called on a band with the isolate option. */ enum isl_ast_loop_type isl_ast_build_get_loop_type( __isl_keep isl_ast_build *build, int isolated) { … } /* Extract the isolated set from the isolate option, if any, * and store in the build. * If there is no isolate option, then the isolated set is * set to the empty set. * * The isolate option is of the form * * isolate[[outer bands] -> current_band] * * We flatten this set and then map it back to the internal * schedule space. * * If we have already extracted the isolated set * or if internal2input is no longer set, then we do not * need to do anything. In the latter case, we know * that the current band cannot have any isolate option. */ __isl_give isl_ast_build *isl_ast_build_extract_isolated( __isl_take isl_ast_build *build) { … } /* Does "build" have a non-empty isolated set? * * The caller is assumed to have called isl_ast_build_extract_isolated first. */ int isl_ast_build_has_isolated(__isl_keep isl_ast_build *build) { … } /* Return a copy of the isolated set of "build". * * The caller is assume to have called isl_ast_build_has_isolated first, * with this function returning true. * In particular, this function should not be called if we are no * longer keeping track of internal2input (and there therefore could * not possibly be any isolated set). */ __isl_give isl_set *isl_ast_build_get_isolated(__isl_keep isl_ast_build *build) { … } /* Extract the separation class mapping at the current depth. * * In particular, find and return the subset of build->options that is of * the following form * * schedule_domain -> separation_class[[depth] -> [class]] * * The caller is expected to eliminate inner dimensions from the domain. * * Note that the domain of build->options has been reformulated * in terms of the internal build space in embed_options, * but the position is still that within the current code generation. */ __isl_give isl_map *isl_ast_build_get_separation_class( __isl_keep isl_ast_build *build) { … } /* Eliminate dimensions inner to the current dimension. */ __isl_give isl_set *isl_ast_build_eliminate_inner( __isl_keep isl_ast_build *build, __isl_take isl_set *set) { … } /* Eliminate unknown divs and divs that depend on the current dimension. * * Note that during the elimination of unknown divs, we may discover * an explicit representation of some other unknown divs, which may * depend on the current dimension. We therefore need to eliminate * unknown divs first. */ __isl_give isl_set *isl_ast_build_eliminate_divs( __isl_keep isl_ast_build *build, __isl_take isl_set *set) { … } /* Eliminate dimensions inner to the current dimension as well as * unknown divs and divs that depend on the current dimension. * The result then consists only of constraints that are independent * of the current dimension and upper and lower bounds on the current * dimension. */ __isl_give isl_set *isl_ast_build_eliminate( __isl_keep isl_ast_build *build, __isl_take isl_set *domain) { … } /* Replace build->single_valued by "sv". */ __isl_give isl_ast_build *isl_ast_build_set_single_valued( __isl_take isl_ast_build *build, int sv) { … }