summaryrefslogtreecommitdiffstats
path: root/polly/lib/External/isl/interface
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2018-08-09 05:07:05 +0000
committerTobias Grosser <tobias@grosser.es>2018-08-09 05:07:05 +0000
commit26269d34d47a4008ee2c1b87e6ac2237589078ef (patch)
treea0dbc30cd538ebe8a92d4523867ad52ab1c0de71 /polly/lib/External/isl/interface
parent954eab1087ea48b6276ceb4d6d44425c715c3834 (diff)
downloadbcm5719-llvm-26269d34d47a4008ee2c1b87e6ac2237589078ef.tar.gz
bcm5719-llvm-26269d34d47a4008ee2c1b87e6ac2237589078ef.zip
Update to isl-0.20-65-gb822a210
This update fixes https://https:/llvm.org/PR38348. Thanks Michael for reporting the issue to isl and Sven for fixing the issue. llvm-svn: 339311
Diffstat (limited to 'polly/lib/External/isl/interface')
-rw-r--r--polly/lib/External/isl/interface/cpp.cc141
-rw-r--r--polly/lib/External/isl/interface/cpp.h6
-rw-r--r--polly/lib/External/isl/interface/generator.cc17
-rw-r--r--polly/lib/External/isl/interface/generator.h1
-rw-r--r--polly/lib/External/isl/interface/isl.py11
-rw-r--r--polly/lib/External/isl/interface/python.cc4
6 files changed, 121 insertions, 59 deletions
diff --git a/polly/lib/External/isl/interface/cpp.cc b/polly/lib/External/isl/interface/cpp.cc
index 67deece27ac..a52e6fec06b 100644
--- a/polly/lib/External/isl/interface/cpp.cc
+++ b/polly/lib/External/isl/interface/cpp.cc
@@ -448,6 +448,50 @@ static void print_throw_NULL_input(ostream &os)
osprintf(os, " exception::throw_NULL_input(__FILE__, __LINE__);\n");
}
+/* Print code that checks that "ptr" is not NULL at input.
+ *
+ * Omit the check if checked C++ bindings are being generated.
+ */
+void cpp_generator::print_check_ptr(ostream &os, const char *ptr)
+{
+ if (checked)
+ return;
+
+ osprintf(os, " if (!%s)\n", ptr);
+ print_throw_NULL_input(os);
+}
+
+/* Print code that checks that "ptr" is not NULL at input and
+ * that saves a copy of the isl_ctx of "ptr" for a later check.
+ *
+ * Omit the check if checked C++ bindings are being generated.
+ */
+void cpp_generator::print_check_ptr_start(ostream &os, const isl_class &clazz,
+ const char *ptr)
+{
+ if (checked)
+ return;
+
+ print_check_ptr(os, ptr);
+ osprintf(os, " auto ctx = %s_get_ctx(%s);\n", clazz.name.c_str(), ptr);
+ print_on_error_continue(os);
+}
+
+/* Print code that checks that "ptr" is not NULL at the end.
+ * A copy of the isl_ctx is expected to have been saved by
+ * code generated by print_check_ptr_start.
+ *
+ * Omit the check if checked C++ bindings are being generated.
+ */
+void cpp_generator::print_check_ptr_end(ostream &os, const char *ptr)
+{
+ if (checked)
+ return;
+
+ osprintf(os, " if (!%s)\n", ptr);
+ print_throw_last_error(os);
+}
+
/* Print implementation of global factory functions to "os".
*
* Each class has two global factory functions:
@@ -470,26 +514,15 @@ void cpp_generator::print_class_factory_impl(ostream &os,
const char *cppname = cppstring.c_str();
osprintf(os, "%s manage(__isl_take %s *ptr) {\n", cppname, name);
- if (!checked) {
- osprintf(os, " if (!ptr)\n");
- print_throw_NULL_input(os);
- }
+ print_check_ptr(os, "ptr");
osprintf(os, " return %s(ptr);\n", cppname);
osprintf(os, "}\n");
osprintf(os, "%s manage_copy(__isl_keep %s *ptr) {\n", cppname,
name);
- if (!checked) {
- osprintf(os, " if (!ptr)\n");
- print_throw_NULL_input(os);
- osprintf(os, " auto ctx = %s_get_ctx(ptr);\n", name);
- print_on_error_continue(os);
- }
+ print_check_ptr_start(os, clazz, "ptr");
osprintf(os, " ptr = %s_copy(ptr);\n", name);
- if (!checked) {
- osprintf(os, " if (!ptr)\n");
- print_throw_last_error(os);
- }
+ print_check_ptr_end(os, "ptr");
osprintf(os, " return %s(ptr);\n", cppname);
osprintf(os, "}\n");
}
@@ -519,7 +552,6 @@ void cpp_generator::print_private_constructors_impl(ostream &os,
void cpp_generator::print_public_constructors_impl(ostream &os,
const isl_class &clazz)
{
- const char *name = clazz.name.c_str();
std::string cppstring = type2cpp(clazz);
const char *cppname = cppstring.c_str();
@@ -527,17 +559,9 @@ void cpp_generator::print_public_constructors_impl(ostream &os,
osprintf(os, "%s::%s(const %s &obj)\n : ptr(nullptr)\n",
cppname, cppname, cppname);
osprintf(os, "{\n");
- if (!checked) {
- osprintf(os, " if (!obj.ptr)\n");
- print_throw_NULL_input(os);
- osprintf(os, " auto ctx = %s_get_ctx(obj.ptr);\n", name);
- print_on_error_continue(os);
- }
+ print_check_ptr_start(os, clazz, "obj.ptr");
osprintf(os, " ptr = obj.copy();\n");
- if (!checked) {
- osprintf(os, " if (obj.ptr && !ptr)\n");
- print_throw_last_error(os);
- }
+ print_check_ptr_end(os, "ptr");
osprintf(os, "}\n");
}
@@ -879,16 +903,10 @@ void cpp_generator::print_exceptional_execution_check(ostream &os,
print_throw_last_error(os);
}
-/* Print definition for "method" in class "clazz" to "os".
- *
- * "kind" specifies the kind of method that should be generated.
+/* Print the return statement of the C++ method corresponding
+ * to the C function "method" in class "clazz" to "os".
*
- * This method distinguishes three kinds of methods: member methods, static
- * methods, and constructors.
- *
- * Member methods call "method" by passing to the underlying isl function the
- * isl object belonging to "this" as first argument and the remaining arguments
- * as subsequent arguments. The result of the isl function is returned as a new
+ * The result of the isl function is returned as a new
* object if the underlying isl function returns an isl_* ptr, as a bool
* if the isl function returns an isl_bool, as void if the isl functions
* returns an isl_stat,
@@ -898,6 +916,38 @@ void cpp_generator::print_exceptional_execution_check(ostream &os,
* then an isl_bool return type is transformed into a boolean and
* an isl_stat into a stat since no exceptions can be generated
* on negative results from the isl function.
+ */
+void cpp_generator::print_method_return(ostream &os, const isl_class &clazz,
+ FunctionDecl *method)
+{
+ QualType return_type = method->getReturnType();
+
+ if (is_isl_type(return_type) ||
+ (checked &&
+ (is_isl_bool(return_type) || is_isl_stat(return_type)))) {
+ osprintf(os, " return manage(res);\n");
+ } else if (is_isl_stat(return_type)) {
+ osprintf(os, " return;\n");
+ } else if (is_string(return_type)) {
+ osprintf(os, " std::string tmp(res);\n");
+ if (gives(method))
+ osprintf(os, " free(res);\n");
+ osprintf(os, " return tmp;\n");
+ } else {
+ osprintf(os, " return res;\n");
+ }
+}
+
+/* Print definition for "method" in class "clazz" to "os".
+ *
+ * "kind" specifies the kind of method that should be generated.
+ *
+ * This method distinguishes three kinds of methods: member methods, static
+ * methods, and constructors.
+ *
+ * Member methods call "method" by passing to the underlying isl function the
+ * isl object belonging to "this" as first argument and the remaining arguments
+ * as subsequent arguments.
*
* Static methods call "method" by passing all arguments to the underlying isl
* function, as no this-pointer is available. The result is a newly managed
@@ -925,9 +975,6 @@ void cpp_generator::print_method_impl(ostream &os, const isl_class &clazz,
{
string methodname = method->getName();
int num_params = method->getNumParams();
- QualType return_type = method->getReturnType();
- string rettype_str = type2cpp(return_type);
- bool has_callback = false;
print_method_header(os, clazz, method, false, kind);
osprintf(os, "{\n");
@@ -938,7 +985,6 @@ void cpp_generator::print_method_impl(ostream &os, const isl_class &clazz,
for (int i = 0; i < num_params; ++i) {
ParmVarDecl *param = method->getParamDecl(i);
if (is_callback(param->getType())) {
- has_callback = true;
num_params -= 1;
print_callback_local(os, param);
}
@@ -963,19 +1009,8 @@ void cpp_generator::print_method_impl(ostream &os, const isl_class &clazz,
print_exceptional_execution_check(os, method);
if (kind == function_kind_constructor) {
osprintf(os, " ptr = res;\n");
- } else if (is_isl_type(return_type) ||
- (checked &&
- (is_isl_bool(return_type) || is_isl_stat(return_type)))) {
- osprintf(os, " return manage(res);\n");
- } else if (has_callback) {
- osprintf(os, " return %s(res);\n", rettype_str.c_str());
- } else if (is_string(return_type)) {
- osprintf(os, " std::string tmp(res);\n");
- if (gives(method))
- osprintf(os, " free(res);\n");
- osprintf(os, " return tmp;\n");
} else {
- osprintf(os, " return res;\n");
+ print_method_return(os, clazz, method);
}
osprintf(os, "}\n");
@@ -1109,7 +1144,7 @@ string cpp_generator::generate_callback_args(QualType type, bool cpp)
const FunctionProtoType *callback;
int num_params;
- callback = type->getPointeeType()->getAs<FunctionProtoType>();
+ callback = extract_prototype(type);
num_params = callback->getNumArgs();
if (cpp)
num_params--;
@@ -1145,7 +1180,7 @@ string cpp_generator::generate_callback_args(QualType type, bool cpp)
string cpp_generator::generate_callback_type(QualType type)
{
std::string type_str;
- const FunctionProtoType *callback = type->getPointeeType()->getAs<FunctionProtoType>();
+ const FunctionProtoType *callback = extract_prototype(type);
QualType return_type = callback->getReturnType();
string rettype_str = type2cpp(return_type);
@@ -1271,7 +1306,7 @@ void cpp_generator::print_callback_local(ostream &os, ParmVarDecl *param)
c_args = generate_callback_args(ptype, false);
cpp_args = generate_callback_type(ptype);
- callback = ptype->getPointeeType()->getAs<FunctionProtoType>();
+ callback = extract_prototype(ptype);
rettype = callback->getReturnType().getAsString();
num_params = callback->getNumArgs();
diff --git a/polly/lib/External/isl/interface/cpp.h b/polly/lib/External/isl/interface/cpp.h
index b46d37f4e52..0e97c71533a 100644
--- a/polly/lib/External/isl/interface/cpp.h
+++ b/polly/lib/External/isl/interface/cpp.h
@@ -50,6 +50,10 @@ private:
FunctionDecl *method, function_kind kind);
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_private_constructors_impl(ostream &os,
const isl_class &clazz);
@@ -70,6 +74,8 @@ private:
void print_on_error_continue(ostream &os);
void print_exceptional_execution_check(ostream &os,
FunctionDecl *method);
+ void print_method_return(ostream &os, const isl_class &clazz,
+ FunctionDecl *method);
void print_method_impl(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
void print_method_param_use(ostream &os, ParmVarDecl *param,
diff --git a/polly/lib/External/isl/interface/generator.cc b/polly/lib/External/isl/interface/generator.cc
index c3572852d19..fee2347b6c5 100644
--- a/polly/lib/External/isl/interface/generator.cc
+++ b/polly/lib/External/isl/interface/generator.cc
@@ -110,13 +110,14 @@ generator::generator(SourceManager &SM, set<RecordDecl *> &exported_types,
for (in = exported_functions.begin(); in != exported_functions.end();
++in) {
- isl_class *c = method2class(*in);
+ FunctionDecl *method = *in;
+ isl_class *c = method2class(method);
+
if (!c)
continue;
- if (is_constructor(*in)) {
- c->constructors.insert(*in);
+ if (is_constructor(method)) {
+ c->constructors.insert(method);
} else {
- FunctionDecl *method = *in;
string fullname = c->name_without_type_suffix(method);
c->methods[fullname].insert(method);
}
@@ -412,6 +413,14 @@ string generator::extract_type(QualType type)
die("Cannot extract type from non-pointer type");
}
+/* Given the type of a function pointer, return the corresponding
+ * function prototype.
+ */
+const FunctionProtoType *generator::extract_prototype(QualType type)
+{
+ return type->getPointeeType()->getAs<FunctionProtoType>();
+}
+
/* If "method" is overloaded, then return its name with the suffix
* corresponding to the type of the final argument removed.
* Otherwise, simply return the name of the function.
diff --git a/polly/lib/External/isl/interface/generator.h b/polly/lib/External/isl/interface/generator.h
index 8195a36d960..2f8d88dbef8 100644
--- a/polly/lib/External/isl/interface/generator.h
+++ b/polly/lib/External/isl/interface/generator.h
@@ -75,6 +75,7 @@ public:
static bool is_string(QualType type);
static bool is_static(const isl_class &clazz, FunctionDecl *method);
static string extract_type(QualType type);
+ static const FunctionProtoType *extract_prototype(QualType type);
};
#endif /* ISL_INTERFACE_GENERATOR_H */
diff --git a/polly/lib/External/isl/interface/isl.py b/polly/lib/External/isl/interface/isl.py
index e6bdc7560f5..11c18b5c523 100644
--- a/polly/lib/External/isl/interface/isl.py
+++ b/polly/lib/External/isl/interface/isl.py
@@ -5523,6 +5523,15 @@ class val(object):
ctx = Context.getDefaultInstance()
res = isl.isl_val_one(ctx)
return val(ctx=ctx, ptr=res)
+ def pow2(arg0):
+ try:
+ if not arg0.__class__ is val:
+ arg0 = val(arg0)
+ except:
+ raise
+ ctx = arg0.ctx
+ res = isl.isl_val_pow2(isl.isl_val_copy(arg0.ptr))
+ return val(ctx=ctx, ptr=res)
def sgn(arg0):
try:
if not arg0.__class__ is val:
@@ -5640,6 +5649,8 @@ isl.isl_val_negone.restype = c_void_p
isl.isl_val_negone.argtypes = [Context]
isl.isl_val_one.restype = c_void_p
isl.isl_val_one.argtypes = [Context]
+isl.isl_val_pow2.restype = c_void_p
+isl.isl_val_pow2.argtypes = [c_void_p]
isl.isl_val_sgn.argtypes = [c_void_p]
isl.isl_val_sub.restype = c_void_p
isl.isl_val_sub.argtypes = [c_void_p, c_void_p]
diff --git a/polly/lib/External/isl/interface/python.cc b/polly/lib/External/isl/interface/python.cc
index 33a96c2d273..7e6fd182d28 100644
--- a/polly/lib/External/isl/interface/python.cc
+++ b/polly/lib/External/isl/interface/python.cc
@@ -126,8 +126,8 @@ void python_generator::print_copy(QualType type)
*/
void python_generator::print_callback(ParmVarDecl *param, int arg)
{
- QualType type = param->getOriginalType()->getPointeeType();
- const FunctionProtoType *fn = type->getAs<FunctionProtoType>();
+ QualType type = param->getOriginalType();
+ const FunctionProtoType *fn = extract_prototype(type);
unsigned n_arg = fn->getNumArgs();
printf(" exc_info = [None]\n");
OpenPOWER on IntegriCloud