[llvm-commits] CVS: llvm/lib/Support/APInt.cpp
Zhou Sheng
zhousheng00 at gmail.com
Thu Feb 8 23:48:40 PST 2007
Changes in directory llvm/lib/Support:
APInt.cpp updated: 1.6 -> 1.7
---
Log message:
Eliminates friend function declaration inside APInt, instead, adds public
methods as those global function's internal implementation.
---
Diffs of the changes: (+23 -23)
APInt.cpp | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.6 llvm/lib/Support/APInt.cpp:1.7
--- llvm/lib/Support/APInt.cpp:1.6 Thu Feb 8 10:45:48 2007
+++ llvm/lib/Support/APInt.cpp Fri Feb 9 01:48:24 2007
@@ -674,8 +674,8 @@
/// @brief Array-indexing support.
bool APInt::operator[](unsigned bitPosition) const {
- return maskBit(bitPosition) & (isSingleWord() ?
- VAL : pVal[whichWord(bitPosition)]) != 0;
+ return (maskBit(bitPosition) & (isSingleWord() ?
+ VAL : pVal[whichWord(bitPosition)])) != 0;
}
/// @brief Equality operator. Compare this APInt with the given APInt& RHS
@@ -932,14 +932,14 @@
/// ByteSwap - This function returns a byte-swapped representation of the
-/// APInt argument, APIVal.
-APInt llvm::APIntOps::ByteSwap(const APInt& APIVal) {
- if (APIVal.BitsNum <= 32)
- return APInt(APIVal.BitsNum, ByteSwap_32(unsigned(APIVal.VAL)));
- else if (APIVal.BitsNum <= 64)
- return APInt(APIVal.BitsNum, ByteSwap_64(APIVal.VAL));
+/// this APInt.
+APInt APInt::ByteSwap() const {
+ if (BitsNum <= 32)
+ return APInt(BitsNum, ByteSwap_32(unsigned(VAL)));
+ else if (BitsNum <= 64)
+ return APInt(BitsNum, ByteSwap_64(VAL));
else
- return APIVal;
+ return *this;
}
/// GreatestCommonDivisor - This function returns the greatest common
@@ -955,10 +955,10 @@
return A;
}
-/// Arithmetic right-shift the APInt by shiftAmt.
+/// Arithmetic right-shift this APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
-APInt llvm::APIntOps::ashr(const APInt& LHS, unsigned shiftAmt) {
- APInt API(LHS);
+APInt APInt::ashr(unsigned shiftAmt) const {
+ APInt API(*this);
if (API.isSingleWord())
API.VAL = (((int64_t(API.VAL) << (64 - API.BitsNum)) >> (64 - API.BitsNum))
>> shiftAmt) & (~uint64_t(0UL) >> (64 - API.BitsNum));
@@ -981,10 +981,10 @@
return API;
}
-/// Logical right-shift the APInt by shiftAmt.
+/// Logical right-shift this APInt by shiftAmt.
/// @brief Logical right-shift function.
-APInt llvm::APIntOps::lshr(const APInt& RHS, unsigned shiftAmt) {
- APInt API(RHS);
+APInt APInt::lshr(unsigned shiftAmt) const {
+ APInt API(*this);
if (API.isSingleWord())
API.VAL >>= shiftAmt;
else {
@@ -1000,10 +1000,10 @@
return API;
}
-/// Left-shift the APInt by shiftAmt.
+/// Left-shift this APInt by shiftAmt.
/// @brief Left-shift function.
-APInt llvm::APIntOps::shl(const APInt& RHS, unsigned shiftAmt) {
- APInt API(RHS);
+APInt APInt::shl(unsigned shiftAmt) const {
+ APInt API(*this);
if (shiftAmt >= API.BitsNum) {
if (API.isSingleWord())
API.VAL = 0;
@@ -1019,10 +1019,10 @@
return API;
}
-/// Unsigned divide APInt LHS by APInt RHS.
+/// Unsigned divide this APInt by APInt RHS.
/// @brief Unsigned division function for APInt.
-APInt llvm::APIntOps::udiv(const APInt& LHS, const APInt& RHS) {
- APInt API(LHS);
+APInt APInt::udiv(const APInt& RHS) const {
+ APInt API(*this);
unsigned first = RHS.getNumWords() * APInt::APINT_BITS_PER_WORD -
RHS.CountLeadingZeros();
unsigned ylen = !first ? 0 : APInt::whichWord(first - 1) + 1;
@@ -1066,8 +1066,8 @@
/// Unsigned remainder operation on APInt.
/// @brief Function for unsigned remainder operation.
-APInt llvm::APIntOps::urem(const APInt& LHS, const APInt& RHS) {
- APInt API(LHS);
+APInt APInt::urem(const APInt& RHS) const {
+ APInt API(*this);
unsigned first = RHS.getNumWords() * APInt::APINT_BITS_PER_WORD -
RHS.CountLeadingZeros();
unsigned ylen = !first ? 0 : APInt::whichWord(first - 1) + 1;
More information about the llvm-commits
mailing list