summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/APInt.h
diff options
context:
space:
mode:
authorWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-06-23 19:39:50 +0000
committerWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-06-23 19:39:50 +0000
commit300c6c5167d2869d1568d783d0e3e48bf4b03a6c (patch)
tree6cdbf87bd8a4d8048a3ad81750f225520ce21b39 /include/llvm/ADT/APInt.h
parent180c1691c7fd79e2376bdd59e962d190607e20fa (diff)
downloadllvm-300c6c5167d2869d1568d783d0e3e48bf4b03a6c.tar.gz
llvm-300c6c5167d2869d1568d783d0e3e48bf4b03a6c.tar.bz2
llvm-300c6c5167d2869d1568d783d0e3e48bf4b03a6c.tar.xz
First step to fix PR2088. Implement routine to compute the
multiplicative inverse of a given number. Modify udivrem to allow input and output pairs of arguments to overlap. Patch is based on the work by Chandler Carruth. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r--include/llvm/ADT/APInt.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index d2a1baff24..c98ff18d10 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -668,9 +668,11 @@ public:
return this->urem(RHS);
}
- /// Sometimes it is convenient to divide two APInt values and obtain both
- /// the quotient and remainder. This function does both operations in the
- /// same computation making it a little more efficient.
+ /// Sometimes it is convenient to divide two APInt values and obtain both the
+ /// quotient and remainder. This function does both operations in the same
+ /// computation making it a little more efficient. The pair of input arguments
+ /// may overlap with the pair of output arguments. It is safe to call
+ /// udivrem(X, Y, X, Y), for example.
/// @brief Dual division/remainder interface.
static void udivrem(const APInt &LHS, const APInt &RHS,
APInt &Quotient, APInt &Remainder);
@@ -1107,6 +1109,9 @@ public:
return *this;
}
+ /// @returns the multiplicative inverse for a given modulo.
+ APInt multiplicativeInverse(const APInt& modulo) const;
+
/// @}
/// @name Building-block Operations for APInt and APFloat
/// @{
@@ -1301,7 +1306,7 @@ inline uint32_t logBase2(const APInt& APIVal) {
}
/// GreatestCommonDivisor - This function returns the greatest common
-/// divisor of the two APInt values using Enclid's algorithm.
+/// divisor of the two APInt values using Euclid's algorithm.
/// @returns the greatest common divisor of Val1 and Val2
/// @brief Compute GCD of two APInt values.
APInt GreatestCommonDivisor(const APInt& Val1, const APInt& Val2);