keep cache of blocks of isl_ints
[platform/upstream/isl.git] / isl_ctx.c
1 #include "isl_ctx.h"
2 #include "isl_vec.h"
3 #ifdef ISL_POLYLIB
4 #include <polylib/polylibgmp.h>
5 #endif
6
7 struct isl_ctx *isl_ctx_alloc()
8 {
9         struct isl_ctx *ctx = NULL;
10
11         ctx = isl_alloc_type(NULL, struct isl_ctx);
12         if (!ctx)
13                 goto error;
14
15         isl_int_init(ctx->one);
16         isl_int_set_si(ctx->one, 1);
17
18         ctx->n_cached = 0;
19
20 #ifdef ISL_POLYLIB
21         ctx->MaxRays = POL_NO_DUAL | POL_INTEGER;
22 #endif
23
24         return ctx;
25 error:
26         free(ctx);
27         return NULL;
28 }
29
30 void isl_ctx_free(struct isl_ctx *ctx)
31 {
32         if (!ctx)
33                 return;
34         isl_blk_clear_cache(ctx);
35         isl_int_clear(ctx->one);
36         free(ctx);
37 }