48static const char *
s_error_msg[] = {
"error code 0",
"boolean true",
49 "out of memory",
"argument out of range",
50 "result undefined",
"output truncated",
51 "invalid argument", NULL};
65 0.000000000, 0.000000000, 1.000000000, 0.630929754,
66 0.500000000, 0.430676558, 0.386852807, 0.356207187,
67 0.333333333, 0.315464877, 0.301029996, 0.289064826,
68 0.278942946, 0.270238154, 0.262649535, 0.255958025,
69 0.250000000, 0.244650542, 0.239812467, 0.235408913,
70 0.231378213, 0.227670249, 0.224243824, 0.221064729,
71 0.218104292, 0.215338279, 0.212746054, 0.210309918,
72 0.208014598, 0.205846832, 0.203795047, 0.201849087,
73 0.200000000, 0.198239863, 0.196561632, 0.194959022,
78#define MP_VALUE_DIGITS(V) \
79 ((sizeof(V) + (sizeof(mp_digit) - 1)) / sizeof(mp_digit))
96 memcpy(q__, p__, i__);
100static inline void REV(
unsigned char *
A,
int N) {
101 unsigned char *u_ =
A;
102 unsigned char *v_ = u_ +
N - 1;
104 unsigned char xch = *u_;
114 while (uz_ > 1 && (*dz_-- == 0)) --uz_;
119static inline int MIN(
int A,
int B) {
return (
B <
A ?
B :
A); }
124#define SWAP(T, A, B) \
136#define DECLARE_TEMP(N) \
146 for (int i = 0; i < temp_.len; i++) { \
147 mp_int_init(TEMP(i)); \
152#define CLEANUP_TEMP() \
155 for (int i = 0; i < temp_.len; i++) { \
156 mp_int_clear(TEMP(i)); \
158 if (temp_.err != MP_OK) { \
164#define TEMP(K) (temp_.value + (K))
173 if (temp_.err != MP_OK) goto CLEANUP; \
178 if (Z->
used == 1 && Z->
digits[0] == 0)
return 0;
216static void s_free(
void *ptr);
334static char s_val2ch(
int v,
int caps);
337static void s_2comp(
unsigned char *buf,
int len);
391 }
else if (prec == 1) {
409 assert(z != NULL && old != NULL);
431 s_fake(&vtmp, value, vbuf);
447 s_fake(&vtmp, value, vbuf);
460 if (z == NULL)
return;
477 assert(
a != NULL && c != NULL);
517 assert(
a != NULL && c != NULL);
527 assert(
a != NULL && c != NULL);
538 assert(
a != NULL &&
b != NULL && c != NULL);
572 }
else if (
cmp < 0) {
598 s_fake(&vtmp, value, vbuf);
604 assert(
a != NULL &&
b != NULL && c != NULL);
660 s_fake(&vtmp, value, vbuf);
666 assert(
a != NULL &&
b != NULL && c != NULL);
682 osize = 4 * ((osize + 1) / 2);
686 if (c ==
a || c ==
b) {
719 s_fake(&vtmp, value, vbuf);
725 assert(
a != NULL && c != NULL && p2 >= 0);
738 assert(
a != NULL && c != NULL);
775 assert(
a != NULL &&
b != NULL && q != r);
793 }
else if (
cmp == 0) {
875 s_fake(&vtmp, value, vbuf);
887 assert(
a != NULL && p2 >= 0 && q != r);
909 unsigned int v = labs(
b);
933 unsigned int v = labs(
b);
950 assert(
a != NULL &&
b != NULL && c != NULL);
957 for (
unsigned ix = 0; ix <
MP_USED(
b); ++ix) {
966 if (d == 0 && ix + 1 ==
MP_USED(
b))
break;
1023 return (value < 0) ? 1 : -1;
1038 assert(
a != NULL &&
b != NULL && c != NULL &&
m != NULL);
1050 if (c ==
b || c ==
m) {
1070 s_fake(&vtmp, value, vbuf);
1079 s_fake(&vtmp, value, vbuf);
1097 if (c ==
b || c ==
m) {
1113 assert(
m != NULL && c != NULL &&
m != c);
1119 assert(
a != NULL &&
m != NULL && c != NULL);
1151 assert(
a != NULL &&
b != NULL && c != NULL);
1155 if (ca == 0 && cb == 0) {
1157 }
else if (ca == 0) {
1159 }
else if (cb == 0) {
1175 k =
MIN(div2_u, div2_v);
1212 assert(
a != NULL &&
b != NULL && c != NULL && (x != NULL || y != NULL));
1217 if (ca == 0 && cb == 0) {
1219 }
else if (ca == 0) {
1224 }
else if (cb == 0) {
1247 k =
MIN(div2_u, div2_v);
1309 assert(
a != NULL &&
b != NULL && c != NULL);
1347 assert(
a != NULL && c != NULL &&
b > 0);
1442 assert(z != NULL &&
str != NULL && limit >= 2);
1462 for (; limit > 0; --limit) {
1465 if ((
cmp =
CMPZ(&tmp)) == 0)
break;
1513 while (isspace((
unsigned char)*
str)) ++
str;
1549 if (end != NULL) *end = (
char *)
str;
1564 if (uz == 1 && z->
digits[0] == 0)
return 1;
1579 static const int PAD_FOR_2C = 1;
1581 assert(z != NULL && buf != NULL);
1592 assert(z != NULL && buf != NULL && len > 0);
1602 if (buf[0] >> (CHAR_BIT - 1)) {
1608 unsigned char *tmp = buf;
1609 for (
int i = len; i > 0; --i, ++tmp) {
1622 if (
res <= 0)
return res;
1629 if (bytes * CHAR_BIT ==
res) ++bytes;
1635 static const int NO_PADDING = 0;
1637 assert(z != NULL && buf != NULL);
1639 return s_tobin(z, buf, &limit, NO_PADDING);
1643 assert(z != NULL && buf != NULL && len > 0);
1651 unsigned char *tmp = buf;
1652 for (
int i = len; i > 0; --i, ++tmp) {
1653 (void)
s_qmul(z, CHAR_BIT);
1662 if (
res <= 0)
return res;
1664 int bytes = (
res + (CHAR_BIT - 1)) / CHAR_BIT;
1695 for (
mp_size ix = 0; ix < num; ++ix) out[ix] = fill;
1705 for (
mp_size ix = 0; ix < nsize; ++ix)
new[ix] = fill;
1706 memcpy(
new, old, osize *
sizeof(
mp_digit));
1723 if ((tmp =
s_alloc(nsize)) == NULL)
return false;
1753 mp_digit *dat = da + len - 1, *dbt = db + len - 1;
1755 for (; len != 0; --len, --dat, --dbt) {
1758 }
else if (*dat < *dbt) {
1787 }
else if (ub > ua) {
1813 if (size_b > size_a) {
1819 for (
pos = 0;
pos < size_b; ++
pos, ++da, ++db, ++dc) {
1826 for (;
pos < size_a; ++
pos, ++da, ++dc) {
1843 assert(size_a >= size_b);
1846 for (
pos = 0;
pos < size_b; ++
pos, ++da, ++db, ++dc) {
1856 for (;
pos < size_a; ++
pos, ++da, ++dc) {
1874 if (size_b > size_a) {
1882 bot_size = (size_a + 1) / 2;
1894 mp_size at_size = size_a - bot_size;
1895 mp_size bt_size = size_b - bot_size;
1896 mp_size buf_size = 2 * bot_size;
1903 if ((
t1 =
s_alloc(4 * buf_size)) == NULL)
return 0;
1917 (void)
s_kmul(
t1,
t2, t3, bot_size + 1, bot_size + 1);
1924 (void)
s_kmul(da, db,
t1, bot_size, bot_size);
1925 (void)
s_kmul(a_top, b_top,
t2, at_size, bt_size);
1928 s_usub(t3,
t1, t3, buf_size + 2, buf_size);
1929 s_usub(t3,
t2, t3, buf_size + 2, buf_size);
1933 carry =
s_uadd(t3, dc + bot_size, dc + bot_size, buf_size + 1, buf_size);
1937 s_uadd(
t2, dc + 2 * bot_size, dc + 2 * bot_size, buf_size, buf_size);
1942 s_umul(da, db, dc, size_a, size_b);
1953 for (
a = 0;
a < size_a; ++
a, ++dc, ++da) {
1957 if (*da == 0)
continue;
1960 for (
b = 0;
b < size_b; ++
b, ++dbt, ++dct) {
1973 mp_size bot_size = (size_a + 1) / 2;
1976 mp_size at_size = size_a - bot_size;
1977 mp_size buf_size = 2 * bot_size;
1979 if ((
t1 =
s_alloc(4 * buf_size)) == NULL)
return 0;
1987 (void)
s_kmul(da, a_top, t3, bot_size, at_size);
1991 int i, top = bot_size + at_size;
1994 for (i = 0; i < top; ++i) {
1996 w = (w << 1) | save;
2004 COPY(
t1, dc, 2 * bot_size);
2005 carry =
s_uadd(t3, dc + bot_size, dc + bot_size, buf_size + 1, buf_size);
2009 s_uadd(
t2, dc + 2 * bot_size, dc + 2 * bot_size, buf_size, buf_size);
2025 for (i = 0; i < size_a; ++i, dc += 2, ++da) {
2028 if (*da == 0)
continue;
2037 for (j = i + 1; j < size_a; ++j, ++dat, ++dct) {
2080 for (ua -= 1; ua > 0; --ua, ++da) {
2114 while (size_a > 0) {
2130 for (; ua > 0; --ua, --da) {
2163 for (mark = ndig; mark < uz; ++mark) {
2167 z->
used = uz - ndig;
2177 for (; uz > 0; --uz, --dz) {
2180 *dz = (*dz >> nbits) | (d << up);
2197 z->
digits[start - 1] &= mask;
2203 mp_size uz, need, rest, extra, i;
2206 if (p2 == 0)
return 1;
2222 if (!
s_pad(z, uz + need + extra))
return 0;
2231 for (i = 0; i < uz; ++i) *to-- = *from--;
2239 for (i = need, from =
MP_DIGITS(z) + need; i < uz; ++i, ++from) {
2242 *from = (*from << rest) | (d >> (
MP_DIGIT_BIT - rest));
2267 if (!
s_pad(z, tdig + 1))
return 0;
2291 if (
MP_USED(z) == 1 && *dp == 0)
return 1;
2299 while ((d & 1) == 0) {
2312 if (*dz++ != 0)
return -1;
2319 if (d & 1)
return -1;
2334 if (!
s_pad(z, ndig))
return 0;
2338 *(dz + ndig - 1) = (1u << rest);
2397 if ((
CMPZ(x) < 0) && !
s_qsub(x, umb_p1))
return 0;
2548 if (k == 0 ||
MP_USED(u) !=
m +
n + 1) {
2581 for (; j >= 0; j--) {
2590 qhat = pfx / v->
digits[
n - 1];
2611 TEMP(1)->used =
n + 1;
2619 TEMP(1)->used =
n + 1;
2625 TEMP(1)->used =
n + 1;
2659 TEMP(0)->used =
m + 1;
2664 if (k != 0)
s_qdiv(u, k);
2677 double raw = (double)bits *
s_log2[r];
2679 return (
int)(raw + 0.999999);
2683 double raw = (double)len /
s_log2[r];
2698 if (isdigit((
unsigned char)c))
2700 else if (r > 10 && isalpha((
unsigned char)c))
2701 out = toupper((
unsigned char)c) -
'A' + 10;
2705 return (out >= r) ? -1 : out;
2714 char out = (v - 10) +
'a';
2717 return toupper((
unsigned char)out);
2725 unsigned short s = 1;
2727 for (
int i = len - 1; i >= 0; --i) {
2728 unsigned char c = ~buf[i];
2741 int pos = 0, limit = *limpos;
2745 while (uz > 0 &&
pos < limit) {
2749 for (i =
sizeof(
mp_digit); i > 0 &&
pos < limit; --i) {
2750 buf[
pos++] = (
unsigned char)d;
2754 if (d == 0 && uz == 1) i = 0;
2763 if (pad != 0 && (buf[
pos - 1] >> (CHAR_BIT - 1))) {
static RegisterPass< ScopViewerWrapperPass > X("view-scops", "Polly - View Scops of function")
static RegisterPass< ScopOnlyPrinterWrapperPass > N("dot-scops-only", "Polly - Print Scops of function (with no function bodies)")
static RegisterPass< ScopOnlyViewerWrapperPass > Y("view-scops-only", "Polly - View Scops of function (with no function bodies)")
int GMPQAPI() cmp(mp_rat op1, mp_rat op2)
static mp_result s_brmu(mp_int z, mp_int m)
static void s_free(void *ptr)
static void s_2comp(unsigned char *buf, int len)
const mp_result MP_BADARG
static int s_ucmp(mp_int a, mp_int b)
static mp_digit s_ddiv(mp_int a, mp_digit b)
static void s_fake(mp_int z, mp_small value, mp_digit vbuf[])
static char s_val2ch(int v, int caps)
static mp_size default_precision
static void USQR(mp_int X, mp_int Z)
static int s_outlen(mp_int z, mp_size r)
static mp_size multiply_threshold
static int s_dp2k(mp_int z)
static void UMUL(mp_int X, mp_int Y, mp_int Z)
static int s_ksqr(mp_digit *da, mp_digit *dc, mp_size size_a)
static int s_cdig(mp_digit *da, mp_digit *db, mp_size len)
static void s_dadd(mp_int a, mp_digit b)
const mp_sign MP_ZPOS
A sign indicating a zero or positive value.
static mp_size s_round_prec(mp_size P)
static mp_digit LOWER_HALF(mp_word W)
static mp_size s_inlen(int len, mp_size r)
static void REV(unsigned char *A, int N)
static int s_2expt(mp_int z, mp_small k)
static const char * s_unknown_err
static void CLAMP(mp_int z_)
void mp_int_multiply_threshold(mp_size thresh)
Sets the number of digits below which multiplication will use the standard quadratic "schoolbook" mul...
static mp_digit s_uadd(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b)
static void s_umul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b)
static void s_usub(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b)
static mp_result s_udiv_knuth(mp_int a, mp_int b)
#define MP_VALUE_DIGITS(V)
static mp_result s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad)
static int s_norm(mp_int a, mp_int b)
static mp_digit * s_alloc(mp_size num)
static int s_ch2val(char c, int r)
static bool ADD_WILL_OVERFLOW(mp_word W, mp_word V)
static int s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b)
static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
static mp_digit * s_realloc(mp_digit *old, mp_size osize, mp_size nsize)
const mp_result MP_MINERR
static void s_usqr(mp_digit *da, mp_digit *dc, mp_size size_a)
static void COPY(mp_digit *P, mp_digit *Q, mp_size S)
const mp_result MP_MEMORY
static int s_qsub(mp_int z, mp_size p2)
static void s_dmul(mp_int a, mp_digit b)
static void s_dbmul(mp_digit *da, mp_digit b, mp_digit *dc, mp_size size_a)
static mp_word UPPER_HALF(mp_word W)
static int s_uvpack(mp_usmall v, mp_digit t[])
static int s_isp2(mp_int z)
mp_int mp_int_alloc(void)
Allocates a fresh zero-valued mpz_t on the heap, returning NULL in case of error.
static mp_size MAX(mp_size A, mp_size B)
static int CMPZ(mp_int Z)
static const double s_log2[]
static mp_result GROW(mp_int Z, mp_size N)
static void s_qmod(mp_int z, mp_size p2)
const mp_sign MP_NEG
A sign indicating a (strictly) negative value.
static bool HIGH_BIT_SET(mp_word W)
static bool s_pad(mp_int z, mp_size min)
static int MIN(int A, int B)
static void s_ufake(mp_int z, mp_usmall value, mp_digit vbuf[])
static int s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2)
static int s_uvcmp(mp_int a, mp_usmall uv)
static int s_vcmp(mp_int a, mp_small v)
static const char * s_error_msg[]
void mp_int_default_precision(mp_size size)
Sets the default number of digits allocated to an mp_int constructed by mp_int_init_size() with prec ...
static void s_qdiv(mp_int z, mp_size p2)
static int s_qmul(mp_int z, mp_size p2)
static bool mp_int_is_odd(mp_int z)
Reports whether z is odd, having remainder 1 when divided by 2.
static mp_digit * MP_DIGITS(mp_int Z)
static mp_size MP_ALLOC(mp_int Z)
static mp_size MP_USED(mp_int Z)
static bool mp_int_is_even(mp_int z)
Reports whether z is even, having remainder 0 when divided by 2.
static mp_sign MP_SIGN(mp_int Z)
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
static __isl_give isl_schedule_node * carry(__isl_take isl_schedule_node *node, struct isl_sched_graph *graph, int fallback, int coincidence)
#define mp_int_divisible_value
#define mp_int_read_cstring
#define mp_int_read_binary
#define mp_int_compare_zero
#define mp_int_string_len
#define mp_int_compare_unsigned
#define mp_int_unsigned_len
#define mp_int_compare_uvalue
#define mp_int_to_unsigned
#define mp_int_exptmod_evalue
#define mp_int_read_string
#define mp_int_count_bits
#define mp_int_init_value
#define mp_int_read_unsigned
#define mp_int_exptmod_known
#define mp_int_expt_value
#define mp_int_set_uvalue
#define mp_int_compare_value
#define mp_int_exptmod_bvalue
#define mp_int_init_uvalue
#define mp_int_binary_len
#define mp_int_redux_const