mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 22:24:28 +00:00
Add support to APInt for shift and rotate operations with APInt
instead of uint32_t for the shift/rotate count operand type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47741 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -584,6 +584,10 @@ public:
|
|||||||
return shl(Bits);
|
return shl(Bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt operator<<(const APInt &Bits) const {
|
||||||
|
return shl(Bits);
|
||||||
|
}
|
||||||
|
|
||||||
/// Arithmetic right-shift this APInt by shiftAmt.
|
/// Arithmetic right-shift this APInt by shiftAmt.
|
||||||
/// @brief Arithmetic right-shift function.
|
/// @brief Arithmetic right-shift function.
|
||||||
APInt ashr(uint32_t shiftAmt) const;
|
APInt ashr(uint32_t shiftAmt) const;
|
||||||
@ -602,6 +606,24 @@ public:
|
|||||||
/// @brief Rotate right by rotateAmt.
|
/// @brief Rotate right by rotateAmt.
|
||||||
APInt rotr(uint32_t rotateAmt) const;
|
APInt rotr(uint32_t rotateAmt) const;
|
||||||
|
|
||||||
|
/// Arithmetic right-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Arithmetic right-shift function.
|
||||||
|
APInt ashr(const APInt &shiftAmt) const;
|
||||||
|
|
||||||
|
/// Logical right-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Logical right-shift function.
|
||||||
|
APInt lshr(const APInt &shiftAmt) const;
|
||||||
|
|
||||||
|
/// Left-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Left-shift function.
|
||||||
|
APInt shl(const APInt &shiftAmt) const;
|
||||||
|
|
||||||
|
/// @brief Rotate left by rotateAmt.
|
||||||
|
APInt rotl(const APInt &rotateAmt) const;
|
||||||
|
|
||||||
|
/// @brief Rotate right by rotateAmt.
|
||||||
|
APInt rotr(const APInt &rotateAmt) const;
|
||||||
|
|
||||||
/// Perform an unsigned divide operation on this APInt by RHS. Both this and
|
/// Perform an unsigned divide operation on this APInt by RHS. Both this and
|
||||||
/// RHS are treated as unsigned quantities for purposes of this division.
|
/// RHS are treated as unsigned quantities for purposes of this division.
|
||||||
/// @returns a new APInt value containing the division result
|
/// @returns a new APInt value containing the division result
|
||||||
|
@ -1083,6 +1083,12 @@ APInt &APInt::sextOrTrunc(uint32_t width) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Arithmetic right-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Arithmetic right-shift function.
|
||||||
|
APInt APInt::ashr(const APInt &shiftAmt) const {
|
||||||
|
return ashr(shiftAmt.getLimitedValue(BitWidth));
|
||||||
|
}
|
||||||
|
|
||||||
/// Arithmetic right-shift this APInt by shiftAmt.
|
/// Arithmetic right-shift this APInt by shiftAmt.
|
||||||
/// @brief Arithmetic right-shift function.
|
/// @brief Arithmetic right-shift function.
|
||||||
APInt APInt::ashr(uint32_t shiftAmt) const {
|
APInt APInt::ashr(uint32_t shiftAmt) const {
|
||||||
@ -1166,6 +1172,12 @@ APInt APInt::ashr(uint32_t shiftAmt) const {
|
|||||||
return APInt(val, BitWidth).clearUnusedBits();
|
return APInt(val, BitWidth).clearUnusedBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Logical right-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Logical right-shift function.
|
||||||
|
APInt APInt::lshr(const APInt &shiftAmt) const {
|
||||||
|
return ashr(shiftAmt.getLimitedValue(BitWidth));
|
||||||
|
}
|
||||||
|
|
||||||
/// Logical right-shift this APInt by shiftAmt.
|
/// Logical right-shift this APInt by shiftAmt.
|
||||||
/// @brief Logical right-shift function.
|
/// @brief Logical right-shift function.
|
||||||
APInt APInt::lshr(uint32_t shiftAmt) const {
|
APInt APInt::lshr(uint32_t shiftAmt) const {
|
||||||
@ -1228,6 +1240,13 @@ APInt APInt::lshr(uint32_t shiftAmt) const {
|
|||||||
return APInt(val, BitWidth).clearUnusedBits();
|
return APInt(val, BitWidth).clearUnusedBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Left-shift this APInt by shiftAmt.
|
||||||
|
/// @brief Left-shift function.
|
||||||
|
APInt APInt::shl(const APInt &shiftAmt) const {
|
||||||
|
// It's undefined behavior in C to shift by BitWidth or greater, but
|
||||||
|
return shl(shiftAmt.getLimitedValue(BitWidth));
|
||||||
|
}
|
||||||
|
|
||||||
/// Left-shift this APInt by shiftAmt.
|
/// Left-shift this APInt by shiftAmt.
|
||||||
/// @brief Left-shift function.
|
/// @brief Left-shift function.
|
||||||
APInt APInt::shl(uint32_t shiftAmt) const {
|
APInt APInt::shl(uint32_t shiftAmt) const {
|
||||||
@ -1287,6 +1306,10 @@ APInt APInt::shl(uint32_t shiftAmt) const {
|
|||||||
return APInt(val, BitWidth).clearUnusedBits();
|
return APInt(val, BitWidth).clearUnusedBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt APInt::rotl(const APInt &rotateAmt) const {
|
||||||
|
return rotl(rotateAmt.getLimitedValue(BitWidth));
|
||||||
|
}
|
||||||
|
|
||||||
APInt APInt::rotl(uint32_t rotateAmt) const {
|
APInt APInt::rotl(uint32_t rotateAmt) const {
|
||||||
if (rotateAmt == 0)
|
if (rotateAmt == 0)
|
||||||
return *this;
|
return *this;
|
||||||
@ -1298,6 +1321,10 @@ APInt APInt::rotl(uint32_t rotateAmt) const {
|
|||||||
return hi | lo;
|
return hi | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt APInt::rotr(const APInt &rotateAmt) const {
|
||||||
|
return rotr(rotateAmt.getLimitedValue(BitWidth));
|
||||||
|
}
|
||||||
|
|
||||||
APInt APInt::rotr(uint32_t rotateAmt) const {
|
APInt APInt::rotr(uint32_t rotateAmt) const {
|
||||||
if (rotateAmt == 0)
|
if (rotateAmt == 0)
|
||||||
return *this;
|
return *this;
|
||||||
|
Reference in New Issue
Block a user