Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions gen_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, name,
class Method:
def __init__(self, cls, name, c_name,
return_semantics, return_base_type, return_ptr,
args, is_exported, is_constructor):
args, is_exported, is_constructor, is_internal):
self.cls = cls
self.name = name
assert name
Expand All @@ -128,6 +128,7 @@ def __init__(self, cls, name, c_name,
self.args = args
self.mutator_veto = False
self.is_exported = is_exported
self.is_internal = is_internal
self.is_constructor = is_constructor

if not self.is_static:
Expand Down Expand Up @@ -490,7 +491,7 @@ def get_preprocessed_header(self, fname):

# {{{ read_header

def read_header(self, fname):
def read_header(self, fname, is_internal=False):
lines = self.get_preprocessed_header(fname).split("\n")

# heed continuations, split at semicolons
Expand Down Expand Up @@ -562,13 +563,13 @@ def read_header(self, fname):
line = lines[i].strip()

if not STRUCT_DECL_RE.search(decl):
self.parse_decl(decl)
self.parse_decl(decl, is_internal)

# }}}

# {{{ parse_decl

def parse_decl(self, decl):
def parse_decl(self, decl, is_internal):
decl_match = DECL_RE.match(decl)
if decl_match is None:
print(f"WARNING: func decl regexp not matched: {decl}")
Expand Down Expand Up @@ -702,7 +703,8 @@ def parse_decl(self, decl):
cls_meth_list.append(Method(
class_name, name, c_name,
return_semantics, return_base_type, return_ptr,
args, is_exported=is_exported, is_constructor=is_constructor))
args, is_exported=is_exported, is_constructor=is_constructor,
is_internal=is_internal))

self.seen_c_names.add(c_name)

Expand Down Expand Up @@ -1394,10 +1396,18 @@ def write_exposer(outf, meth, arg_names, doc_str):
# doc_str = "(static method)\n" + doc_str

if not meth.is_exported:
doc_str = doc_str + (
"\n\n.. warning::\n\n "
"This function is not part of the officially public isl API. "
"Use at your own risk.")
if meth.is_internal:
doc_str = doc_str + (
"\n\n.. warning::\n\n "
"This function is so internal, it is not even exposed in isl's "
"public headers. We declared it on our own, in hopes that "
"isl didn't change the functions prototype. "
"Really, if you have any sense at all, don't use this.")
else:
doc_str = doc_str + (
"\n\n.. warning::\n\n "
"This function is not part of the officially public isl API. "
"Use at your own risk.")

doc_str_arg = ', "{}"'.format(doc_str.replace("\n", "\\n"))

Expand Down Expand Up @@ -1460,7 +1470,8 @@ def write_wrappers(expf, wrapf, methods):
}


def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None,
include_internal=False):
fdata = FunctionData(["."] + include_dirs)
fdata.read_header("isl/ctx.h")
fdata.read_header("isl/id.h")
Expand Down Expand Up @@ -1490,6 +1501,12 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
fdata.read_header("isl/ast_type.h")
fdata.read_header("isl/ilp.h")

if include_internal:
# We're reaching deep into isl here, to functions that we're not
# supposed to touch.
fdata.include_dirs.append("isl")
fdata.read_header("isl_equalities.h", is_internal=True)

if include_barvinok:
fdata.read_header("barvinok/isl.h")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#line 13
#include <isl/set.h>
#include <isl/mat.h>





__isl_give isl_mat *isl_mat_final_variable_compression(__isl_take isl_mat *B,
int first, __isl_give isl_mat **T2);
__isl_give isl_mat *isl_mat_variable_compression(__isl_take isl_mat *B,
__isl_give isl_mat **T2);
__isl_give isl_mat *isl_mat_parameter_compression(__isl_take isl_mat *B,
__isl_take isl_vec *d);
__isl_give isl_mat *isl_mat_parameter_compression_ext(__isl_take isl_mat *B,
__isl_take isl_mat *A);
__isl_give isl_basic_set *isl_basic_set_remove_equalities(
__isl_take isl_basic_set *bset, __isl_give isl_mat **T,
__isl_give isl_mat **T2);
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def get_config_schema():
Switch("USE_BARVINOK", False, "Include wrapper for Barvinok"),
Switch("USE_IMATH_SIO", True, "When using imath, use small-integer "
"optimization"),
Switch("INCLUDE_INTERNAL", True, "Expose infuriatingly useful "
"but sadly very internal functionality of isl"),

IncludeDir("GMP", []),
LibraryDir("GMP", []),
Expand Down Expand Up @@ -264,7 +266,11 @@ def main():
exec(compile(version_py, init_filename, "exec"), conf)

from gen_wrap import gen_wrapper
gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"])
gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"],
include_internal=conf["INCLUDE_INTERNAL"])

if conf["INCLUDE_INTERNAL"]:
EXTRA_DEFINES["ISLPY_INCLUDE_ISL_INTERNAL_HEADERS"] = 1

with open("README.rst") as readme_f:
readme = readme_f.read()
Expand Down
7 changes: 7 additions & 0 deletions src/wrapper/wrap_isl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
#include <barvinok/isl.h>
#endif

#ifdef ISLPY_INCLUDE_ISL_INTERNAL_HEADERS
// Your scientists were so preoccupied with whether or not they could, they
// didn't stop to think if they should.
// -- Dr. Ian Malcolm
#include "../../isl/isl_equalities.h"
#endif

#include <iostream>
#include <stdexcept>
#include <pybind11/pybind11.h>
Expand Down