582 changes: 394 additions & 188 deletions polly/lib/External/isl/interface/config.guess
100644 → 100755

Large diffs are not rendered by default.

2,572 changes: 1,312 additions & 1,260 deletions polly/lib/External/isl/interface/config.sub
100644 → 100755

Large diffs are not rendered by default.

1,549 changes: 1,268 additions & 281 deletions polly/lib/External/isl/interface/configure
100644 → 100755

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions polly/lib/External/isl/interface/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ CXXCPP="$CXXCPP_FOR_BUILD"
EXEEXT="$BUILD_EXEEXT"
OBJEXT="$BUILD_OBJEXT"

AX_CXX_COMPILE_STDCXX_11_NO_OVERRIDE

AC_DISABLE_SHARED
AC_PROG_LIBTOOL

Expand Down
2,804 changes: 708 additions & 2,096 deletions polly/lib/External/isl/interface/cpp.cc

Large diffs are not rendered by default.

320 changes: 167 additions & 153 deletions polly/lib/External/isl/interface/cpp.h
Original file line number Diff line number Diff line change
@@ -1,169 +1,183 @@
#ifndef ISL_INTERFACE_CPP_H
#define ISL_INTERFACE_CPP_H

#include <iostream>
#include <string>
#include <vector>

#include "generator.h"

using namespace std;
using namespace clang;
/* A generated C++ method derived from an isl function.
*
* "clazz" is the class to which the method belongs.
* "fd" is the original isl function.
* "name" is the name of the method, which may be different
* from the default name derived from "fd".
* "kind" is the type of the method.
* "callback" stores the callback argument, if any, or NULL.
*/
struct Method {
enum Kind {
static_method,
member_method,
constructor,
};

/* Generator for C++ bindings.
Method(const isl_class &clazz, FunctionDecl *fd,
const std::string &name);
Method(const isl_class &clazz, FunctionDecl *fd);

int c_num_params() const;
virtual int num_params() const;
virtual bool param_needs_copy(int pos) const;
virtual clang::ParmVarDecl *get_param(int pos) const;
virtual void print_param_use(ostream &os, int pos) const;
bool is_subclass_mutator() const;
static void print_arg_list(std::ostream &os, int start, int end,
const std::function<void(int i)> &print_arg);
void print_cpp_arg_list(std::ostream &os,
const std::function<void(int i)> &print_arg) const;

const isl_class &clazz;
FunctionDecl *const fd;
const std::string name;
const enum Kind kind;
ParmVarDecl *const callback;
};

/* A method that does not require its isl type parameters to be a copy.
*/
struct NoCopyMethod : Method {
NoCopyMethod(const Method &method) : Method(method) {}

virtual bool param_needs_copy(int pos) const override;
};

/* A generated method that performs one or more argument conversions and
* then calls the original method.
*
* A ConversionMethod inherits from a NoCopyMethod, because
* unlike methods that call an isl C function,
* a conversion method never calls release() on an isl type argument,
* so they can all be passed as const references.
*
* "this_type" is the name of the type to which "this" should be converted
* (if different from clazz.name).
* "get_param_fn" returns the method argument at position "pos".
*/
struct ConversionMethod : NoCopyMethod {
ConversionMethod(const Method &method, const std::string &this_type,
const std::function<clang::ParmVarDecl *(int pos)> &get_param);
ConversionMethod(const Method &method, const std::string &this_type);
ConversionMethod(const Method &method,
const std::function<clang::ParmVarDecl *(int pos)> &get_param);
virtual clang::ParmVarDecl *get_param(int pos) const override;

void print_call(std::ostream &os, const std::string &ns) const;

const std::string this_type;
const std::function<clang::ParmVarDecl *(int pos)> get_param_fn;
};

/* A specialized generated C++ method for setting an enum.
*
* "checked" is set if C++ bindings should be generated
* that rely on the user to check for error conditions.
* "enum_name" is a string representation of the enum value
* set by this method.
*/
struct EnumMethod : public Method {
EnumMethod(const isl_class &clazz, FunctionDecl *fd,
const std::string &method_name, const std::string &enum_name);

virtual int num_params() const override;
virtual void print_param_use(ostream &os, int pos) const override;

std::string enum_name;
};

/* A type printer for converting argument and return types,
* as well as the class type,
* to string representations of the corresponding types
* in the C++ interface.
*/
struct cpp_type_printer {
cpp_type_printer() {}

virtual std::string isl_bool() const;
virtual std::string isl_stat() const;
virtual std::string isl_size() const;
virtual std::string isl_namespace() const;
virtual std::string class_type(const std::string &cpp_name) const;
virtual std::string qualified(int arg, const std::string &cpp_type)
const;
std::string isl_type(int arg, QualType type) const;
std::string generate_callback_args(int arg, QualType type, bool cpp)
const;
std::string generate_callback_type(int arg, QualType type) const;
std::string param(int arg, QualType type) const;
std::string return_type(const Method &method) const;
};

/* Generator for C++ bindings.
*/
class cpp_generator : public generator {
protected:
bool checked;
struct class_printer;
public:
cpp_generator(SourceManager &SM, set<RecordDecl *> &exported_types,
set<FunctionDecl *> exported_functions,
set<FunctionDecl *> functions,
bool checked = false) :
generator(SM, exported_types, exported_functions, functions),
checked(checked) {}

enum function_kind {
function_kind_static_method,
function_kind_member_method,
function_kind_constructor,
};
enum method_part {
decl,
impl,
};

virtual void generate();
set<FunctionDecl *> functions);
private:
void print_forward_declarations(ostream &os);
void print_declarations(ostream &os);
void print_class(ostream &os, const isl_class &clazz);
void print_subclass_type(ostream &os, const isl_class &clazz);
void print_class_forward_decl(ostream &os, const isl_class &clazz);
void print_class_factory_decl(ostream &os, const isl_class &clazz,
const std::string &prefix = std::string());
void print_protected_constructors_decl(ostream &os,
const isl_class &clazz);
void print_copy_assignment_decl(ostream &os, const isl_class &clazz);
void print_public_constructors_decl(ostream &os,
const isl_class &clazz);
void print_constructors_decl(ostream &os, const isl_class &clazz);
void print_destructor_decl(ostream &os, const isl_class &clazz);
void print_ptr_decl(ostream &os, const isl_class &clazz);
void print_isa_type_template(ostream &os, int indent,
const isl_class &super);
void print_downcast_decl(ostream &os, const isl_class &clazz);
void print_ctx_decl(ostream &os);
void print_persistent_callback_prototype(ostream &os,
const isl_class &clazz, FunctionDecl *method,
bool is_declaration);
void print_persistent_callback_setter_prototype(ostream &os,
const isl_class &clazz, FunctionDecl *method,
bool is_declaration);
void print_persistent_callback_data(ostream &os, const isl_class &clazz,
FunctionDecl *method);
void print_persistent_callbacks_decl(ostream &os,
const isl_class &clazz);
void print_methods_decl(ostream &os, const isl_class &clazz);
bool next_variant(FunctionDecl *fd, std::vector<bool> &convert);
template <enum method_part>
void print_method_variants(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_method_group_decl(ostream &os, const isl_class &clazz,
const function_set &methods);
void print_named_method_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &name, function_kind kind,
const std::vector<bool> &convert = {});
template <enum method_part>
void print_method(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
template <enum method_part>
void print_method(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind,
const std::vector<bool> &convert);
void print_set_enum_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &name);
void print_set_enums_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_set_enums_decl(ostream &os, const isl_class &clazz);
void print_implementations(ostream &os);
void print_class_impl(ostream &os, const isl_class &clazz);
void print_check_ptr(ostream &os, const char *ptr);
void print_check_ptr_start(ostream &os, const isl_class &clazz,
const char *ptr);
void print_check_ptr_end(ostream &os, const char *ptr);
void print_class_factory_impl(ostream &os, const isl_class &clazz);
void print_protected_constructors_impl(ostream &os,
const isl_class &clazz);
void print_public_constructors_impl(ostream &os,
const isl_class &clazz);
void print_constructors_impl(ostream &os, const isl_class &clazz);
void print_copy_assignment_impl(ostream &os, const isl_class &clazz);
void print_destructor_impl(ostream &os, const isl_class &clazz);
void print_check_no_persistent_callback(ostream &os,
const isl_class &clazz, FunctionDecl *fd);
void print_ptr_impl(ostream &os, const isl_class &clazz);
void print_downcast_impl(ostream &os, const isl_class &clazz);
void print_ctx_impl(ostream &os, const isl_class &clazz);
void print_persistent_callbacks_impl(ostream &os,
const isl_class &clazz);
void print_methods_impl(ostream &os, const isl_class &clazz);
void print_method_group_impl(ostream &os, const isl_class &clazz,
const function_set &methods);
void print_argument_validity_check(ostream &os, FunctionDecl *method,
function_kind kind);
void print_save_ctx(ostream &os, FunctionDecl *method,
function_kind kind);
void print_on_error_continue(ostream &os);
void print_exceptional_execution_check(ostream &os,
const isl_class &clazz, FunctionDecl *method,
function_kind kind);
void print_set_persistent_callback(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
void print_method_return(ostream &os, const isl_class &clazz,
FunctionDecl *method);
void print_set_enum_impl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &enum_name,
const string &method_name);
void print_set_enums_impl(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_set_enums_impl(ostream &os, const isl_class &clazz);
template <enum method_part>
void print_get_method(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_invalid(ostream &os, int indent, const char *msg,
const char *checked_code);
void print_stream_insertion(ostream &os, const isl_class &clazz);
void print_method_param_use(ostream &os, ParmVarDecl *param,
bool load_from_this_ptr);
std::string get_return_type(const isl_class &clazz, FunctionDecl *fd);
ParmVarDecl *get_param(FunctionDecl *fd, int pos,
const std::vector<bool> &convert);
void print_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, const string &cname, int num_params,
bool is_declaration, function_kind kind,
const std::vector<bool> &convert = {});
void print_named_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, string name, bool is_declaration,
function_kind kind, const std::vector<bool> &convert = {});
void print_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, bool is_declaration, function_kind kind);
string generate_callback_args(QualType type, bool cpp);
string generate_callback_type(QualType type);
void print_wrapped_call_checked(std::ostream &os, int indent,
const std::string &call);
void print_wrapped_call(std::ostream &os, int indent,
const std::string &call, QualType rtype);
void print_callback_data_decl(ostream &os, ParmVarDecl *param,
const string &name);
void print_callback_body(ostream &os, int indent, ParmVarDecl *param,
const string &name);
void print_callback_local(ostream &os, ParmVarDecl *param);
std::string rename_method(std::string name);
string isl_bool2cpp();
string isl_namespace();
string type2cpp(QualType type);
bool is_implicit_conversion(const isl_class &clazz, FunctionDecl *cons);
void set_class_construction_types(isl_class &clazz);
void set_construction_types();
void copy_methods(isl_class &clazz, const std::string &name,
const isl_class &super, const function_set &methods);
void copy_super_methods(isl_class &clazz, const isl_class &super);
void copy_super_methods(isl_class &clazz, set<string> &done);
void copy_super_methods();
bool is_implicit_conversion(const Method &cons);
bool is_subclass(QualType subclass_type, const isl_class &class_type);
function_kind get_method_kind(const isl_class &clazz,
FunctionDecl *method);
public:
static string type2cpp(const isl_class &clazz);
static string type2cpp(string type_string);
};

/* A helper class for printing method declarations and definitions
* of a class.
*
* "os" is the stream onto which the methods are printed.
* "clazz" describes the methods of the class.
* "cppstring" is the C++ name of the class.
* "generator" is the C++ interface generator printing the classes.
* "declarations" is set if this object is used to print declarations.
*/
struct cpp_generator::class_printer {
std::ostream &os;
const isl_class &clazz;
const std::string cppstring;
cpp_generator &generator;
const bool declarations;

class_printer(std::ostream &os, const isl_class &clazz,
cpp_generator &generator, bool declarations);

void print_constructors();
void print_methods();
bool next_variant(FunctionDecl *fd, std::vector<bool> &convert);
void print_method_variants(FunctionDecl *fd, const std::string &name);
virtual bool want_descendent_overloads(const function_set &methods) = 0;
void print_descendent_overloads(FunctionDecl *fd,
const std::string &name);
void print_method_group(const function_set &methods,
const std::string &name);
virtual void print_method(const Method &method) = 0;
virtual void print_method(const ConversionMethod &method) = 0;
virtual void print_get_method(FunctionDecl *fd) = 0;
void print_set_enums(FunctionDecl *fd);
void print_set_enums();
ParmVarDecl *get_param(FunctionDecl *fd, int pos,
const std::vector<bool> &convert);
void print_method_header(const Method &method,
const cpp_type_printer &type_printer);
};

#endif
2 changes: 1 addition & 1 deletion polly/lib/External/isl/interface/depcomp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

scriptversion=2018-03-07.03; # UTC

# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Copyright (C) 1999-2020 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
15 changes: 11 additions & 4 deletions polly/lib/External/isl/interface/extract_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
#include "extract_interface.h"
#include "generator.h"
#include "python.h"
#include "cpp.h"
#include "plain_cpp.h"
#include "cpp_conversion.h"
#include "template_cpp.h"

using namespace std;
using namespace clang;
Expand Down Expand Up @@ -420,12 +421,15 @@ static void create_main_file_id(SourceManager &SM, const FileEntry *file)

#ifdef SETLANGDEFAULTS_TAKES_5_ARGUMENTS

#include "set_lang_defaults_arg4.h"

static void set_lang_defaults(CompilerInstance *Clang)
{
PreprocessorOptions &PO = Clang->getPreprocessorOpts();
TargetOptions &TO = Clang->getTargetOpts();
llvm::Triple T(TO.Triple);
CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, T, PO,
CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C, T,
setLangDefaultsArg4(PO),
LangStandard::lang_unspecified);
}

Expand Down Expand Up @@ -506,14 +510,17 @@ static void generate(MyASTConsumer &consumer, SourceManager &SM)
gen = new python_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else if (OutputLanguage.compare("cpp") == 0) {
gen = new cpp_generator(SM, consumer.exported_types,
gen = new plain_cpp_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else if (OutputLanguage.compare("cpp-checked") == 0) {
gen = new cpp_generator(SM, consumer.exported_types,
gen = new plain_cpp_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions, true);
} else if (OutputLanguage.compare("cpp-checked-conversion") == 0) {
gen = new cpp_conversion_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else if (OutputLanguage.compare("template-cpp") == 0) {
gen = new template_cpp_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else {
cerr << "Language '" << OutputLanguage
<< "' not recognized." << endl
Expand Down
35 changes: 24 additions & 11 deletions polly/lib/External/isl/interface/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,35 @@
const char *isl_class::get_prefix = "get_";
const char *isl_class::set_callback_prefix = "set_";

/* Should "method" be considered to be a static method?
* That is, is the first argument something other than
* an instance of the class?
/* Is the first argument an instance of the class?
*/
bool isl_class::is_static(FunctionDecl *method) const
bool isl_class::first_arg_matches_class(FunctionDecl *method) const
{
ParmVarDecl *param;
QualType type;

if (method->getNumParams() < 1)
return true;
return false;

param = method->getParamDecl(0);
type = param->getOriginalType();
if (!generator::is_isl_type(type))
return true;
return generator::extract_type(type) != name;
return false;
return generator::extract_type(type) == name;
}

/* Should "method" be considered to be a static method?
* That is, is the first argument something other than
* an instance of the class?
*
* If this method was copied from a superclass, then check
* whether the method is static with respect to this superclass.
*/
bool isl_class::is_static(FunctionDecl *method) const
{
if (copied_from.count(method) != 0)
return copied_from.at(method).is_static(method);
return !first_arg_matches_class(method);
}

/* Should "method" be considered to be a static method?
Expand Down Expand Up @@ -417,8 +429,8 @@ generator::generator(SourceManager &SM, set<RecordDecl *> &exported_types,
std::string name = method->getName().str();
die(name + " has unhandled enum argument");
} else {
string fullname = c->name_without_type_suffixes(method);
c->methods[fullname].insert(method);
string name = c->method_name(method);
c->methods[name].insert(method);
}
}

Expand Down Expand Up @@ -791,7 +803,8 @@ static std::string type_suffix(ParmVarDecl *param)
/* If "suffix" is a suffix of "s", then return "s" with the suffix removed.
* Otherwise, simply return "s".
*/
static std::string drop_suffix(const std::string &s, const std::string &suffix)
std::string generator::drop_suffix(const std::string &s,
const std::string &suffix)
{
size_t len, suffix_len;

Expand Down Expand Up @@ -828,7 +841,7 @@ string isl_class::name_without_type_suffixes(FunctionDecl *method)
param = method->getParamDecl(i);
type = type_suffix(param);

name = drop_suffix(name, type);
name = generator::drop_suffix(name, type);
}

return name;
Expand Down
20 changes: 20 additions & 0 deletions polly/lib/External/isl/interface/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ typedef std::set<FunctionDecl *, function_name_less> function_set;
* "fn_type" is a reference to a function that described subclasses, if any.
* If "fn_type" is set, then "type_subclasses" maps the values returned
* by that function to the names of the corresponding subclasses.
*
* The following fields are only used for the C++ bindings.
* For methods that are not derived from a function that applies
* directly to this class, but are rather copied from some ancestor,
* "copied_from" records the direct superclass from which the method
* was copied (where it may have been copied from a further ancestor) and
* "copy_depth" records the distance to the ancestor to which
* the function applies.
* "construction_types" contains the set of isl classes that can be
* implicitly converted to this class through a unary constructor,
* mapped to the single argument
* of this unary constructor.
*/
struct isl_class {
string name;
Expand All @@ -80,6 +92,12 @@ struct isl_class {
FunctionDecl *fn_copy;
FunctionDecl *fn_free;

std::map<clang::FunctionDecl *, const isl_class &> copied_from;
std::map<clang::FunctionDecl *, int> copy_depth;
std::map<std::string, clang::ParmVarDecl *> construction_types;

/* Is the first argument an instance of the class? */
bool first_arg_matches_class(FunctionDecl *method) const;
/* Does "method" correspond to a static method? */
bool is_static(FunctionDecl *method) const;
/* Is this class a subclass based on a type function? */
Expand Down Expand Up @@ -152,6 +170,8 @@ class generator {
void extract_class_automatic_conversions(const isl_class &clazz);
void extract_automatic_conversions();
public:
static std::string drop_suffix(const std::string &s,
const std::string &suffix);
static void die(const char *msg) __attribute__((noreturn));
static void die(string msg) __attribute__((noreturn));
static vector<string> find_superclasses(Decl *decl);
Expand Down
161 changes: 92 additions & 69 deletions polly/lib/External/isl/interface/install-sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile

scriptversion=2018-03-11.20; # UTC
scriptversion=2020-11-14.01; # UTC

# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
Expand Down Expand Up @@ -69,6 +69,11 @@ posix_mkdir=
# Desired mode of installed file.
mode=0755

# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22

backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
Expand Down Expand Up @@ -99,18 +104,28 @@ Options:
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
"

while test $# -ne 0; do
Expand All @@ -137,8 +152,13 @@ while test $# -ne 0; do
-o) chowncmd="$chownprog $2"
shift;;

-p) cpprog="$cpprog -p";;

-s) stripcmd=$stripprog;;

-S) backupsuffix="$2"
shift;;

-t)
is_target_a_directory=always
dst_arg=$2
Expand Down Expand Up @@ -255,6 +275,10 @@ do
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else

# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
Expand Down Expand Up @@ -301,22 +325,6 @@ do
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;

*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac

# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
Expand All @@ -326,52 +334,49 @@ do
fi

posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$

trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0

# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$

trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0

# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac

if
Expand All @@ -382,7 +387,7 @@ do
then :
else

# The umask is ridiculous, or mkdir does not conform to POSIX,
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.

Expand Down Expand Up @@ -411,7 +416,7 @@ do
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
Expand Down Expand Up @@ -451,7 +456,18 @@ do
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0

# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
(umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&

# and set any options; do chmod last to preserve setuid bits.
#
Expand All @@ -477,6 +493,13 @@ do
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi

# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||

Expand All @@ -491,9 +514,9 @@ do
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
Expand Down
3,581 changes: 2,524 additions & 1,057 deletions polly/lib/External/isl/interface/isl.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions polly/lib/External/isl/interface/isl_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
/* 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

Expand Down
768 changes: 443 additions & 325 deletions polly/lib/External/isl/interface/ltmain.sh

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion polly/lib/External/isl/interface/missing
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

scriptversion=2018-03-07.03; # UTC

# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.

# This program is free software; you can redistribute it and/or modify
Expand Down
1,917 changes: 1,917 additions & 0 deletions polly/lib/External/isl/interface/plain_cpp.cc

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions polly/lib/External/isl/interface/plain_cpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#ifndef ISL_INTERFACE_PLAIN_CPP_H
#define ISL_INTERFACE_PLAIN_CPP_H

#include <functional>
#include <memory>

#include "cpp.h"
#include "generator.h"

using namespace std;
using namespace clang;

/* A type printer for converting argument and return types
* to string representations of the corresponding types
* in the checked C++ interface.
*/
struct checked_cpp_type_printer : public cpp_type_printer {
virtual std::string isl_bool() const override;
virtual std::string isl_stat() const override;
virtual std::string isl_size() const override;
virtual std::string isl_namespace() const override;
};

/* Generator for plain C++ bindings.
*
* "checked" is set if C++ bindings should be generated
* that rely on the user to check for error conditions.
*/
class plain_cpp_generator : public cpp_generator {
struct plain_printer;
struct decl_printer;
struct impl_printer;
protected:
bool checked;
public:
plain_cpp_generator(SourceManager &SM,
set<RecordDecl *> &exported_types,
set<FunctionDecl *> exported_functions,
set<FunctionDecl *> functions,
bool checked = false);

virtual void generate();
private:
void print_forward_declarations(ostream &os);
void print_declarations(ostream &os);
void print_class(ostream &os, const isl_class &clazz);
void print_class_forward_decl(ostream &os, const isl_class &clazz);
void print_implementations(ostream &os);
void print_class_impl(ostream &os, const isl_class &clazz);
void print_check_no_persistent_callback(ostream &os,
const isl_class &clazz, FunctionDecl *fd);
void print_invalid(ostream &os, int indent, const char *msg,
const char *checked_code);
void print_method_param_use(ostream &os, ParmVarDecl *param,
bool load_from_this_ptr);
std::unique_ptr<cpp_type_printer> type_printer();
std::string get_return_type(const Method &method);
string generate_callback_args(QualType type, bool cpp);
string generate_callback_type(QualType type);
string isl_bool2cpp();
string isl_namespace();
string param2cpp(QualType type);
};

/* A helper class for printing method declarations and definitions
* of a class for the plain C++ interface.
*
* "generator" is the C++ interface generator printing the classes.
*/
struct plain_cpp_generator::plain_printer : public cpp_generator::class_printer {
plain_cpp_generator &generator;

plain_printer(std::ostream &os, const isl_class &clazz,
plain_cpp_generator &generator, bool is_declaration) :
class_printer(os, clazz, generator, is_declaration),
generator(generator) {}

void print_persistent_callback_prototype(FunctionDecl *method);
void print_persistent_callback_setter_prototype(FunctionDecl *method);
void print_full_method_header(const Method &method);
void print_callback_data_decl(ParmVarDecl *param, const string &name);
virtual bool want_descendent_overloads(const function_set &methods)
override;
};

/* A helper class for printing method declarations of a class.
*/
struct plain_cpp_generator::decl_printer :
public plain_cpp_generator::plain_printer
{
decl_printer(std::ostream &os, const isl_class &clazz,
plain_cpp_generator &generator) :
plain_printer(os, clazz, generator, true) {}

void print_subclass_type();
void print_class_factory(const std::string &prefix = std::string());
void print_protected_constructors();
void print_copy_assignment();
void print_public_constructors();
void print_destructor();
void print_ptr();
void print_isa_type_template(int indent, const isl_class &super);
void print_downcast();
void print_ctx();
void print_persistent_callback_data(FunctionDecl *method);
void print_persistent_callbacks();
virtual void print_method(const Method &method) override;
virtual void print_method(const ConversionMethod &method) override;
virtual void print_get_method(FunctionDecl *fd) override;
};

/* A helper class for printing method definitions of a class.
*/
struct plain_cpp_generator::impl_printer :
public plain_cpp_generator::plain_printer
{
impl_printer(std::ostream &os, const isl_class &clazz,
plain_cpp_generator &generator) :
plain_printer(os, clazz, generator, false) {}

void print_arg_conversion(ParmVarDecl *dst, ParmVarDecl *src);
virtual void print_method(const Method &method) override;
virtual void print_method(const ConversionMethod &method) override;
virtual void print_get_method(FunctionDecl *fd) override;
void print_check_ptr(const char *ptr);
void print_check_ptr_start(const char *ptr);
void print_check_ptr_end(const char *ptr);
void print_class_factory();
void print_protected_constructors();
void print_public_constructors();
void print_copy_assignment();
void print_destructor();
void print_ptr();
void print_downcast();
void print_ctx();
void print_set_persistent_callback(const Method &method);
void print_persistent_callbacks();
void print_argument_validity_check(const Method &method);
void print_save_ctx(const Method &method);
void print_on_error_continue();
void print_exceptional_execution_check(const Method &method);
void print_method_return(const Method &method);
void print_stream_insertion();
void print_wrapped_call_checked(int indent, const std::string &call);
void print_wrapped_call(int indent, const std::string &call,
QualType rtype);
void print_callback_body(int indent, ParmVarDecl *param,
const string &name);
void print_callback_local(ParmVarDecl *param);
};

#endif
10 changes: 4 additions & 6 deletions polly/lib/External/isl/interface/python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ void python_generator::print_callback(ParmVarDecl *param, int arg)
printf("cb_arg%d", i);
}
printf(")\n");
printf(" except:\n");
printf(" import sys\n");
printf(" exc_info[0] = sys.exc_info()\n");
printf(" except BaseException as e:\n");
printf(" exc_info[0] = e\n");
if (is_isl_stat(return_type) || is_isl_bool(return_type))
printf(" return -1\n");
else
Expand Down Expand Up @@ -325,9 +324,8 @@ void python_generator::print_arg_in_call(FunctionDecl *fd, const char *fmt,
*/
static void print_rethrow(int indent, const char *exc_info)
{
print_indent(indent, "if %s != None:\n", exc_info);
print_indent(indent, " raise (%s[0], %s[1], %s[2])\n",
exc_info, exc_info, exc_info);
print_indent(indent, "if %s is not None:\n", exc_info);
print_indent(indent, " raise %s\n", exc_info);
}

/* Print code with the given indentation that checks
Expand Down
16 changes: 16 additions & 0 deletions polly/lib/External/isl/interface/set_lang_defaults_arg4.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <string>
#include <vector>

#include <clang/Lex/PreprocessorOptions.h>

/* Convert a clang::PreprocessorOptions to the fourth argument
* of CompilerInvocation::setLangDefaults, which may be either
* a clang::PreprocessorOptions itself or its Includes.
*/
struct setLangDefaultsArg4 {
setLangDefaultsArg4(clang::PreprocessorOptions &PO) : PO(PO) {}
operator clang::PreprocessorOptions &() { return PO; }
operator std::vector<std::string> &() { return PO.Includes; }

clang::PreprocessorOptions &PO;
};
2,817 changes: 2,817 additions & 0 deletions polly/lib/External/isl/interface/template_cpp.cc

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions polly/lib/External/isl/interface/template_cpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#ifndef ISL_INTERFACE_TEMPLATE_CPP_H
#define ISL_INTERFACE_TEMPLATE_CPP_H

#include <initializer_list>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>

#include "cpp.h"

struct Fixed;

struct TupleKind;

/* A shared pointer to a TupleKind.
*/
struct TupleKindPtr : public std::shared_ptr<const TupleKind> {
using Base = std::shared_ptr<const TupleKind>;
TupleKindPtr() = default;
TupleKindPtr(Fixed);
TupleKindPtr(Base base) : Base(base) {}
TupleKindPtr(const std::string &name);
TupleKindPtr(const TupleKindPtr &left, const TupleKindPtr &right);
};

/* A substitution mapping leaf tuple kind names to tuple kinds.
*/
using Substitution = std::unordered_map<std::string, TupleKindPtr>;

/* A representation of a (possibly improper) tuple kind.
* That is, this also includes tuple kinds for types
* that do not have any tuples.
*
* The kind could be a name (the base case) or
* a (currently) unnamed nested pair of tuple kinds.
*/
struct TupleKind {
TupleKind(const std::string &name) : name(name) {}

virtual std::string to_string() const;
virtual std::vector<std::string> params() const;
virtual TupleKindPtr apply(const Substitution &subs,
const TupleKindPtr &self) const;
virtual TupleKindPtr left() const;
virtual TupleKindPtr right() const;

const std::string name;
};

/* A sequence of tuple kinds, representing a kind of objects.
*/
struct Kind : public std::vector<TupleKindPtr> {
Kind() {}
Kind(std::initializer_list<TupleKindPtr> list) : vector(list) {}

bool is_anon() const;
bool is_set() const;
bool is_anon_set() const;
std::vector<std::string> params() const;
Kind apply(const Substitution &subs) const;
};

/* A representation of a template class.
*
* "class_name" is the name of the template class.
* "super_name" is the (fully qualified) name of the corresponding
* plain C++ interface class, from which this template class derives.
* "clazz" describes the plain class.
*
* "class_tuples" contains the specializations.
* It is initialized with a predefined set of specializations,
* but may be extended during the generations of the specializations.
*/
struct template_class {
const std::string class_name;
const std::string super_name;
const isl_class &clazz;

std::vector<Kind> class_tuples;

bool is_anon() const;
bool is_anon_set() const;
void add_specialization(const Kind &kind);
};

/* A generator for templated C++ bindings.
*
* "template_classes" contains all generated template classes,
* keyed on their names.
*/
class template_cpp_generator : public cpp_generator {
struct class_printer;
struct method_decl_printer;
struct method_impl_printer;
struct class_decl_printer;
struct class_impl_printer;

void add_template_class(const isl_class &clazz, const std::string &name,
const std::vector<Kind> &base_kinds);
public:
template_cpp_generator(clang::SourceManager &SM,
std::set<clang::RecordDecl *> &exported_types,
std::set<clang::FunctionDecl *> exported_functions,
std::set<clang::FunctionDecl *> functions);

virtual void generate() override;
void foreach_template_class(
const std::function<void(const template_class &)> &fn) const;
void print_forward_declarations(std::ostream &os);
void print_friends(std::ostream &os);

std::map<std::string, template_class> template_classes;
};

#endif
239 changes: 231 additions & 8 deletions polly/lib/External/isl/isl_aff.c

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions polly/lib/External/isl/isl_aff_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ __isl_give isl_map *isl_map_from_multi_aff(__isl_take isl_multi_aff *ma)
return isl_map_from_multi_aff_internal(ma);
}

/* This function performs the same operation as isl_map_from_multi_aff,
* but is considered as a function on an isl_multi_aff when exported.
*/
__isl_give isl_map *isl_multi_aff_as_map(__isl_take isl_multi_aff *ma)
{
return isl_map_from_multi_aff(ma);
}

/* Construct a set mapping the parameter domain the multi-affine expression
* to its space, with each dimension in the space equated to the
* corresponding affine expression.
Expand All @@ -239,6 +247,14 @@ __isl_give isl_set *isl_set_from_multi_aff(__isl_take isl_multi_aff *ma)
return isl_map_from_multi_aff_internal(ma);
}

/* This function performs the same operation as isl_set_from_multi_aff,
* but is considered as a function on an isl_multi_aff when exported.
*/
__isl_give isl_set *isl_multi_aff_as_set(__isl_take isl_multi_aff *ma)
{
return isl_set_from_multi_aff(ma);
}

/* Construct a basic map mapping a domain in the given space to
* to an n-dimensional range, with n the number of elements in the list,
* where each coordinate in the range is prescribed by the
Expand Down Expand Up @@ -315,6 +331,14 @@ __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff)
return isl_map_from_pw_aff_internal(pwaff);
}

/* This function performs the same operation as isl_map_from_pw_aff,
* but is considered as a function on an isl_pw_aff when exported.
*/
__isl_give isl_map *isl_pw_aff_as_map(__isl_take isl_pw_aff *pa)
{
return isl_map_from_pw_aff(pa);
}

/* Construct a one-dimensional set with as parameter domain
* the domain of pwaff and the single set dimension
* corresponding to the affine expressions.
Expand Down Expand Up @@ -376,13 +400,29 @@ __isl_give isl_map *isl_map_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
return isl_map_from_pw_multi_aff_internal(pma);
}

/* This function performs the same operation as isl_map_from_pw_multi_aff,
* but is considered as a function on an isl_pw_multi_aff when exported.
*/
__isl_give isl_map *isl_pw_multi_aff_as_map(__isl_take isl_pw_multi_aff *pma)
{
return isl_map_from_pw_multi_aff(pma);
}

__isl_give isl_set *isl_set_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
{
if (check_input_is_set(isl_pw_multi_aff_peek_space(pma)) < 0)
pma = isl_pw_multi_aff_free(pma);
return set_from_map(isl_map_from_pw_multi_aff_internal(pma));
}

/* This function performs the same operation as isl_set_from_pw_multi_aff,
* but is considered as a function on an isl_pw_multi_aff when exported.
*/
__isl_give isl_set *isl_pw_multi_aff_as_set(__isl_take isl_pw_multi_aff *pma)
{
return isl_set_from_pw_multi_aff(pma);
}

/* Construct a set or map mapping the shared (parameter) domain
* of the piecewise affine expressions to the range of "mpa"
* with each dimension in the range equated to the
Expand Down Expand Up @@ -438,6 +478,14 @@ __isl_give isl_map *isl_map_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa)
return map_from_multi_pw_aff(mpa);
}

/* This function performs the same operation as isl_map_from_multi_pw_aff,
* but is considered as a function on an isl_multi_pw_aff when exported.
*/
__isl_give isl_map *isl_multi_pw_aff_as_map(__isl_take isl_multi_pw_aff *mpa)
{
return isl_map_from_multi_pw_aff(mpa);
}

/* Construct a set mapping the shared parameter domain
* of the piecewise affine expressions to the space of "mpa"
* with each dimension in the range equated to the
Expand All @@ -450,6 +498,14 @@ __isl_give isl_set *isl_set_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa)
return set_from_map(map_from_multi_pw_aff(mpa));
}

/* This function performs the same operation as isl_set_from_multi_pw_aff,
* but is considered as a function on an isl_multi_pw_aff when exported.
*/
__isl_give isl_set *isl_multi_pw_aff_as_set(__isl_take isl_multi_pw_aff *mpa)
{
return isl_set_from_multi_pw_aff(mpa);
}

/* Convert "pa" to an isl_map and add it to *umap.
*/
static isl_stat map_from_pw_aff_entry(__isl_take isl_pw_aff *pa, void *user)
Expand Down Expand Up @@ -528,3 +584,13 @@ __isl_give isl_union_map *isl_union_map_from_union_pw_multi_aff(
isl_union_map_free(umap);
return NULL;
}

/* This function performs the same operation as
* isl_union_map_from_union_pw_multi_aff,
* but is considered as a function on an isl_union_pw_multi_aff when exported.
*/
__isl_give isl_union_map *isl_union_pw_multi_aff_as_union_map(
__isl_take isl_union_pw_multi_aff *upma)
{
return isl_union_map_from_union_pw_multi_aff(upma);
}
13 changes: 12 additions & 1 deletion polly/lib/External/isl/isl_aff_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <isl/local_space.h>
#include <isl_int.h>
#include <isl_reordering.h>
#include <isl/stream.h>

/* ls represents the domain space.
*
Expand Down Expand Up @@ -101,6 +102,8 @@ __isl_give isl_aff *isl_aff_normalize(__isl_take isl_aff *aff);
__isl_give isl_aff *isl_aff_expand_divs( __isl_take isl_aff *aff,
__isl_take isl_mat *div, int *exp);

__isl_give isl_aff *isl_stream_read_aff(__isl_keep isl_stream *s);

__isl_give isl_pw_aff *isl_pw_aff_alloc_size(__isl_take isl_space *space,
int n);
__isl_give isl_pw_aff *isl_pw_aff_reset_space(__isl_take isl_pw_aff *pwaff,
Expand All @@ -126,6 +129,8 @@ __isl_give isl_pw_aff *isl_pw_aff_scale(__isl_take isl_pw_aff *pwaff,
__isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff,
isl_int f);

__isl_give isl_pw_aff *isl_stream_read_pw_aff(__isl_keep isl_stream *s);

isl_bool isl_aff_matching_params(__isl_keep isl_aff *aff,
__isl_keep isl_space *space);
isl_stat isl_aff_check_match_domain_space(__isl_keep isl_aff *aff,
Expand Down Expand Up @@ -176,9 +181,15 @@ isl_stat isl_seq_preimage(isl_int *dst, isl_int *src,
__isl_give isl_aff *isl_aff_substitute_equalities(__isl_take isl_aff *aff,
__isl_take isl_basic_set *eq);
__isl_give isl_pw_multi_aff *isl_pw_multi_aff_substitute(
__isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, unsigned pos,
__isl_take isl_pw_multi_aff *pma, unsigned pos,
__isl_keep isl_pw_aff *subs);

__isl_give isl_pw_multi_aff *isl_stream_read_pw_multi_aff(
__isl_keep isl_stream *s);

__isl_give isl_union_pw_aff *isl_stream_read_union_pw_aff(
__isl_keep isl_stream *s);

isl_stat isl_pw_aff_check_named_params(__isl_keep isl_pw_aff *pa);
isl_stat isl_multi_aff_check_named_params(__isl_keep isl_multi_aff *ma);
isl_stat isl_pw_multi_aff_check_named_params(__isl_keep isl_pw_multi_aff *pma);
Expand Down
18 changes: 9 additions & 9 deletions polly/lib/External/isl/isl_ast_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,9 @@ __isl_give isl_map *isl_ast_build_get_schedule_map(
/* Return the position of the dimension in build->domain for which
* an AST node is currently being generated.
*/
int isl_ast_build_get_depth(__isl_keep isl_ast_build *build)
isl_size isl_ast_build_get_depth(__isl_keep isl_ast_build *build)
{
return build ? build->depth : -1;
return build ? build->depth : isl_size_error;
}

/* Prepare for generating code for the next level.
Expand Down Expand Up @@ -1373,14 +1373,14 @@ __isl_give isl_multi_aff *isl_ast_build_get_stride_expansion(
{
isl_space *space;
isl_multi_aff *ma;
int pos;
isl_size pos;
isl_aff *aff, *offset;
isl_val *stride;

if (!build)
pos = isl_ast_build_get_depth(build);
if (pos < 0)
return NULL;

pos = isl_ast_build_get_depth(build);
space = isl_ast_build_get_space(build, 1);
space = isl_space_map_from_set(space);
ma = isl_multi_aff_identity(space);
Expand Down Expand Up @@ -1438,16 +1438,16 @@ __isl_give isl_ast_build *isl_ast_build_include_stride(
__isl_give isl_ast_build *isl_ast_build_detect_strides(
__isl_take isl_ast_build *build, __isl_take isl_set *set)
{
int pos;
isl_size pos;
isl_bool no_stride;
isl_val *stride;
isl_aff *offset;
isl_stride_info *si;

if (!build)
pos = isl_ast_build_get_depth(build);
if (pos < 0)
goto error;

pos = isl_ast_build_get_depth(build);
si = isl_set_get_stride_info(set, pos);
stride = isl_stride_info_get_stride(si);
offset = isl_stride_info_get_offset(si);
Expand Down Expand Up @@ -1949,7 +1949,7 @@ isl_bool isl_ast_build_has_stride(__isl_keep isl_ast_build *build, int pos)
*
* f + s a
*
* with a an integer, return s through *stride.
* with a an integer, return s.
*/
__isl_give isl_val *isl_ast_build_get_stride(__isl_keep isl_ast_build *build,
int pos)
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_ast_build_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ __isl_give isl_ast_build *isl_ast_build_clear_local_info(
__isl_take isl_ast_build *build);
__isl_give isl_ast_build *isl_ast_build_increase_depth(
__isl_take isl_ast_build *build);
int isl_ast_build_get_depth(__isl_keep isl_ast_build *build);
isl_size isl_ast_build_get_depth(__isl_keep isl_ast_build *build);
isl_size isl_ast_build_dim(__isl_keep isl_ast_build *build,
enum isl_dim_type type);
__isl_give isl_space *isl_ast_build_get_space(
Expand Down
108 changes: 69 additions & 39 deletions polly/lib/External/isl/isl_ast_codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,15 @@ static __isl_give isl_set *add_implied_guards(__isl_take isl_set *guard,
int degenerate, __isl_keep isl_basic_set *bounds,
__isl_keep isl_ast_build *build)
{
int depth, has_stride;
isl_size depth;
isl_bool has_stride;
isl_space *space;
isl_set *dom, *set;

depth = isl_ast_build_get_depth(build);
has_stride = isl_ast_build_has_stride(build, depth);
if (depth < 0 || has_stride < 0)
return isl_set_free(guard);
if (!has_stride && !degenerate)
return guard;

Expand Down Expand Up @@ -783,7 +786,7 @@ static __isl_give isl_set *add_implied_guards(__isl_take isl_set *guard,
*
* We set the initialization part of the for loop to the single
* value attained by the current dimension.
* The increment and condition are not strictly needed as the are known
* The increment and condition are not strictly needed as they are known
* to be "1" and "iterator <= value" respectively.
*/
static __isl_give isl_ast_graft *refine_degenerate(
Expand Down Expand Up @@ -1060,14 +1063,14 @@ static __isl_give isl_ast_graft *set_for_cond_from_set(
*/
static __isl_give isl_ast_expr *for_inc(__isl_keep isl_ast_build *build)
{
int depth;
isl_size depth;
isl_val *v;
isl_ctx *ctx;

if (!build)
depth = isl_ast_build_get_depth(build);
if (depth < 0)
return NULL;
ctx = isl_ast_build_get_ctx(build);
depth = isl_ast_build_get_depth(build);

if (!isl_ast_build_has_stride(build, depth))
return isl_ast_expr_alloc_int_si(ctx, 1);
Expand Down Expand Up @@ -1178,18 +1181,18 @@ static __isl_give isl_ast_graft *refine_generic_bounds(
__isl_take isl_constraint_list *c_upper,
__isl_keep isl_set *domain, __isl_keep isl_ast_build *build)
{
int depth;
isl_size depth;
isl_ctx *ctx;
isl_pw_aff_list *lower;
int use_list;
isl_set *upper_set = NULL;
isl_pw_aff_list *upper_list = NULL;
isl_size n_lower, n_upper;

if (!graft || !c_lower || !c_upper || !build)
depth = isl_ast_build_get_depth(build);
if (!graft || !c_lower || !c_upper || depth < 0)
goto error;

depth = isl_ast_build_get_depth(build);
ctx = isl_ast_graft_get_ctx(graft);

n_lower = isl_constraint_list_n_constraint(c_lower);
Expand Down Expand Up @@ -1284,13 +1287,17 @@ static __isl_give isl_ast_graft *refine_generic_split(
__isl_keep isl_set *domain, __isl_keep isl_ast_build *build)
{
struct isl_ast_count_constraints_data data;
isl_size depth;
isl_constraint_list *lower;
isl_constraint_list *upper;

depth = isl_ast_build_get_depth(build);
if (depth < 0)
list = isl_constraint_list_free(list);
if (!list)
return isl_ast_graft_free(graft);

data.pos = isl_ast_build_get_depth(build);
data.pos = depth;

list = isl_constraint_list_sort(list, &cmp_constraint, &data.pos);
if (!list)
Expand Down Expand Up @@ -1345,14 +1352,14 @@ static __isl_give isl_ast_graft *refine_generic(
static __isl_give isl_ast_node *create_for(__isl_keep isl_ast_build *build,
int degenerate)
{
int depth;
isl_size depth;
isl_id *id;
isl_ast_node *node;

if (!build)
depth = isl_ast_build_get_depth(build);
if (depth < 0)
return NULL;

depth = isl_ast_build_get_depth(build);
id = isl_ast_build_get_iterator_id(build, depth);
node = isl_ast_node_alloc_for(id);
if (degenerate)
Expand Down Expand Up @@ -1475,7 +1482,7 @@ static __isl_give isl_ast_graft *create_node_scaled(
__isl_take isl_basic_set *bounds, __isl_take isl_set *domain,
__isl_take isl_ast_build *build)
{
int depth;
isl_size depth;
int degenerate;
isl_bool eliminated;
isl_size n;
Expand All @@ -1495,6 +1502,8 @@ static __isl_give isl_ast_graft *create_node_scaled(
build = isl_ast_build_set_executed(build, isl_union_map_copy(executed));

depth = isl_ast_build_get_depth(build);
if (depth < 0)
build = isl_ast_build_free(build);
sub_build = isl_ast_build_copy(build);
bounds = isl_basic_set_remove_redundancies(bounds);
bounds = isl_ast_build_specialize_basic_set(sub_build, bounds);
Expand Down Expand Up @@ -1695,6 +1704,7 @@ static __isl_give isl_ast_graft *create_node(__isl_take isl_union_map *executed,
__isl_take isl_ast_build *build)
{
struct isl_check_scaled_data data;
isl_size depth;
isl_ctx *ctx;
isl_aff *offset;
isl_val *d;
Expand All @@ -1703,7 +1713,10 @@ static __isl_give isl_ast_graft *create_node(__isl_take isl_union_map *executed,
if (!isl_options_get_ast_build_scale_strides(ctx))
return create_node_scaled(executed, bounds, domain, build);

data.depth = isl_ast_build_get_depth(build);
depth = isl_ast_build_get_depth(build);
if (depth < 0)
build = isl_ast_build_free(build);
data.depth = depth;
if (!isl_ast_build_has_stride(build, data.depth))
return create_node_scaled(executed, bounds, domain, build);

Expand Down Expand Up @@ -1986,7 +1999,8 @@ struct isl_add_nodes_data {
static isl_stat add_nodes(__isl_take isl_basic_set_list *scc, void *user)
{
struct isl_add_nodes_data *data = user;
int i, depth;
int i;
isl_size depth;
isl_size n;
isl_basic_set *bset, *first;
isl_basic_set_list *list;
Expand All @@ -2006,6 +2020,8 @@ static isl_stat add_nodes(__isl_take isl_basic_set_list *scc, void *user)
}

depth = isl_ast_build_get_depth(data->build);
if (depth < 0)
bset = isl_basic_set_free(bset);
space = isl_basic_set_get_space(bset);
space = isl_space_map_from_set(space);
gt = isl_basic_map_universe(space);
Expand Down Expand Up @@ -2064,7 +2080,7 @@ static __isl_give isl_ast_graft_list *generate_sorted_domains(
{
isl_ctx *ctx;
struct isl_add_nodes_data data;
int depth;
isl_size depth;
isl_size n;

n = isl_basic_set_list_n_basic_set(domain_list);
Expand All @@ -2083,7 +2099,7 @@ static __isl_give isl_ast_graft_list *generate_sorted_domains(
depth = isl_ast_build_get_depth(build);
data.executed = executed;
data.build = build;
if (isl_basic_set_list_foreach_scc(domain_list,
if (depth < 0 || isl_basic_set_list_foreach_scc(domain_list,
&domain_follows_at_depth, &depth,
&add_nodes, &data) < 0)
data.list = isl_ast_graft_list_free(data.list);
Expand Down Expand Up @@ -2186,7 +2202,7 @@ static __isl_give isl_ast_graft_list *generate_parallel_domains(
__isl_keep isl_basic_set_list *domain_list,
__isl_keep isl_union_map *executed, __isl_keep isl_ast_build *build)
{
int depth;
isl_size depth;
struct isl_ast_generate_parallel_domains_data data;

data.n = isl_basic_set_list_n_basic_set(domain_list);
Expand All @@ -2197,6 +2213,8 @@ static __isl_give isl_ast_graft_list *generate_parallel_domains(
return generate_sorted_domains(domain_list, executed, build);

depth = isl_ast_build_get_depth(build);
if (depth < 0)
return NULL;
data.list = NULL;
data.executed = executed;
data.build = build;
Expand Down Expand Up @@ -2252,16 +2270,16 @@ static __isl_give isl_set *explicit_bounds(__isl_take isl_map *map,
__isl_keep isl_ast_build *build)
{
isl_set *domain;
int depth;
isl_size depth;
isl_size dim;

depth = isl_ast_build_get_depth(build);
dim = isl_map_dim(map, isl_dim_out);
if (dim < 0)
if (depth < 0 || dim < 0)
return isl_map_domain(isl_map_free(map));
map = isl_map_drop_constraints_involving_dims(map, isl_dim_out, 0, dim);

domain = isl_map_domain(map);
depth = isl_ast_build_get_depth(build);
dim = isl_set_dim(domain, isl_dim_set);
domain = isl_set_detect_equalities(domain);
domain = isl_set_drop_constraints_involving_dims(domain,
Expand Down Expand Up @@ -2628,14 +2646,16 @@ static int foreach_iteration(__isl_take isl_set *domain,
int (*fn)(__isl_take isl_basic_set *bset, void *user), void *user)
{
int i, n;
int empty;
int depth;
isl_bool empty;
isl_size depth;
isl_multi_aff *expansion;
isl_basic_map *bmap;
isl_aff *lower = NULL;
isl_ast_build *stride_build;

depth = isl_ast_build_get_depth(build);
if (depth < 0)
domain = isl_set_free(domain);

domain = isl_ast_build_eliminate_inner(build, domain);
domain = isl_set_intersect(domain, isl_ast_build_get_domain(build));
Expand Down Expand Up @@ -3286,7 +3306,7 @@ static isl_bool has_pure_outer_disjunction(__isl_keep isl_set *domain,
isl_basic_set *hull;
isl_set *shared, *inner;
isl_bool equal;
int depth;
isl_size depth;
isl_size n;
isl_size dim;

Expand All @@ -3296,11 +3316,11 @@ static isl_bool has_pure_outer_disjunction(__isl_keep isl_set *domain,
if (n <= 1)
return isl_bool_false;
dim = isl_set_dim(domain, isl_dim_set);
if (dim < 0)
depth = isl_ast_build_get_depth(build);
if (dim < 0 || depth < 0)
return isl_bool_error;

inner = isl_set_copy(domain);
depth = isl_ast_build_get_depth(build);
inner = isl_set_drop_constraints_not_involving_dims(inner,
isl_dim_set, depth, dim - depth);
hull = isl_set_plain_unshifted_simple_hull(isl_set_copy(inner));
Expand Down Expand Up @@ -3410,13 +3430,13 @@ static __isl_give isl_set *extract_disjunction(__isl_take isl_set *domain,
__isl_keep isl_ast_build *build)
{
isl_set *hull;
int depth;
isl_size depth;
isl_size dim;

domain = isl_ast_build_specialize(build, domain);
depth = isl_ast_build_get_depth(build);
dim = isl_set_dim(domain, isl_dim_set);
if (dim < 0)
if (depth < 0 || dim < 0)
return isl_set_free(domain);
domain = isl_set_eliminate(domain, isl_dim_set, depth, dim - depth);
domain = isl_set_remove_unknown_divs(domain);
Expand Down Expand Up @@ -3606,7 +3626,8 @@ static __isl_give isl_ast_graft_list *generate_shifted_component_only_after(
static __isl_give isl_ast_graft_list *generate_shifted_component_tree(
__isl_take isl_union_map *executed, __isl_take isl_ast_build *build)
{
int i, depth;
int i;
isl_size depth;
int empty, has_isolate;
isl_space *space;
isl_union_set *schedule_domain;
Expand Down Expand Up @@ -3638,11 +3659,14 @@ static __isl_give isl_ast_graft_list *generate_shifted_component_tree(
isl_set_free(domain);
return generate_shifted_component_tree_base(executed, build, 0);
}
depth = isl_ast_build_get_depth(build);
if (depth < 0)
goto error;

isolated = isl_ast_build_eliminate(build, isolated);
hull = isl_set_unshifted_simple_hull(isolated);
isolated = isl_set_from_basic_set(hull);

depth = isl_ast_build_get_depth(build);
space = isl_space_map_from_set(isl_set_get_space(isolated));
gt = isl_map_universe(space);
for (i = 0; i < depth; ++i)
Expand Down Expand Up @@ -3946,16 +3970,18 @@ static int first_offset(struct isl_set_map_pair *domain, int *order, int n,
static __isl_give isl_union_map *construct_shifted_executed(
struct isl_set_map_pair *domain, int *order, int n,
__isl_keep isl_val *stride, __isl_keep isl_multi_val *offset,
__isl_take isl_ast_build *build)
__isl_keep isl_ast_build *build)
{
int i;
isl_union_map *executed;
isl_space *space;
isl_map *map;
int depth;
isl_size depth;
isl_constraint *c;

depth = isl_ast_build_get_depth(build);
if (depth < 0)
return NULL;
space = isl_ast_build_get_space(build, 1);
executed = isl_union_map_empty(isl_space_copy(space));
space = isl_space_map_from_set(space);
Expand Down Expand Up @@ -4029,7 +4055,7 @@ static __isl_give isl_ast_graft_list *generate_shift_component(
{
isl_ast_graft_list *list;
int first;
int depth;
isl_size depth;
isl_val *val;
isl_multi_val *mv;
isl_space *space;
Expand All @@ -4039,7 +4065,7 @@ static __isl_give isl_ast_graft_list *generate_shift_component(
depth = isl_ast_build_get_depth(build);

first = first_offset(domain, order, n, build);
if (first < 0)
if (depth < 0 || first < 0)
goto error;

mv = isl_multi_val_copy(offset);
Expand Down Expand Up @@ -4160,7 +4186,7 @@ static __isl_give isl_ast_graft_list *generate_component(
__isl_take isl_ast_build *build)
{
int i, d;
int depth;
isl_size depth;
isl_ctx *ctx;
isl_map *map;
isl_set *deltas;
Expand All @@ -4172,6 +4198,8 @@ static __isl_give isl_ast_graft_list *generate_component(
int res = 0;

depth = isl_ast_build_get_depth(build);
if (depth < 0)
goto error;

skip = n == 1;
if (skip >= 0 && !skip)
Expand Down Expand Up @@ -4752,6 +4780,7 @@ static __isl_give isl_ast_graft_list *generate_components(
int i;
isl_ctx *ctx = isl_ast_build_get_ctx(build);
isl_size n = isl_union_map_n_map(executed);
isl_size depth;
struct isl_any_scheduled_after_data data;
struct isl_set_map_pair *next;
struct isl_tarjan_graph *g = NULL;
Expand All @@ -4770,10 +4799,11 @@ static __isl_give isl_ast_graft_list *generate_components(
if (isl_union_map_foreach_map(executed, &extract_domain, &next) < 0)
goto error;

if (!build)
depth = isl_ast_build_get_depth(build);
if (depth < 0)
goto error;
data.build = build;
data.depth = isl_ast_build_get_depth(build);
data.depth = depth;
data.group_coscheduled = isl_options_get_ast_build_group_coscheduled(ctx);
g = isl_tarjan_graph_init(ctx, n, &any_scheduled_after, &data);
if (!g)
Expand Down Expand Up @@ -4833,7 +4863,7 @@ error: list = isl_ast_graft_list_free(list);
static __isl_give isl_ast_graft_list *generate_next_level(
__isl_take isl_union_map *executed, __isl_take isl_ast_build *build)
{
int depth;
isl_size depth;
isl_size dim;
isl_size n;

Expand All @@ -4849,7 +4879,7 @@ static __isl_give isl_ast_graft_list *generate_next_level(

depth = isl_ast_build_get_depth(build);
dim = isl_ast_build_dim(build, isl_dim_set);
if (dim < 0)
if (depth < 0 || dim < 0)
goto error;
if (depth >= dim)
return generate_inner_level(executed, build);
Expand Down
26 changes: 13 additions & 13 deletions polly/lib/External/isl/isl_ast_graft.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ static isl_bool equal_independent_guards(__isl_keep isl_ast_graft_list *list,
{
int i;
isl_size n;
int depth;
isl_size depth;
isl_size dim;
isl_ast_graft *graft_0;
isl_bool equal = isl_bool_true;
isl_bool skip;

n = isl_ast_graft_list_n_ast_graft(list);
if (n < 0)
depth = isl_ast_build_get_depth(build);
if (n < 0 || depth < 0)
return isl_bool_error;
graft_0 = isl_ast_graft_list_get_ast_graft(list, 0);
if (!graft_0)
return isl_bool_error;

depth = isl_ast_build_get_depth(build);
dim = isl_set_dim(graft_0->guard, isl_dim_set);
if (dim < 0)
return isl_bool_error;
if (dim <= depth)
skip = isl_bool_error;
else if (dim <= depth)
skip = isl_bool_false;
else
skip = isl_set_involves_dims(graft_0->guard,
Expand Down Expand Up @@ -161,12 +161,12 @@ static isl_bool equal_independent_guards(__isl_keep isl_ast_graft_list *list,
static __isl_give isl_set *hoist_guard(__isl_take isl_set *guard,
__isl_keep isl_ast_build *build)
{
int depth;
isl_size depth;
isl_size dim;

depth = isl_ast_build_get_depth(build);
dim = isl_set_dim(guard, isl_dim_set);
if (dim < 0)
if (depth < 0 || dim < 0)
return isl_set_free(guard);
if (depth < dim) {
guard = isl_set_remove_divs_involving_dims(guard,
Expand Down Expand Up @@ -473,21 +473,21 @@ static __isl_give isl_ast_graft_list *graft_extend_body(
__isl_keep isl_ast_build *build)
{
isl_size n;
int depth;
isl_size depth;
isl_ast_graft *last;
isl_space *space;
isl_basic_set *enforced;

n = isl_ast_graft_list_n_ast_graft(list);
if (n < 0 || !graft)
depth = isl_ast_build_get_depth(build);
if (n < 0 || depth < 0 || !graft)
goto error;
extend_body(body, isl_ast_node_copy(graft->node));
if (!*body)
goto error;

last = isl_ast_graft_list_get_ast_graft(list, n - 1);

depth = isl_ast_build_get_depth(build);
space = isl_ast_build_get_space(build, 1);
enforced = isl_basic_set_empty(space);
enforced = update_enforced(enforced, last, depth);
Expand Down Expand Up @@ -760,18 +760,18 @@ __isl_give isl_basic_set *isl_ast_graft_list_extract_shared_enforced(
{
int i;
isl_size n;
int depth;
isl_size depth;
isl_space *space;
isl_basic_set *enforced;

n = isl_ast_graft_list_n_ast_graft(list);
if (n < 0)
depth = isl_ast_build_get_depth(build);
if (n < 0 || depth < 0)
return NULL;

space = isl_ast_build_get_space(build, 1);
enforced = isl_basic_set_empty(space);

depth = isl_ast_build_get_depth(build);
for (i = 0; i < n; ++i) {
isl_ast_graft *graft;

Expand Down
42 changes: 42 additions & 0 deletions polly/lib/External/isl/isl_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,48 @@ __isl_give isl_fixed_box *isl_set_get_simple_fixed_box_hull(
return box;
}

/* Check whether the output elements lie on a rectangular lattice,
* possibly depending on the parameters and the input dimensions.
* Return a tile in this lattice.
* If no stride information can be found, then return a tile of size 1
* (and offset 0).
*
* Obtain stride information in each output dimension separately and
* combine the results.
*/
__isl_give isl_fixed_box *isl_map_get_range_lattice_tile(
__isl_keep isl_map *map)
{
int i;
isl_size n;
isl_space *space;
isl_fixed_box *box;

n = isl_map_dim(map, isl_dim_out);
if (n < 0)
return NULL;
space = isl_map_get_space(map);
box = isl_fixed_box_init(space);

for (i = 0; i < n; ++i) {
isl_val *stride;
isl_aff *offset;
isl_stride_info *si;

si = isl_map_get_range_stride_info(map, i);
stride = isl_stride_info_get_stride(si);
offset = isl_stride_info_get_offset(si);
isl_stride_info_free(si);

box = isl_fixed_box_set_valid_extent(box, i, offset, stride);

isl_aff_free(offset);
isl_val_free(stride);
}

return box;
}

#undef BASE
#define BASE multi_val
#include "print_yaml_field_templ.c"
Expand Down
6 changes: 4 additions & 2 deletions polly/lib/External/isl/isl_coalesce.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static int number_of_constraints_increases(int i, int j,
* replaced if the total number of constraints does not increase.
* While the number of integer divisions in the two basic maps
* is assumed to be the same, the actual definitions may be different.
* We only copy the definition from one of the basic map if it is
* We only copy the definition from one of the basic maps if it is
* the same as that of the other basic map. Otherwise, we mark
* the integer division as unknown and simplify the basic map
* in an attempt to recover the integer division definition.
Expand Down Expand Up @@ -3533,7 +3533,7 @@ static enum isl_change coalesce_subset_with_equalities(int i, int j,
return change;
}

/* Check if the union of and the basic maps represented by info[i] and info[j]
/* Check if the union of the basic maps represented by info[i] and info[j]
* can be represented by a single basic map, by aligning or equating
* their integer divisions.
* If so, replace the pair by the single basic map and return
Expand Down Expand Up @@ -3606,6 +3606,8 @@ static isl_bool has_nested_div(__isl_keep isl_basic_map *bmap)
* If no such list can be constructed, then the number of elements
* in the returned list is smaller than the number of integer divisions
* in "bmap_i".
* The integer division of "bmap_i" and "bmap_j" are assumed to be known and
* not contain any nested divs.
*/
static __isl_give isl_aff_list *set_up_substitutions(
__isl_keep isl_basic_map *bmap_i, __isl_keep isl_basic_map *bmap_j,
Expand Down
18 changes: 0 additions & 18 deletions polly/lib/External/isl/isl_constraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,24 +574,6 @@ __isl_give isl_constraint *isl_constraint_set_constant_si(
return constraint;
}

__isl_give isl_constraint *isl_constraint_set_coefficient(
__isl_take isl_constraint *constraint,
enum isl_dim_type type, int pos, isl_int v)
{
constraint = isl_constraint_cow(constraint);
if (isl_constraint_check_range(constraint, type, pos, 1) < 0)
return isl_constraint_free(constraint);

constraint->v = isl_vec_cow(constraint->v);
if (!constraint->v)
return isl_constraint_free(constraint);

pos += isl_local_space_offset(constraint->ls, type);
isl_int_set(constraint->v->el[pos], v);

return constraint;
}

/* Replace the coefficient of the variable of type "type" at position "pos"
* of "constraint" by "v".
*/
Expand Down
1 change: 1 addition & 0 deletions polly/lib/External/isl/isl_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define EL_BASE id

#include <isl_list_templ.c>
#include <isl_list_read_templ.c>

/* A special, static isl_id to use as domains (and ranges)
* of sets and parameters domains.
Expand Down
63 changes: 63 additions & 0 deletions polly/lib/External/isl/isl_list_read_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2017 Sven Verdoolaege
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege.
*/

#include <isl/stream.h>

#include <isl_list_macro.h>

/* Read a list of elements of type EL from "s".
* The input format corresponds to the way lists are printed
* by isl_printer_print_list_*.
* In particular, the elements are separated by a comma and
* the entire list is surrounded by parentheses.
*/
static __isl_give LIST(EL) *FN(isl_stream_read,LIST(EL_BASE))(isl_stream *s)
{
isl_ctx *ctx;
LIST(EL) *list;

if (!s)
return NULL;
ctx = isl_stream_get_ctx(s);
list = FN(LIST(EL),alloc)(ctx, 0);
if (!list)
return NULL;
if (isl_stream_eat(s, '(') < 0)
return FN(LIST(EL),free)(list);
do {
EL *el;

el = FN(isl_stream_read,EL_BASE)(s);
list = FN(LIST(EL),add)(list, el);
if (!list)
return NULL;
} while (isl_stream_eat_if_available(s, ','));
if (isl_stream_eat(s, ')') < 0)
return FN(LIST(EL),free)(list);
return list;
}

/* Read a list of elements of type EL from the string "str".
* The input format corresponds to the way lists are printed
* by isl_printer_print_list_*.
* In particular, the elements are separated by a comma and
* the entire list is surrounded by parentheses.
*/
__isl_give LIST(EL) *FN(LIST(EL),read_from_str)(isl_ctx *ctx,
const char *str)
{
LIST(EL) *list;
isl_stream *s;

s = isl_stream_new_str(ctx, str);
if (!s)
return NULL;
list = FN(isl_stream_read,LIST(EL_BASE))(s);
isl_stream_free(s);
return list;
}
8 changes: 8 additions & 0 deletions polly/lib/External/isl/isl_list_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ __isl_give LIST(EL) *FN(FN(LIST(EL),from),EL_BASE)(__isl_take EL *el)
return NULL;
}

/* This function performs the same operation as isl_*_list_from_*,
* but is considered as a function on the element when exported.
*/
__isl_give LIST(EL) *FN(EL,to_list)(__isl_take EL *el)
{
return FN(FN(LIST(EL),from),EL_BASE)(el);
}

/* Append the elements of "list2" to "list1", where "list1" is known
* to have only a single reference and enough room to hold
* the extra elements.
Expand Down
266 changes: 141 additions & 125 deletions polly/lib/External/isl/isl_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,32 @@ isl_size isl_map_dim(__isl_keep isl_map *map, enum isl_dim_type type)
return isl_space_dim(isl_map_peek_space(map), type);
}

/* Return the dimensionality of the domain (tuple) of the map.
*/
isl_size isl_map_domain_tuple_dim(__isl_keep isl_map *map)
{
return isl_map_dim(map, isl_dim_in);
}

/* Return the dimensionality of the range (tuple) of the map.
*/
isl_size isl_map_range_tuple_dim(__isl_keep isl_map *map)
{
return isl_map_dim(map, isl_dim_out);
}

isl_size isl_set_dim(__isl_keep isl_set *set, enum isl_dim_type type)
{
return isl_map_dim(set_to_map(set), type);
}

/* Return the dimensionality of the (tuple of the) set.
*/
isl_size isl_set_tuple_dim(__isl_keep isl_set *set)
{
return isl_set_dim(set, isl_dim_set);
}

/* Return the position of the variables of the given type
* within the sequence of variables of "bmap".
*/
Expand Down Expand Up @@ -742,6 +763,22 @@ __isl_give isl_map *isl_map_set_tuple_id(__isl_take isl_map *map,
return isl_map_reset_space(map, isl_map_get_space(map));
}

/* Replace the identifier of the domain tuple of "map" by "id".
*/
__isl_give isl_map *isl_map_set_domain_tuple_id(__isl_take isl_map *map,
__isl_take isl_id *id)
{
return isl_map_set_tuple_id(map, isl_dim_in, id);
}

/* Replace the identifier of the range tuple of "map" by "id".
*/
__isl_give isl_map *isl_map_set_range_tuple_id(__isl_take isl_map *map,
__isl_take isl_id *id)
{
return isl_map_set_tuple_id(map, isl_dim_out, id);
}

__isl_give isl_set *isl_set_set_tuple_id(__isl_take isl_set *set,
__isl_take isl_id *id)
{
Expand Down Expand Up @@ -770,12 +807,40 @@ isl_bool isl_map_has_tuple_id(__isl_keep isl_map *map, enum isl_dim_type type)
return map ? isl_space_has_tuple_id(map->dim, type) : isl_bool_error;
}

/* Does the domain tuple of "map" have an identifier?
*/
isl_bool isl_map_has_domain_tuple_id(__isl_keep isl_map *map)
{
return isl_map_has_tuple_id(map, isl_dim_in);
}

/* Does the range tuple of "map" have an identifier?
*/
isl_bool isl_map_has_range_tuple_id(__isl_keep isl_map *map)
{
return isl_map_has_tuple_id(map, isl_dim_out);
}

__isl_give isl_id *isl_map_get_tuple_id(__isl_keep isl_map *map,
enum isl_dim_type type)
{
return map ? isl_space_get_tuple_id(map->dim, type) : NULL;
}

/* Return the identifier of the domain tuple of "map", assuming it has one.
*/
__isl_give isl_id *isl_map_get_domain_tuple_id(__isl_keep isl_map *map)
{
return isl_map_get_tuple_id(map, isl_dim_in);
}

/* Return the identifier of the range tuple of "map", assuming it has one.
*/
__isl_give isl_id *isl_map_get_range_tuple_id(__isl_keep isl_map *map)
{
return isl_map_get_tuple_id(map, isl_dim_out);
}

isl_bool isl_set_has_tuple_id(__isl_keep isl_set *set)
{
return isl_map_has_tuple_id(set, isl_dim_set);
Expand Down Expand Up @@ -2103,19 +2168,22 @@ static __isl_give isl_basic_map *isl_basic_map_swap_vars(
* Since the basic map has conflicting constraints,
* it must have at least one constraint, except perhaps
* if it was already explicitly marked as being empty.
* Do nothing in the latter case.
* Do nothing in the latter case, i.e., if it has been marked empty and
* has no constraints.
*/
__isl_give isl_basic_map *isl_basic_map_set_to_empty(
__isl_take isl_basic_map *bmap)
{
int i = 0;
isl_bool empty;
isl_size n;
isl_size total;

n = isl_basic_map_n_constraint(bmap);
empty = isl_basic_map_plain_is_empty(bmap);
if (empty < 0)
if (n < 0 || empty < 0)
return isl_basic_map_free(bmap);
if (empty)
if (n == 0 && empty)
return bmap;
total = isl_basic_map_dim(bmap, isl_dim_all);
if (total < 0)
Expand Down Expand Up @@ -3423,6 +3491,14 @@ __isl_give isl_set *isl_set_from_basic_set(__isl_take isl_basic_set *bset)
return isl_map_from_basic_map(bset);
}

/* This function performs the same operation as isl_set_from_basic_set,
* but is considered as a function on an isl_basic_set when exported.
*/
__isl_give isl_set *isl_basic_set_to_set(__isl_take isl_basic_set *bset)
{
return isl_set_from_basic_set(bset);
}

__isl_give isl_map *isl_map_from_basic_map(__isl_take isl_basic_map *bmap)
{
struct isl_map *map;
Expand Down Expand Up @@ -3711,6 +3787,41 @@ __isl_give isl_basic_set *isl_basic_set_intersect_params(
return isl_basic_set_intersect(bset1, bset2);
}

/* Does "map" consist of a single disjunct, without any local variables?
*/
static isl_bool is_convex_no_locals(__isl_keep isl_map *map)
{
isl_size n_div;

if (!map)
return isl_bool_error;
if (map->n != 1)
return isl_bool_false;
n_div = isl_basic_map_dim(map->p[0], isl_dim_div);
if (n_div < 0)
return isl_bool_error;
if (n_div != 0)
return isl_bool_false;
return isl_bool_true;
}

/* Check that "map" consists of a single disjunct, without any local variables.
*/
static isl_stat check_convex_no_locals(__isl_keep isl_map *map)
{
isl_bool ok;

ok = is_convex_no_locals(map);
if (ok < 0)
return isl_stat_error;
if (ok)
return isl_stat_ok;

isl_die(isl_map_get_ctx(map), isl_error_internal,
"unexpectedly not convex or involving local variables",
return isl_stat_error);
}

/* Special case of isl_map_intersect, where both map1 and map2
* are convex, without any divs and such that either map1 or map2
* contains a single constraint. This constraint is then simply
Expand All @@ -3719,10 +3830,9 @@ __isl_give isl_basic_set *isl_basic_set_intersect_params(
static __isl_give isl_map *map_intersect_add_constraint(
__isl_take isl_map *map1, __isl_take isl_map *map2)
{
isl_assert(map1->ctx, map1->n == 1, goto error);
isl_assert(map2->ctx, map1->n == 1, goto error);
isl_assert(map1->ctx, map1->p[0]->n_div == 0, goto error);
isl_assert(map2->ctx, map1->p[0]->n_div == 0, goto error);
if (check_convex_no_locals(map1) < 0 ||
check_convex_no_locals(map2) < 0)
goto error;

if (map2->p[0]->n_eq + map2->p[0]->n_ineq != 1)
return isl_map_intersect(map2, map1);
Expand Down Expand Up @@ -3788,8 +3898,8 @@ static __isl_give isl_map *map_intersect_internal(__isl_take isl_map *map1,
return map2;
}

if (map1->n == 1 && map2->n == 1 &&
map1->p[0]->n_div == 0 && map2->p[0]->n_div == 0 &&
if (is_convex_no_locals(map1) == isl_bool_true &&
is_convex_no_locals(map2) == isl_bool_true &&
isl_space_is_equal(map1->dim, map2->dim) &&
(map1->p[0]->n_eq + map1->p[0]->n_ineq == 1 ||
map2->p[0]->n_eq + map2->p[0]->n_ineq == 1))
Expand Down Expand Up @@ -6277,6 +6387,14 @@ __isl_give isl_map *isl_map_universe(__isl_take isl_space *space)
return map;
}

/* This function performs the same operation as isl_map_universe,
* but is considered as a function on an isl_space when exported.
*/
__isl_give isl_map *isl_space_universe_map(__isl_take isl_space *space)
{
return isl_map_universe(space);
}

__isl_give isl_set *isl_set_universe(__isl_take isl_space *space)
{
struct isl_set *set;
Expand All @@ -6287,6 +6405,14 @@ __isl_give isl_set *isl_set_universe(__isl_take isl_space *space)
return set;
}

/* This function performs the same operation as isl_set_universe,
* but is considered as a function on an isl_space when exported.
*/
__isl_give isl_set *isl_space_universe_set(__isl_take isl_space *space)
{
return isl_set_universe(space);
}

__isl_give isl_map *isl_map_dup(__isl_keep isl_map *map)
{
int i;
Expand Down Expand Up @@ -13399,129 +13525,19 @@ __isl_give isl_aff *isl_basic_set_get_div(__isl_keep isl_basic_set *bset,
return isl_basic_map_get_div(bset, pos);
}

/* Plug in "subs" for dimension "type", "pos" of "bset".
*
* Let i be the dimension to replace and let "subs" be of the form
*
* f/d
*
* Any integer division with a non-zero coefficient for i,
*
* floor((a i + g)/m)
*
* is replaced by
*
* floor((a f + d g)/(m d))
*
* Constraints of the form
*
* a i + g
*
* are replaced by
*
* a f + d g
*
* We currently require that "subs" is an integral expression.
* Handling rational expressions may require us to add stride constraints
* as we do in isl_basic_set_preimage_multi_aff.
*/
__isl_give isl_basic_set *isl_basic_set_substitute(
__isl_take isl_basic_set *bset,
enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
{
int i;
isl_int v;
isl_ctx *ctx;
isl_size n_div;

if (bset && isl_basic_set_plain_is_empty(bset))
return bset;

bset = isl_basic_set_cow(bset);
if (!bset || !subs)
goto error;

ctx = isl_basic_set_get_ctx(bset);
if (!isl_space_is_equal(bset->dim, subs->ls->dim))
isl_die(ctx, isl_error_invalid,
"spaces don't match", goto error);
n_div = isl_local_space_dim(subs->ls, isl_dim_div);
if (n_div < 0)
goto error;
if (n_div != 0)
isl_die(ctx, isl_error_unsupported,
"cannot handle divs yet", goto error);
if (!isl_int_is_one(subs->v->el[0]))
isl_die(ctx, isl_error_invalid,
"can only substitute integer expressions", goto error);

pos += isl_basic_set_offset(bset, type);

isl_int_init(v);

for (i = 0; i < bset->n_eq; ++i) {
if (isl_int_is_zero(bset->eq[i][pos]))
continue;
isl_int_set(v, bset->eq[i][pos]);
isl_int_set_si(bset->eq[i][pos], 0);
isl_seq_combine(bset->eq[i], subs->v->el[0], bset->eq[i],
v, subs->v->el + 1, subs->v->size - 1);
}

for (i = 0; i < bset->n_ineq; ++i) {
if (isl_int_is_zero(bset->ineq[i][pos]))
continue;
isl_int_set(v, bset->ineq[i][pos]);
isl_int_set_si(bset->ineq[i][pos], 0);
isl_seq_combine(bset->ineq[i], subs->v->el[0], bset->ineq[i],
v, subs->v->el + 1, subs->v->size - 1);
}

for (i = 0; i < bset->n_div; ++i) {
if (isl_int_is_zero(bset->div[i][1 + pos]))
continue;
isl_int_set(v, bset->div[i][1 + pos]);
isl_int_set_si(bset->div[i][1 + pos], 0);
isl_seq_combine(bset->div[i] + 1,
subs->v->el[0], bset->div[i] + 1,
v, subs->v->el + 1, subs->v->size - 1);
isl_int_mul(bset->div[i][0], bset->div[i][0], subs->v->el[0]);
}

isl_int_clear(v);

bset = isl_basic_set_simplify(bset);
return isl_basic_set_finalize(bset);
error:
isl_basic_set_free(bset);
return NULL;
}

/* Plug in "subs" for dimension "type", "pos" of "set".
/* Plug in "subs" for set dimension "pos" of "set".
*/
__isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
unsigned pos, __isl_keep isl_aff *subs)
{
int i;
isl_multi_aff *ma;

if (set && isl_set_plain_is_empty(set))
return set;

set = isl_set_cow(set);
if (!set || !subs)
goto error;

for (i = set->n - 1; i >= 0; --i) {
set->p[i] = isl_basic_set_substitute(set->p[i], type, pos, subs);
set = set_from_map(remove_if_empty(set_to_map(set), i));
if (!set)
return NULL;
}

return set;
error:
isl_set_free(set);
return NULL;
ma = isl_multi_aff_identity_on_domain_space(isl_set_get_space(set));
ma = isl_multi_aff_set_aff(ma, pos, isl_aff_copy(subs));
return isl_set_preimage_multi_aff(set, ma);
}

/* Check if the range of "ma" is compatible with the domain or range
Expand Down
1 change: 1 addition & 0 deletions polly/lib/External/isl/isl_map_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define EL_BASE map

#include <isl_list_templ.c>
#include <isl_list_read_templ.c>

#undef EL
#define EL isl_union_map
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_map_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ isl_bool isl_map_align_params_map_map_and_test(__isl_keep isl_map *map1,
isl_bool (*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2));

__isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs);
unsigned pos, __isl_keep isl_aff *subs);

__isl_give isl_set *isl_set_gist_params_basic_set(__isl_take isl_set *set,
__isl_take isl_basic_set *context);
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_map_subtract.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ __isl_give isl_map *isl_map_subtract_range(__isl_take isl_map *map,
}

/* A diff collector that aborts as soon as its add function is called,
* setting empty to 0.
* setting empty to isl_false.
*/
struct isl_is_empty_diff_collector {
struct isl_diff_collector dc;
Expand Down
10 changes: 10 additions & 0 deletions polly/lib/External/isl/isl_multi_identity_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),identity_on_domain_space)(
return FN(MULTI(BASE),identity)(isl_space_map_from_set(space));
}

/* This function performs the same operation as
* isl_multi_*_identity_on_domain_space,
* but is considered as a function on an isl_space when exported.
*/
__isl_give MULTI(BASE) *FN(FN(isl_space_identity_multi,BASE),on_domain)(
__isl_take isl_space *space)
{
return FN(MULTI(BASE),identity_on_domain_space)(space);
}

/* Create a multi expression in the same space as "multi" that maps each
* input dimension to the corresponding output dimension.
*/
Expand Down
9 changes: 9 additions & 0 deletions polly/lib/External/isl/isl_multi_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),from),LIST(BASE))(
return NULL;
}

/* This function performs the same operation as isl_multi_*_from_*_list,
* but is considered as a function on an isl_space when exported.
*/
__isl_give MULTI(BASE) *FN(isl_space_multi,BASE)(__isl_take isl_space *space,
__isl_take LIST(EL) *list)
{
return FN(FN(MULTI(BASE),from),LIST(BASE))(space, list);
}

__isl_give MULTI(BASE) *FN(MULTI(BASE),drop_dims)(
__isl_take MULTI(BASE) *multi,
enum isl_dim_type type, unsigned first, unsigned n)
Expand Down
51 changes: 51 additions & 0 deletions polly/lib/External/isl/isl_multi_tuple_id_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ isl_bool FN(MULTI(BASE),has_tuple_id)(__isl_keep MULTI(BASE) *multi,
return isl_space_has_tuple_id(multi->space, type);
}

/* Does the (range) tuple of "multi" have an identifier?
*
* Technically, the implementation should use isl_dim_set if "multi"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
isl_bool FN(MULTI(BASE),has_range_tuple_id)(__isl_keep MULTI(BASE) *multi)
{
return FN(MULTI(BASE),has_tuple_id)(multi, isl_dim_out);
}

/* Return the id of the specified tuple.
*/
__isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,
Expand All @@ -36,6 +48,19 @@ __isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,
return multi ? isl_space_get_tuple_id(multi->space, type) : NULL;
}

/* Return the identifier of the (range) tuple of "multi", assuming it has one.
*
* Technically, the implementation should use isl_dim_set if "multi"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
__isl_give isl_id *FN(MULTI(BASE),get_range_tuple_id)(
__isl_keep MULTI(BASE) *multi)
{
return FN(MULTI(BASE),get_tuple_id)(multi, isl_dim_out);
}

__isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)(
__isl_keep MULTI(BASE) *multi, enum isl_dim_type type,
const char *s)
Expand Down Expand Up @@ -71,6 +96,19 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)(
return NULL;
}

/* Replace the identifier of the (range) tuple of "multi" by "id".
*
* Technically, the implementation should use isl_dim_set if "multi"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),set_range_tuple_id)(
__isl_take MULTI(BASE) *multi, __isl_take isl_id *id)
{
return FN(MULTI(BASE),set_tuple_id)(multi, isl_dim_out, id);
}

/* Drop the id on the specified tuple.
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(
Expand All @@ -92,3 +130,16 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(

return FN(MULTI(BASE),reset_space)(multi, space);
}

/* Drop the identifier of the (range) tuple of "multi".
*
* Technically, the implementation should use isl_dim_set if "multi"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),reset_range_tuple_id)(
__isl_take MULTI(BASE) *multi)
{
return FN(MULTI(BASE),reset_tuple_id)(multi, isl_dim_out);
}
21 changes: 21 additions & 0 deletions polly/lib/External/isl/isl_multi_zero_space_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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/space.h>

#include "isl_multi_macro.h"

/* This function performs the same operation as isl_multi_*_zero,
* but is considered as a function on an isl_space when exported.
*/
__isl_give MULTI(BASE) *FN(isl_space_zero_multi,BASE)(
__isl_take isl_space *space)
{
return FN(MULTI(BASE),zero)(space);
}
2 changes: 2 additions & 0 deletions polly/lib/External/isl/isl_multi_zero_templ.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),zero)(__isl_take isl_space *space)
isl_space_free(space);
return NULL;
}

#include "isl_multi_zero_space_templ.c"
8 changes: 8 additions & 0 deletions polly/lib/External/isl/isl_point.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,14 @@ __isl_give isl_set *isl_set_from_point(__isl_take isl_point *pnt)
return isl_set_from_basic_set(bset);
}

/* This function performs the same operation as isl_set_from_point,
* but is considered as a function on an isl_point when exported.
*/
__isl_give isl_set *isl_point_to_set(__isl_take isl_point *pnt)
{
return isl_set_from_point(pnt);
}

/* Construct a union set, containing the single element "pnt".
* If "pnt" is void, then return an empty union set.
*/
Expand Down
33 changes: 31 additions & 2 deletions polly/lib/External/isl/isl_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -4773,6 +4773,33 @@ struct isl_multiplicative_call_data_pw_qpolynomial {
isl_pw_qpolynomial *pwqp;
};

/* Call "fn" on "bset" and return the result,
* but first check if "bset" has any redundant constraints or
* implicit equality constraints.
* If so, there may be further opportunities for detecting factors or
* removing equality constraints, so recursively call
* the top-level isl_basic_set_multiplicative_call.
*/
static __isl_give isl_pw_qpolynomial *multiplicative_call_base(
__isl_take isl_basic_set *bset,
__isl_give isl_pw_qpolynomial *(*fn)(__isl_take isl_basic_set *bset))
{
isl_size n1, n2, n_eq;

n1 = isl_basic_set_n_constraint(bset);
if (n1 < 0)
bset = isl_basic_set_free(bset);
bset = isl_basic_set_remove_redundancies(bset);
bset = isl_basic_set_detect_equalities(bset);
n2 = isl_basic_set_n_constraint(bset);
n_eq = isl_basic_set_n_equality(bset);
if (n2 < 0 || n_eq < 0)
bset = isl_basic_set_free(bset);
else if (n2 < n1 || n_eq > 0)
return isl_basic_set_multiplicative_call(bset, fn);
return fn(bset);
}

/* isl_factorizer_every_factor_basic_set callback that applies
* data->fn to the factor "bset" and multiplies in the result
* in data->pwqp.
Expand All @@ -4781,9 +4808,11 @@ 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;
isl_pw_qpolynomial *res;

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

Expand Down Expand Up @@ -4812,7 +4841,7 @@ static __isl_give isl_pw_qpolynomial *compressed_multiplicative_call(
goto error;
if (f->n_group == 0) {
isl_factorizer_free(f);
return fn(bset);
return multiplicative_call_base(bset, fn);
}

space = isl_basic_set_get_space(bset);
Expand Down
46 changes: 46 additions & 0 deletions polly/lib/External/isl/isl_pw_range_tuple_id_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2018 Sven Verdoolaege
* 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
*/

/* Does the (range) tuple of "pw" have an identifier?
*
* Technically, the implementation should use isl_dim_set if "pw"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
isl_bool FN(PW,has_range_tuple_id)(__isl_keep PW *pw)
{
return FN(PW,has_tuple_id)(pw, isl_dim_out);
}

/* Return the identifier of the (range) tuple of "pw", assuming it has one.
*
* Technically, the implementation should use isl_dim_set if "pw"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
__isl_give isl_id *FN(PW,get_range_tuple_id)(__isl_keep PW *pw)
{
return FN(PW,get_tuple_id)(pw, isl_dim_out);
}

/* Replace the identifier of the (range) tuple of "pw" by "id".
*
* Technically, the implementation should use isl_dim_set if "pw"
* lives in a set space and isl_dim_out if it lives in a map space.
* Internally, however, it can be assumed that isl_dim_set is equal
* to isl_dim_out.
*/
__isl_give PW *FN(PW,set_range_tuple_id)(__isl_take PW *pw,
__isl_take isl_id *id)
{
return FN(PW,set_tuple_id)(pw, isl_dim_out, id);
}
6 changes: 6 additions & 0 deletions polly/lib/External/isl/isl_schedule_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,17 @@ __isl_give isl_schedule_constraints *isl_schedule_constraints_set_context(
}

/* Replace the constraints of type "type" in "sc" by "c".
*
* First detect any equality constraints that may be implicit in "c"
* in order to try and improve the accuracy of the input (and therefore
* also the output) of the isl_set_coefficients calls
* that are eventually performed on (some of) these constraints.
*/
static __isl_give isl_schedule_constraints *isl_schedule_constraints_set(
__isl_take isl_schedule_constraints *sc, enum isl_edge_type type,
__isl_take isl_union_map *c)
{
c = isl_union_map_detect_equalities(c);
if (!sc || !c)
goto error;

Expand Down
1 change: 1 addition & 0 deletions polly/lib/External/isl/isl_set_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
#define EL_BASE union_set

#include <isl_list_templ.c>
#include <isl_list_read_templ.c>
62 changes: 62 additions & 0 deletions polly/lib/External/isl/isl_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,24 @@ isl_bool isl_space_has_tuple_id(__isl_keep isl_space *space,
return isl_bool_ok(space->tuple_id[type - isl_dim_in] != NULL);
}

/* Does the domain tuple of the map space "space" have an identifier?
*/
isl_bool isl_space_has_domain_tuple_id(__isl_keep isl_space *space)
{
if (isl_space_check_is_map(space) < 0)
return isl_bool_error;
return isl_space_has_tuple_id(space, isl_dim_in);
}

/* Does the range tuple of the map space "space" have an identifier?
*/
isl_bool isl_space_has_range_tuple_id(__isl_keep isl_space *space)
{
if (isl_space_check_is_map(space) < 0)
return isl_bool_error;
return isl_space_has_tuple_id(space, isl_dim_out);
}

__isl_give isl_id *isl_space_get_tuple_id(__isl_keep isl_space *space,
enum isl_dim_type type)
{
Expand All @@ -594,6 +612,28 @@ __isl_give isl_id *isl_space_get_tuple_id(__isl_keep isl_space *space,
return isl_id_copy(space->tuple_id[type - isl_dim_in]);
}

/* Return the identifier of the domain tuple of the map space "space",
* assuming it has one.
*/
__isl_give isl_id *isl_space_get_domain_tuple_id(
__isl_keep isl_space *space)
{
if (isl_space_check_is_map(space) < 0)
return NULL;
return isl_space_get_tuple_id(space, isl_dim_in);
}

/* Return the identifier of the range tuple of the map space "space",
* assuming it has one.
*/
__isl_give isl_id *isl_space_get_range_tuple_id(
__isl_keep isl_space *space)
{
if (isl_space_check_is_map(space) < 0)
return NULL;
return isl_space_get_tuple_id(space, isl_dim_out);
}

__isl_give isl_space *isl_space_set_tuple_id(__isl_take isl_space *space,
enum isl_dim_type type, __isl_take isl_id *id)
{
Expand All @@ -615,6 +655,28 @@ __isl_give isl_space *isl_space_set_tuple_id(__isl_take isl_space *space,
return NULL;
}

/* Replace the identifier of the domain tuple of the map space "space"
* by "id".
*/
__isl_give isl_space *isl_space_set_domain_tuple_id(
__isl_take isl_space *space, __isl_take isl_id *id)
{
if (isl_space_check_is_map(space) < 0)
space = isl_space_free(space);
return isl_space_set_tuple_id(space, isl_dim_in, id);
}

/* Replace the identifier of the range tuple of the map space "space"
* by "id".
*/
__isl_give isl_space *isl_space_set_range_tuple_id(
__isl_take isl_space *space, __isl_take isl_id *id)
{
if (isl_space_check_is_map(space) < 0)
space = isl_space_free(space);
return isl_space_set_tuple_id(space, isl_dim_out, id);
}

__isl_give isl_space *isl_space_reset_tuple_id(__isl_take isl_space *space,
enum isl_dim_type type)
{
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/isl_tab_pip.c
Original file line number Diff line number Diff line change
Expand Up @@ -5934,7 +5934,7 @@ static __isl_give isl_pw_multi_aff *split_domain_pma(
pma = isl_pw_multi_aff_free(pma);
} else if (subs) {
pma = isl_pw_multi_aff_substitute(pma,
isl_dim_in, n_in - 1, min_expr_pa);
n_in - 1, min_expr_pa);
} else {
isl_bool split;
split = need_split_set(opt->p[i].set, cst);
Expand Down
166 changes: 38 additions & 128 deletions polly/lib/External/isl/isl_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7833,6 +7833,15 @@ struct isl_vertices_test_data {
"[n, m] -> { [1, 1, m] : 0 < m <= n }",
"[n, m] -> { [1, 1, 1] : 0 < m <= n }"
} },
/* An input with implicit equality constraints among the parameters. */
{ "[N, M] -> { [a, b] : M >= 3 and 9 + 3M <= a <= 29 + 2N + 11M and "
"2b >= M + a and 5 - 2N - M + a <= 2b <= 3 + a and "
"3b >= 15 + a }",
2, {
"[N, M] -> { [(21), (12)] : M = 3 and N >= 0 }",
"[N, M] -> { [(61 + 2N), (32 + N)] : M = 3 and N >= 0 }",
}
},
};

/* Check that "vertex" corresponds to one of the vertices in data->vertex.
Expand Down Expand Up @@ -8693,6 +8702,34 @@ int test_sample(isl_ctx *ctx)
return 0;
}

/* Perform a projection on a basic set that is known to be empty
* but that has not been assigned a canonical representation.
* Earlier versions of isl would run into a stack overflow
* on this example.
*/
static int test_empty_projection(isl_ctx *ctx)
{
const char *str;
isl_bool empty;
isl_basic_set *bset;

str = "{ [a, b, c, d, e, f, g, h] : 5f = 1 + 4a - b + 5c - d - 2e and "
"3h = 2 + b + c and 14c >= 9 - 3a + 25b and "
"4c <= 50 - 3a + 23b and 6b <= -39 + a and "
"9g >= -6 + 3a + b + c and e < a + b - 2d and "
"7d >= -5 + 2a + 2b and 5g >= -14 + a - 4b + d + 2e and "
"9g <= -28 - 5b - 2c + 3d + 6e }";
bset = isl_basic_set_read_from_str(ctx, str);
empty = isl_basic_set_is_empty(bset);
bset = isl_basic_set_params(bset);
isl_basic_set_free(bset);

if (empty < 0)
return -1;

return 0;
}

int test_fixed_power(isl_ctx *ctx)
{
const char *str;
Expand Down Expand Up @@ -9240,133 +9277,6 @@ static int test_curry(isl_ctx *ctx)
return 0;
}

struct {
const char *set;
const char *ma;
const char *res;
} preimage_tests[] = {
{ "{ B[i,j] : 0 <= i < 10 and 0 <= j < 100 }",
"{ A[j,i] -> B[i,j] }",
"{ A[j,i] : 0 <= i < 10 and 0 <= j < 100 }" },
{ "{ rat: B[i,j] : 0 <= i, j and 3 i + 5 j <= 100 }",
"{ A[a,b] -> B[a/2,b/6] }",
"{ rat: A[a,b] : 0 <= a, b and 9 a + 5 b <= 600 }" },
{ "{ B[i,j] : 0 <= i, j and 3 i + 5 j <= 100 }",
"{ A[a,b] -> B[a/2,b/6] }",
"{ A[a,b] : 0 <= a, b and 9 a + 5 b <= 600 and "
"exists i,j : a = 2 i and b = 6 j }" },
{ "[n] -> { S[i] : 0 <= i <= 100 }", "[n] -> { S[n] }",
"[n] -> { : 0 <= n <= 100 }" },
{ "{ B[i] : 0 <= i < 100 and exists a : i = 4 a }",
"{ A[a] -> B[2a] }",
"{ A[a] : 0 <= a < 50 and exists b : a = 2 b }" },
{ "{ B[i] : 0 <= i < 100 and exists a : i = 4 a }",
"{ A[a] -> B[([a/2])] }",
"{ A[a] : 0 <= a < 200 and exists b : [a/2] = 4 b }" },
{ "{ B[i,j,k] : 0 <= i,j,k <= 100 }",
"{ A[a] -> B[a,a,a/3] }",
"{ A[a] : 0 <= a <= 100 and exists b : a = 3 b }" },
{ "{ B[i,j] : j = [(i)/2] } ", "{ A[i,j] -> B[i/3,j] }",
"{ A[i,j] : j = [(i)/6] and exists a : i = 3 a }" },
};

static int test_preimage_basic_set(isl_ctx *ctx)
{
int i;
isl_basic_set *bset1, *bset2;
isl_multi_aff *ma;
int equal;

for (i = 0; i < ARRAY_SIZE(preimage_tests); ++i) {
bset1 = isl_basic_set_read_from_str(ctx, preimage_tests[i].set);
ma = isl_multi_aff_read_from_str(ctx, preimage_tests[i].ma);
bset2 = isl_basic_set_read_from_str(ctx, preimage_tests[i].res);
bset1 = isl_basic_set_preimage_multi_aff(bset1, ma);
equal = isl_basic_set_is_equal(bset1, bset2);
isl_basic_set_free(bset1);
isl_basic_set_free(bset2);
if (equal < 0)
return -1;
if (!equal)
isl_die(ctx, isl_error_unknown, "bad preimage",
return -1);
}

return 0;
}

struct {
const char *map;
const char *ma;
const char *res;
} preimage_domain_tests[] = {
{ "{ B[i,j] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }",
"{ A[j,i] -> B[i,j] }",
"{ A[j,i] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }" },
{ "{ B[i] -> C[i]; D[i] -> E[i] }",
"{ A[i] -> B[i + 1] }",
"{ A[i] -> C[i + 1] }" },
{ "{ B[i] -> C[i]; B[i] -> E[i] }",
"{ A[i] -> B[i + 1] }",
"{ A[i] -> C[i + 1]; A[i] -> E[i + 1] }" },
{ "{ B[i] -> C[([i/2])] }",
"{ A[i] -> B[2i] }",
"{ A[i] -> C[i] }" },
{ "{ B[i,j] -> C[([i/2]), ([(i+j)/3])] }",
"{ A[i] -> B[([i/5]), ([i/7])] }",
"{ A[i] -> C[([([i/5])/2]), ([(([i/5])+([i/7]))/3])] }" },
{ "[N] -> { B[i] -> C[([N/2]), i, ([N/3])] }",
"[N] -> { A[] -> B[([N/5])] }",
"[N] -> { A[] -> C[([N/2]), ([N/5]), ([N/3])] }" },
{ "{ B[i] -> C[i] : exists a : i = 5 a }",
"{ A[i] -> B[2i] }",
"{ A[i] -> C[2i] : exists a : 2i = 5 a }" },
{ "{ B[i] -> C[i] : exists a : i = 2 a; "
"B[i] -> D[i] : exists a : i = 2 a + 1 }",
"{ A[i] -> B[2i] }",
"{ A[i] -> C[2i] }" },
{ "{ A[i] -> B[i] }", "{ C[i] -> A[(i + floor(i/3))/2] }",
"{ C[i] -> B[j] : 2j = i + floor(i/3) }" },
};

static int test_preimage_union_map(isl_ctx *ctx)
{
int i;
isl_union_map *umap1, *umap2;
isl_multi_aff *ma;
int equal;

for (i = 0; i < ARRAY_SIZE(preimage_domain_tests); ++i) {
umap1 = isl_union_map_read_from_str(ctx,
preimage_domain_tests[i].map);
ma = isl_multi_aff_read_from_str(ctx,
preimage_domain_tests[i].ma);
umap2 = isl_union_map_read_from_str(ctx,
preimage_domain_tests[i].res);
umap1 = isl_union_map_preimage_domain_multi_aff(umap1, ma);
equal = isl_union_map_is_equal(umap1, umap2);
isl_union_map_free(umap1);
isl_union_map_free(umap2);
if (equal < 0)
return -1;
if (!equal)
isl_die(ctx, isl_error_unknown, "bad preimage",
return -1);
}

return 0;
}

static int test_preimage(isl_ctx *ctx)
{
if (test_preimage_basic_set(ctx) < 0)
return -1;
if (test_preimage_union_map(ctx) < 0)
return -1;

return 0;
}

struct {
const char *ma1;
const char *ma;
Expand Down Expand Up @@ -10813,7 +10723,6 @@ struct {
{ "list", &test_list },
{ "align parameters", &test_align_parameters },
{ "drop unused parameters", &test_drop_unused_parameters },
{ "preimage", &test_preimage },
{ "pullback", &test_pullback },
{ "AST", &test_ast },
{ "AST build", &test_ast_build },
Expand All @@ -10825,6 +10734,7 @@ struct {
{ "slice", &test_slice },
{ "fixed power", &test_fixed_power },
{ "sample", &test_sample },
{ "empty projection", &test_empty_projection },
{ "output", &test_output },
{ "vertices", &test_vertices },
{ "chambers", &test_chambers },
Expand Down
Loading