/* Extract a common guard from the grafts in "list" that can be hoisted * out of the current level. If no such guard can be found, then return * a universal set. * * If all the grafts in the list have the same guard and if this guard * is independent of the current level, then it can be hoisted out. * Otherwise, we return the unshifted simple hull of the guards. * * The special case for equal guards is needed in case those guards * are non-convex. Taking the simple hull would remove information * and would not allow for these guards to be hoisted completely. */ static __isl_give isl_set *extract_hoistable_guard( __isl_keep isl_ast_graft_list *list, __isl_keep isl_ast_build *build) { int i, n; int depth; isl_ast_graft *graft_0; int equal; isl_set *guard; if (!list || !build) return NULL; n = isl_ast_graft_list_n_ast_graft(list); if (n == 0) return isl_set_universe(isl_ast_build_get_space(build, 1)); equal = equal_independent_guards(list, build); if (equal < 0) return NULL; graft_0 = isl_ast_graft_list_get_ast_graft(list, 0); if (!graft_0) return NULL; guard = isl_set_copy(graft_0->guard); isl_ast_graft_free(graft_0); if (equal) return guard; depth = isl_ast_build_get_depth(build); if (depth < isl_set_dim(guard, isl_dim_set)) { guard = isl_set_remove_divs_involving_dims(guard, isl_dim_set, depth, 1); guard = isl_set_eliminate(guard, isl_dim_set, depth, 1); guard = isl_set_compute_divs(guard); } for (i = 1; i < n; ++i) { isl_ast_graft *graft; isl_basic_set *hull; int is_universe; is_universe = isl_set_plain_is_universe(guard); if (is_universe < 0) guard = isl_set_free(guard); if (is_universe) break; graft = isl_ast_graft_list_get_ast_graft(list, i); if (!graft) { guard = isl_set_free(guard); break; } guard = isl_set_union(guard, isl_set_copy(graft->guard)); hull = isl_set_unshifted_simple_hull(guard); guard = isl_set_from_basic_set(hull); isl_ast_graft_free(graft); } return guard; }
int isl_set_foreach_point(__isl_keep isl_set *set, int (*fn)(__isl_take isl_point *pnt, void *user), void *user) { struct isl_foreach_point fp = { { &foreach_point }, fn, user }; int i; if (!set) return -1; fp.dim = isl_set_get_dim(set); if (!fp.dim) return -1; set = isl_set_copy(set); set = isl_set_cow(set); set = isl_set_make_disjoint(set); set = isl_set_compute_divs(set); if (!set) goto error; for (i = 0; i < set->n; ++i) if (isl_basic_set_scan(isl_basic_set_copy(set->p[i]), &fp.callback) < 0) goto error; isl_set_free(set); isl_dim_free(fp.dim); return 0; error: isl_set_free(set); isl_dim_free(fp.dim); return -1; }
/* Hoist "guard" out of the current level (given by "build"). * * In particular, eliminate the dimension corresponding to the current depth. */ static __isl_give isl_set *hoist_guard(__isl_take isl_set *guard, __isl_keep isl_ast_build *build) { int depth; depth = isl_ast_build_get_depth(build); if (depth < isl_set_dim(guard, isl_dim_set)) { guard = isl_set_remove_divs_involving_dims(guard, isl_dim_set, depth, 1); guard = isl_set_eliminate(guard, isl_dim_set, depth, 1); guard = isl_set_compute_divs(guard); } return guard; }
/// Translate a isl_set to a ScopLib matrix. /// /// @param PS The set to be translated /// @return A ScopLib Matrix scoplib_matrix_p ScopLib::domainToMatrix(__isl_take isl_set *set) { set = isl_set_compute_divs (set); set = isl_set_align_divs (set); // Initialize the matrix. unsigned NbRows, NbColumns; NbRows = 0; NbColumns = isl_set_n_dim(set) + isl_set_n_param(set) + 2; scoplib_matrix_p matrix = scoplib_matrix_malloc(NbRows, NbColumns); // Copy the content into the matrix. isl_set_foreach_basic_set(set, &domainToMatrix_basic_set, matrix); isl_set_free(set); return matrix; }
int isl_set_scan(__isl_take isl_set *set, struct isl_scan_callback *callback) { int i; if (!set || !callback) goto error; set = isl_set_cow(set); set = isl_set_make_disjoint(set); set = isl_set_compute_divs(set); if (!set) goto error; for (i = 0; i < set->n; ++i) if (isl_basic_set_scan(isl_basic_set_copy(set->p[i]), callback) < 0) goto error; isl_set_free(set); return 0; error: isl_set_free(set); return -1; }