/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/isl_power_templ.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include <isl_val_private.h> |
2 | | |
3 | 25 | #define xFN(TYPE,NAME) TYPE ## _ ## NAME |
4 | 25 | #define FN(TYPE,NAME) xFN(TYPE,NAME) |
5 | | |
6 | | /* Compute the given non-zero power of "map" and return the result. |
7 | | * If the exponent "exp" is negative, then the -exp th power of the inverse |
8 | | * relation is computed. |
9 | | */ |
10 | | __isl_give TYPE *FN(TYPE,fixed_power)(__isl_take TYPE *map, isl_int exp) |
11 | 1 | { |
12 | 1 | isl_ctx *ctx; |
13 | 1 | TYPE *res = NULL; |
14 | 1 | isl_int r; |
15 | 1 | |
16 | 1 | if (!map) |
17 | 0 | return NULL; |
18 | 1 | |
19 | 1 | ctx = FN(TYPE,get_ctx)(map); |
20 | 1 | if (isl_int_is_zero(exp)) |
21 | 1 | isl_die0 (ctx, isl_error_invalid, |
22 | 1 | "expecting non-zero exponent", goto error); |
23 | 1 | |
24 | 1 | if (isl_int_is_neg(exp)) { |
25 | 0 | isl_int_neg(exp, exp); |
26 | 0 | map = FN(TYPE,reverse)(map); |
27 | 0 | return FN(TYPE,fixed_power)(map, exp); |
28 | 0 | } |
29 | 1 | |
30 | 1 | isl_int_init(r); |
31 | 5 | for (;;) { |
32 | 5 | isl_int_fdiv_r(r, exp, ctx->two); |
33 | 5 | |
34 | 5 | if (!isl_int_is_zero(r)) { |
35 | 4 | if (!res) |
36 | 1 | res = FN(TYPE,copy)(map); |
37 | 3 | else { |
38 | 3 | res = FN(TYPE,apply_range)(res, |
39 | 3 | FN(TYPE,copy)(map)); |
40 | 3 | res = FN(TYPE,coalesce)(res); |
41 | 3 | } |
42 | 4 | if (!res) |
43 | 0 | break; |
44 | 5 | } |
45 | 5 | |
46 | 5 | isl_int_fdiv_q(exp, exp, ctx->two); |
47 | 5 | if (isl_int_is_zero(exp)) |
48 | 5 | break1 ; |
49 | 4 | |
50 | 4 | map = FN(TYPE,apply_range)(map, FN(TYPE,copy)(map)); |
51 | 4 | map = FN(TYPE,coalesce)(map); |
52 | 4 | } |
53 | 1 | isl_int_clear(r); |
54 | 1 | |
55 | 1 | FN(TYPE,free)(map); |
56 | 1 | return res; |
57 | 1 | error: |
58 | 0 | FN(TYPE,free)(map); |
59 | 0 | return NULL; |
60 | 1 | } Line | Count | Source | 11 | 1 | { | 12 | 1 | isl_ctx *ctx; | 13 | 1 | TYPE *res = NULL; | 14 | 1 | isl_int r; | 15 | 1 | | 16 | 1 | if (!map) | 17 | 0 | return NULL; | 18 | 1 | | 19 | 1 | ctx = FN(TYPE,get_ctx)(map); | 20 | 1 | if (isl_int_is_zero(exp)) | 21 | 1 | isl_die0 (ctx, isl_error_invalid, | 22 | 1 | "expecting non-zero exponent", goto error); | 23 | 1 | | 24 | 1 | if (isl_int_is_neg(exp)) { | 25 | 0 | isl_int_neg(exp, exp); | 26 | 0 | map = FN(TYPE,reverse)(map); | 27 | 0 | return FN(TYPE,fixed_power)(map, exp); | 28 | 0 | } | 29 | 1 | | 30 | 1 | isl_int_init(r); | 31 | 5 | for (;;) { | 32 | 5 | isl_int_fdiv_r(r, exp, ctx->two); | 33 | 5 | | 34 | 5 | if (!isl_int_is_zero(r)) { | 35 | 4 | if (!res) | 36 | 1 | res = FN(TYPE,copy)(map); | 37 | 3 | else { | 38 | 3 | res = FN(TYPE,apply_range)(res, | 39 | 3 | FN(TYPE,copy)(map)); | 40 | 3 | res = FN(TYPE,coalesce)(res); | 41 | 3 | } | 42 | 4 | if (!res) | 43 | 0 | break; | 44 | 5 | } | 45 | 5 | | 46 | 5 | isl_int_fdiv_q(exp, exp, ctx->two); | 47 | 5 | if (isl_int_is_zero(exp)) | 48 | 5 | break1 ; | 49 | 4 | | 50 | 4 | map = FN(TYPE,apply_range)(map, FN(TYPE,copy)(map)); | 51 | 4 | map = FN(TYPE,coalesce)(map); | 52 | 4 | } | 53 | 1 | isl_int_clear(r); | 54 | 1 | | 55 | 1 | FN(TYPE,free)(map); | 56 | 1 | return res; | 57 | 1 | error: | 58 | 0 | FN(TYPE,free)(map); | 59 | 0 | return NULL; | 60 | 1 | } |
Unexecuted instantiation: isl_union_map_fixed_power |
61 | | |
62 | | /* Compute the given non-zero power of "map" and return the result. |
63 | | * If the exponent "exp" is negative, then the -exp th power of the inverse |
64 | | * relation is computed. |
65 | | */ |
66 | | __isl_give TYPE *FN(TYPE,fixed_power_val)(__isl_take TYPE *map, |
67 | | __isl_take isl_val *exp) |
68 | 1 | { |
69 | 1 | if (!map || !exp) |
70 | 0 | goto error; |
71 | 1 | if (!isl_val_is_int(exp)) |
72 | 1 | isl_die0 (FN(TYPE,get_ctx)(map), isl_error_invalid, |
73 | 1 | "expecting integer exponent", goto error); |
74 | 1 | map = FN(TYPE,fixed_power)(map, exp->n); |
75 | 1 | isl_val_free(exp); |
76 | 1 | return map; |
77 | 1 | error: |
78 | 0 | FN(TYPE,free)(map); |
79 | 0 | isl_val_free(exp); |
80 | 0 | return NULL; |
81 | 1 | } Line | Count | Source | 68 | 1 | { | 69 | 1 | if (!map || !exp) | 70 | 0 | goto error; | 71 | 1 | if (!isl_val_is_int(exp)) | 72 | 1 | isl_die0 (FN(TYPE,get_ctx)(map), isl_error_invalid, | 73 | 1 | "expecting integer exponent", goto error); | 74 | 1 | map = FN(TYPE,fixed_power)(map, exp->n); | 75 | 1 | isl_val_free(exp); | 76 | 1 | return map; | 77 | 1 | error: | 78 | 0 | FN(TYPE,free)(map); | 79 | 0 | isl_val_free(exp); | 80 | 0 | return NULL; | 81 | 1 | } |
Unexecuted instantiation: isl_union_map_fixed_power_val |