[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / polly / lib / External / isl / isl_imath.c
blobd870f1486da8d5994863028598216534554a8c72
1 #include <isl_int.h>
3 uint32_t isl_imath_hash(mp_int v, uint32_t hash)
5 unsigned const char *data = (unsigned char *)v->digits;
6 unsigned const char *end = data + v->used * sizeof(v->digits[0]);
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;
15 /* Try a standard conversion that fits into a long.
17 int isl_imath_fits_slong_p(mp_int op)
19 long out;
20 mp_result res = mp_int_to_int(op, &out);
21 return res == MP_OK;
24 /* Try a standard conversion that fits into an unsigned long.
26 int isl_imath_fits_ulong_p(mp_int op)
28 unsigned long out;
29 mp_result res = mp_int_to_uint(op, &out);
30 return res == MP_OK;
33 void isl_imath_addmul_ui(mp_int rop, mp_int op1, unsigned long op2)
35 mpz_t temp;
36 mp_int_init(&temp);
38 mp_int_set_uvalue(&temp, op2);
39 mp_int_mul(op1, &temp, &temp);
40 mp_int_add(rop, &temp, rop);
42 mp_int_clear(&temp);
45 void isl_imath_submul_ui(mp_int rop, mp_int op1, unsigned long op2)
47 mpz_t temp;
48 mp_int_init(&temp);
50 mp_int_set_uvalue(&temp, op2);
51 mp_int_mul(op1, &temp, &temp);
52 mp_int_sub(rop, &temp, rop);
54 mp_int_clear(&temp);
57 /* Compute the division of lhs by a rhs of type unsigned long, rounding towards
58 * positive infinity (Ceil).
60 void isl_imath_cdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
62 mpz_t temp;
63 mp_int_init(&temp);
65 mp_int_set_uvalue(&temp, rhs);
66 impz_cdiv_q(rop, lhs, &temp);
68 mp_int_clear(&temp);
71 /* Compute the division of lhs by a rhs of type unsigned long, rounding towards
72 * negative infinity (Floor).
74 void isl_imath_fdiv_q_ui(mp_int rop, mp_int lhs, unsigned long rhs)
76 mpz_t temp;
77 mp_int_init(&temp);
79 mp_int_set_uvalue(&temp, rhs);
80 impz_fdiv_q(rop, lhs, &temp);
82 mp_int_clear(&temp);