2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
11 #include <isl_union_macro.h>
13 /* Evaluate "u" in the void point "pnt".
14 * In particular, return the value NaN.
16 static __isl_give isl_val
*FN(UNION
,eval_void
)(__isl_take UNION
*u
,
17 __isl_take isl_point
*pnt
)
21 ctx
= isl_point_get_ctx(pnt
);
24 return isl_val_nan(ctx
);
27 /* Internal data structure for isl_union_*_eval.
29 * "pnt" is the point in which the function is evaluated.
30 * "v" stores the result and is initialized to zero.
37 /* Update the evaluation in data->v based on the evaluation of "part".
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.
44 static isl_stat
FN(UNION
,eval_entry
)(__isl_take PART
*part
, void *user
)
46 S(UNION
,eval_data
) *data
= user
;
49 v
= FN(PART
,eval
)(part
, isl_point_copy(data
->pnt
));
50 data
->v
= isl_val_add(data
->v
, v
);
52 return isl_stat_non_null(data
->v
);
55 /* Evaluate "u" in the point "pnt".
57 __isl_give isl_val
*FN(UNION
,eval
)(__isl_take UNION
*u
,
58 __isl_take isl_point
*pnt
)
60 S(UNION
,eval_data
) data
= { pnt
};
64 is_void
= isl_point_is_void(pnt
);
68 return FN(UNION
,eval_void
)(u
, pnt
);
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
);