/* Returns A / B (computed as unsigned depending on UNS, and rounded as
specified by CODE). CODE is enum tree_code in fact, but double_int.h
- must be included before tree.h. */
+ must be included before tree.h. The remainder after the division is
+ stored to MOD. */
double_int
-double_int_div (double_int a, double_int b, bool uns, unsigned code)
+double_int_divmod (double_int a, double_int b, bool uns, unsigned code,
+ double_int *mod)
{
- unsigned HOST_WIDE_INT rem_lo;
- HOST_WIDE_INT rem_hi;
double_int ret;
div_and_round_double (code, uns, a.low, a.high, b.low, b.high,
- &ret.low, &ret.high, &rem_lo, &rem_hi);
+ &ret.low, &ret.high, &mod->low, &mod->high);
return ret;
}
+/* The same as double_int_divmod with UNS = false. */
+
+double_int
+double_int_sdivmod (double_int a, double_int b, unsigned code, double_int *mod)
+{
+ return double_int_divmod (a, b, false, code, mod);
+}
+
+/* The same as double_int_divmod with UNS = true. */
+
+double_int
+double_int_udivmod (double_int a, double_int b, unsigned code, double_int *mod)
+{
+ return double_int_divmod (a, b, true, code, mod);
+}
+
+/* Returns A / B (computed as unsigned depending on UNS, and rounded as
+ specified by CODE). CODE is enum tree_code in fact, but double_int.h
+ must be included before tree.h. */
+
+double_int
+double_int_div (double_int a, double_int b, bool uns, unsigned code)
+{
+ double_int mod;
+
+ return double_int_divmod (a, b, uns, code, &mod);
+}
+
/* The same as double_int_div with UNS = false. */
double_int
return double_int_div (a, b, true, code);
}
+/* Returns A % B (computed as unsigned depending on UNS, and rounded as
+ specified by CODE). CODE is enum tree_code in fact, but double_int.h
+ must be included before tree.h. */
+
+double_int
+double_int_mod (double_int a, double_int b, bool uns, unsigned code)
+{
+ double_int mod;
+
+ double_int_divmod (a, b, uns, code, &mod);
+ return mod;
+}
+
+/* The same as double_int_mod with UNS = false. */
+
+double_int
+double_int_smod (double_int a, double_int b, unsigned code)
+{
+ return double_int_mod (a, b, false, code);
+}
+
+/* The same as double_int_mod with UNS = true. */
+
+double_int
+double_int_umod (double_int a, double_int b, unsigned code)
+{
+ return double_int_mod (a, b, true, code);
+}
+
/* Constructs tree in type TYPE from with value given by CST. */
tree