mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
1. Split getValue() into getSExtValue() and getZExtValue() to match
ConstantInt better. 2. Add a getHashValue() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -447,16 +447,27 @@ public:
|
|||||||
return BitWidth - countLeadingZeros();
|
return BitWidth - countLeadingZeros();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns a uint64_t value from this APInt. If this APInt contains a single
|
/// This method attempts to return the value of this APInt as a zero extended
|
||||||
/// word, just returns VAL, otherwise pVal[0].
|
/// uint64_t. The bitwidth must be <= 64 or the value must fit within a
|
||||||
inline uint64_t getValue(bool isSigned = false) const {
|
/// uint64_t. Otherwise an assertion will result.
|
||||||
|
/// @brief Get zero extended value
|
||||||
|
inline uint64_t getZExtValue() const {
|
||||||
if (isSingleWord())
|
if (isSingleWord())
|
||||||
return isSigned ? int64_t(VAL << (64 - BitWidth)) >>
|
return VAL;
|
||||||
(64 - BitWidth) : VAL;
|
assert(getActiveBits() <= 64 && "Too many bits for uint64_t");
|
||||||
uint32_t n = getActiveBits();
|
return pVal[0];
|
||||||
if (n <= 64)
|
}
|
||||||
return pVal[0];
|
|
||||||
assert(0 && "This APInt's bitwidth > 64");
|
/// This method attempts to return the value of this APInt as a sign extended
|
||||||
|
/// int64_t. The bit width must be <= 64 or the value must fit within an
|
||||||
|
/// int64_t. Otherwise an assertion will result.
|
||||||
|
/// @brief Get sign extended value
|
||||||
|
inline int64_t getSExtValue() const {
|
||||||
|
if (isSingleWord())
|
||||||
|
return int64_t(VAL << (APINT_BITS_PER_WORD - BitWidth)) >>
|
||||||
|
(APINT_BITS_PER_WORD - BitWidth);
|
||||||
|
assert(getActiveBits() <= 64 && "Too many bits for int64_t");
|
||||||
|
return int64_t(pVal[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns the largest value for an APInt of the specified bit-width and
|
/// @returns the largest value for an APInt of the specified bit-width and
|
||||||
@@ -478,6 +489,11 @@ public:
|
|||||||
/// @brief Get the '0' value.
|
/// @brief Get the '0' value.
|
||||||
static APInt getNullValue(uint32_t numBits);
|
static APInt getNullValue(uint32_t numBits);
|
||||||
|
|
||||||
|
/// The hash value is computed as the sum of the words and the bit width.
|
||||||
|
/// @returns A hash value computed from the sum of the APInt words.
|
||||||
|
/// @brief Get a hash value based on this APInt
|
||||||
|
uint64_t getHashValue() const;
|
||||||
|
|
||||||
/// This converts the APInt to a boolean valy as a test against zero.
|
/// This converts the APInt to a boolean valy as a test against zero.
|
||||||
/// @brief Boolean conversion function.
|
/// @brief Boolean conversion function.
|
||||||
inline bool getBoolValue() const {
|
inline bool getBoolValue() const {
|
||||||
|
Reference in New Issue
Block a user