diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-12 21:47:33 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-12 21:47:33 +0000 |
commit | ffe3e2514a2550152267072ed7afeebb3dd3016c (patch) | |
tree | 7c6a6b24a26a4efb183d096d05a6a876474bd580 /include/llvm/ADT/APInt.h | |
parent | caf4fbd5df1f4e0c1bd305391271e203949a2477 (diff) | |
download | llvm-ffe3e2514a2550152267072ed7afeebb3dd3016c.tar.gz llvm-ffe3e2514a2550152267072ed7afeebb3dd3016c.tar.bz2 llvm-ffe3e2514a2550152267072ed7afeebb3dd3016c.tar.xz |
Change APInt::getBitsSet to accept a "half-open" range, where the
hiBit parameter marks the index one past the last desired set bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r-- | include/llvm/ADT/APInt.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index a1ccb8513c..34c05e6df7 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -370,22 +370,22 @@ public: APInt getLoBits(uint32_t numBits) const; /// Constructs an APInt value that has a contiguous range of bits set. The - /// bits from loBit to hiBit will be set. All other bits will be zero. For - /// example, with parameters(32, 0, 15) you would get 0x0000FFFF. If hiBit is - /// less than loBit then the set bits "wrap". For example, with - /// parameters (32, 28, 3), you would get 0xF000000F. + /// bits from loBit (inclusive) to hiBit (exclusive) will be set. All other + /// bits will be zero. For example, with parameters(32, 0, 16) you would get + /// 0x0000FFFF. If hiBit is less than loBit then the set bits "wrap". For + /// example, with parameters (32, 28, 4), you would get 0xF000000F. /// @param numBits the intended bit width of the result /// @param loBit the index of the lowest bit set. /// @param hiBit the index of the highest bit set. /// @returns An APInt value with the requested bits set. /// @brief Get a value with a block of bits set. static APInt getBitsSet(uint32_t numBits, uint32_t loBit, uint32_t hiBit) { - assert(hiBit < numBits && "hiBit out of range"); + assert(hiBit <= numBits && "hiBit out of range"); assert(loBit < numBits && "loBit out of range"); if (hiBit < loBit) - return getLowBitsSet(numBits, hiBit+1) | + return getLowBitsSet(numBits, hiBit) | getHighBitsSet(numBits, numBits-loBit); - return getLowBitsSet(numBits, hiBit-loBit+1).shl(loBit); + return getLowBitsSet(numBits, hiBit-loBit).shl(loBit); } /// Constructs an APInt value that has the top hiBitsSet bits set. |