isl_tab_basic_map_partial_lexopt: detect modulos and integer divisions
[isl.git] / isl_ilp_opt_val_templ.c
blob7e3520d65460774cecff0005b8b0941127ee7866
1 /*
2 * Copyright 2017 Sven Verdoolaege
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege
7 */
9 #define xCAT(A,B) A ## B
10 #define CAT(A,B) xCAT(A,B)
11 #undef TYPE
12 #define TYPE CAT(isl_,BASE)
13 #define xBFN(BASE,NAME) isl_ ## BASE ## _ ## NAME
14 #define BFN(BASE,NAME) xBFN(BASE,NAME)
16 /* Return the minimal (maximal if "max" is set) value attained
17 * by the given set dimension,
18 * independently of the parameter values and of any other dimensions.
20 * Return infinity or negative infinity if the optimal value is unbounded and
21 * NaN if "set" is empty.
23 static __isl_give isl_val *BFN(BASE,dim_opt_val)(__isl_take TYPE *set, int max,
24 int pos)
26 isl_local_space *ls;
27 isl_aff *obj;
28 isl_val *v;
30 if (BFN(BASE,check_range)(set, isl_dim_set, pos, 1) < 0)
31 goto error;
32 ls = isl_local_space_from_space(BFN(BASE,get_space)(set));
33 obj = isl_aff_var_on_domain(ls, isl_dim_set, pos);
34 v = BFN(BASE,opt_val)(set, max, obj);
35 isl_aff_free(obj);
36 BFN(BASE,free)(set);
38 return v;
39 error:
40 BFN(BASE,free)(set);
41 return NULL;