Coverage Report

Created: 2017-06-28 17:40

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_val_sioimath.c
Line
Count
Source (jump to first uncovered line)
1
#include <isl_val_private.h>
2
3
/* Return a reference to an isl_val representing the unsigned
4
 * integer value stored in the "n" chunks of size "size" at "chunks".
5
 * The least significant chunk is assumed to be stored first.
6
 */
7
__isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx, size_t n,
8
  size_t size, const void *chunks)
9
17.3k
{
10
17.3k
  isl_val *v;
11
17.3k
12
17.3k
  v = isl_val_alloc(ctx);
13
17.3k
  if (!v)
14
0
    return NULL;
15
17.3k
16
17.3k
  impz_import(isl_sioimath_reinit_big(v->n), n, -1, size, 0, 0, chunks);
17
17.3k
  isl_sioimath_try_demote(v->n);
18
17.3k
  isl_int_set_si(v->d, 1);
19
17.3k
20
17.3k
  return v;
21
17.3k
}
22
23
/* Store a representation of the absolute value of the numerator of "v"
24
 * in terms of chunks of size "size" at "chunks".
25
 * The least significant chunk is stored first.
26
 * The number of chunks in the result can be obtained by calling
27
 * isl_val_n_abs_num_chunks.  The user is responsible for allocating
28
 * enough memory to store the results.
29
 *
30
 * In the special case of a zero value, isl_val_n_abs_num_chunks will
31
 * return one, while impz_export will not fill in any chunks.  We therefore
32
 * do it ourselves.
33
 */
34
int isl_val_get_abs_num_chunks(__isl_keep isl_val *v, size_t size,
35
  void *chunks)
36
2.10k
{
37
2.10k
  isl_sioimath_scratchspace_t scratch;
38
2.10k
39
2.10k
  if (
!v || 2.10k
!chunks2.10k
)
40
0
    return -1;
41
2.10k
42
2.10k
  
if (2.10k
!isl_val_is_rat(v)2.10k
)
43
0
    isl_die(isl_val_get_ctx(v), isl_error_invalid,
44
2.10k
      "expecting rational value", return -1);
45
2.10k
46
2.10k
  impz_export(chunks, NULL, -1, size, 0, 0,
47
2.10k
      isl_sioimath_bigarg_src(*v->n, &scratch));
48
2.10k
  if (isl_val_is_zero(v))
49
2.10k
    memset(chunks, 0, size);
50
2.10k
51
2.10k
  return 0;
52
2.10k
}
53
54
/* Return the number of chunks of size "size" required to
55
 * store the absolute value of the numerator of "v".
56
 */
57
size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v, size_t size)
58
2.10k
{
59
2.10k
  if (!v)
60
0
    return 0;
61
2.10k
62
2.10k
  
if (2.10k
!isl_val_is_rat(v)2.10k
)
63
0
    isl_die(isl_val_get_ctx(v), isl_error_invalid,
64
2.10k
      "expecting rational value", return 0);
65
2.10k
66
2.10k
  size *= 8;
67
2.10k
  return (isl_sioimath_sizeinbase(*v->n, 2) + size - 1) / size;
68
2.10k
}