423 changes: 300 additions & 123 deletions polly/lib/External/isl/isl_coalesce.c

Large diffs are not rendered by default.

87 changes: 0 additions & 87 deletions polly/lib/External/isl/isl_config.h.in
Original file line number Diff line number Diff line change
@@ -1,48 +1,12 @@
/* isl_config.h.in. Generated from configure.ac by autoheader. */

/* Define if HeaderSearchOptions::AddPath takes 4 arguments */
#undef ADDPATH_TAKES_4_ARGUMENTS

/* Clang installation prefix */
#undef CLANG_PREFIX

/* Define if CompilerInstance::createDiagnostics takes argc and argv */
#undef CREATEDIAGNOSTICS_TAKES_ARG

/* Define if CompilerInstance::createPreprocessor takes TranslationUnitKind */
#undef CREATEPREPROCESSOR_TAKES_TUKIND

/* Define if TargetInfo::CreateTargetInfo takes pointer */
#undef CREATETARGETINFO_TAKES_POINTER

/* Define if TargetInfo::CreateTargetInfo takes shared_ptr */
#undef CREATETARGETINFO_TAKES_SHARED_PTR

/* Define if CompilerInvocation::CreateFromArgs takes ArrayRef */
#undef CREATE_FROM_ARGS_TAKES_ARRAYREF

/* Define if Driver constructor takes default image name */
#undef DRIVER_CTOR_TAKES_DEFAULTIMAGENAME

/* Define to Diagnostic for older versions of clang */
#undef DiagnosticsEngine

/* most gcc compilers know a function __attribute__((__warn_unused_result__))
*/
#undef GCC_WARN_UNUSED_RESULT

/* Define if llvm/ADT/OwningPtr.h exists */
#undef HAVE_ADT_OWNINGPTR_H

/* Define if clang/Basic/DiagnosticOptions.h exists */
#undef HAVE_BASIC_DIAGNOSTICOPTIONS_H

/* define if the compiler supports basic C++11 syntax */
#undef HAVE_CXX11

/* Define if Driver constructor takes CXXIsProduction argument */
#undef HAVE_CXXISPRODUCTION

/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS

Expand Down Expand Up @@ -88,24 +52,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define if Driver constructor takes IsProduction argument */
#undef HAVE_ISPRODUCTION

/* Define if clang/Lex/PreprocessorOptions.h exists */
#undef HAVE_LEX_PREPROCESSOROPTIONS_H

/* Define to 1 if you have the `gmp' library (-lgmp). */
#undef HAVE_LIBGMP

/* Define if llvm/Option/Arg.h exists */
#undef HAVE_LLVM_OPTION_ARG_H

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define if SourceManager has a setMainFileID method */
#undef HAVE_SETMAINFILEID

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

Expand All @@ -130,15 +82,6 @@
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__

/* Return type of HandleTopLevelDeclReturn */
#undef HandleTopLevelDeclContinue

/* Return type of HandleTopLevelDeclReturn */
#undef HandleTopLevelDeclReturn

/* Define to Language::C or InputKind::C for newer versions of clang */
#undef IK_C

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR

Expand All @@ -163,12 +106,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* Defined if CompilerInstance::setInvocation takes a shared_ptr */
#undef SETINVOCATION_TAKES_SHARED_PTR

/* Define if CompilerInvocation::setLangDefaults takes 5 arguments */
#undef SETLANGDEFAULTS_TAKES_5_ARGUMENTS

/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR

Expand All @@ -187,9 +124,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

/* Define if Driver::BuildCompilation takes ArrayRef */
#undef USE_ARRAYREF

/* use gmp to implement isl_int */
#undef USE_GMP_FOR_MP

Expand All @@ -202,25 +136,4 @@
/* Version number of package */
#undef VERSION

/* Define to getParamType for newer versions of clang */
#undef getArgType

/* Define to getHostTriple for older versions of clang */
#undef getDefaultTargetTriple

/* Define to getInstantiationLineNumber for older versions of clang */
#undef getExpansionLineNumber

/* Define to getImmediateInstantiationRange for older versions of clang */
#undef getImmediateExpansionRange

/* Define to getNumParams for newer versions of clang */
#undef getNumArgs

/* Define to getResultType for older versions of clang */
#undef getReturnType

/* Define to InitializeBuiltins for older versions of clang */
#undef initializeBuiltins

#include <isl_config_post.h>
37 changes: 20 additions & 17 deletions polly/lib/External/isl/isl_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ isl_ctx *isl_constraint_get_ctx(__isl_keep isl_constraint *c)
return c ? isl_local_space_get_ctx(c->ls) : NULL;
}

static isl_size n(struct isl_constraint *c, enum isl_dim_type type)
static isl_size n(__isl_keep isl_constraint *c, enum isl_dim_type type)
{
return isl_local_space_dim(c->ls, type);
}

static unsigned offset(struct isl_constraint *c, enum isl_dim_type type)
static unsigned offset(__isl_keep isl_constraint *c, enum isl_dim_type type)
{
return isl_local_space_offset(c->ls, type);
}
Expand Down Expand Up @@ -85,8 +85,8 @@ __isl_give isl_constraint *isl_constraint_alloc(int eq,
return isl_constraint_alloc_vec(eq, ls, v);
}

struct isl_constraint *isl_basic_map_constraint(struct isl_basic_map *bmap,
isl_int **line)
__isl_give isl_constraint *isl_basic_map_constraint(
__isl_take isl_basic_map *bmap, isl_int **line)
{
int eq;
isl_size dim;
Expand Down Expand Up @@ -119,8 +119,8 @@ struct isl_constraint *isl_basic_map_constraint(struct isl_basic_map *bmap,
return NULL;
}

struct isl_constraint *isl_basic_set_constraint(struct isl_basic_set *bset,
isl_int **line)
__isl_give isl_constraint *isl_basic_set_constraint(
__isl_take isl_basic_set *bset, isl_int **line)
{
return isl_basic_map_constraint(bset_to_bmap(bset), line);
}
Expand All @@ -137,7 +137,7 @@ __isl_give isl_constraint *isl_constraint_alloc_inequality(
return isl_constraint_alloc(0, ls);
}

struct isl_constraint *isl_constraint_dup(struct isl_constraint *c)
__isl_give isl_constraint *isl_constraint_dup(__isl_keep isl_constraint *c)
{
if (!c)
return NULL;
Expand All @@ -146,7 +146,7 @@ struct isl_constraint *isl_constraint_dup(struct isl_constraint *c)
isl_vec_copy(c->v));
}

struct isl_constraint *isl_constraint_cow(struct isl_constraint *c)
__isl_give isl_constraint *isl_constraint_cow(__isl_take isl_constraint *c)
{
if (!c)
return NULL;
Expand All @@ -157,7 +157,8 @@ struct isl_constraint *isl_constraint_cow(struct isl_constraint *c)
return isl_constraint_dup(c);
}

struct isl_constraint *isl_constraint_copy(struct isl_constraint *constraint)
__isl_give isl_constraint *isl_constraint_copy(
__isl_keep isl_constraint *constraint)
{
if (!constraint)
return NULL;
Expand Down Expand Up @@ -301,8 +302,8 @@ __isl_give isl_constraint_list *isl_basic_set_get_constraint_list(
return isl_basic_map_get_constraint_list(bset);
}

int isl_constraint_is_equal(struct isl_constraint *constraint1,
struct isl_constraint *constraint2)
int isl_constraint_is_equal(__isl_keep isl_constraint *constraint1,
__isl_keep isl_constraint *constraint2)
{
int equal;

Expand All @@ -316,8 +317,8 @@ int isl_constraint_is_equal(struct isl_constraint *constraint1,
return isl_vec_is_equal(constraint1->v, constraint2->v);
}

struct isl_basic_map *isl_basic_map_add_constraint(
struct isl_basic_map *bmap, struct isl_constraint *constraint)
__isl_give isl_basic_map *isl_basic_map_add_constraint(
__isl_take isl_basic_map *bmap, __isl_take isl_constraint *constraint)
{
isl_ctx *ctx;
isl_space *space;
Expand All @@ -341,8 +342,8 @@ struct isl_basic_map *isl_basic_map_add_constraint(
return NULL;
}

struct isl_basic_set *isl_basic_set_add_constraint(
struct isl_basic_set *bset, struct isl_constraint *constraint)
__isl_give isl_basic_set *isl_basic_set_add_constraint(
__isl_take isl_basic_set *bset, __isl_take isl_constraint *constraint)
{
return bset_from_bmap(isl_basic_map_add_constraint(bset_to_bmap(bset),
constraint));
Expand Down Expand Up @@ -488,7 +489,7 @@ __isl_give isl_val *isl_constraint_get_constant_val(
return isl_val_int_from_isl_int(ctx, constraint->v->el[0]);
}

void isl_constraint_get_coefficient(struct isl_constraint *constraint,
void isl_constraint_get_coefficient(__isl_keep isl_constraint *constraint,
enum isl_dim_type type, int pos, isl_int *v)
{
if (isl_constraint_check_range(constraint, type, pos, 1) < 0)
Expand Down Expand Up @@ -635,7 +636,8 @@ __isl_give isl_constraint *isl_constraint_set_coefficient_si(
return constraint;
}

struct isl_constraint *isl_constraint_negate(struct isl_constraint *constraint)
__isl_give isl_constraint *isl_constraint_negate(
__isl_take isl_constraint *constraint)
{
isl_ctx *ctx;

Expand Down Expand Up @@ -1249,6 +1251,7 @@ __isl_give isl_aff *isl_constraint_get_bound(
isl_seq_neg(aff->v->el + 1, constraint->v->el, aff->v->size - 1);
isl_int_set_si(aff->v->el[1 + pos], 0);
isl_int_abs(aff->v->el[0], constraint->v->el[pos]);
aff = isl_aff_normalize(aff);

return aff;
}
Expand Down
4 changes: 2 additions & 2 deletions polly/lib/External/isl/isl_constraint_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct isl_constraint {

#include <isl_list_templ.h>

struct isl_constraint *isl_basic_set_constraint(struct isl_basic_set *bset,
isl_int **line);
__isl_give isl_constraint *isl_basic_set_constraint(
__isl_take isl_basic_set *bset, isl_int **line);

void isl_constraint_get_constant(__isl_keep isl_constraint *constraint,
isl_int *v);
Expand Down
20 changes: 9 additions & 11 deletions polly/lib/External/isl/isl_convex_hull.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ static __isl_give isl_basic_set *modulo_lineality(__isl_take isl_set *set,
static __isl_give isl_basic_set *valid_direction_lp(
__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2)
{
isl_space *dim;
isl_space *space;
struct isl_basic_set *lp;
unsigned d;
int n;
Expand All @@ -1006,8 +1006,8 @@ static __isl_give isl_basic_set *valid_direction_lp(
d = 1 + total;
n = 2 +
2 * bset1->n_eq + bset1->n_ineq + 2 * bset2->n_eq + bset2->n_ineq;
dim = isl_space_set_alloc(bset1->ctx, 0, n);
lp = isl_basic_set_alloc_space(dim, 0, d, n);
space = isl_space_set_alloc(bset1->ctx, 0, n);
lp = isl_basic_set_alloc_space(space, 0, d, n);
if (!lp)
goto error;
for (i = 0; i < n; ++i) {
Expand Down Expand Up @@ -1591,7 +1591,7 @@ static isl_bool has_constraint(struct isl_ctx *ctx,
*/
static isl_bool has_facets(__isl_keep isl_basic_set *bset)
{
int n_eq;
isl_size n_eq;

n_eq = isl_basic_set_n_equality(bset);
if (n_eq < 0)
Expand Down Expand Up @@ -1972,7 +1972,7 @@ __isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map)
return NULL;
}

struct isl_basic_set *isl_set_convex_hull(struct isl_set *set)
__isl_give isl_basic_set *isl_set_convex_hull(__isl_take isl_set *set)
{
return bset_from_bmap(isl_map_convex_hull(set_to_map(set)));
}
Expand Down Expand Up @@ -2476,7 +2476,7 @@ __isl_give isl_basic_map *isl_map_simple_hull(__isl_take isl_map *map)
return map_simple_hull(map, 1);
}

struct isl_basic_set *isl_set_simple_hull(struct isl_set *set)
__isl_give isl_basic_set *isl_set_simple_hull(__isl_take isl_set *set)
{
return bset_from_bmap(isl_map_simple_hull(set_to_map(set)));
}
Expand Down Expand Up @@ -2616,12 +2616,10 @@ __isl_give isl_basic_map *isl_basic_map_plain_unshifted_simple_hull(
if (isl_basic_map_check_equal_space(bmap1, bmap2) < 0)
goto error;

bmap1 = isl_basic_map_drop_constraint_involving_unknown_divs(bmap1);
bmap2 = isl_basic_map_drop_constraint_involving_unknown_divs(bmap2);
bmap1 = isl_basic_map_drop_constraints_involving_unknown_divs(bmap1);
bmap2 = isl_basic_map_drop_constraints_involving_unknown_divs(bmap2);
bmap2 = isl_basic_map_align_divs(bmap2, bmap1);
bmap1 = isl_basic_map_align_divs(bmap1, bmap2);
bmap1 = isl_basic_map_gauss(bmap1, NULL);
bmap2 = isl_basic_map_gauss(bmap2, NULL);
bmap1 = isl_basic_map_sort_constraints(bmap1);
bmap2 = isl_basic_map_sort_constraints(bmap2);

Expand Down Expand Up @@ -2659,7 +2657,7 @@ __isl_give isl_basic_map *isl_map_plain_unshifted_simple_hull(
return NULL;
if (map->n <= 1)
return map_simple_hull_trivial(map);
map = isl_map_drop_constraint_involving_unknown_divs(map);
map = isl_map_drop_constraints_involving_unknown_divs(map);
hull = isl_basic_map_copy(map->p[0]);
for (i = 1; i < map->n; ++i) {
isl_basic_map *bmap_i;
Expand Down
16 changes: 9 additions & 7 deletions polly/lib/External/isl/isl_equalities.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
* then the constraints admit no integer solution and
* a zero-column matrix is returned.
*/
static struct isl_mat *particular_solution(struct isl_mat *B, struct isl_vec *d)
static __isl_give isl_mat *particular_solution(__isl_keep isl_mat *B,
__isl_keep isl_vec *d)
{
int i, j;
struct isl_mat *M = NULL;
Expand Down Expand Up @@ -125,8 +126,8 @@ static struct isl_mat *particular_solution(struct isl_mat *B, struct isl_vec *d)
* The columns of this matrix generate the lattice that satisfies
* the single (linear) modulo constraint.
*/
static struct isl_mat *parameter_compression_1(
struct isl_mat *B, struct isl_vec *d)
static __isl_take isl_mat *parameter_compression_1(__isl_keep isl_mat *B,
__isl_keep isl_vec *d)
{
struct isl_mat *U;

Expand Down Expand Up @@ -156,8 +157,8 @@ static struct isl_mat *parameter_compression_1(
* Putting this on the common denominator, we have
* D * L_i^{-T} = U_i^T diag(D/d_i, D, ..., D).
*/
static struct isl_mat *parameter_compression_multi(
struct isl_mat *B, struct isl_vec *d)
static __isl_give isl_mat *parameter_compression_multi(__isl_keep isl_mat *B,
__isl_keep isl_vec *d)
{
int i, j, k;
isl_int D;
Expand Down Expand Up @@ -704,8 +705,9 @@ static __isl_give isl_basic_set *compress_variables(
return NULL;
}

struct isl_basic_set *isl_basic_set_remove_equalities(
struct isl_basic_set *bset, struct isl_mat **T, struct isl_mat **T2)
__isl_give isl_basic_set *isl_basic_set_remove_equalities(
__isl_take isl_basic_set *bset, __isl_give isl_mat **T,
__isl_give isl_mat **T2)
{
if (T)
*T = NULL;
Expand Down
5 changes: 3 additions & 2 deletions polly/lib/External/isl/isl_equalities.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ __isl_give isl_mat *isl_mat_parameter_compression(__isl_take isl_mat *B,
__isl_take isl_vec *d);
__isl_give isl_mat *isl_mat_parameter_compression_ext(__isl_take isl_mat *B,
__isl_take isl_mat *A);
struct isl_basic_set *isl_basic_set_remove_equalities(
struct isl_basic_set *bset, struct isl_mat **T, struct isl_mat **T2);
__isl_give isl_basic_set *isl_basic_set_remove_equalities(
__isl_take isl_basic_set *bset, __isl_give isl_mat **T,
__isl_give isl_mat **T2);

#if defined(__cplusplus)
}
Expand Down
71 changes: 66 additions & 5 deletions polly/lib/External/isl/isl_factorization.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@
#include <isl_space_private.h>
#include <isl_mat_private.h>

/* Return the isl_ctx to which "f" belongs.
*/
isl_ctx *isl_factorizer_get_ctx(__isl_keep isl_factorizer *f)
{
if (!f)
return NULL;
return isl_basic_set_get_ctx(f->bset);
}

static __isl_give isl_factorizer *isl_factorizer_alloc(
__isl_take isl_morph *morph, int n_group)
__isl_keep isl_basic_set *bset, __isl_take isl_morph *morph,
int n_group)
{
isl_factorizer *f = NULL;
int *len = NULL;
Expand All @@ -37,6 +47,7 @@ static __isl_give isl_factorizer *isl_factorizer_alloc(
if (!f)
goto error;

f->bset = isl_basic_set_copy(bset);
f->morph = morph;
f->n_group = n_group;
f->len = len;
Expand All @@ -48,14 +59,16 @@ static __isl_give isl_factorizer *isl_factorizer_alloc(
return NULL;
}

void isl_factorizer_free(__isl_take isl_factorizer *f)
__isl_null isl_factorizer *isl_factorizer_free(__isl_take isl_factorizer *f)
{
if (!f)
return;
return NULL;

isl_basic_set_free(f->bset);
isl_morph_free(f->morph);
free(f->len);
free(f);
return NULL;
}

void isl_factorizer_dump(__isl_take isl_factorizer *f)
Expand All @@ -77,7 +90,7 @@ void isl_factorizer_dump(__isl_take isl_factorizer *f)

__isl_give isl_factorizer *isl_factorizer_identity(__isl_keep isl_basic_set *bset)
{
return isl_factorizer_alloc(isl_morph_identity(bset), 0);
return isl_factorizer_alloc(bset, isl_morph_identity(bset), 0);
}

__isl_give isl_factorizer *isl_factorizer_groups(__isl_keep isl_basic_set *bset,
Expand Down Expand Up @@ -108,7 +121,7 @@ __isl_give isl_factorizer *isl_factorizer_groups(__isl_keep isl_basic_set *bset,
space = isl_space_add_dims(space, isl_dim_set, nvar);
ran = isl_basic_set_universe(space);
morph = isl_morph_alloc(dom, ran, Q, U);
f = isl_factorizer_alloc(morph, n);
f = isl_factorizer_alloc(bset, morph, n);
if (!f)
return NULL;
for (i = 0; i < n; ++i)
Expand Down Expand Up @@ -326,3 +339,51 @@ __isl_give isl_factorizer *isl_basic_set_factorizer(
clear_groups(&g);
return NULL;
}

/* Given the factorizer "f" of a basic set,
* call "test" on each resulting factor as long as each call succeeds.
*/
__isl_give isl_bool isl_factorizer_every_factor_basic_set(
__isl_keep isl_factorizer *f,
isl_bool (*test)(__isl_keep isl_basic_set *bset, void *user),
void *user)
{
int i, n;
isl_bool every = isl_bool_true;
isl_size nparam, nvar;
isl_basic_set *bset;

if (!f)
return isl_bool_error;
nparam = isl_basic_set_dim(f->bset, isl_dim_param);
nvar = isl_basic_set_dim(f->bset, isl_dim_set);
if (nparam < 0 || nvar < 0)
return isl_bool_error;

bset = isl_basic_set_copy(f->bset);
bset = isl_morph_basic_set(isl_morph_copy(f->morph), bset);

for (i = 0, n = 0; i < f->n_group; ++i) {
isl_basic_set *factor;

factor = isl_basic_set_copy(bset);
factor = isl_basic_set_drop_constraints_involving(factor,
nparam + n + f->len[i], nvar - n - f->len[i]);
factor = isl_basic_set_drop_constraints_involving(factor,
nparam, n);
factor = isl_basic_set_drop(factor, isl_dim_set,
n + f->len[i], nvar - n - f->len[i]);
factor = isl_basic_set_drop(factor, isl_dim_set, 0, n);
every = test(factor, user);
isl_basic_set_free(factor);

if (every < 0 || !every)
break;

n += f->len[i];
}

isl_basic_set_free(bset);

return every;
}
12 changes: 10 additions & 2 deletions polly/lib/External/isl/isl_factorization.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
extern "C" {
#endif

/* Data for factorizing a particular basic set.
/* Data for factorizing the basic set "bset".
* After applying "morph" to the basic set, there are "n_group"
* groups of consecutive set variables, each of length "len[i]",
* with 0 <= i < n_group.
* If no factorization is possible, then "n_group" is set to 0.
*/
struct isl_factorizer {
isl_basic_set *bset;
isl_morph *morph;
int n_group;
int *len;
Expand All @@ -24,9 +25,16 @@ typedef struct isl_factorizer isl_factorizer;
__isl_give isl_factorizer *isl_basic_set_factorizer(
__isl_keep isl_basic_set *bset);

void isl_factorizer_free(__isl_take isl_factorizer *f);
isl_ctx *isl_factorizer_get_ctx(__isl_keep isl_factorizer *f);

__isl_null isl_factorizer *isl_factorizer_free(__isl_take isl_factorizer *f);
void isl_factorizer_dump(__isl_take isl_factorizer *f);

__isl_give isl_bool isl_factorizer_every_factor_basic_set(
__isl_keep isl_factorizer *f,
isl_bool (*test)(__isl_keep isl_basic_set *bset, void *user),
void *user);

#if defined(__cplusplus)
}
#endif
Expand Down
551 changes: 541 additions & 10 deletions polly/lib/External/isl/isl_farkas.c

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions polly/lib/External/isl/isl_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ static __isl_give isl_flow *isl_flow_alloc(__isl_keep isl_access_info *acc)

dep->n_source = n;
for (i = 0; i < acc->n_must; ++i) {
isl_space *dim;
dim = space_align_and_join(
isl_space *space;
space = space_align_and_join(
isl_map_get_space(acc->source[i].map),
isl_space_reverse(isl_map_get_space(acc->sink.map)));
dep->dep[2 * i].map = isl_map_empty(dim);
dep->dep[2 * i].map = isl_map_empty(space);
dep->dep[2 * i + 1].map = isl_map_copy(dep->dep[2 * i].map);
dep->dep[2 * i].data = acc->source[i].data;
dep->dep[2 * i + 1].data = acc->source[i].data;
Expand All @@ -462,11 +462,11 @@ static __isl_give isl_flow *isl_flow_alloc(__isl_keep isl_access_info *acc)
goto error;
}
for (i = acc->n_must; i < acc->n_must + acc->n_may; ++i) {
isl_space *dim;
dim = space_align_and_join(
isl_space *space;
space = space_align_and_join(
isl_map_get_space(acc->source[i].map),
isl_space_reverse(isl_map_get_space(acc->sink.map)));
dep->dep[acc->n_must + i].map = isl_map_empty(dim);
dep->dep[acc->n_must + i].map = isl_map_empty(space);
dep->dep[acc->n_must + i].data = acc->source[i].data;
dep->dep[acc->n_must + i].must = 0;
if (!dep->dep[acc->n_must + i].map)
Expand Down Expand Up @@ -552,14 +552,15 @@ isl_ctx *isl_flow_get_ctx(__isl_keep isl_flow *deps)
* be greater than the loop iterator of the range at the last
* of the level/2 shared loops, i.e., loop level/2 - 1.
*/
static __isl_give isl_map *after_at_level(__isl_take isl_space *dim, int level)
static __isl_give isl_map *after_at_level(__isl_take isl_space *space,
int level)
{
struct isl_basic_map *bmap;

if (level % 2)
bmap = isl_basic_map_equal(dim, level/2);
bmap = isl_basic_map_equal(space, level/2);
else
bmap = isl_basic_map_more_at(dim, level/2 - 1);
bmap = isl_basic_map_more_at(space, level/2 - 1);

return isl_map_from_basic_map(bmap);
}
Expand Down Expand Up @@ -666,7 +667,7 @@ static struct isl_map *last_later_source(struct isl_access_info *acc,
int k, int after_level,
struct isl_set **empty)
{
isl_space *dim;
isl_space *space;
struct isl_set *set_C;
struct isl_map *read_map;
struct isl_map *write_map;
Expand All @@ -681,9 +682,9 @@ static struct isl_map *last_later_source(struct isl_access_info *acc,

write_map = isl_map_reverse(write_map);
dep_map = isl_map_apply_range(read_map, write_map);
dim = space_align_and_join(isl_map_get_space(acc->source[k].map),
space = space_align_and_join(isl_map_get_space(acc->source[k].map),
isl_space_reverse(isl_map_get_space(acc->source[j].map)));
after_write = after_at_level(dim, after_level);
after_write = after_at_level(space, after_level);
after_write = isl_map_apply_range(after_write, old_map);
after_write = isl_map_reverse(after_write);
dep_map = isl_map_intersect(dep_map, after_write);
Expand Down Expand Up @@ -808,7 +809,7 @@ static __isl_give isl_map *all_later_sources(__isl_keep isl_access_info *acc,
__isl_take isl_map *old_map,
int j, int before_level, int k, int after_level)
{
isl_space *dim;
isl_space *space;
isl_set *set_C;
isl_map *read_map;
isl_map *write_map;
Expand All @@ -823,9 +824,10 @@ static __isl_give isl_map *all_later_sources(__isl_keep isl_access_info *acc,

write_map = isl_map_reverse(write_map);
dep_map = isl_map_apply_range(read_map, write_map);
dim = isl_space_join(isl_map_get_space(acc->source[acc->n_must + j].map),
space = isl_space_join(isl_map_get_space(
acc->source[acc->n_must + j].map),
isl_space_reverse(isl_map_get_space(acc->source[k].map)));
after_write = after_at_level(dim, after_level);
after_write = after_at_level(space, after_level);
after_write = isl_map_apply_range(after_write, old_map);
after_write = isl_map_reverse(after_write);
dep_map = isl_map_intersect(dep_map, after_write);
Expand Down Expand Up @@ -1069,7 +1071,7 @@ static __isl_give isl_flow *compute_mem_based_dependences(
for (i = 0; i < acc->n_may; ++i) {
int plevel;
int is_before;
isl_space *dim;
isl_space *space;
isl_map *before;
isl_map *dep;

Expand All @@ -1080,11 +1082,11 @@ static __isl_give isl_flow *compute_mem_based_dependences(
is_before = plevel & 1;
plevel >>= 1;

dim = isl_map_get_space(res->dep[i].map);
space = isl_map_get_space(res->dep[i].map);
if (is_before)
before = isl_map_lex_le_first(dim, plevel);
before = isl_map_lex_le_first(space, plevel);
else
before = isl_map_lex_lt_first(dim, plevel);
before = isl_map_lex_lt_first(space, plevel);
dep = isl_map_apply_range(isl_map_copy(acc->source[i].map),
isl_map_reverse(isl_map_copy(acc->sink.map)));
dep = isl_map_intersect(dep, before);
Expand Down Expand Up @@ -2340,16 +2342,16 @@ struct isl_compute_flow_data {
static isl_stat count_matching_array(__isl_take isl_map *map, void *user)
{
int eq;
isl_space *dim;
isl_space *space;
struct isl_compute_flow_data *data;

data = (struct isl_compute_flow_data *)user;

dim = isl_space_range(isl_map_get_space(map));
space = isl_space_range(isl_map_get_space(map));

eq = isl_space_is_equal(dim, data->dim);
eq = isl_space_is_equal(space, data->dim);

isl_space_free(dim);
isl_space_free(space);
isl_map_free(map);

if (eq < 0)
Expand All @@ -2363,17 +2365,17 @@ static isl_stat count_matching_array(__isl_take isl_map *map, void *user)
static isl_stat collect_matching_array(__isl_take isl_map *map, void *user)
{
int eq;
isl_space *dim;
isl_space *space;
struct isl_sched_info *info;
struct isl_compute_flow_data *data;

data = (struct isl_compute_flow_data *)user;

dim = isl_space_range(isl_map_get_space(map));
space = isl_space_range(isl_map_get_space(map));

eq = isl_space_is_equal(dim, data->dim);
eq = isl_space_is_equal(space, data->dim);

isl_space_free(dim);
isl_space_free(space);

if (eq < 0)
goto error;
Expand Down
40 changes: 20 additions & 20 deletions polly/lib/External/isl/isl_fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,28 @@ __isl_give isl_space *isl_qpolynomial_fold_get_space(
}

__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_domain_space(
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *dim)
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space)
{
int i;

fold = isl_qpolynomial_fold_cow(fold);
if (!fold || !dim)
if (!fold || !space)
goto error;

for (i = 0; i < fold->n; ++i) {
fold->qp[i] = isl_qpolynomial_reset_domain_space(fold->qp[i],
isl_space_copy(dim));
isl_space_copy(space));
if (!fold->qp[i])
goto error;
}

isl_space_free(fold->dim);
fold->dim = dim;
fold->dim = space;

return fold;
error:
isl_qpolynomial_fold_free(fold);
isl_space_free(dim);
isl_space_free(space);
return NULL;
}

Expand Down Expand Up @@ -716,9 +716,9 @@ static __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_zero_in_space(
#include <isl_union_eval.c>

__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_empty(enum isl_fold type,
__isl_take isl_space *dim)
__isl_take isl_space *space)
{
return qpolynomial_fold_alloc(type, dim, 0);
return qpolynomial_fold_alloc(type, space, 0);
}

__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_alloc(
Expand Down Expand Up @@ -1347,15 +1347,15 @@ enum isl_fold isl_union_pw_qpolynomial_fold_get_type(
}

__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_lift(
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *dim)
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space)
{
int i;

if (!fold || !dim)
if (!fold || !space)
goto error;

if (isl_space_is_equal(fold->dim, dim)) {
isl_space_free(dim);
if (isl_space_is_equal(fold->dim, space)) {
isl_space_free(space);
return fold;
}

Expand All @@ -1364,23 +1364,23 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_lift(
goto error;

isl_space_free(fold->dim);
fold->dim = isl_space_copy(dim);
fold->dim = isl_space_copy(space);
if (!fold->dim)
goto error;

for (i = 0; i < fold->n; ++i) {
fold->qp[i] = isl_qpolynomial_lift(fold->qp[i],
isl_space_copy(dim));
isl_space_copy(space));
if (!fold->qp[i])
goto error;
}

isl_space_free(dim);
isl_space_free(space);

return fold;
error:
isl_qpolynomial_fold_free(fold);
isl_space_free(dim);
isl_space_free(space);
return NULL;
}

Expand Down Expand Up @@ -1646,7 +1646,7 @@ __isl_give isl_union_pw_qpolynomial_fold *isl_union_map_apply_union_pw_qpolynomi
__isl_take isl_union_map *umap,
__isl_take isl_union_pw_qpolynomial_fold *upwf, isl_bool *tight)
{
isl_space *dim;
isl_space *space;
enum isl_fold type;
struct isl_apply_fold_data data;

Expand All @@ -1657,9 +1657,9 @@ __isl_give isl_union_pw_qpolynomial_fold *isl_union_map_apply_union_pw_qpolynomi

data.upwf = upwf;
data.tight = tight ? isl_bool_true : isl_bool_false;
dim = isl_union_pw_qpolynomial_fold_get_space(upwf);
space = isl_union_pw_qpolynomial_fold_get_space(upwf);
type = isl_union_pw_qpolynomial_fold_get_type(upwf);
data.res = isl_union_pw_qpolynomial_fold_zero(dim, type);
data.res = isl_union_pw_qpolynomial_fold_zero(space, type);
if (isl_union_map_foreach_map(umap, &map_apply, &data) < 0)
goto error;

Expand Down Expand Up @@ -1724,8 +1724,8 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_mul_isl_int(
return fold;
if (fold && isl_int_is_zero(v)) {
isl_qpolynomial_fold *zero;
isl_space *dim = isl_space_copy(fold->dim);
zero = isl_qpolynomial_fold_empty(fold->type, dim);
isl_space *space = isl_space_copy(fold->dim);
zero = isl_qpolynomial_fold_empty(fold->type, space);
isl_qpolynomial_fold_free(fold);
return zero;
}
Expand Down
51 changes: 37 additions & 14 deletions polly/lib/External/isl/isl_ilp.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,14 @@ static __isl_give isl_val *isl_pw_aff_opt_val(__isl_take isl_pw_aff *pa,
return data.res;
}

#undef TYPE
#define TYPE isl_pw_multi_aff
#include "isl_ilp_opt_multi_val_templ.c"

#undef TYPE
#define TYPE isl_multi_pw_aff
#include "isl_ilp_opt_multi_val_templ.c"

/* Internal data structure for isl_union_pw_aff_opt_val.
*
* "max" is set if the maximum should be computed.
Expand Down Expand Up @@ -861,6 +869,10 @@ __isl_give isl_multi_val *isl_multi_union_pw_aff_max_multi_val(
return isl_multi_union_pw_aff_opt_multi_val(mupa, 1);
}

#undef BASE
#define BASE basic_set
#include "isl_ilp_opt_val_templ.c"

/* Return the maximal value attained by the given set dimension,
* independently of the parameter values and of any other dimensions.
*
Expand All @@ -870,20 +882,31 @@ __isl_give isl_multi_val *isl_multi_union_pw_aff_max_multi_val(
__isl_give isl_val *isl_basic_set_dim_max_val(__isl_take isl_basic_set *bset,
int pos)
{
isl_local_space *ls;
isl_aff *obj;
isl_val *v;
return isl_basic_set_dim_opt_val(bset, 1, pos);
}

if (isl_basic_set_check_range(bset, isl_dim_set, pos, 1) < 0)
goto error;
ls = isl_local_space_from_space(isl_basic_set_get_space(bset));
obj = isl_aff_var_on_domain(ls, isl_dim_set, pos);
v = isl_basic_set_max_val(bset, obj);
isl_aff_free(obj);
isl_basic_set_free(bset);
#undef BASE
#define BASE set
#include "isl_ilp_opt_val_templ.c"

return v;
error:
isl_basic_set_free(bset);
return NULL;
/* Return the minimal value attained by the given set dimension,
* independently of the parameter values and of any other dimensions.
*
* Return negative infinity if the optimal value is unbounded and
* NaN if "set" is empty.
*/
__isl_give isl_val *isl_set_dim_min_val(__isl_take isl_set *set, int pos)
{
return isl_set_dim_opt_val(set, 0, pos);
}

/* Return the maximal value attained by the given set dimension,
* independently of the parameter values and of any other dimensions.
*
* Return infinity if the optimal value is unbounded and
* NaN if "set" is empty.
*/
__isl_give isl_val *isl_set_dim_max_val(__isl_take isl_set *set, int pos)
{
return isl_set_dim_opt_val(set, 1, pos);
}
75 changes: 75 additions & 0 deletions polly/lib/External/isl/isl_ilp_opt_multi_val_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

/* Return a list of minima (maxima if "max" is set)
* for each of the expressions in "f" over their (shared) domain.
*
* An element in the list is infinity or negative infinity if the optimal
* value of the corresponding expression is unbounded and
* NaN if the domain of the expression is empty.
*
* Iterate over all the expressions in "f" and collect the results.
*/
static __isl_give isl_multi_val *FN(TYPE,opt_multi_val)(__isl_take TYPE *f,
int max)
{
int i;
isl_size n;
isl_space *space;
isl_multi_val *mv;

n = FN(TYPE,dim)(f, isl_dim_out);
if (n < 0)
f = FN(TYPE,free)(f);
if (!f)
return NULL;

space = isl_space_range(FN(TYPE,get_space)(f));
space = isl_space_drop_all_params(space);
mv = isl_multi_val_zero(space);

for (i = 0; i < n; ++i) {
isl_val *v;
isl_pw_aff *pa;

pa = FN(TYPE,get_pw_aff)(f, i);
v = isl_pw_aff_opt_val(pa, max);
mv = isl_multi_val_set_val(mv, i, v);
}

FN(TYPE,free)(f);
return mv;
}

/* Return a list of minima
* for each of the expressions in "f" over their (shared) domain.
*
* An element in the list is negative infinity if the optimal
* value of the corresponding expression is unbounded and
* NaN if the domain of the expression is empty.
*/
__isl_give isl_multi_val *FN(TYPE,min_multi_val)(__isl_take TYPE *f)
{
return FN(TYPE,opt_multi_val)(f, 0);
}

/* Return a list of maxima
* for each of the expressions in "f" over their (shared) domain.
*
* An element in the list is infinity if the optimal
* value of the corresponding expression is unbounded and
* NaN if the domain of the expression is empty.
*/
__isl_give isl_multi_val *FN(TYPE,max_multi_val)(__isl_take TYPE *f)
{
return FN(TYPE,opt_multi_val)(f, 1);
}
42 changes: 42 additions & 0 deletions polly/lib/External/isl/isl_ilp_opt_val_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2017 Sven Verdoolaege
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege
*/

#define xCAT(A,B) A ## B
#define CAT(A,B) xCAT(A,B)
#undef TYPE
#define TYPE CAT(isl_,BASE)
#define xBFN(BASE,NAME) isl_ ## BASE ## _ ## NAME
#define BFN(BASE,NAME) xBFN(BASE,NAME)

/* Return the minimal (maximal if "max" is set) value attained
* by the given set dimension,
* independently of the parameter values and of any other dimensions.
*
* Return infinity or negative infinity if the optimal value is unbounded and
* NaN if "set" is empty.
*/
static __isl_give isl_val *BFN(BASE,dim_opt_val)(__isl_take TYPE *set, int max,
int pos)
{
isl_local_space *ls;
isl_aff *obj;
isl_val *v;

if (BFN(BASE,check_range)(set, isl_dim_set, pos, 1) < 0)
goto error;
ls = isl_local_space_from_space(BFN(BASE,get_space)(set));
obj = isl_aff_var_on_domain(ls, isl_dim_set, pos);
v = BFN(BASE,opt_val)(set, max, obj);
isl_aff_free(obj);
BFN(BASE,free)(set);

return v;
error:
BFN(BASE,free)(set);
return NULL;
}
53 changes: 25 additions & 28 deletions polly/lib/External/isl/isl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ __isl_give isl_val *isl_stream_read_val(__isl_keep isl_stream *s)

/* Read an isl_val from "str".
*/
struct isl_val *isl_val_read_from_str(struct isl_ctx *ctx,
const char *str)
__isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx, const char *str)
{
isl_val *val;
isl_stream *s = isl_stream_new_str(ctx, str);
Expand Down Expand Up @@ -337,10 +336,10 @@ static __isl_give isl_pw_aff *affine_mod(__isl_keep isl_stream *s,
static __isl_give isl_pw_aff *accept_affine(__isl_keep isl_stream *s,
__isl_take isl_space *space, struct vars *v);
static __isl_give isl_pw_aff_list *accept_affine_list(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v);
__isl_take isl_space *space, struct vars *v);

static __isl_give isl_pw_aff *accept_minmax(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v)
__isl_take isl_space *space, struct vars *v)
{
struct isl_token *tok;
isl_pw_aff_list *list = NULL;
Expand All @@ -355,17 +354,17 @@ static __isl_give isl_pw_aff *accept_minmax(__isl_keep isl_stream *s,
if (isl_stream_eat(s, '('))
goto error;

list = accept_affine_list(s, isl_space_copy(dim), v);
list = accept_affine_list(s, isl_space_copy(space), v);
if (!list)
goto error;

if (isl_stream_eat(s, ')'))
goto error;

isl_space_free(dim);
isl_space_free(space);
return min ? isl_pw_aff_list_min(list) : isl_pw_aff_list_max(list);
error:
isl_space_free(dim);
isl_space_free(space);
isl_pw_aff_list_free(list);
return NULL;
}
Expand Down Expand Up @@ -400,7 +399,7 @@ static int is_start_of_div(struct isl_token *tok)
* ceild(<affine expression>,<denominator>)
*/
static __isl_give isl_pw_aff *accept_div(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v)
__isl_take isl_space *space, struct vars *v)
{
struct isl_token *tok;
int f = 0;
Expand All @@ -424,7 +423,7 @@ static __isl_give isl_pw_aff *accept_div(__isl_keep isl_stream *s,
goto error;
}

pwaff = accept_affine(s, isl_space_copy(dim), v);
pwaff = accept_affine(s, isl_space_copy(space), v);

if (extra) {
if (isl_stream_eat(s, ','))
Expand Down Expand Up @@ -455,10 +454,10 @@ static __isl_give isl_pw_aff *accept_div(__isl_keep isl_stream *s,
goto error;
}

isl_space_free(dim);
isl_space_free(space);
return pwaff;
error:
isl_space_free(dim);
isl_space_free(space);
isl_pw_aff_free(pwaff);
return NULL;
}
Expand Down Expand Up @@ -736,7 +735,7 @@ static int is_comparator(struct isl_token *tok)
static __isl_give isl_map *read_formula(__isl_keep isl_stream *s,
struct vars *v, __isl_take isl_map *map, int rational);
static __isl_give isl_pw_aff *accept_extended_affine(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v, int rational);
__isl_take isl_space *space, struct vars *v, int rational);

/* Accept a ternary operator, given the first argument.
*/
Expand Down Expand Up @@ -834,16 +833,15 @@ static int next_is_comparator(__isl_keep isl_stream *s)
* argument of a ternary operator and try to parse that.
*/
static __isl_give isl_pw_aff *accept_extended_affine(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v, int rational)
__isl_take isl_space *space, struct vars *v, int rational)
{
isl_space *space;
isl_map *cond;
isl_pw_aff *pwaff;
int line = -1, col = -1;

set_current_line_col(s, &line, &col);

pwaff = accept_affine(s, dim, v);
pwaff = accept_affine(s, space, v);
if (rational)
pwaff = isl_pw_aff_set_rational(pwaff);
if (!pwaff)
Expand Down Expand Up @@ -900,13 +898,13 @@ static __isl_give isl_map *read_var_def(__isl_keep isl_stream *s,
}

static __isl_give isl_pw_aff_list *accept_affine_list(__isl_keep isl_stream *s,
__isl_take isl_space *dim, struct vars *v)
__isl_take isl_space *space, struct vars *v)
{
isl_pw_aff *pwaff;
isl_pw_aff_list *list;
struct isl_token *tok = NULL;

pwaff = accept_affine(s, isl_space_copy(dim), v);
pwaff = accept_affine(s, isl_space_copy(space), v);
list = isl_pw_aff_list_from_pw_aff(pwaff);
if (!list)
goto error;
Expand All @@ -923,17 +921,17 @@ static __isl_give isl_pw_aff_list *accept_affine_list(__isl_keep isl_stream *s,
}
isl_token_free(tok);

pwaff = accept_affine(s, isl_space_copy(dim), v);
pwaff = accept_affine(s, isl_space_copy(space), v);
list = isl_pw_aff_list_concat(list,
isl_pw_aff_list_from_pw_aff(pwaff));
if (!list)
goto error;
}

isl_space_free(dim);
isl_space_free(space);
return list;
error:
isl_space_free(dim);
isl_space_free(space);
isl_pw_aff_list_free(list);
return NULL;
}
Expand Down Expand Up @@ -2029,9 +2027,9 @@ static __isl_give isl_map *read_conjunct(__isl_keep isl_stream *s,
return map;

if (isl_stream_eat_if_available(s, ISL_TOKEN_FALSE)) {
isl_space *dim = isl_map_get_space(map);
isl_space *space = isl_map_get_space(map);
isl_map_free(map);
return isl_map_empty(dim);
return isl_map_empty(space);
}

return add_constraint(s, v, map, rational);
Expand Down Expand Up @@ -2066,7 +2064,7 @@ static __isl_give isl_map *read_conjuncts(__isl_keep isl_stream *s,
return res;
}

static struct isl_map *read_disjuncts(__isl_keep isl_stream *s,
static __isl_give isl_map *read_disjuncts(__isl_keep isl_stream *s,
struct vars *v, __isl_take isl_map *map, int rational)
{
isl_map *res;
Expand Down Expand Up @@ -2344,7 +2342,7 @@ static __isl_give isl_basic_map *basic_map_read_polylib(
return NULL;
}

static struct isl_map *map_read_polylib(__isl_keep isl_stream *s)
static __isl_give isl_map *map_read_polylib(__isl_keep isl_stream *s)
{
struct isl_token *tok;
struct isl_token *tok2;
Expand Down Expand Up @@ -3177,7 +3175,7 @@ __isl_give isl_basic_set *isl_basic_set_read_from_file(isl_ctx *ctx,
return bset;
}

struct isl_basic_map *isl_basic_map_read_from_str(struct isl_ctx *ctx,
__isl_give isl_basic_map *isl_basic_map_read_from_str(isl_ctx *ctx,
const char *str)
{
struct isl_basic_map *bmap;
Expand All @@ -3189,7 +3187,7 @@ struct isl_basic_map *isl_basic_map_read_from_str(struct isl_ctx *ctx,
return bmap;
}

struct isl_basic_set *isl_basic_set_read_from_str(struct isl_ctx *ctx,
__isl_give isl_basic_set *isl_basic_set_read_from_str(isl_ctx *ctx,
const char *str)
{
isl_basic_set *bset;
Expand Down Expand Up @@ -3237,8 +3235,7 @@ __isl_give isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
return set;
}

struct isl_set *isl_set_read_from_str(struct isl_ctx *ctx,
const char *str)
__isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx, const char *str)
{
isl_set *set;
isl_stream *s = isl_stream_new_str(ctx, str);
Expand Down
39 changes: 39 additions & 0 deletions polly/lib/External/isl/isl_insert_domain_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

/* Given a function defined over a parameter domain,
* convert it to a function defined over a domain corresponding
* to "domain".
*/
__isl_give TYPE *FN(TYPE,insert_domain)(__isl_take TYPE *obj,
__isl_take isl_space *domain)
{
isl_size dim;
isl_space *obj_space;

obj_space = FN(TYPE,peek_space)(obj);
if (isl_space_check_is_set(domain) < 0 ||
isl_space_check_is_set(obj_space) < 0)
goto error;
dim = isl_space_dim(domain, isl_dim_set);
if (dim < 0)
goto error;

domain = isl_space_replace_params(domain, obj_space);

obj = FN(TYPE,from_range)(obj);
obj = FN(TYPE,add_dims)(obj, isl_dim_in, dim);
obj = FN(TYPE,reset_domain_space)(obj, domain);

return obj;
error:
isl_space_free(domain);
FN(TYPE,free)(obj);
return NULL;
}
21 changes: 21 additions & 0 deletions polly/lib/External/isl/isl_list_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,27 @@ isl_stat FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list,
return isl_stat_ok;
}

/* Does "test" succeed on every element of "list"?
*/
isl_bool FN(LIST(EL),every)(__isl_keep LIST(EL) *list,
isl_bool (*test)(__isl_keep EL *el, void *user), void *user)
{
int i;

if (!list)
return isl_bool_error;

for (i = 0; i < list->n; ++i) {
isl_bool r;

r = test(list->p[i], user);
if (r < 0 || !r)
return r;
}

return isl_bool_true;
}

/* Replace each element in "list" by the result of calling "fn"
* on the element.
*/
Expand Down
13 changes: 7 additions & 6 deletions polly/lib/External/isl/isl_local_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ __isl_give isl_local_space *isl_local_space_alloc(__isl_take isl_space *space,
return isl_local_space_alloc_div(space, div);
}

__isl_give isl_local_space *isl_local_space_from_space(__isl_take isl_space *dim)
__isl_give isl_local_space *isl_local_space_from_space(
__isl_take isl_space *space)
{
return isl_local_space_alloc(dim, 0);
return isl_local_space_alloc(space, 0);
}

__isl_give isl_local_space *isl_local_space_copy(__isl_keep isl_local_space *ls)
Expand Down Expand Up @@ -534,19 +535,19 @@ __isl_give isl_local_space *isl_local_space_set_from_params(
}

__isl_give isl_local_space *isl_local_space_reset_space(
__isl_take isl_local_space *ls, __isl_take isl_space *dim)
__isl_take isl_local_space *ls, __isl_take isl_space *space)
{
ls = isl_local_space_cow(ls);
if (!ls || !dim)
if (!ls || !space)
goto error;

isl_space_free(ls->dim);
ls->dim = dim;
ls->dim = space;

return ls;
error:
isl_local_space_free(ls);
isl_space_free(dim);
isl_space_free(space);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_local_space_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ isl_bool isl_local_space_has_equal_space(__isl_keep isl_local_space *ls1,
__isl_keep isl_local_space *ls2);

__isl_give isl_local_space *isl_local_space_reset_space(
__isl_take isl_local_space *ls, __isl_take isl_space *dim);
__isl_take isl_local_space *ls, __isl_take isl_space *space);
__isl_give isl_local_space *isl_local_space_realign(
__isl_take isl_local_space *ls, __isl_take isl_reordering *r);

Expand Down
11 changes: 5 additions & 6 deletions polly/lib/External/isl/isl_lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ enum isl_lp_result isl_basic_map_solve_lp(__isl_keep isl_basic_map *bmap,
return isl_tab_solve_lp(bmap, max, f, d, opt, opt_denom, sol);
}

enum isl_lp_result isl_basic_set_solve_lp(struct isl_basic_set *bset, int max,
isl_int *f, isl_int d, isl_int *opt,
isl_int *opt_denom,
struct isl_vec **sol)
enum isl_lp_result isl_basic_set_solve_lp(__isl_keep isl_basic_set *bset,
int max, isl_int *f, isl_int d, isl_int *opt, isl_int *opt_denom,
__isl_give isl_vec **sol)
{
return isl_basic_map_solve_lp(bset_to_bmap(bset), max,
f, d, opt, opt_denom, sol);
Expand All @@ -88,7 +87,7 @@ enum isl_lp_result isl_basic_set_solve_lp(struct isl_basic_set *bset, int max,
enum isl_lp_result isl_map_solve_lp(__isl_keep isl_map *map, int max,
isl_int *f, isl_int d, isl_int *opt,
isl_int *opt_denom,
struct isl_vec **sol)
__isl_give isl_vec **sol)
{
int i;
isl_int o;
Expand Down Expand Up @@ -199,7 +198,7 @@ enum isl_lp_result isl_map_solve_lp(__isl_keep isl_map *map, int max,
enum isl_lp_result isl_set_solve_lp(__isl_keep isl_set *set, int max,
isl_int *f, isl_int d, isl_int *opt,
isl_int *opt_denom,
struct isl_vec **sol)
__isl_give isl_vec **sol)
{
return isl_map_solve_lp(set_to_map(set), max,
f, d, opt, opt_denom, sol);
Expand Down
599 changes: 373 additions & 226 deletions polly/lib/External/isl/isl_map.c

Large diffs are not rendered by default.

80 changes: 48 additions & 32 deletions polly/lib/External/isl/isl_map_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ __isl_keep isl_space *isl_map_peek_space(__isl_keep const isl_map *map);
__isl_keep isl_space *isl_set_peek_space(__isl_keep isl_set *set);

__isl_give isl_basic_set *isl_basic_set_reset_space(
__isl_take isl_basic_set *bset, __isl_take isl_space *dim);
__isl_take isl_basic_set *bset, __isl_take isl_space *space);
__isl_give isl_basic_map *isl_basic_map_reset_space(
__isl_take isl_basic_map *bmap, __isl_take isl_space *dim);
__isl_take isl_basic_map *bmap, __isl_take isl_space *space);
__isl_give isl_map *isl_map_reset_space(__isl_take isl_map *map,
__isl_take isl_space *space);
__isl_give isl_map *isl_map_reset_equal_dim_space(__isl_take isl_map *map,
Expand Down Expand Up @@ -199,24 +199,24 @@ __isl_give isl_basic_set *isl_basic_set_extend(__isl_take isl_basic_set *base,
unsigned extra, unsigned n_eq, unsigned n_ineq);

__isl_give isl_map *isl_map_grow(__isl_take isl_map *map, int n);
struct isl_set *isl_set_grow(struct isl_set *set, int n);
__isl_give isl_set *isl_set_grow(__isl_take isl_set *set, int n);

isl_bool isl_basic_set_contains(__isl_keep isl_basic_set *bset,
__isl_keep isl_vec *vec);
isl_bool isl_basic_map_contains(__isl_keep isl_basic_map *bmap,
__isl_keep isl_vec *vec);

__isl_give isl_basic_set *isl_basic_set_alloc_space(__isl_take isl_space *dim,
__isl_give isl_basic_set *isl_basic_set_alloc_space(__isl_take isl_space *space,
unsigned extra, unsigned n_eq, unsigned n_ineq);
__isl_give isl_set *isl_set_alloc_space(__isl_take isl_space *dim, int n,
__isl_give isl_set *isl_set_alloc_space(__isl_take isl_space *space, int n,
unsigned flags);
__isl_give isl_basic_map *isl_basic_map_alloc_space(__isl_take isl_space *space,
unsigned extra, unsigned n_eq, unsigned n_ineq);
__isl_give isl_map *isl_map_alloc_space(__isl_take isl_space *dim, int n,
__isl_give isl_map *isl_map_alloc_space(__isl_take isl_space *space, int n,
unsigned flags);

int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
int isl_basic_map_alloc_equality(__isl_keep isl_basic_map *bmap);
int isl_basic_set_alloc_equality(__isl_keep isl_basic_set *bset);
__isl_give isl_basic_set *isl_basic_set_free_inequality(
__isl_take isl_basic_set *bset, unsigned n);
__isl_give isl_basic_map *isl_basic_map_free_equality(
Expand All @@ -227,18 +227,18 @@ int isl_basic_set_alloc_inequality(__isl_keep isl_basic_set *bset);
int isl_basic_map_alloc_inequality(__isl_keep isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_free_inequality(
__isl_take isl_basic_map *bmap, unsigned n);
int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
int isl_basic_map_alloc_div(__isl_keep isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_insert_div(
__isl_take isl_basic_map *bmap, int pos, __isl_keep isl_vec *div);
int isl_basic_set_alloc_div(struct isl_basic_set *bset);
isl_stat isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
int isl_basic_set_alloc_div(__isl_keep isl_basic_set *bset);
isl_stat isl_basic_map_free_div(__isl_keep isl_basic_map *bmap, unsigned n);
__isl_give isl_basic_map *isl_basic_map_drop_div(
__isl_take isl_basic_map *bmap, unsigned div);
void isl_basic_map_inequality_to_equality(
struct isl_basic_map *bmap, unsigned pos);
int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
__isl_keep isl_basic_map *bmap, unsigned pos);
int isl_basic_map_drop_equality(__isl_keep isl_basic_map *bmap, unsigned pos);
int isl_basic_set_drop_inequality(__isl_keep isl_basic_set *bset, unsigned pos);
int isl_basic_map_drop_inequality(__isl_keep isl_basic_map *bmap, unsigned pos);
__isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
isl_int *eq);
__isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
Expand Down Expand Up @@ -269,7 +269,6 @@ __isl_give isl_basic_map *isl_basic_map_set_to_empty(
__isl_take isl_basic_map *bmap);
__isl_give isl_basic_set *isl_basic_set_set_to_empty(
__isl_take isl_basic_set *bset);
struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
__isl_give isl_basic_map *isl_basic_map_swap_div(__isl_take isl_basic_map *bmap,
int a, int b);
__isl_give isl_basic_map *isl_basic_map_order_divs(
Expand Down Expand Up @@ -320,9 +319,11 @@ __isl_give isl_basic_set_list *isl_basic_map_list_underlying_set(
__isl_give isl_set *isl_map_underlying_set(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_map_overlying_set(
__isl_take isl_basic_set *bset, __isl_take isl_basic_map *like);
__isl_give isl_basic_map *isl_basic_map_drop_constraint_involving_unknown_divs(
__isl_give isl_basic_set *isl_basic_set_drop_constraints_involving_unknown_divs(
__isl_take isl_basic_set *bset);
__isl_give isl_basic_map *isl_basic_map_drop_constraints_involving_unknown_divs(
__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_drop_constraint_involving_unknown_divs(
__isl_give isl_map *isl_map_drop_constraints_involving_unknown_divs(
__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_map_drop_constraints_involving(
__isl_take isl_basic_map *bmap, unsigned first, unsigned n);
Expand All @@ -341,24 +342,23 @@ __isl_give isl_map *isl_map_drop(__isl_take isl_map *map,
__isl_give isl_basic_map *isl_basic_map_drop_unrelated_constraints(
__isl_take isl_basic_map *bmap, __isl_take int *group);

__isl_give isl_basic_map *isl_basic_map_eliminate_pure_unit_divs(
__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_remove_duplicate_constraints(
__isl_take isl_basic_map *bmap, int *progress, int detect_divs);
__isl_give isl_basic_map *isl_basic_map_detect_inequality_pairs(
__isl_take isl_basic_map *bmap, int *progress);

__isl_give isl_map *isl_map_remove_empty_parts(__isl_take isl_map *map);
struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
__isl_give isl_set *isl_set_remove_empty_parts(__isl_take isl_set *set);
__isl_give isl_map *isl_map_remove_obvious_duplicates(__isl_take isl_map *map);

struct isl_set *isl_set_normalize(struct isl_set *set);

struct isl_set *isl_set_drop_vars(
struct isl_set *set, unsigned first, unsigned n);
__isl_give isl_set *isl_set_normalize(__isl_take isl_set *set);

__isl_give isl_basic_map *isl_basic_map_eliminate_vars(
__isl_take isl_basic_map *bmap, unsigned pos, unsigned n);
struct isl_basic_set *isl_basic_set_eliminate_vars(
struct isl_basic_set *bset, unsigned pos, unsigned n);
__isl_give isl_basic_set *isl_basic_set_eliminate_vars(
__isl_take isl_basic_set *bset, unsigned pos, unsigned n);

__isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
enum isl_dim_type type, unsigned first, unsigned n);
Expand Down Expand Up @@ -403,6 +403,8 @@ __isl_give isl_basic_map *isl_basic_map_from_multi_aff2(
__isl_give isl_map *isl_map_from_multi_aff_internal(
__isl_take isl_multi_aff *ma);
__isl_give isl_map *isl_map_from_pw_aff_internal(__isl_take isl_pw_aff *pa);
__isl_give isl_map *isl_map_from_pw_multi_aff_internal(
__isl_take isl_pw_multi_aff *pma);

struct isl_mat;

Expand Down Expand Up @@ -436,8 +438,6 @@ isl_bool isl_basic_set_eq_is_stride(__isl_keep isl_basic_set *bset, int i);

isl_bool isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
isl_int *constraint, unsigned div);
isl_bool isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
isl_int *constraint, unsigned div);

__isl_give isl_basic_set *isl_basic_set_from_local_space(
__isl_take isl_local_space *ls);
Expand All @@ -448,10 +448,10 @@ __isl_give isl_basic_set *isl_basic_set_expand_divs(
__isl_give isl_basic_map *isl_basic_map_expand_divs(
__isl_take isl_basic_set *bmap, __isl_take isl_mat *div, int *exp);

int isl_basic_set_n_equality(__isl_keep isl_basic_set *bset);
int isl_basic_map_n_equality(__isl_keep isl_basic_map *bmap);
int isl_basic_set_n_inequality(__isl_keep isl_basic_set *bset);
int isl_basic_map_n_inequality(__isl_keep isl_basic_map *bmap);
isl_size isl_basic_set_n_equality(__isl_keep isl_basic_set *bset);
isl_size isl_basic_map_n_equality(__isl_keep isl_basic_map *bmap);
isl_size isl_basic_set_n_inequality(__isl_keep isl_basic_set *bset);
isl_size isl_basic_map_n_inequality(__isl_keep isl_basic_map *bmap);

__isl_give isl_basic_map *isl_basic_map_mark_div_unknown(
__isl_take isl_basic_map *bmap, int div);
Expand All @@ -465,6 +465,9 @@ isl_bool isl_map_divs_known(__isl_keep isl_map *map);
__isl_give isl_mat *isl_basic_set_get_divs(__isl_keep isl_basic_set *bset);
__isl_give isl_mat *isl_basic_map_get_divs(__isl_keep isl_basic_map *bmap);

isl_bool isl_set_every_basic_set(__isl_keep isl_set *set,
isl_bool (*test)(__isl_keep isl_basic_set *bset, void *user),
void *user);
__isl_give isl_map *isl_map_inline_foreach_basic_map(__isl_take isl_map *map,
__isl_give isl_basic_map *(*fn)(__isl_take isl_basic_map *bmap));

Expand All @@ -473,6 +476,8 @@ isl_stat isl_basic_set_check_no_locals(__isl_keep isl_basic_set *bset);

isl_stat isl_basic_set_check_range(__isl_keep isl_basic_set *bset,
enum isl_dim_type type, unsigned first, unsigned n);
isl_stat isl_set_check_range(__isl_keep isl_set *set,
enum isl_dim_type type, unsigned first, unsigned n);
isl_stat isl_basic_map_check_range(__isl_keep isl_basic_map *bmap,
enum isl_dim_type type, unsigned first, unsigned n);
isl_stat isl_map_check_named_params(__isl_keep isl_map *map);
Expand Down Expand Up @@ -551,7 +556,15 @@ int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset,
isl_int max, isl_int *count);
int isl_set_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count);

isl_stat isl_map_check_equal_tuples(__isl_keep isl_map *map);
isl_bool isl_map_space_tuple_is_equal(__isl_keep isl_map *map,
enum isl_dim_type type1, __isl_keep isl_space *space,
enum isl_dim_type type2);
isl_bool isl_map_tuple_is_equal(__isl_keep isl_map *map1,
enum isl_dim_type type1, __isl_keep isl_map *map2,
enum isl_dim_type type2);

isl_bool isl_basic_map_is_transformation(__isl_keep isl_basic_map *bmap);
isl_stat isl_map_check_transformation(__isl_keep isl_map *map);
isl_stat isl_basic_set_check_equal_space(__isl_keep isl_basic_set *bset1,
__isl_keep isl_basic_set *bset2);
isl_stat isl_basic_map_check_equal_space(__isl_keep isl_basic_map *bmap1,
Expand All @@ -563,6 +576,9 @@ isl_stat isl_map_basic_map_check_equal_space(__isl_keep isl_map *map,
isl_stat isl_map_check_equal_space(__isl_keep isl_map *map1,
__isl_keep isl_map *map2);

isl_bool isl_basic_map_applies_range(__isl_keep isl_basic_map *bmap1,
__isl_keep isl_basic_map *bmap2);

__isl_give isl_mat *isl_basic_set_extract_equalities(
__isl_keep isl_basic_set *bset);

Expand Down
332 changes: 240 additions & 92 deletions polly/lib/External/isl/isl_map_simplify.c

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion polly/lib/External/isl/isl_map_subtract.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ __isl_give isl_map *isl_map_subtract( __isl_take isl_map *map1,
return NULL;
}

struct isl_set *isl_set_subtract(struct isl_set *set1, struct isl_set *set2)
__isl_give isl_set *isl_set_subtract(__isl_take isl_set *set1,
__isl_take isl_set *set2)
{
return set_from_map(isl_map_subtract(set_to_map(set1),
set_to_map(set2)));
Expand Down
29 changes: 15 additions & 14 deletions polly/lib/External/isl/isl_mat.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ uint32_t isl_mat_get_hash(__isl_keep isl_mat *mat)
return hash;
}

struct isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
__isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
unsigned n_row, unsigned n_col)
{
int i;
Expand Down Expand Up @@ -86,7 +86,7 @@ struct isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
return NULL;
}

struct isl_mat *isl_mat_extend(struct isl_mat *mat,
__isl_give isl_mat *isl_mat_extend(__isl_take isl_mat *mat,
unsigned n_row, unsigned n_col)
{
int i;
Expand Down Expand Up @@ -580,8 +580,8 @@ __isl_give isl_mat *isl_mat_aff_direct_sum(__isl_take isl_mat *left,
return NULL;
}

static void exchange(struct isl_mat *M, struct isl_mat **U,
struct isl_mat **Q, unsigned row, unsigned i, unsigned j)
static void exchange(__isl_keep isl_mat *M, __isl_keep isl_mat **U,
__isl_keep isl_mat **Q, unsigned row, unsigned i, unsigned j)
{
int r;
for (r = row; r < M->n_row; ++r)
Expand All @@ -594,8 +594,8 @@ static void exchange(struct isl_mat *M, struct isl_mat **U,
isl_mat_swap_rows(*Q, i, j);
}

static void subtract(struct isl_mat *M, struct isl_mat **U,
struct isl_mat **Q, unsigned row, unsigned i, unsigned j, isl_int m)
static void subtract(__isl_keep isl_mat *M, __isl_keep isl_mat **U,
__isl_keep isl_mat **Q, unsigned row, unsigned i, unsigned j, isl_int m)
{
int r;
for (r = row; r < M->n_row; ++r)
Expand All @@ -610,8 +610,8 @@ static void subtract(struct isl_mat *M, struct isl_mat **U,
}
}

static void oppose(struct isl_mat *M, struct isl_mat **U,
struct isl_mat **Q, unsigned row, unsigned col)
static void oppose(__isl_keep isl_mat *M, __isl_keep isl_mat **U,
__isl_keep isl_mat **Q, unsigned row, unsigned col)
{
int r;
for (r = row; r < M->n_row; ++r)
Expand Down Expand Up @@ -979,13 +979,13 @@ static isl_stat inv_exchange(__isl_keep isl_mat **left,
}

static void inv_oppose(
struct isl_mat *left, struct isl_mat *right, unsigned row)
__isl_keep isl_mat *left, __isl_keep isl_mat *right, unsigned row)
{
isl_seq_neg(left->row[row]+row, left->row[row]+row, left->n_col-row);
isl_seq_neg(right->row[row], right->row[row], right->n_col);
}

static void inv_subtract(struct isl_mat *left, struct isl_mat *right,
static void inv_subtract(__isl_keep isl_mat *left, __isl_keep isl_mat *right,
unsigned row, unsigned i, isl_int m)
{
isl_int_neg(m, m);
Expand Down Expand Up @@ -1092,15 +1092,15 @@ __isl_give isl_mat *isl_mat_inverse_product(__isl_take isl_mat *left,
return NULL;
}

void isl_mat_col_scale(struct isl_mat *mat, unsigned col, isl_int m)
void isl_mat_col_scale(__isl_keep isl_mat *mat, unsigned col, isl_int m)
{
int i;

for (i = 0; i < mat->n_row; ++i)
isl_int_mul(mat->row[i][col], mat->row[i][col], m);
}

void isl_mat_col_combine(struct isl_mat *mat, unsigned dst,
void isl_mat_col_combine(__isl_keep isl_mat *mat, unsigned dst,
isl_int m1, unsigned src1, isl_int m2, unsigned src2)
{
int i;
Expand Down Expand Up @@ -1639,7 +1639,7 @@ __isl_give isl_mat *isl_mat_add_zero_rows(__isl_take isl_mat *mat, unsigned n)
return isl_mat_insert_zero_rows(mat, mat->n_row, n);
}

void isl_mat_col_submul(struct isl_mat *mat,
void isl_mat_col_submul(__isl_keep isl_mat *mat,
int dst_col, isl_int f, int src_col)
{
int i;
Expand All @@ -1660,7 +1660,8 @@ void isl_mat_col_add(__isl_keep isl_mat *mat, int dst_col, int src_col)
mat->row[i][dst_col], mat->row[i][src_col]);
}

void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col)
void isl_mat_col_mul(__isl_keep isl_mat *mat, int dst_col, isl_int f,
int src_col)
{
int i;

Expand Down
5 changes: 3 additions & 2 deletions polly/lib/External/isl/isl_mat_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ isl_bool isl_mat_is_scaled_identity(__isl_keep isl_mat *mat);

isl_stat isl_mat_row_gcd(__isl_keep isl_mat *mat, int row, isl_int *gcd);

void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col);
void isl_mat_col_submul(struct isl_mat *mat,
void isl_mat_col_mul(__isl_keep isl_mat *mat, int dst_col, isl_int f,
int src_col);
void isl_mat_col_submul(__isl_keep isl_mat *mat,
int dst_col, isl_int f, int src_col);
__isl_give isl_mat *isl_mat_col_addmul(__isl_take isl_mat *mat, int dst_col,
isl_int f, int src_col);
Expand Down
2 changes: 0 additions & 2 deletions polly/lib/External/isl/isl_multi_arith_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
__isl_give MULTI(BASE) *FN(MULTI(BASE),add)(__isl_take MULTI(BASE) *multi1,
__isl_take MULTI(BASE) *multi2)
{
FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,add));
}

Expand All @@ -27,7 +26,6 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),add)(__isl_take MULTI(BASE) *multi1,
__isl_give MULTI(BASE) *FN(MULTI(BASE),sub)(__isl_take MULTI(BASE) *multi1,
__isl_take MULTI(BASE) *multi2)
{
FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,sub));
}

Expand Down
14 changes: 14 additions & 0 deletions polly/lib/External/isl/isl_multi_insert_domain_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#include <isl_multi_macro.h>

#undef TYPE
#define TYPE MULTI(BASE)
#include <isl_insert_domain_templ.c>
24 changes: 24 additions & 0 deletions polly/lib/External/isl/isl_multi_min_max_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

/* Return the (elementwise) minimum of "multi1" and "multi2".
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),min)(__isl_take MULTI(BASE) *multi1,
__isl_take MULTI(BASE) *multi2)
{
return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,min));
}

/* Return the (elementwise) maximum of "multi1" and "multi2".
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),max)(__isl_take MULTI(BASE) *multi1,
__isl_take MULTI(BASE) *multi2)
{
return FN(MULTI(BASE),bin_op)(multi1, multi2, &FN(EL,max));
}
22 changes: 22 additions & 0 deletions polly/lib/External/isl/isl_multi_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,27 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),set),BASE)(
return FN(MULTI(BASE),set_at)(multi, pos, el);
}

/* Return the base expressions of "multi" as a list.
*/
__isl_give LIST(EL) *FN(MULTI(BASE),get_list)(
__isl_keep MULTI(BASE) *multi)
{
isl_size n;
int i;
LIST(EL) *list;

n = FN(MULTI(BASE),size)(multi);
if (n < 0)
return NULL;
list = FN(LIST(EL),alloc)(FN(MULTI(BASE),get_ctx(multi)), n);
for (i = 0; i < n; ++i) {
EL *el = FN(MULTI(BASE),get_at)(multi, i);
list = FN(LIST(EL),add)(list, el);
}

return list;
}

/* Reset the space of "multi". 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,
Expand Down Expand Up @@ -745,6 +766,7 @@ static __isl_give MULTI(BASE) *FN(MULTI(BASE),bin_op)(
{
int i;

FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
multi1 = FN(MULTI(BASE),cow)(multi1);
if (FN(MULTI(BASE),check_equal_space)(multi1, multi2) < 0)
goto error;
Expand Down
14 changes: 14 additions & 0 deletions polly/lib/External/isl/isl_multi_unbind_params_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#include <isl_multi_macro.h>

#undef TYPE
#define TYPE MULTI(BASE)
#include "isl_unbind_params_templ.c"
81 changes: 81 additions & 0 deletions polly/lib/External/isl/isl_multi_union_add_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2017 Sven Verdoolaege
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege.
*/

#include <isl_multi_macro.h>

/* Compute the sum of "multi1" and "multi2" on the union of their domains,
* with the actual sum on the shared domain and
* the defined expression on the symmetric difference of the domains.
*
* We simply iterate over the elements in both arguments and
* call isl_union_pw_aff_union_add on each of them, if there is
* at least one element.
*
* Otherwise, the two expressions have an explicit domain and
* the union of these explicit domains is computed.
* This assumes that the explicit domains are either both in terms
* of specific domains elements or both in terms of parameters.
* However, if one of the expressions does not have any constraints
* on its explicit domain, then this is allowed as well and the result
* is the expression with no constraints on its explicit domain.
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),union_add)(
__isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
{
isl_bool has_domain, is_params1, is_params2;

if (!multi1)
goto error;
if (multi1->n > 0)
return FN(MULTI(BASE),bin_op)(multi1, multi2,
&FN(EL,union_add));
FN(MULTI(BASE),align_params_bin)(&multi1, &multi2);
if (FN(MULTI(BASE),check_equal_space)(multi1, multi2) < 0)
goto error;
if (FN(MULTI(BASE),check_has_explicit_domain)(multi1) < 0 ||
FN(MULTI(BASE),check_has_explicit_domain)(multi2) < 0)
goto error;

has_domain = FN(MULTI(BASE),has_non_trivial_domain)(multi1);
if (has_domain < 0)
goto error;
if (!has_domain) {
FN(MULTI(BASE),free)(multi2);
return multi1;
}
has_domain = FN(MULTI(BASE),has_non_trivial_domain)(multi2);
if (has_domain < 0)
goto error;
if (!has_domain) {
FN(MULTI(BASE),free)(multi1);
return multi2;
}

is_params1 = FN(DOM,is_params)(multi1->u.dom);
is_params2 = FN(DOM,is_params)(multi2->u.dom);
if (is_params1 < 0 || is_params2 < 0)
goto error;
if (is_params1 != is_params2)
isl_die(FN(MULTI(BASE),get_ctx)(multi1),
isl_error_invalid,
"cannot compute union of concrete domain and "
"parameter constraints", goto error);
multi1 = FN(MULTI(BASE),cow)(multi1);
if (!multi1)
goto error;
multi1->u.dom = FN(DOM,union)(multi1->u.dom,
FN(DOM,copy)(multi2->u.dom));
if (!multi1->u.dom)
goto error;
FN(MULTI(BASE),free)(multi2);
return multi1;
error:
FN(MULTI(BASE),free)(multi1);
FN(MULTI(BASE),free)(multi2);
return NULL;
}
51 changes: 51 additions & 0 deletions polly/lib/External/isl/isl_opt_mpa_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2018 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#undef TYPE
#define TYPE CAT(isl_,BASE)
#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

/* Compute the optima of the set or output dimensions as a function of the
* parameters (and input dimensions), but independently of
* the other set or output dimensions,
* given a function "opt" that computes this optimum
* for a single dimension.
*
* If the resulting multi piecewise affine expression has
* an explicit domain, then assign it the parameter domain of the input.
* In other cases, the parameter domain is stored in the individual elements.
*/
static __isl_give isl_multi_pw_aff *FN(BASE,opt_mpa)(__isl_take TYPE *obj,
__isl_give isl_pw_aff *(*opt)(__isl_take TYPE *obj, int pos))
{
int i;
isl_size n;
isl_multi_pw_aff *mpa;

mpa = isl_multi_pw_aff_alloc(FN(TYPE,get_space)(obj));
n = isl_multi_pw_aff_size(mpa);
if (n < 0)
mpa = isl_multi_pw_aff_free(mpa);
for (i = 0; i < n; ++i) {
isl_pw_aff *pa;

pa = opt(FN(TYPE,copy)(obj), i);
mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
}
if (isl_multi_pw_aff_has_explicit_domain(mpa)) {
isl_set *dom;

dom = FN(TYPE,params)(FN(TYPE,copy)(obj));
mpa = isl_multi_pw_aff_intersect_params(mpa, dom);
}
FN(TYPE,free)(obj);

return mpa;
}
7 changes: 7 additions & 0 deletions polly/lib/External/isl/isl_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
ISL_ARG_BOOL(struct isl_options, ast_always_print_block, 0,
"ast-always-print-block", 0, "print for and if bodies as a block "
"regardless of the number of statements in the body")
ISL_ARG_BOOL(struct isl_options, ast_print_outermost_block, 0,
"ast-print-outermost-block", 1, "print outermost block node as a block")
ISL_ARG_BOOL(struct isl_options, ast_print_macro_once, 0,
"ast-print-macro-once", 0, "only print macro definitions once")
ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
Expand Down Expand Up @@ -359,6 +361,11 @@ ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
ast_always_print_block)

ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
ast_print_outermost_block)
ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
ast_print_outermost_block)

ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
ast_print_macro_once)
ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
Expand Down
1 change: 1 addition & 0 deletions polly/lib/External/isl/isl_options_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct isl_options {

char *ast_iterator_type;
int ast_always_print_block;
int ast_print_outermost_block;
int ast_print_macro_once;

int ast_build_atomic_upper_bound;
Expand Down
26 changes: 13 additions & 13 deletions polly/lib/External/isl/isl_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static isl_bool can_print_div_expr(__isl_keep isl_printer *p,
return isl_bool_not(isl_local_div_is_marked_unknown(div, pos));
}

static __isl_give isl_printer *print_div(__isl_keep isl_space *dim,
static __isl_give isl_printer *print_div(__isl_keep isl_space *space,
__isl_keep isl_mat *div, int pos, __isl_take isl_printer *p);

static __isl_give isl_printer *print_term(__isl_keep isl_space *space,
Expand Down Expand Up @@ -317,7 +317,7 @@ static __isl_give isl_printer *print_term(__isl_keep isl_space *space,
return p;
}

static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *dim,
static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *space,
__isl_keep isl_mat *div,
__isl_take isl_printer *p, isl_int *c, int len)
{
Expand All @@ -337,7 +337,7 @@ static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *dim,
p = isl_printer_print_str(p, " + ");
}
first = 0;
p = print_term(dim, div, c[i], i, p, 0);
p = print_term(space, div, c[i], i, p, 0);
if (flip)
isl_int_neg(c[i], c[i]);
}
Expand Down Expand Up @@ -439,13 +439,13 @@ static __isl_give isl_printer *print_nested_tuple(__isl_take isl_printer *p,
return p;
}

static __isl_give isl_printer *print_tuple(__isl_keep isl_space *dim,
static __isl_give isl_printer *print_tuple(__isl_keep isl_space *space,
__isl_take isl_printer *p, enum isl_dim_type type,
struct isl_print_space_data *data)
{
data->space = dim;
data->space = space;
data->type = type;
return print_nested_tuple(p, dim, type, data, 0);
return print_nested_tuple(p, space, type, data, 0);
}

static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p,
Expand Down Expand Up @@ -871,7 +871,7 @@ static __isl_give isl_printer *print_constraints(__isl_keep isl_basic_map *bmap,
return NULL;
}

static __isl_give isl_printer *print_div(__isl_keep isl_space *dim,
static __isl_give isl_printer *print_div(__isl_keep isl_space *space,
__isl_keep isl_mat *div, int pos, __isl_take isl_printer *p)
{
int c;
Expand All @@ -881,7 +881,7 @@ static __isl_give isl_printer *print_div(__isl_keep isl_space *dim,

c = p->output_format == ISL_FORMAT_C;
p = isl_printer_print_str(p, c ? "floord(" : "floor((");
p = print_affine_of_len(dim, div, p,
p = print_affine_of_len(space, div, p,
div->row[pos] + 1, div->n_col - 1);
p = isl_printer_print_str(p, c ? ", " : ")/");
p = isl_printer_print_isl_int(p, div->row[pos][0]);
Expand Down Expand Up @@ -1381,7 +1381,7 @@ static __isl_give struct isl_aff_split *split_aff(__isl_keep isl_map *map)
}

static int defining_equality(__isl_keep isl_basic_map *eq,
__isl_keep isl_space *dim, enum isl_dim_type type, int pos)
__isl_keep isl_space *space, enum isl_dim_type type, int pos)
{
int i;
isl_size total;
Expand All @@ -1390,7 +1390,7 @@ static int defining_equality(__isl_keep isl_basic_map *eq,
if (total < 0)
return -1;

pos += isl_space_offset(dim, type);
pos += isl_space_offset(space, type);

for (i = 0; i < eq->n_eq; ++i) {
if (isl_seq_last_non_zero(eq->eq[i] + 1, total) != pos)
Expand Down Expand Up @@ -1803,16 +1803,16 @@ static __isl_give isl_printer *print_base(__isl_take isl_printer *p,
}

static __isl_give isl_printer *print_pow(__isl_take isl_printer *p,
__isl_keep isl_space *dim, __isl_keep isl_mat *div, int var, int exp)
__isl_keep isl_space *space, __isl_keep isl_mat *div, int var, int exp)
{
p = print_base(p, dim, div, var);
p = print_base(p, space, div, var);
if (exp == 1)
return p;
if (p->output_format == ISL_FORMAT_C) {
int i;
for (i = 1; i < exp; ++i) {
p = isl_printer_print_str(p, "*");
p = print_base(p, dim, div, var);
p = print_base(p, space, div, var);
}
} else {
p = isl_printer_print_str(p, "^");
Expand Down
4 changes: 2 additions & 2 deletions polly/lib/External/isl/isl_point.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,11 @@ __isl_give isl_basic_set *isl_basic_set_box_from_points(
isl_space_is_equal(pnt1->dim, pnt2->dim), goto error);

if (isl_point_is_void(pnt1) && isl_point_is_void(pnt2)) {
isl_space *dim = isl_space_copy(pnt1->dim);
isl_space *space = isl_space_copy(pnt1->dim);
isl_point_free(pnt1);
isl_point_free(pnt2);
isl_int_clear(t);
return isl_basic_set_empty(dim);
return isl_basic_set_empty(space);
}
if (isl_point_is_void(pnt1)) {
isl_point_free(pnt1);
Expand Down
110 changes: 50 additions & 60 deletions polly/lib/External/isl/isl_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

#include <isl_list_templ.c>

static unsigned pos(__isl_keep isl_space *dim, enum isl_dim_type type)
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
{
switch (type) {
case isl_dim_param: return 0;
case isl_dim_in: return dim->nparam;
case isl_dim_out: return dim->nparam + dim->n_in;
case isl_dim_in: return space->nparam;
case isl_dim_out: return space->nparam + space->n_in;
default: return 0;
}
}
Expand Down Expand Up @@ -408,19 +408,19 @@ __isl_give isl_poly_rec *isl_poly_alloc_rec(isl_ctx *ctx, int var, int size)
}

__isl_give isl_qpolynomial *isl_qpolynomial_reset_domain_space(
__isl_take isl_qpolynomial *qp, __isl_take isl_space *dim)
__isl_take isl_qpolynomial *qp, __isl_take isl_space *space)
{
qp = isl_qpolynomial_cow(qp);
if (!qp || !dim)
if (!qp || !space)
goto error;

isl_space_free(qp->dim);
qp->dim = dim;
qp->dim = space;

return qp;
error:
isl_qpolynomial_free(qp);
isl_space_free(dim);
isl_space_free(space);
return NULL;
}

Expand Down Expand Up @@ -3374,19 +3374,6 @@ __isl_give isl_qpolynomial *isl_qpolynomial_add_dims(
return isl_qpolynomial_insert_dims(qp, type, pos, n);
}

__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_dims(
__isl_take isl_pw_qpolynomial *pwqp,
enum isl_dim_type type, unsigned n)
{
isl_size pos;

pos = isl_pw_qpolynomial_dim(pwqp, type);
if (pos < 0)
return isl_pw_qpolynomial_free(pwqp);

return isl_pw_qpolynomial_insert_dims(pwqp, type, pos, n);
}

static int *reordering_move(isl_ctx *ctx,
unsigned len, unsigned dst, unsigned src, unsigned n)
{
Expand Down Expand Up @@ -4752,7 +4739,7 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_split_periods(
static __isl_give isl_pw_qpolynomial *constant_on_domain(
__isl_take isl_basic_set *bset, int cst)
{
isl_space *dim;
isl_space *space;
isl_qpolynomial *qp;

if (cst < 0 && isl_basic_set_is_empty(bset) == isl_bool_true)
Expand All @@ -4761,16 +4748,42 @@ static __isl_give isl_pw_qpolynomial *constant_on_domain(
return NULL;

bset = isl_basic_set_params(bset);
dim = isl_basic_set_get_space(bset);
space = isl_basic_set_get_space(bset);
if (cst < 0)
qp = isl_qpolynomial_infty_on_domain(dim);
qp = isl_qpolynomial_infty_on_domain(space);
else if (cst == 0)
qp = isl_qpolynomial_zero_on_domain(dim);
qp = isl_qpolynomial_zero_on_domain(space);
else
qp = isl_qpolynomial_one_on_domain(dim);
qp = isl_qpolynomial_one_on_domain(space);
return isl_pw_qpolynomial_alloc(isl_set_from_basic_set(bset), qp);
}

/* Internal data structure for multiplicative_call_factor_pw_qpolynomial.
* "fn" is the function that is called on each factor.
* "pwpq" collects the results.
*/
struct isl_multiplicative_call_data_pw_qpolynomial {
__isl_give isl_pw_qpolynomial *(*fn)(__isl_take isl_basic_set *bset);
isl_pw_qpolynomial *pwqp;
};

/* isl_factorizer_every_factor_basic_set callback that applies
* data->fn to the factor "bset" and multiplies in the result
* in data->pwqp.
*/
static isl_bool multiplicative_call_factor_pw_qpolynomial(
__isl_keep isl_basic_set *bset, void *user)
{
struct isl_multiplicative_call_data_pw_qpolynomial *data = user;

bset = isl_basic_set_copy(bset);
data->pwqp = isl_pw_qpolynomial_mul(data->pwqp, data->fn(bset));
if (!data->pwqp)
return isl_bool_error;

return isl_bool_true;
}

/* Factor bset, call fn on each of the factors and return the product.
*
* If no factors can be found, simply call fn on the input.
Expand All @@ -4781,14 +4794,12 @@ static __isl_give isl_pw_qpolynomial *compressed_multiplicative_call(
__isl_take isl_basic_set *bset,
__isl_give isl_pw_qpolynomial *(*fn)(__isl_take isl_basic_set *bset))
{
int i, n;
struct isl_multiplicative_call_data_pw_qpolynomial data = { fn };
isl_space *space;
isl_set *set;
isl_factorizer *f;
isl_qpolynomial *qp;
isl_pw_qpolynomial *pwqp;
isl_size nparam;
isl_size nvar;
isl_bool every;

f = isl_basic_set_factorizer(bset);
if (!f)
Expand All @@ -4798,42 +4809,21 @@ static __isl_give isl_pw_qpolynomial *compressed_multiplicative_call(
return fn(bset);
}

nparam = isl_basic_set_dim(bset, isl_dim_param);
nvar = isl_basic_set_dim(bset, isl_dim_set);
if (nparam < 0 || nvar < 0)
bset = isl_basic_set_free(bset);

space = isl_basic_set_get_space(bset);
space = isl_space_params(space);
set = isl_set_universe(isl_space_copy(space));
qp = isl_qpolynomial_one_on_domain(space);
pwqp = isl_pw_qpolynomial_alloc(set, qp);

bset = isl_morph_basic_set(isl_morph_copy(f->morph), bset);

for (i = 0, n = 0; i < f->n_group; ++i) {
isl_basic_set *bset_i;
isl_pw_qpolynomial *pwqp_i;

bset_i = isl_basic_set_copy(bset);
bset_i = isl_basic_set_drop_constraints_involving(bset_i,
nparam + n + f->len[i], nvar - n - f->len[i]);
bset_i = isl_basic_set_drop_constraints_involving(bset_i,
nparam, n);
bset_i = isl_basic_set_drop(bset_i, isl_dim_set,
n + f->len[i], nvar - n - f->len[i]);
bset_i = isl_basic_set_drop(bset_i, isl_dim_set, 0, n);
data.pwqp = isl_pw_qpolynomial_alloc(set, qp);

pwqp_i = fn(bset_i);
pwqp = isl_pw_qpolynomial_mul(pwqp, pwqp_i);

n += f->len[i];
}
every = isl_factorizer_every_factor_basic_set(f,
&multiplicative_call_factor_pw_qpolynomial, &data);
if (every < 0)
data.pwqp = isl_pw_qpolynomial_free(data.pwqp);

isl_basic_set_free(bset);
isl_factorizer_free(f);

return pwqp;
return data.pwqp;
error:
isl_basic_set_free(bset);
return NULL;
Expand Down Expand Up @@ -5153,7 +5143,7 @@ __isl_give isl_basic_map *isl_basic_map_from_qpolynomial(
__isl_take isl_qpolynomial *qp)
{
int i, k;
isl_space *dim;
isl_space *space;
isl_vec *aff = NULL;
isl_basic_map *bmap = NULL;
isl_bool is_affine;
Expand All @@ -5171,10 +5161,10 @@ __isl_give isl_basic_map *isl_basic_map_from_qpolynomial(
aff = isl_qpolynomial_extract_affine(qp);
if (!aff)
goto error;
dim = isl_qpolynomial_get_space(qp);
pos = 1 + isl_space_offset(dim, isl_dim_out);
space = isl_qpolynomial_get_space(qp);
pos = 1 + isl_space_offset(space, isl_dim_out);
n_div = qp->div->n_row;
bmap = isl_basic_map_alloc_space(dim, n_div, 1, 2 * n_div);
bmap = isl_basic_map_alloc_space(space, n_div, 1, 2 * n_div);

for (i = 0; i < n_div; ++i) {
k = isl_basic_map_alloc_div(bmap);
Expand Down
16 changes: 9 additions & 7 deletions polly/lib/External/isl/isl_polynomial_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ __isl_give isl_qpolynomial *isl_qpolynomial_alloc(__isl_take isl_space *space,
__isl_give isl_qpolynomial *isl_qpolynomial_cow(__isl_take isl_qpolynomial *qp);
__isl_give isl_qpolynomial *isl_qpolynomial_dup(__isl_keep isl_qpolynomial *qp);

__isl_give isl_qpolynomial *isl_qpolynomial_cst_on_domain(__isl_take isl_space *dim,
__isl_give isl_qpolynomial *isl_qpolynomial_cst_on_domain(
__isl_take isl_space *domain,
isl_int v);
__isl_give isl_qpolynomial *isl_qpolynomial_rat_cst_on_domain(
__isl_take isl_space *space, const isl_int n, const isl_int d);
__isl_give isl_qpolynomial *isl_qpolynomial_var_pow_on_domain(__isl_take isl_space *dim,
__isl_take isl_space *domain, const isl_int n, const isl_int d);
__isl_give isl_qpolynomial *isl_qpolynomial_var_pow_on_domain(
__isl_take isl_space *domain,
int pos, int power);
isl_bool isl_qpolynomial_is_one(__isl_keep isl_qpolynomial *qp);
isl_bool isl_qpolynomial_is_affine(__isl_keep isl_qpolynomial *qp);
Expand Down Expand Up @@ -234,7 +236,7 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_morph_domain(
__isl_give isl_qpolynomial *isl_qpolynomial_lift(__isl_take isl_qpolynomial *qp,
__isl_take isl_space *space);
__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_lift(
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *dim);
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space);

__isl_give isl_qpolynomial *isl_qpolynomial_substitute_equalities(
__isl_take isl_qpolynomial *qp, __isl_take isl_basic_set *eq);
Expand All @@ -255,17 +257,17 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_realign_domain(
__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_reset_space(
__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_space *space);
__isl_give isl_qpolynomial *isl_qpolynomial_reset_domain_space(
__isl_take isl_qpolynomial *qp, __isl_take isl_space *dim);
__isl_take isl_qpolynomial *qp, __isl_take isl_space *space);
__isl_give isl_qpolynomial *isl_qpolynomial_reset_space_and_domain(
__isl_take isl_qpolynomial *qp, __isl_take isl_space *space,
__isl_take isl_space *domain);
__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_domain_space(
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *dim);
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space);
__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_reset_space_and_domain(
__isl_take isl_qpolynomial_fold *fold, __isl_take isl_space *space,
__isl_take isl_space *domain);
__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_reset_domain_space(
__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_space *dim);
__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_space *space);

__isl_give isl_val *isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp);
__isl_give isl_qpolynomial *isl_qpolynomial_add_isl_int(
Expand Down
12 changes: 12 additions & 0 deletions polly/lib/External/isl/isl_pw_insert_dims_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ __isl_give PW *FN(PW,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
FN(PW,free)(pw);
return NULL;
}

__isl_give PW *FN(PW,add_dims)(__isl_take PW *pw, enum isl_dim_type type,
unsigned n)
{
isl_size pos;

pos = FN(PW,dim)(pw, type);
if (pos < 0)
return FN(PW,free)(pw);

return FN(PW,insert_dims)(pw, type, pos, n);
}
14 changes: 14 additions & 0 deletions polly/lib/External/isl/isl_pw_insert_domain_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2019 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#include <isl_pw_macro.h>

#undef TYPE
#define TYPE PW
#include <isl_insert_domain_templ.c>
16 changes: 1 addition & 15 deletions polly/lib/External/isl/isl_pw_lift_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@

#include <isl_pw_macro.h>

static isl_bool any_divs(__isl_keep isl_set *set)
{
int i;

if (!set)
return isl_bool_error;

for (i = 0; i < set->n; ++i)
if (set->p[i]->n_div > 0)
return isl_bool_true;

return isl_bool_false;
}

static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
__isl_take EL *el,
isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
Expand Down Expand Up @@ -72,7 +58,7 @@ isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,
isl_set *set;
EL *el;

any = any_divs(pw->p[i].set);
any = isl_set_involves_locals(pw->p[i].set);
if (any < 0)
return isl_stat_error;
set = isl_set_copy(pw->p[i].set);
Expand Down
35 changes: 35 additions & 0 deletions polly/lib/External/isl/isl_pw_locals_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2020 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#include <isl_pw_macro.h>

/* isl_pw_*_every_piece callback that checks whether "set" and "el"
* are free of local variables.
*/
static isl_bool FN(PW,piece_no_local)(__isl_keep isl_set *set,
__isl_keep EL *el, void *user)
{
isl_bool involves;

involves = isl_set_involves_locals(set);
if (involves >= 0 && !involves)
involves = FN(EL,involves_locals)(el);

return isl_bool_not(involves);
}

/* Does "pw" involve any local variables, i.e., integer divisions?
*/
isl_bool FN(PW,involves_locals)(__isl_keep PW *pw)
{
isl_bool no_locals;

no_locals = FN(PW,every_piece)(pw, &FN(PW,piece_no_local), NULL);
return isl_bool_not(no_locals);
}
72 changes: 59 additions & 13 deletions polly/lib/External/isl/isl_pw_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ __isl_give PW *FN(PW,ZERO)(__isl_take isl_space *space OPT_TYPE_PARAM)
return FN(PW,alloc_size)(space OPT_TYPE_ARG(NO_LOC), 0);
}

__isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
/* Add a piece with domain "set" and base expression "el"
* to the piecewise expression "pw".
*
* Do this independently of the values of "set" and "el",
* such that this function can be used by isl_pw_*_dup.
*/
__isl_give PW *FN(PW,add_dup_piece)(__isl_take PW *pw,
__isl_take isl_set *set, __isl_take EL *el)
{
isl_ctx *ctx;
Expand All @@ -60,12 +66,6 @@ __isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
if (!pw || !set || !el)
goto error;

if (isl_set_plain_is_empty(set) || FN(EL,EL_IS_ZERO)(el)) {
isl_set_free(set);
FN(EL,free)(el);
return pw;
}

ctx = isl_set_get_ctx(set);
if (!OPT_EQUAL_TYPES(pw->, el->))
isl_die(ctx, isl_error_invalid, "fold types don't match",
Expand All @@ -88,6 +88,29 @@ __isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
return NULL;
}

/* Add a piece with domain "set" and base expression "el"
* to the piecewise expression "pw", provided the domain
* is not obviously empty and the base expression
* is not equal to the default value.
*/
__isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
__isl_take isl_set *set, __isl_take EL *el)
{
isl_bool skip;

skip = isl_set_plain_is_empty(set);
if (skip >= 0 && !skip)
skip = FN(EL,EL_IS_ZERO)(el);
if (skip >= 0 && !skip)
return FN(PW,add_dup_piece)(pw, set, el);

isl_set_free(set);
FN(EL,free)(el);
if (skip < 0)
return FN(PW,free)(pw);
return pw;
}

/* Does the space of "set" correspond to that of the domain of "el".
*/
static isl_bool FN(PW,compatible_domain)(__isl_keep EL *el,
Expand Down Expand Up @@ -154,7 +177,7 @@ __isl_give PW *FN(PW,dup)(__isl_keep PW *pw)
return NULL;

for (i = 0; i < pw->n; ++i)
dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
dup = FN(PW,add_dup_piece)(dup, isl_set_copy(pw->p[i].set),
FN(EL,copy)(pw->p[i].FIELD));

return dup;
Expand Down Expand Up @@ -1573,12 +1596,13 @@ __isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
return FN(PW,reset_space_and_domain)(pw, space, domain);
}

__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw,
__isl_take isl_space *space)
{
isl_space *domain;

domain = isl_space_domain(isl_space_copy(dim));
return FN(PW,reset_space_and_domain)(pw, dim, domain);
domain = isl_space_domain(isl_space_copy(space));
return FN(PW,reset_space_and_domain)(pw, space, domain);
}

__isl_give PW *FN(PW,set_tuple_id)(__isl_take PW *pw, enum isl_dim_type type,
Expand Down Expand Up @@ -1668,6 +1692,28 @@ isl_stat FN(PW,foreach_piece)(__isl_keep PW *pw,
return isl_stat_ok;
}

/* Does "test" succeed on every cell of "pw"?
*/
isl_bool FN(PW,every_piece)(__isl_keep PW *pw,
isl_bool (*test)(__isl_keep isl_set *set,
__isl_keep EL *el, void *user), void *user)
{
int i;

if (!pw)
return isl_bool_error;

for (i = 0; i < pw->n; ++i) {
isl_bool r;

r = test(pw->p[i].set, pw->p[i].FIELD, user);
if (r < 0 || !r)
return r;
}

return isl_bool_true;
}

/* Is "pw" defined over a single universe domain?
*
* If the default value of this piecewise type is zero,
Expand Down Expand Up @@ -1791,8 +1837,8 @@ __isl_give PW *FN(PW,mul_isl_int)(__isl_take PW *pw, isl_int v)
return pw;
if (pw && DEFAULT_IS_ZERO && isl_int_is_zero(v)) {
PW *zero;
isl_space *dim = FN(PW,get_space)(pw);
zero = FN(PW,ZERO)(dim OPT_TYPE_ARG(pw->));
isl_space *space = FN(PW,get_space)(pw);
zero = FN(PW,ZERO)(space OPT_TYPE_ARG(pw->));
FN(PW,free)(pw);
return zero;
}
Expand Down
104 changes: 59 additions & 45 deletions polly/lib/External/isl/isl_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static int greedy_search(isl_ctx *ctx, struct isl_tab *tab,
* reduction computation to return early. That is, as soon as it
* finds a reasonable first direction.
*/
struct isl_vec *isl_tab_sample(struct isl_tab *tab)
__isl_give isl_vec *isl_tab_sample(struct isl_tab *tab)
{
unsigned dim;
unsigned gbr;
Expand Down Expand Up @@ -531,72 +531,86 @@ struct isl_vec *isl_tab_sample(struct isl_tab *tab)

static __isl_give isl_vec *sample_bounded(__isl_take isl_basic_set *bset);

/* Internal data for factored_sample.
* "sample" collects the sample and may get reset to a zero-length vector
* signaling the absence of a sample vector.
* "pos" is the position of the contribution of the next factor.
*/
struct isl_factored_sample_data {
isl_vec *sample;
int pos;
};

/* isl_factorizer_every_factor_basic_set callback that extends
* the sample in data->sample with the contribution
* of the factor "bset".
* If "bset" turns out to be empty, then the product is empty too and
* no further factors need to be considered.
*/
static isl_bool factor_sample(__isl_keep isl_basic_set *bset, void *user)
{
struct isl_factored_sample_data *data = user;
isl_vec *sample;
isl_size n;

n = isl_basic_set_dim(bset, isl_dim_set);
if (n < 0)
return isl_bool_error;

sample = sample_bounded(isl_basic_set_copy(bset));
if (!sample)
return isl_bool_error;
if (sample->size == 0) {
isl_vec_free(data->sample);
data->sample = sample;
return isl_bool_false;
}
isl_seq_cpy(data->sample->el + data->pos, sample->el + 1, n);
isl_vec_free(sample);
data->pos += n;

return isl_bool_true;
}

/* Compute a sample point of the given basic set, based on the given,
* non-trivial factorization.
*/
static __isl_give isl_vec *factored_sample(__isl_take isl_basic_set *bset,
__isl_take isl_factorizer *f)
{
int i, n;
isl_vec *sample = NULL;
struct isl_factored_sample_data data = { NULL };
isl_ctx *ctx;
isl_size nparam;
isl_size nvar;
isl_size total;
isl_bool every;

ctx = isl_basic_set_get_ctx(bset);
nparam = isl_basic_set_dim(bset, isl_dim_param);
nvar = isl_basic_set_dim(bset, isl_dim_set);
total = isl_basic_set_dim(bset, isl_dim_all);
if (!ctx || nparam < 0 || nvar < 0 || total < 0)
if (!ctx || total < 0)
goto error;

sample = isl_vec_alloc(ctx, 1 + total);
if (!sample)
data.sample = isl_vec_alloc(ctx, 1 + total);
if (!data.sample)
goto error;
isl_int_set_si(sample->el[0], 1);

bset = isl_morph_basic_set(isl_morph_copy(f->morph), bset);

for (i = 0, n = 0; i < f->n_group; ++i) {
isl_basic_set *bset_i;
isl_vec *sample_i;
isl_int_set_si(data.sample->el[0], 1);
data.pos = 1;

bset_i = isl_basic_set_copy(bset);
bset_i = isl_basic_set_drop_constraints_involving(bset_i,
nparam + n + f->len[i], nvar - n - f->len[i]);
bset_i = isl_basic_set_drop_constraints_involving(bset_i,
nparam, n);
bset_i = isl_basic_set_drop(bset_i, isl_dim_set,
n + f->len[i], nvar - n - f->len[i]);
bset_i = isl_basic_set_drop(bset_i, isl_dim_set, 0, n);

sample_i = sample_bounded(bset_i);
if (!sample_i)
goto error;
if (sample_i->size == 0) {
isl_basic_set_free(bset);
isl_factorizer_free(f);
isl_vec_free(sample);
return sample_i;
}
isl_seq_cpy(sample->el + 1 + nparam + n,
sample_i->el + 1, f->len[i]);
isl_vec_free(sample_i);
every = isl_factorizer_every_factor_basic_set(f, &factor_sample, &data);
if (every < 0) {
data.sample = isl_vec_free(data.sample);
} else if (every) {
isl_morph *morph;

n += f->len[i];
morph = isl_morph_inverse(isl_morph_copy(f->morph));
data.sample = isl_morph_vec(morph, data.sample);
}

f->morph = isl_morph_inverse(f->morph);
sample = isl_morph_vec(isl_morph_copy(f->morph), sample);

isl_basic_set_free(bset);
isl_factorizer_free(f);
return sample;
return data.sample;
error:
isl_basic_set_free(bset);
isl_factorizer_free(f);
isl_vec_free(sample);
isl_vec_free(data.sample);
return NULL;
}

Expand Down Expand Up @@ -976,7 +990,7 @@ __isl_give isl_vec *isl_basic_set_sample_with_cone(
return NULL;
}

static void vec_sum_of_neg(struct isl_vec *v, isl_int *s)
static void vec_sum_of_neg(__isl_keep isl_vec *v, isl_int *s)
{
int i;

Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __isl_give isl_basic_set *isl_basic_set_from_vec(__isl_take isl_vec *vec);

int isl_tab_set_initial_basis_with_cone(struct isl_tab *tab,
struct isl_tab *tab_cone);
struct isl_vec *isl_tab_sample(struct isl_tab *tab);
__isl_give isl_vec *isl_tab_sample(struct isl_tab *tab);

#if defined(__cplusplus)
}
Expand Down
36 changes: 22 additions & 14 deletions polly/lib/External/isl/isl_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,10 +2080,12 @@ static __isl_give isl_basic_set *add_constraints_dim_map(
__isl_take isl_basic_set *dst, __isl_take isl_basic_set *src,
__isl_take isl_dim_map *dim_map)
{
int n_eq, n_ineq;
isl_size n_eq, n_ineq;

n_eq = isl_basic_set_n_equality(src);
n_ineq = isl_basic_set_n_inequality(src);
if (n_eq < 0 || n_ineq < 0)
dst = isl_basic_set_free(dst);
dst = isl_basic_set_extend_constraints(dst, n_eq, n_ineq);
dst = isl_basic_set_add_constraints_dim_map(dst, src, dim_map);
return dst;
Expand Down Expand Up @@ -2561,13 +2563,18 @@ static int parametric_intra_edge_multiplicity(struct isl_sched_edge *edge,
static isl_stat update_count(__isl_take isl_basic_set *bset,
int f, int *n_eq, int *n_ineq)
{
if (!bset)
return isl_stat_error;
isl_size eq, ineq;

*n_eq += isl_basic_set_n_equality(bset);
*n_ineq += isl_basic_set_n_inequality(bset);
eq = isl_basic_set_n_equality(bset);
ineq = isl_basic_set_n_inequality(bset);
isl_basic_set_free(bset);

if (eq < 0 || ineq < 0)
return isl_stat_error;

*n_eq += eq;
*n_ineq += ineq;

return isl_stat_ok;
}

Expand Down Expand Up @@ -4404,7 +4411,7 @@ static isl_stat setup_carry_lp(isl_ctx *ctx, struct isl_sched_graph *graph,
{
int i;
int k;
isl_space *dim;
isl_space *space;
unsigned total;
int n_eq, n_ineq;

Expand All @@ -4418,11 +4425,11 @@ static isl_stat setup_carry_lp(isl_ctx *ctx, struct isl_sched_graph *graph,
if (count_all_constraints(intra, inter, &n_eq, &n_ineq) < 0)
return isl_stat_error;

dim = isl_space_set_alloc(ctx, 0, total);
space = isl_space_set_alloc(ctx, 0, total);
isl_basic_set_free(graph->lp);
n_eq += 3;
n_ineq += n_edge;
graph->lp = isl_basic_set_alloc_space(dim, 0, n_eq, n_ineq);
graph->lp = isl_basic_set_alloc_space(space, 0, n_eq, n_ineq);
graph->lp = isl_basic_set_set_rational(graph->lp);

k = isl_basic_set_alloc_equality(graph->lp);
Expand Down Expand Up @@ -5007,13 +5014,13 @@ static isl_stat add_lineality(__isl_take isl_set *set, void *user)
struct isl_exploit_lineality_data *data = user;
isl_basic_set *hull;
isl_size dim;
int n_eq;
isl_size n_eq;

set = isl_set_remove_divs(set);
hull = isl_set_unshifted_simple_hull(set);
dim = isl_basic_set_dim(hull, isl_dim_set);
n_eq = isl_basic_set_n_equality(hull);
if (dim < 0)
if (dim < 0 || n_eq < 0)
goto error;
if (dim != n_eq)
return add_non_trivial_lineality(hull, data);
Expand Down Expand Up @@ -7318,7 +7325,7 @@ static isl_stat compute_weights(struct isl_sched_graph *graph,
struct isl_sched_node *dst = edge->dst;
isl_basic_map *hull;
isl_bool prox;
isl_size n_in, n_out;
isl_size n_in, n_out, n;

prox = is_non_empty_proximity(edge);
if (prox < 0)
Expand Down Expand Up @@ -7350,10 +7357,11 @@ static isl_stat compute_weights(struct isl_sched_graph *graph,
isl_dim_in, 0, n_in);
hull = isl_basic_map_drop_constraints_not_involving_dims(hull,
isl_dim_out, 0, n_out);
if (!hull)
return isl_stat_error;
edge->weight = isl_basic_map_n_equality(hull);
n = isl_basic_map_n_equality(hull);
isl_basic_map_free(hull);
if (n < 0)
return isl_stat_error;
edge->weight = n;

if (edge->weight > graph->max_weight)
graph->max_weight = edge->weight;
Expand Down
44 changes: 22 additions & 22 deletions polly/lib/External/isl/isl_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ isl_size isl_space_wrapped_dim(__isl_keep isl_space *space,
return isl_space_dim(isl_space_peek_nested(space, pos), inner);
}

unsigned isl_space_offset(__isl_keep isl_space *dim, enum isl_dim_type type)
unsigned isl_space_offset(__isl_keep isl_space *space, enum isl_dim_type type)
{
if (!dim)
if (!space)
return 0;
return offset(dim, type);
return offset(space, type);
}

static __isl_give isl_space *copy_ids(__isl_take isl_space *dst,
Expand Down Expand Up @@ -890,27 +890,27 @@ __isl_give isl_space *isl_space_reset_user(__isl_take isl_space *space)
return space;
}

static __isl_keep isl_id *tuple_id(__isl_keep isl_space *dim,
static __isl_keep isl_id *tuple_id(__isl_keep isl_space *space,
enum isl_dim_type type)
{
if (!dim)
if (!space)
return NULL;
if (type == isl_dim_in)
return dim->tuple_id[0];
return space->tuple_id[0];
if (type == isl_dim_out)
return dim->tuple_id[1];
return space->tuple_id[1];
return NULL;
}

static __isl_keep isl_space *nested(__isl_keep isl_space *dim,
static __isl_keep isl_space *nested(__isl_keep isl_space *space,
enum isl_dim_type type)
{
if (!dim)
if (!space)
return NULL;
if (type == isl_dim_in)
return dim->nested[0];
return space->nested[0];
if (type == isl_dim_out)
return dim->nested[1];
return space->nested[1];
return NULL;
}

Expand Down Expand Up @@ -1043,13 +1043,13 @@ isl_bool isl_space_match(__isl_keep isl_space *space1, enum isl_dim_type type1,
return match(space1, type1, space2, type2);
}

static void get_ids(__isl_keep isl_space *dim, enum isl_dim_type type,
static void get_ids(__isl_keep isl_space *space, enum isl_dim_type type,
unsigned first, unsigned n, __isl_keep isl_id **ids)
{
int i;

for (i = 0; i < n ; ++i)
ids[i] = get_id(dim, type, first + i);
ids[i] = get_id(space, type, first + i);
}

static __isl_give isl_space *space_extend(__isl_take isl_space *space,
Expand Down Expand Up @@ -1803,16 +1803,16 @@ __isl_give isl_space *isl_space_map_from_domain_and_range(
return NULL;
}

static __isl_give isl_space *set_ids(__isl_take isl_space *dim,
static __isl_give isl_space *set_ids(__isl_take isl_space *space,
enum isl_dim_type type,
unsigned first, unsigned n, __isl_take isl_id **ids)
{
int i;

for (i = 0; i < n ; ++i)
dim = set_id(dim, type, first + i, ids[i]);
space = set_id(space, type, first + i, ids[i]);

return dim;
return space;
}

__isl_give isl_space *isl_space_reverse(__isl_take isl_space *space)
Expand Down Expand Up @@ -1961,20 +1961,20 @@ __isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *space,
return NULL;
}

__isl_give isl_space *isl_space_drop_inputs(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_drop_inputs(__isl_take isl_space *space,
unsigned first, unsigned n)
{
if (!dim)
if (!space)
return NULL;
return isl_space_drop_dims(dim, isl_dim_in, first, n);
return isl_space_drop_dims(space, isl_dim_in, first, n);
}

__isl_give isl_space *isl_space_drop_outputs(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_drop_outputs(__isl_take isl_space *space,
unsigned first, unsigned n)
{
if (!dim)
if (!space)
return NULL;
return isl_space_drop_dims(dim, isl_dim_out, first, n);
return isl_space_drop_dims(space, isl_dim_out, first, n);
}

/* Remove all parameters from "space".
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_space_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ isl_stat isl_space_check_domain_wrapped_domain_tuples(

isl_size isl_space_wrapped_dim(__isl_keep isl_space *space,
enum isl_dim_type outer, enum isl_dim_type inner);
unsigned isl_space_offset(__isl_keep isl_space *dim, enum isl_dim_type type);
unsigned isl_space_offset(__isl_keep isl_space *space, enum isl_dim_type type);

isl_stat isl_space_check_range(__isl_keep isl_space *space,
enum isl_dim_type type, unsigned first, unsigned n);
Expand Down
16 changes: 8 additions & 8 deletions polly/lib/External/isl/isl_tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ struct isl_tab *isl_tab_dup(struct isl_tab *tab)
dup->need_undo = 0;
dup->in_undo = 0;
dup->M = tab->M;
tab->cone = tab->cone;
dup->cone = tab->cone;
dup->bottom.type = isl_tab_undo_bottom;
dup->bottom.next = NULL;
dup->top = &dup->bottom;
Expand Down Expand Up @@ -320,8 +320,8 @@ struct isl_tab *isl_tab_dup(struct isl_tab *tab)
* The order of the rows and columns in the result is as explained
* in isl_tab_product.
*/
static struct isl_mat *tab_mat_product(struct isl_mat *mat1,
struct isl_mat *mat2, unsigned row1, unsigned row2,
static __isl_give isl_mat *tab_mat_product(__isl_keep isl_mat *mat1,
__isl_keep isl_mat *mat2, unsigned row1, unsigned row2,
unsigned col1, unsigned col2,
unsigned off, unsigned r1, unsigned r2, unsigned d1, unsigned d2)
{
Expand Down Expand Up @@ -2573,7 +2573,7 @@ static struct isl_vec *extract_integer_sample(struct isl_tab *tab)
return vec;
}

struct isl_vec *isl_tab_get_sample_value(struct isl_tab *tab)
__isl_give isl_vec *isl_tab_get_sample_value(struct isl_tab *tab)
{
int i;
struct isl_vec *vec;
Expand Down Expand Up @@ -2632,8 +2632,8 @@ static void get_rounded_sample_value(struct isl_tab *tab,
* The tableau is assumed to have been created from "bmap" using
* isl_tab_from_basic_map.
*/
struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
struct isl_tab *tab)
__isl_give isl_basic_map *isl_basic_map_update_from_tab(
__isl_take isl_basic_map *bmap, struct isl_tab *tab)
{
int i;
unsigned n_eq;
Expand Down Expand Up @@ -2661,8 +2661,8 @@ struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
return bmap;
}

struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
struct isl_tab *tab)
__isl_give isl_basic_set *isl_basic_set_update_from_tab(
__isl_take isl_basic_set *bset, struct isl_tab *tab)
{
return bset_from_bmap(isl_basic_map_update_from_tab(bset_to_bmap(bset),
tab));
Expand Down
Loading