add isl_basic_map_n_constraint

In analogy with isl_basic_set_n_constraint.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
add isl_basic_{set,map}_get_constraint_list

It is sometimes more convenient to manipulate a list of constraints
rather than to iterate over them individually, for example to sort
the constraints.  In fact, the AST generator already works this way
but uses a private implementation of isl_basic_set_get_constraint_list.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c: use isl_basic_set_get_constraint_list

Use the public isl_basic_set_get_constraint_list function rather
than the private copy we had.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_build_expr_from_basic_set: operate on list of constraints

That is, instead of iterating over the constraint of the input basic set,
first obtain the list of constraints and then iterate over this list.
Obtaining an explicit list first makes it easier to sort the constraints.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
add isl_constraint_plain_cmp

This will be useful for sorting constraints in the AST generator.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
add isl_int_abs_cmp

We will need this in the next commit.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
add isl_constraint_cmp_last_non_zero

This comparison function is somewhat tailored to its use by the AST
generator in the next commit, but it is easier to implement it in
the isl core than in the AST generator itself.  Since we only want
to use public functions in the AST generator, we need to make this
comparison function public too.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_build_expr_from_basic_set: sort constraints

This should make the AST generation output slightly less sensitive
to the internal representation of core isl.
Moreover, by placing constraints that do not involve integer division
before those that do, we can more easily exploit the earlier constraints
to try and simplify the later constraints in the next commit.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_build_expr_from_basic_set: exploit earlier constraints

In particular, exploit the information in constraints that do not
involve integer divisions to try and simplify the integer divisions
in the constraints that do contain them.

For example, the guard

    if (n >= 0 && n >= 4 * floord(n, 4) + 2)

can be simplified to

    if (n >= 0 && n % 4 >= 2)

since the value of the "n >= 4 * floord(n, 4) + 2" is only relevant
if "n >= 0" is true, in which case the argument of the integer division
is known to be non-negative and the integer division can be converted
to a C-like modulo expression.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>