Ejemplo n.º 1
0
/* Compute the size of a bounding box around the origin and "set",
 * where "set" is assumed to contain only non-negative elements.
 * In particular, compute the maximal value of "set" in each direction
 * and add one.
 */
__isl_give isl_multi_pw_aff *ppcg_size_from_extent(__isl_take isl_set *set)
{
	int i, n;
	isl_multi_pw_aff *mpa;

	n = isl_set_dim(set, isl_dim_set);
	mpa = isl_multi_pw_aff_zero(isl_set_get_space(set));
	for (i = 0; i < n; ++i) {
		isl_space *space;
		isl_aff *one;
		isl_pw_aff *bound;

		if (!isl_set_dim_has_upper_bound(set, isl_dim_set, i)) {
			const char *name;
			name = isl_set_get_tuple_name(set);
			if (!name)
				name = "";
			fprintf(stderr, "unable to determine extent of '%s' "
				"in dimension %d\n", name, i);
			set = isl_set_free(set);
		}
		bound = isl_set_dim_max(isl_set_copy(set), i);

		space = isl_pw_aff_get_domain_space(bound);
		one = isl_aff_zero_on_domain(isl_local_space_from_space(space));
		one = isl_aff_add_constant_si(one, 1);
		bound = isl_pw_aff_add(bound, isl_pw_aff_from_aff(one));
		mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, bound);
	}
	isl_set_free(set);

	return mpa;
}
Ejemplo n.º 2
0
/* Construct an affine expression pet_expr that evaluates
 * to the constant "val" on "space".
 */
static __isl_give pet_expr *universally(__isl_take isl_space *space, int val)
{
	isl_ctx *ctx;
	isl_local_space *ls;
	isl_aff *aff;
	isl_multi_pw_aff *mpa;

	ctx = isl_space_get_ctx(space);
	ls = isl_local_space_from_space(space);
	aff = isl_aff_val_on_domain(ls, isl_val_int_from_si(ctx, val));
	mpa = isl_multi_pw_aff_from_pw_aff(isl_pw_aff_from_aff(aff));

	return pet_expr_from_index(mpa);
}