diff options
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index c26d4829275..8aec54730ca 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -480,6 +480,15 @@ APInt APInt::operator+(const APInt& RHS) const { return Result; } +APInt APInt::operator+(uint64_t RHS) const { + if (isSingleWord()) + return APInt(BitWidth, VAL + RHS); + APInt Result(*this); + add_1(Result.pVal, Result.pVal, getNumWords(), RHS); + Result.clearUnusedBits(); + return Result; +} + APInt APInt::operator-(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) @@ -490,6 +499,15 @@ APInt APInt::operator-(const APInt& RHS) const { return Result; } +APInt APInt::operator-(uint64_t RHS) const { + if (isSingleWord()) + return APInt(BitWidth, VAL - RHS); + APInt Result(*this); + sub_1(Result.pVal, getNumWords(), RHS); + Result.clearUnusedBits(); + return Result; +} + bool APInt::EqualSlowCase(const APInt& RHS) const { return std::equal(pVal, pVal + getNumWords(), RHS.pVal); } |