diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-03 00:38:40 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-03 00:38:40 +0000 |
commit | 5005e27f9714f0eaa5b8b7a5a1f6751afa163f07 (patch) | |
tree | 6276391e2456e32c527f50d8d98b7c611d52c859 /include/llvm/Support/MathExtras.h | |
parent | 9372fd3c92777a137f0a1a34375c1863afe64c9c (diff) | |
download | external_llvm-5005e27f9714f0eaa5b8b7a5a1f6751afa163f07.zip external_llvm-5005e27f9714f0eaa5b8b7a5a1f6751afa163f07.tar.gz external_llvm-5005e27f9714f0eaa5b8b7a5a1f6751afa163f07.tar.bz2 |
Factor code out of APInt to form a isUIntN helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r-- | include/llvm/Support/MathExtras.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 3b90780..dafb479 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -71,6 +71,12 @@ inline bool isUInt<32>(uint64_t x) { return static_cast<uint32_t>(x) == x; } +/// isUIntN - Checks if an unsigned integer fits into the given (dynamic) +/// bit width. +inline bool isUIntN(unsigned N, uint64_t x) { + return x == (x & (~0ULL >> (64 - N))); +} + /// isMask_32 - This function returns true if the argument is a sequence of ones /// starting at the least significant bit with the remainder zero (32 bit /// version). Ex. isMask_32(0x0000FFFFU) == true. |