OSDN Git Service

2006-10-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / double-int.c
index 5a7b51d..3be0abf 100644 (file)
@@ -203,20 +203,48 @@ double_int_neg (double_int a)
 
 /* 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
@@ -233,6 +261,35 @@ double_int_udiv (double_int a, double_int b, unsigned code)
   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