2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
21 __isl_give isl_int_obj *isl_int_obj_alloc(isl_ctx *ctx, isl_int v)
25 i = isl_alloc_type(ctx, isl_int_obj);
38 __isl_give isl_int_obj *isl_int_obj_copy(__isl_keep isl_int_obj *i)
47 __isl_give isl_int_obj *isl_int_obj_dup(__isl_keep isl_int_obj *i)
52 return isl_int_obj_alloc(i->ctx, i->v);
55 __isl_give isl_int_obj *isl_int_obj_cow(__isl_take isl_int_obj *i)
63 return isl_int_obj_dup(i);
66 void isl_int_obj_free(__isl_take isl_int_obj *i)
74 isl_ctx_deref(i->ctx);
79 __isl_give isl_int_obj *isl_int_obj_add(__isl_take isl_int_obj *i1,
80 __isl_take isl_int_obj *i2)
82 i1 = isl_int_obj_cow(i1);
86 isl_int_add(i1->v, i1->v, i2->v);
96 __isl_give isl_int_obj *isl_int_obj_sub(__isl_take isl_int_obj *i1,
97 __isl_take isl_int_obj *i2)
99 i1 = isl_int_obj_cow(i1);
103 isl_int_sub(i1->v, i1->v, i2->v);
105 isl_int_obj_free(i2);
108 isl_int_obj_free(i1);
109 isl_int_obj_free(i2);
113 __isl_give isl_int_obj *isl_int_obj_mul(__isl_take isl_int_obj *i1,
114 __isl_take isl_int_obj *i2)
116 i1 = isl_int_obj_cow(i1);
120 isl_int_mul(i1->v, i1->v, i2->v);
122 isl_int_obj_free(i2);
125 isl_int_obj_free(i1);
126 isl_int_obj_free(i2);
130 void isl_int_obj_get_int(__isl_keep isl_int_obj *i, isl_int *v)
134 isl_int_set(*v, i->v);
137 static void *isl_obj_int_copy(void *v)
139 return isl_int_obj_copy((isl_int_obj *)v);
142 static void isl_obj_int_free(void *v)
144 isl_int_obj_free((isl_int_obj *)v);
147 static __isl_give isl_printer *isl_obj_int_print(__isl_take isl_printer *p,
151 return isl_printer_print_isl_int(p, i->v);
154 static void *isl_obj_int_add(void *v1, void *v2)
156 return isl_int_obj_add((isl_int_obj *)v1, (isl_int_obj *)v2);
159 struct isl_obj_vtable isl_obj_int_vtable = {
166 static void *isl_obj_map_copy(void *v)
168 return isl_map_copy((struct isl_map *)v);
171 static void isl_obj_map_free(void *v)
173 isl_map_free((struct isl_map *)v);
176 static __isl_give isl_printer *isl_obj_map_print(__isl_take isl_printer *p,
179 return isl_printer_print_map(p, (struct isl_map *)v);
182 static void *isl_obj_map_add(void *v1, void *v2)
184 return isl_map_union((struct isl_map *)v1, (struct isl_map *)v2);
187 struct isl_obj_vtable isl_obj_map_vtable = {
194 static void *isl_obj_union_map_copy(void *v)
196 return isl_union_map_copy((isl_union_map *)v);
199 static void isl_obj_union_map_free(void *v)
201 isl_union_map_free((isl_union_map *)v);
204 static __isl_give isl_printer *isl_obj_union_map_print(__isl_take isl_printer *p,
207 return isl_printer_print_union_map(p, (isl_union_map *)v);
210 static void *isl_obj_union_map_add(void *v1, void *v2)
212 return isl_union_map_union((isl_union_map *)v1, (isl_union_map *)v2);
215 struct isl_obj_vtable isl_obj_union_map_vtable = {
216 isl_obj_union_map_copy,
217 isl_obj_union_map_add,
218 isl_obj_union_map_print,
219 isl_obj_union_map_free
222 static void *isl_obj_set_copy(void *v)
224 return isl_set_copy((struct isl_set *)v);
227 static void isl_obj_set_free(void *v)
229 isl_set_free((struct isl_set *)v);
232 static __isl_give isl_printer *isl_obj_set_print(__isl_take isl_printer *p,
235 return isl_printer_print_set(p, (struct isl_set *)v);
238 static void *isl_obj_set_add(void *v1, void *v2)
240 return isl_set_union((struct isl_set *)v1, (struct isl_set *)v2);
243 struct isl_obj_vtable isl_obj_set_vtable = {
250 static void *isl_obj_union_set_copy(void *v)
252 return isl_union_set_copy((isl_union_set *)v);
255 static void isl_obj_union_set_free(void *v)
257 isl_union_set_free((isl_union_set *)v);
260 static __isl_give isl_printer *isl_obj_union_set_print(__isl_take isl_printer *p,
263 return isl_printer_print_union_set(p, (isl_union_set *)v);
266 static void *isl_obj_union_set_add(void *v1, void *v2)
268 return isl_union_set_union((isl_union_set *)v1, (isl_union_set *)v2);
271 struct isl_obj_vtable isl_obj_union_set_vtable = {
272 isl_obj_union_set_copy,
273 isl_obj_union_set_add,
274 isl_obj_union_set_print,
275 isl_obj_union_set_free
278 static void *isl_obj_none_copy(void *v)
283 static void isl_obj_none_free(void *v)
287 static __isl_give isl_printer *isl_obj_none_print(__isl_take isl_printer *p,
293 static void *isl_obj_none_add(void *v1, void *v2)
298 struct isl_obj_vtable isl_obj_none_vtable = {
305 static void *isl_obj_pw_qp_copy(void *v)
307 return isl_pw_qpolynomial_copy((struct isl_pw_qpolynomial *)v);
310 static void isl_obj_pw_qp_free(void *v)
312 isl_pw_qpolynomial_free((struct isl_pw_qpolynomial *)v);
315 static __isl_give isl_printer *isl_obj_pw_qp_print(__isl_take isl_printer *p,
318 return isl_printer_print_pw_qpolynomial(p,
319 (struct isl_pw_qpolynomial *)v);
322 static void *isl_obj_pw_qp_add(void *v1, void *v2)
324 return isl_pw_qpolynomial_add((struct isl_pw_qpolynomial *)v1,
325 (struct isl_pw_qpolynomial *)v2);
328 struct isl_obj_vtable isl_obj_pw_qpolynomial_vtable = {
335 static void *isl_obj_union_pw_qp_copy(void *v)
337 return isl_union_pw_qpolynomial_copy((struct isl_union_pw_qpolynomial *)v);
340 static void isl_obj_union_pw_qp_free(void *v)
342 isl_union_pw_qpolynomial_free((struct isl_union_pw_qpolynomial *)v);
345 static __isl_give isl_printer *isl_obj_union_pw_qp_print(
346 __isl_take isl_printer *p, void *v)
348 return isl_printer_print_union_pw_qpolynomial(p,
349 (struct isl_union_pw_qpolynomial *)v);
352 static void *isl_obj_union_pw_qp_add(void *v1, void *v2)
354 return isl_union_pw_qpolynomial_add(
355 (struct isl_union_pw_qpolynomial *)v1,
356 (struct isl_union_pw_qpolynomial *)v2);
359 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_vtable = {
360 isl_obj_union_pw_qp_copy,
361 isl_obj_union_pw_qp_add,
362 isl_obj_union_pw_qp_print,
363 isl_obj_union_pw_qp_free
366 static void *isl_obj_pw_qpf_copy(void *v)
368 return isl_pw_qpolynomial_fold_copy((struct isl_pw_qpolynomial_fold *)v);
371 static void isl_obj_pw_qpf_free(void *v)
373 isl_pw_qpolynomial_fold_free((struct isl_pw_qpolynomial_fold *)v);
376 static __isl_give isl_printer *isl_obj_pw_qpf_print(__isl_take isl_printer *p,
379 return isl_printer_print_pw_qpolynomial_fold(p,
380 (struct isl_pw_qpolynomial_fold *)v);
383 static void *isl_obj_pw_qpf_add(void *v1, void *v2)
385 return isl_pw_qpolynomial_fold_fold((struct isl_pw_qpolynomial_fold *)v1,
386 (struct isl_pw_qpolynomial_fold *)v2);
389 struct isl_obj_vtable isl_obj_pw_qpolynomial_fold_vtable = {
392 isl_obj_pw_qpf_print,
396 static void *isl_obj_union_pw_qpf_copy(void *v)
398 return isl_union_pw_qpolynomial_fold_copy((struct isl_union_pw_qpolynomial_fold *)v);
401 static void isl_obj_union_pw_qpf_free(void *v)
403 isl_union_pw_qpolynomial_fold_free((struct isl_union_pw_qpolynomial_fold *)v);
406 static __isl_give isl_printer *isl_obj_union_pw_qpf_print(
407 __isl_take isl_printer *p, void *v)
409 return isl_printer_print_union_pw_qpolynomial_fold(p,
410 (struct isl_union_pw_qpolynomial_fold *)v);
413 static void *isl_obj_union_pw_qpf_add(void *v1, void *v2)
415 return isl_union_pw_qpolynomial_fold_fold(
416 (struct isl_union_pw_qpolynomial_fold *)v1,
417 (struct isl_union_pw_qpolynomial_fold *)v2);
420 struct isl_obj_vtable isl_obj_union_pw_qpolynomial_fold_vtable = {
421 isl_obj_union_pw_qpf_copy,
422 isl_obj_union_pw_qpf_add,
423 isl_obj_union_pw_qpf_print,
424 isl_obj_union_pw_qpf_free