mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 06:29:05 +00:00
Actually, for getHighBitsSet and getLowBitsSet, don't make a 0 bit size
illegal. Instead do the 0 valued construction for the user. This is because the caller may not know (or care to check) that the number of bits set is zero. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35315 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -355,7 +355,9 @@ public:
|
|||||||
/// @brief Get a value with high bits set
|
/// @brief Get a value with high bits set
|
||||||
static APInt getHighBitsSet(uint32_t numBits, uint32_t hiBitsSet) {
|
static APInt getHighBitsSet(uint32_t numBits, uint32_t hiBitsSet) {
|
||||||
assert(hiBitsSet <= numBits && "Too many bits to set!");
|
assert(hiBitsSet <= numBits && "Too many bits to set!");
|
||||||
assert(hiBitsSet > 0 && "You must set SOME bits");
|
// Handle a degenerate case, to avoid shifting by word size
|
||||||
|
if (hiBitsSet == 0)
|
||||||
|
return APInt(numBits, 0);
|
||||||
uint32_t shiftAmt = numBits - hiBitsSet;
|
uint32_t shiftAmt = numBits - hiBitsSet;
|
||||||
// For small values, return quickly
|
// For small values, return quickly
|
||||||
if (numBits <= APINT_BITS_PER_WORD)
|
if (numBits <= APINT_BITS_PER_WORD)
|
||||||
@@ -369,7 +371,9 @@ public:
|
|||||||
/// @brief Get a value with low bits set
|
/// @brief Get a value with low bits set
|
||||||
static APInt getLowBitsSet(uint32_t numBits, uint32_t loBitsSet) {
|
static APInt getLowBitsSet(uint32_t numBits, uint32_t loBitsSet) {
|
||||||
assert(loBitsSet <= numBits && "Too many bits to set!");
|
assert(loBitsSet <= numBits && "Too many bits to set!");
|
||||||
assert(loBitsSet > 0 && "You must set SOME bits");
|
// Handle a degenerate case, to avoid shifting by word size
|
||||||
|
if (loBitsSet == 0)
|
||||||
|
return APInt(numBits, 0);
|
||||||
uint32_t shiftAmt = numBits - loBitsSet;
|
uint32_t shiftAmt = numBits - loBitsSet;
|
||||||
// For small values, return quickly
|
// For small values, return quickly
|
||||||
if (numBits <= APINT_BITS_PER_WORD)
|
if (numBits <= APINT_BITS_PER_WORD)
|
||||||
|
Reference in New Issue
Block a user