From 7ad0f5af3257dab2dc6a844178e088dc9ccdd13f Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 15 Mar 2010 16:23:39 +0100 Subject: [PATCH] iscc: add some comparison operations --- doc/isl.tex | 23 +++++++++++++++++- iscc.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/doc/isl.tex b/doc/isl.tex index ca117ef..5eae623 100644 --- a/doc/isl.tex +++ b/doc/isl.tex @@ -67,7 +67,8 @@ $m$: map, $q$: piecewise quasipolynomial, $f$: piecewise quasipolynomial fold, $l$: list, -$i$: integer +$i$: integer, +$b$: boolean } \label{t:iscc} \tablehead{ @@ -182,4 +183,24 @@ is known to be exact $l$[$i$] & the element at position $i$ in the list $l$ \\ +$b$ := $s_1$ \ai[\tt]{=} $s_2$ & is $s_1$ equal to $s_2$? +\\ +$b$ := $m_1$ \ai[\tt]{=} $m_2$ & is $m_1$ equal to $m_2$? +\\ +$b$ := $s_1$ \ai[\tt]{<=} $s_2$ & is $s_1$ a subset of $s_2$? +\\ +$b$ := $m_1$ \ai[\tt]{<=} $m_2$ & is $m_1$ a subset of $m_2$? +\\ +$b$ := $s_1$ \ai[\tt]{<} $s_2$ & is $s_1$ a proper subset of $s_2$? +\\ +$b$ := $m_1$ \ai[\tt]{<} $m_2$ & is $m_1$ a proper subset of $m_2$? +\\ +$b$ := $s_1$ \ai[\tt]{>=} $s_2$ & is $s_1$ a superset of $s_2$? +\\ +$b$ := $m_1$ \ai[\tt]{>=} $m_2$ & is $m_1$ a superset of $m_2$? +\\ +$b$ := $s_1$ \ai[\tt]{>} $s_2$ & is $s_1$ a proper superset of $s_2$? +\\ +$b$ := $m_1$ \ai[\tt]{>} $m_2$ & is $m_1$ a proper superset of $m_2$? +\\ \end{supertabular} diff --git a/iscc.c b/iscc.c index 61a3f56..426cab3 100644 --- a/iscc.c +++ b/iscc.c @@ -47,6 +47,65 @@ struct isl_obj_vtable isl_obj_bool_vtable = { }; #define isl_obj_bool (&isl_obj_bool_vtable) +int *isl_bool_from_int(int res) +{ + return res < 0 ? &isl_bool_error : res ? &isl_bool_true : &isl_bool_false; +} + +int *map_is_equal(__isl_take isl_map *map1, __isl_take isl_map *map2) +{ + int res = isl_map_is_equal(map1, map2); + isl_map_free(map1); + isl_map_free(map2); + return isl_bool_from_int(res); +} +int *set_is_equal(__isl_take isl_set *set1, __isl_take isl_set *set2) +{ + return map_is_equal((isl_map *)set1, (isl_map *)set2); +} + +int *map_is_subset(__isl_take isl_map *map1, __isl_take isl_map *map2) +{ + int res = isl_map_is_subset(map1, map2); + isl_map_free(map1); + isl_map_free(map2); + return isl_bool_from_int(res); +} +int *set_is_subset(__isl_take isl_set *set1, __isl_take isl_set *set2) +{ + return map_is_subset((isl_map *)set1, (isl_map *)set2); +} + +int *map_is_strict_subset(__isl_take isl_map *map1, __isl_take isl_map *map2) +{ + int res = isl_map_is_strict_subset(map1, map2); + isl_map_free(map1); + isl_map_free(map2); + return isl_bool_from_int(res); +} +int *set_is_strict_subset(__isl_take isl_set *set1, __isl_take isl_set *set2) +{ + return map_is_strict_subset((isl_map *)set1, (isl_map *)set2); +} + +int *map_is_superset(__isl_take isl_map *map1, __isl_take isl_map *map2) +{ + return map_is_subset(map2, map1); +} +int *set_is_superset(__isl_take isl_set *set1, __isl_take isl_set *set2) +{ + return set_is_subset(set2, set1); +} + +int *map_is_strict_superset(__isl_take isl_map *map1, __isl_take isl_map *map2) +{ + return map_is_strict_subset(map2, map1); +} +int *set_is_strict_superset(__isl_take isl_set *set1, __isl_take isl_set *set2) +{ + return set_is_strict_subset(set2, set1); +} + extern struct isl_obj_vtable isl_obj_list_vtable; #define isl_obj_list (&isl_obj_list_vtable) @@ -159,6 +218,26 @@ struct isc_bin_op bin_ops[] = { (isc_bin_op_fn) &isl_map_apply_range }, { ISL_TOKEN_TO, isl_obj_set, isl_obj_set, isl_obj_map, (isc_bin_op_fn) &isl_map_from_domain_and_range }, + { '=', isl_obj_set, isl_obj_set, isl_obj_bool, + (isc_bin_op_fn) &set_is_equal }, + { '=', isl_obj_map, isl_obj_map, isl_obj_bool, + (isc_bin_op_fn) &map_is_equal }, + { ISL_TOKEN_LE, isl_obj_set, isl_obj_set, isl_obj_bool, + (isc_bin_op_fn) &set_is_subset }, + { ISL_TOKEN_LE, isl_obj_map, isl_obj_map, isl_obj_bool, + (isc_bin_op_fn) &map_is_subset }, + { ISL_TOKEN_LT, isl_obj_set, isl_obj_set, isl_obj_bool, + (isc_bin_op_fn) &set_is_strict_subset }, + { ISL_TOKEN_LT, isl_obj_map, isl_obj_map, isl_obj_bool, + (isc_bin_op_fn) &map_is_strict_subset }, + { ISL_TOKEN_GE, isl_obj_set, isl_obj_set, isl_obj_bool, + (isc_bin_op_fn) &set_is_superset }, + { ISL_TOKEN_GE, isl_obj_map, isl_obj_map, isl_obj_bool, + (isc_bin_op_fn) &map_is_superset }, + { ISL_TOKEN_GT, isl_obj_set, isl_obj_set, isl_obj_bool, + (isc_bin_op_fn) &set_is_strict_superset }, + { ISL_TOKEN_GT, isl_obj_map, isl_obj_map, isl_obj_bool, + (isc_bin_op_fn) &map_is_strict_superset }, { '+', isl_obj_pw_qpolynomial, isl_obj_pw_qpolynomial, isl_obj_pw_qpolynomial, (isc_bin_op_fn) &isl_pw_qpolynomial_add }, -- 2.11.4.GIT