mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Move part of APInt implementation from header to cpp file. These methods
require call cpp file anyway, so we wouldn't gain anything by keeping them inline. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -799,16 +799,7 @@ public:
|
|||||||
|
|
||||||
/// Signed divide this APInt by APInt RHS.
|
/// Signed divide this APInt by APInt RHS.
|
||||||
/// @brief Signed division function for APInt.
|
/// @brief Signed division function for APInt.
|
||||||
APInt sdiv(const APInt &RHS) const {
|
APInt sdiv(const APInt &RHS) const;
|
||||||
if (isNegative())
|
|
||||||
if (RHS.isNegative())
|
|
||||||
return (-(*this)).udiv(-RHS);
|
|
||||||
else
|
|
||||||
return -((-(*this)).udiv(RHS));
|
|
||||||
else if (RHS.isNegative())
|
|
||||||
return -(this->udiv(-RHS));
|
|
||||||
return this->udiv(RHS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Perform an unsigned remainder operation on this APInt with RHS being the
|
/// Perform an unsigned remainder operation on this APInt with RHS being the
|
||||||
/// divisor. Both this and RHS are treated as unsigned quantities for purposes
|
/// divisor. Both this and RHS are treated as unsigned quantities for purposes
|
||||||
@@ -821,16 +812,7 @@ public:
|
|||||||
|
|
||||||
/// Signed remainder operation on APInt.
|
/// Signed remainder operation on APInt.
|
||||||
/// @brief Function for signed remainder operation.
|
/// @brief Function for signed remainder operation.
|
||||||
APInt srem(const APInt &RHS) const {
|
APInt srem(const APInt &RHS) const;
|
||||||
if (isNegative())
|
|
||||||
if (RHS.isNegative())
|
|
||||||
return -((-(*this)).urem(-RHS));
|
|
||||||
else
|
|
||||||
return -((-(*this)).urem(RHS));
|
|
||||||
else if (RHS.isNegative())
|
|
||||||
return this->urem(-RHS);
|
|
||||||
return this->urem(RHS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sometimes it is convenient to divide two APInt values and obtain both the
|
/// Sometimes it is convenient to divide two APInt values and obtain both the
|
||||||
/// quotient and remainder. This function does both operations in the same
|
/// quotient and remainder. This function does both operations in the same
|
||||||
@@ -842,24 +824,9 @@ public:
|
|||||||
APInt &Quotient, APInt &Remainder);
|
APInt &Quotient, APInt &Remainder);
|
||||||
|
|
||||||
static void sdivrem(const APInt &LHS, const APInt &RHS,
|
static void sdivrem(const APInt &LHS, const APInt &RHS,
|
||||||
APInt &Quotient, APInt &Remainder) {
|
APInt &Quotient, APInt &Remainder);
|
||||||
if (LHS.isNegative()) {
|
|
||||||
if (RHS.isNegative())
|
|
||||||
APInt::udivrem(-LHS, -RHS, Quotient, Remainder);
|
|
||||||
else {
|
|
||||||
APInt::udivrem(-LHS, RHS, Quotient, Remainder);
|
|
||||||
Quotient = -Quotient;
|
|
||||||
}
|
|
||||||
Remainder = -Remainder;
|
|
||||||
} else if (RHS.isNegative()) {
|
|
||||||
APInt::udivrem(LHS, -RHS, Quotient, Remainder);
|
|
||||||
Quotient = -Quotient;
|
|
||||||
} else {
|
|
||||||
APInt::udivrem(LHS, RHS, Quotient, Remainder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Operations that return overflow indicators.
|
// Operations that return overflow indicators.
|
||||||
APInt sadd_ov(const APInt &RHS, bool &Overflow) const;
|
APInt sadd_ov(const APInt &RHS, bool &Overflow) const;
|
||||||
APInt uadd_ov(const APInt &RHS, bool &Overflow) const;
|
APInt uadd_ov(const APInt &RHS, bool &Overflow) const;
|
||||||
|
@@ -1876,6 +1876,17 @@ APInt APInt::udiv(const APInt& RHS) const {
|
|||||||
return Quotient;
|
return Quotient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt APInt::sdiv(const APInt &RHS) const {
|
||||||
|
if (isNegative()) {
|
||||||
|
if (RHS.isNegative())
|
||||||
|
return (-(*this)).udiv(-RHS);
|
||||||
|
return -((-(*this)).udiv(RHS));
|
||||||
|
}
|
||||||
|
if (RHS.isNegative())
|
||||||
|
return -(this->udiv(-RHS));
|
||||||
|
return this->udiv(RHS);
|
||||||
|
}
|
||||||
|
|
||||||
APInt APInt::urem(const APInt& RHS) const {
|
APInt APInt::urem(const APInt& RHS) const {
|
||||||
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
|
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
|
||||||
if (isSingleWord()) {
|
if (isSingleWord()) {
|
||||||
@@ -1913,6 +1924,17 @@ APInt APInt::urem(const APInt& RHS) const {
|
|||||||
return Remainder;
|
return Remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt APInt::srem(const APInt &RHS) const {
|
||||||
|
if (isNegative()) {
|
||||||
|
if (RHS.isNegative())
|
||||||
|
return -((-(*this)).urem(-RHS));
|
||||||
|
return -((-(*this)).urem(RHS));
|
||||||
|
}
|
||||||
|
if (RHS.isNegative())
|
||||||
|
return this->urem(-RHS);
|
||||||
|
return this->urem(RHS);
|
||||||
|
}
|
||||||
|
|
||||||
void APInt::udivrem(const APInt &LHS, const APInt &RHS,
|
void APInt::udivrem(const APInt &LHS, const APInt &RHS,
|
||||||
APInt &Quotient, APInt &Remainder) {
|
APInt &Quotient, APInt &Remainder) {
|
||||||
// Get some size facts about the dividend and divisor
|
// Get some size facts about the dividend and divisor
|
||||||
@@ -1953,6 +1975,24 @@ void APInt::udivrem(const APInt &LHS, const APInt &RHS,
|
|||||||
divide(LHS, lhsWords, RHS, rhsWords, &Quotient, &Remainder);
|
divide(LHS, lhsWords, RHS, rhsWords, &Quotient, &Remainder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APInt::sdivrem(const APInt &LHS, const APInt &RHS,
|
||||||
|
APInt &Quotient, APInt &Remainder) {
|
||||||
|
if (LHS.isNegative()) {
|
||||||
|
if (RHS.isNegative())
|
||||||
|
APInt::udivrem(-LHS, -RHS, Quotient, Remainder);
|
||||||
|
else {
|
||||||
|
APInt::udivrem(-LHS, RHS, Quotient, Remainder);
|
||||||
|
Quotient = -Quotient;
|
||||||
|
}
|
||||||
|
Remainder = -Remainder;
|
||||||
|
} else if (RHS.isNegative()) {
|
||||||
|
APInt::udivrem(LHS, -RHS, Quotient, Remainder);
|
||||||
|
Quotient = -Quotient;
|
||||||
|
} else {
|
||||||
|
APInt::udivrem(LHS, RHS, Quotient, Remainder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
APInt APInt::sadd_ov(const APInt &RHS, bool &Overflow) const {
|
APInt APInt::sadd_ov(const APInt &RHS, bool &Overflow) const {
|
||||||
APInt Res = *this+RHS;
|
APInt Res = *this+RHS;
|
||||||
Overflow = isNonNegative() == RHS.isNonNegative() &&
|
Overflow = isNonNegative() == RHS.isNonNegative() &&
|
||||||
|
Reference in New Issue
Block a user