Polly 19.0.0git
isl_imath.c
Go to the documentation of this file.
1#include <isl_int.h>
2
3uint32_t isl_imath_hash(mp_int v, uint32_t hash)
4{
5 unsigned const char *data = (unsigned char *)v->digits;
6 unsigned const char *end = data + v->used * sizeof(v->digits[0]);
7
8 if (v->sign == 1)
9 isl_hash_byte(hash, 0xFF);
10 for (; data < end; ++data)
11 isl_hash_byte(hash, *data);
12 return hash;
13}
14
15/* Try a standard conversion that fits into a long.
16 */
18{
19 long out;
21 return res == MP_OK;
22}
23
24/* Try a standard conversion that fits into an unsigned long.
25 */
27{
28 unsigned long out;
30 return res == MP_OK;
31}
32
33void isl_imath_addmul_ui(mp_int rop, mp_int op1, unsigned long op2)
34{
35 mpz_t temp;
36 mp_int_init(&temp);
37
38 mp_int_set_uvalue(&temp, op2);
39 mp_int_mul(op1, &temp, &temp);
40 mp_int_add(rop, &temp, rop);
41
42 mp_int_clear(&temp);
43}
44
45void isl_imath_submul_ui(mp_int rop, mp_int op1, unsigned long op2)
46{
47 mpz_t temp;
48 mp_int_init(&temp);
49
50 mp_int_set_uvalue(&temp, op2);
51 mp_int_mul(op1, &temp, &temp);
52 mp_int_sub(rop, &temp, rop);
53
54 mp_int_clear(&temp);
55}
56
57/* Compute the division of lhs by a rhs of type unsigned long, rounding towards
58 * positive infinity (Ceil).
59 */
60void isl_imath_cdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
61{
62 mpz_t temp;
63 mp_int_init(&temp);
64
65 mp_int_set_uvalue(&temp, rhs);
66 impz_cdiv_q(rop, lhs, &temp);
67
68 mp_int_clear(&temp);
69}
70
71/* Compute the division of lhs by a rhs of type unsigned long, rounding towards
72 * negative infinity (Floor).
73 */
74void isl_imath_fdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
75{
76 mpz_t temp;
77 mp_int_init(&temp);
78
79 mp_int_set_uvalue(&temp, rhs);
80 impz_fdiv_q(rop, lhs, &temp);
81
82 mp_int_clear(&temp);
83}
#define isl_hash_byte(h, b)
Definition: hash.h:22
int mp_result
Definition: imath/imath.h:40
int isl_imath_fits_slong_p(mp_int op)
Definition: isl_imath.c:17
void isl_imath_fdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
Definition: isl_imath.c:74
int isl_imath_fits_ulong_p(mp_int op)
Definition: isl_imath.c:26
void isl_imath_addmul_ui(mp_int rop, mp_int op1, unsigned long op2)
Definition: isl_imath.c:33
void isl_imath_cdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
Definition: isl_imath.c:60
void isl_imath_submul_ui(mp_int rop, mp_int op1, unsigned long op2)
Definition: isl_imath.c:45
uint32_t isl_imath_hash(mp_int v, uint32_t hash)
Definition: isl_imath.c:3
__isl_give isl_val *(* op)(__isl_take isl_val *v)
Definition: isl_test.c:773
const char * res
Definition: isl_test.c:775
char * rhs
Definition: isl_test_int.c:493
char * lhs
Definition: isl_test_int.c:493
mp_digit * digits
Definition: imath/imath.h:60
mp_size used
Definition: imath/imath.h:62
mp_sign sign
Definition: imath/imath.h:63
#define mp_int_clear
Definition: wrap.h:72
#define impz_cdiv_q
Definition: wrap.h:32
#define mp_int_add
Definition: wrap.h:68
#define mp_int_sub
Definition: wrap.h:117
#define mp_int_init
Definition: wrap.h:94
#define impz_fdiv_q
Definition: wrap.h:41
#define mp_int_to_int
Definition: wrap.h:121
#define mp_int_set_uvalue
Definition: wrap.h:113
#define mp_int_to_uint
Definition: wrap.h:123
#define mp_int_mul
Definition: wrap.h:103
#define MP_OK
Definition: wrap.h:9