/// Forward declaration.
class APInt;
namespace APIntOps {
- APInt udiv(const APInt& LHS, const APInt& RHS);
- APInt urem(const APInt& LHS, const APInt& RHS);
+ APInt UDiv(const APInt& LHS, const APInt& RHS);
+ APInt URem(const APInt& LHS, const APInt& RHS);
}
//===----------------------------------------------------------------------===//
/// @returns a uint64_t value from this APInt. If this APInt contains a single
/// word, just returns VAL, otherwise pVal[0].
- inline uint64_t getValue() {
+ inline uint64_t getValue() const {
if (isSingleWord())
return VAL;
unsigned n = getNumWords() * 64 - CountLeadingZeros();
/// @brief Get the all-ones value.
static APInt getAllOnesValue(unsigned numBits);
+ /// @returns the '0' value for an APInt of the specified bit-width.
+ /// @brief Get the '0' value.
+ static APInt getNullValue(unsigned numBits);
+
/// @brief Set every bit to 1.
APInt& set();
/// @brief Set a given bit to 1.
APInt& set(unsigned bitPosition);
- /// @returns the '0' value for an APInt of the specified bit-width.
- /// @brief Get the '0' value.
- static APInt getNullValue(unsigned numBits);
-
/// @brief Set every bit to 0.
APInt& clear();
{ return BitsNum; }
/// @brief Check if this APInt has a N-bits integer value.
- inline bool isIntN(unsigned N) const {
+ inline bool IsIntN(unsigned N) const {
if (isSingleWord()) {
return VAL == VAL & (~uint64_t(0ULL) >> (64 - N));
} else {
}
/// @brief Converts this APInt to a double value.
- double APIntRoundToDouble(bool isSigned = false) const;
+ double RoundToDouble(bool isSigned = false) const;
/// Arithmetic right-shift this APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
- APInt ashr(unsigned shiftAmt) const;
+ APInt AShr(unsigned shiftAmt) const;
/// Logical right-shift this APInt by shiftAmt.
/// @brief Logical right-shift function.
- APInt lshr(unsigned shiftAmt) const;
+ APInt LShr(unsigned shiftAmt) const;
/// Left-shift this APInt by shiftAmt.
/// @brief Left-shift function.
- APInt shl(unsigned shiftAmt) const;
+ APInt Shl(unsigned shiftAmt) const;
/// Signed divide this APInt by APInt RHS.
/// @brief Signed division function for APInt.
- inline APInt sdiv(const APInt& RHS) const {
+ inline APInt SDiv(const APInt& RHS) const {
bool isSignedLHS = (*this)[BitsNum - 1], isSignedRHS = RHS[RHS.BitsNum - 1];
- APInt API = APIntOps::udiv(isSignedLHS ? -(*this) : (*this), isSignedRHS ? -RHS : RHS);
+ APInt API = APIntOps::UDiv(isSignedLHS ? -(*this) : (*this), isSignedRHS ? -RHS : RHS);
return isSignedLHS != isSignedRHS ? -API : API;;
}
/// Unsigned divide this APInt by APInt RHS.
/// @brief Unsigned division function for APInt.
- APInt udiv(const APInt& RHS) const;
+ APInt UDiv(const APInt& RHS) const;
/// Signed remainder operation on APInt.
/// @brief Function for signed remainder operation.
- inline APInt srem(const APInt& RHS) const {
+ inline APInt SRem(const APInt& RHS) const {
bool isSignedLHS = (*this)[BitsNum - 1], isSignedRHS = RHS[RHS.BitsNum - 1];
- APInt API = APIntOps::urem(isSignedLHS ? -(*this) : (*this), isSignedRHS ? -RHS : RHS);
+ APInt API = APIntOps::URem(isSignedLHS ? -(*this) : (*this), isSignedRHS ? -RHS : RHS);
return isSignedLHS ? -API : API;
}
/// Unsigned remainder operation on APInt.
/// @brief Function for unsigned remainder operation.
- APInt urem(const APInt& RHS) const;
+ APInt URem(const APInt& RHS) const;
};
/// @brief Check if the specified APInt has a N-bits integer value.
inline bool isIntN(unsigned N, const APInt& APIVal) {
- return APIVal.isIntN(N);
+ return APIVal.IsIntN(N);
}
/// @returns true if the argument APInt value is a sequence of ones
/// @brief Converts the given APInt to a double value.
inline double APIntRoundToDouble(const APInt& APIVal, bool isSigned = false) {
- return APIVal.APIntRoundToDouble(isSigned);
+ return APIVal.RoundToDouble(isSigned);
}
/// @brief Converts the given APInt to a float vlalue.
/// Arithmetic right-shift the APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
-inline APInt ashr(const APInt& LHS, unsigned shiftAmt) {
- return LHS.ashr(shiftAmt);
+inline APInt AShr(const APInt& LHS, unsigned shiftAmt) {
+ return LHS.AShr(shiftAmt);
}
/// Logical right-shift the APInt by shiftAmt.
/// @brief Logical right-shift function.
-inline APInt lshr(const APInt& LHS, unsigned shiftAmt) {
- return LHS.lshr(shiftAmt);
+inline APInt LShr(const APInt& LHS, unsigned shiftAmt) {
+ return LHS.LShr(shiftAmt);
}
/// Left-shift the APInt by shiftAmt.
/// @brief Left-shift function.
-inline APInt shl(const APInt& LHS, unsigned shiftAmt) {
- return LHS.shl(shiftAmt);
+inline APInt Shl(const APInt& LHS, unsigned shiftAmt) {
+ return LHS.Shl(shiftAmt);
}
/// Signed divide APInt LHS by APInt RHS.
/// @brief Signed division function for APInt.
-inline APInt sdiv(const APInt& LHS, const APInt& RHS) {
- return LHS.sdiv(RHS);
+inline APInt SDiv(const APInt& LHS, const APInt& RHS) {
+ return LHS.SDiv(RHS);
}
/// Unsigned divide APInt LHS by APInt RHS.
/// @brief Unsigned division function for APInt.
-inline APInt udiv(const APInt& LHS, const APInt& RHS) {
- return LHS.udiv(RHS);
+inline APInt UDiv(const APInt& LHS, const APInt& RHS) {
+ return LHS.UDiv(RHS);
}
/// Signed remainder operation on APInt.
/// @brief Function for signed remainder operation.
-inline APInt srem(const APInt& LHS, const APInt& RHS) {
- return LHS.srem(RHS);
+inline APInt SRem(const APInt& LHS, const APInt& RHS) {
+ return LHS.SRem(RHS);
}
/// Unsigned remainder operation on APInt.
/// @brief Function for unsigned remainder operation.
-inline APInt urem(const APInt& LHS, const APInt& RHS) {
- return LHS.urem(RHS);
+inline APInt URem(const APInt& LHS, const APInt& RHS) {
+ return LHS.URem(RHS);
}
/// Performs multiplication on APInt values.
/// @brief Function for multiplication operation.
-inline APInt mul(const APInt& LHS, const APInt& RHS) {
+inline APInt Mul(const APInt& LHS, const APInt& RHS) {
return LHS * RHS;
}
/// Performs addition on APInt values.
/// @brief Function for addition operation.
-inline APInt add(const APInt& LHS, const APInt& RHS) {
+inline APInt Add(const APInt& LHS, const APInt& RHS) {
return LHS + RHS;
}
/// Performs subtraction on APInt values.
/// @brief Function for subtraction operation.
-inline APInt sub(const APInt& LHS, const APInt& RHS) {
+inline APInt Sub(const APInt& LHS, const APInt& RHS) {
return LHS - RHS;
}
#include "llvm/ADT/APInt.h"
-#if 0
#include "llvm/DerivedTypes.h"
#include "llvm/Support/MathExtras.h"
#include <cstring>
/// HiBits - This function returns the high "numBits" bits of this APInt.
APInt APInt::HiBits(unsigned numBits) const {
- return APIntOps::lshr(*this, BitsNum - numBits);
+ return APIntOps::LShr(*this, BitsNum - numBits);
}
/// LoBits - This function returns the low "numBits" bits of this APInt.
APInt APInt::LoBits(unsigned numBits) const {
- return APIntOps::lshr(APIntOps::shl(*this, BitsNum - numBits),
+ return APIntOps::LShr(APIntOps::Shl(*this, BitsNum - numBits),
BitsNum - numBits);
}
APInt A = API1, B = API2;
while (!!B) {
APInt T = B;
- B = APIntOps::urem(A, B);
+ B = APIntOps::URem(A, B);
A = T;
}
return A;
return isNeg ? -APInt(mantissa >> (52 - exp)) :
APInt(mantissa >> (52 - exp));
APInt Tmp(mantissa, exp + 1);
- Tmp = Tmp.shl(exp - 52);
+ Tmp = Tmp.Shl(exp - 52);
return isNeg ? -Tmp : Tmp;
}
-/// APIntRoundToDouble - This function convert this APInt to a double.
+/// RoundToDouble - This function convert this APInt to a double.
/// The layout for double is as following (IEEE Standard 754):
/// --------------------------------------
/// | Sign Exponent Fraction Bias |
/// |-------------------------------------- |
/// | 1[63] 11[62-52] 52[51-00] 1023 |
/// --------------------------------------
-double APInt::APIntRoundToDouble(bool isSigned) const {
+double APInt::RoundToDouble(bool isSigned) const {
bool isNeg = isSigned ? (*this)[BitsNum-1] : false;
APInt Tmp(isNeg ? -(*this) : (*this));
if (Tmp.isSingleWord())
/// Arithmetic right-shift this APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
-APInt APInt::ashr(unsigned shiftAmt) const {
+APInt APInt::AShr(unsigned shiftAmt) const {
APInt API(*this);
if (API.isSingleWord())
API.VAL = (((int64_t(API.VAL) << (64 - API.BitsNum)) >> (64 - API.BitsNum))
/// Logical right-shift this APInt by shiftAmt.
/// @brief Logical right-shift function.
-APInt APInt::lshr(unsigned shiftAmt) const {
+APInt APInt::LShr(unsigned shiftAmt) const {
APInt API(*this);
if (API.isSingleWord())
API.VAL >>= shiftAmt;
/// Left-shift this APInt by shiftAmt.
/// @brief Left-shift function.
-APInt APInt::shl(unsigned shiftAmt) const {
+APInt APInt::Shl(unsigned shiftAmt) const {
APInt API(*this);
if (API.isSingleWord())
API.VAL <<= shiftAmt;
/// Unsigned divide this APInt by APInt RHS.
/// @brief Unsigned division function for APInt.
-APInt APInt::udiv(const APInt& RHS) const {
+APInt APInt::UDiv(const APInt& RHS) const {
APInt API(*this);
unsigned first = RHS.getNumWords() * APInt::APINT_BITS_PER_WORD -
RHS.CountLeadingZeros();
/// Unsigned remainder operation on APInt.
/// @brief Function for unsigned remainder operation.
-APInt APInt::urem(const APInt& RHS) const {
+APInt APInt::URem(const APInt& RHS) const {
APInt API(*this);
unsigned first = RHS.getNumWords() * APInt::APINT_BITS_PER_WORD -
RHS.CountLeadingZeros();
}
return API;
}
-
-#endif
-