mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-02 07:32:52 +00:00
Fix APInt::rotl and APInt::rotr so that they work correctly. Found while writing some code that tried to use them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147134 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
090445967f
commit
2acbd7ddc0
@ -1338,14 +1338,10 @@ APInt APInt::rotl(const APInt &rotateAmt) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
APInt APInt::rotl(unsigned rotateAmt) const {
|
APInt APInt::rotl(unsigned rotateAmt) const {
|
||||||
|
rotateAmt %= BitWidth;
|
||||||
if (rotateAmt == 0)
|
if (rotateAmt == 0)
|
||||||
return *this;
|
return *this;
|
||||||
// Don't get too fancy, just use existing shift/or facilities
|
return shl(rotateAmt) | lshr(BitWidth - rotateAmt);
|
||||||
APInt hi(*this);
|
|
||||||
APInt lo(*this);
|
|
||||||
hi.shl(rotateAmt);
|
|
||||||
lo.lshr(BitWidth - rotateAmt);
|
|
||||||
return hi | lo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APInt APInt::rotr(const APInt &rotateAmt) const {
|
APInt APInt::rotr(const APInt &rotateAmt) const {
|
||||||
@ -1353,14 +1349,10 @@ APInt APInt::rotr(const APInt &rotateAmt) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
APInt APInt::rotr(unsigned rotateAmt) const {
|
APInt APInt::rotr(unsigned rotateAmt) const {
|
||||||
|
rotateAmt %= BitWidth;
|
||||||
if (rotateAmt == 0)
|
if (rotateAmt == 0)
|
||||||
return *this;
|
return *this;
|
||||||
// Don't get too fancy, just use existing shift/or facilities
|
return lshr(rotateAmt) | shl(BitWidth - rotateAmt);
|
||||||
APInt hi(*this);
|
|
||||||
APInt lo(*this);
|
|
||||||
lo.lshr(rotateAmt);
|
|
||||||
hi.shl(BitWidth - rotateAmt);
|
|
||||||
return hi | lo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Square Root - this method computes and returns the square root of "this".
|
// Square Root - this method computes and returns the square root of "this".
|
||||||
|
Loading…
Reference in New Issue
Block a user