Polly 19.0.0git
isl_union_eval.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 INRIA Saclay
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
10
11#include <isl_union_macro.h>
12
13/* Evaluate "u" in the void point "pnt".
14 * In particular, return the value NaN.
15 */
18{
19 isl_ctx *ctx;
20
21 ctx = isl_point_get_ctx(pnt);
22 FN(UNION,free)(u);
23 isl_point_free(pnt);
24 return isl_val_nan(ctx);
25}
26
27/* Internal data structure for isl_union_*_eval.
28 *
29 * "pnt" is the point in which the function is evaluated.
30 * "v" stores the result and is initialized to zero.
31 */
32S(UNION,eval_data) {
33 isl_point *pnt;
34 isl_val *v;
35};
36
37/* Update the evaluation in data->v based on the evaluation of "part".
38 *
39 * Only (at most) a single part on which this function is called
40 * is assumed to evaluate to anything other than zero.
41 * Since the value is initialized to zero, the evaluation of "part"
42 * can simply be added.
43 */
44static isl_stat FN(UNION,eval_entry)(__isl_take PART *part, void *user)
45{
46 S(UNION,eval_data) *data = user;
47 isl_val *v;
48
49 v = FN(PART,eval)(part, isl_point_copy(data->pnt));
50 data->v = isl_val_add(data->v, v);
51
52 return isl_stat_non_null(data->v);
53}
54
55/* Evaluate "u" in the point "pnt".
56 */
59{
60 S(UNION,eval_data) data = { pnt };
61 isl_bool is_void;
62 isl_space *space;
63
64 is_void = isl_point_is_void(pnt);
65 if (is_void < 0)
66 goto error;
67 if (is_void)
68 return FN(UNION,eval_void)(u, pnt);
69
70 data.v = isl_val_zero(isl_point_get_ctx(pnt));
71 space = isl_point_peek_space(pnt);
72 if (FN(UNION,foreach_on_domain)(u, space,
73 &FN(UNION,eval_entry), &data) < 0)
74 data.v = isl_val_free(data.v);
75 FN(UNION,free)(u);
76 isl_point_free(pnt);
77 return data.v;
78error:
79 FN(UNION,free)(u);
80 isl_point_free(pnt);
81 return NULL;
82}
#define FN(TYPE, NAME)
isl_stat isl_stat_non_null(void *obj)
Definition: isl_ctx.c:22
#define __isl_take
Definition: ctx.h:22
isl_stat
Definition: ctx.h:84
#define __isl_give
Definition: ctx.h:19
isl_bool
Definition: ctx.h:89
isl_stat isl_stat(*) void user)
Definition: hmap.h:39
static __isl_give isl_val * eval_void(__isl_take isl_aff *aff, __isl_take isl_point *pnt)
Definition: isl_aff.c:9943
static __isl_give isl_val * eval(__isl_keep isl_vec *aff, __isl_keep isl_vec *pnt)
Definition: isl_aff.c:9957
#define S(TYPE, NAME)
__isl_keep isl_space * isl_point_peek_space(__isl_keep isl_point *pnt)
Definition: isl_point.c:39
#define PART
isl_bool isl_point_is_void(__isl_keep isl_point *pnt)
Definition: isl_point.c:172
__isl_give isl_point * isl_point_copy(__isl_keep isl_point *pnt)
Definition: isl_point.c:141
__isl_null isl_point * isl_point_free(__isl_take isl_point *pnt)
Definition: isl_point.c:150
isl_ctx * isl_point_get_ctx(__isl_keep isl_point *pnt)
Definition: isl_point.c:32
__isl_export __isl_give isl_val * isl_val_add(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition: isl_val.c:626
__isl_export __isl_give isl_val * isl_val_zero(isl_ctx *ctx)
Definition: isl_val.c:41
__isl_export __isl_give isl_val * isl_val_nan(isl_ctx *ctx)
Definition: isl_val.c:62
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition: isl_val.c:263