summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-02-09 07:48:24 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-02-09 07:48:24 +0000
commite93db8fba23c2d4366c94f67d27f6b3dc6a45cff (patch)
tree561ec8e6dc9691a9bf5cce9545d324f32af4ead6 /llvm/lib
parent133ae0b2a66e8a1347e55f4a787bdf0a33f15d19 (diff)
downloadbcm5719-llvm-e93db8fba23c2d4366c94f67d27f6b3dc6a45cff.tar.gz
bcm5719-llvm-e93db8fba23c2d4366c94f67d27f6b3dc6a45cff.zip
Eliminates friend function declaration inside APInt, instead, adds public
methods as those global function's internal implementation. llvm-svn: 34083
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/APInt.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index dccabda1b57..80ea80489cc 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -674,8 +674,8 @@ APInt APInt::operator-(const APInt& RHS) const {
/// @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 @@ unsigned APInt::CountPopulation() const {
/// 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 @@ APInt llvm::APIntOps::GreatestCommonDivisor(const APInt& API1,
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 @@ APInt llvm::APIntOps::ashr(const APInt& LHS, unsigned shiftAmt) {
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 @@ APInt llvm::APIntOps::lshr(const APInt& RHS, unsigned shiftAmt) {
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 @@ APInt llvm::APIntOps::shl(const APInt& RHS, unsigned shiftAmt) {
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 @@ APInt llvm::APIntOps::udiv(const APInt& LHS, const APInt& RHS) {
/// 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;
OpenPOWER on IntegriCloud