diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-15 07:12:24 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-15 07:12:24 +0000 |
commit | b35d56c2fe39064a33d0e4e7faf5464b6d8a7352 (patch) | |
tree | 4bc453b9baed22e72cc209025c4f83ea13aa3cd4 /include/llvm | |
parent | ef17f08dbc3897f6826c593e27619383dda1035a (diff) | |
download | external_llvm-b35d56c2fe39064a33d0e4e7faf5464b6d8a7352.zip external_llvm-b35d56c2fe39064a33d0e4e7faf5464b6d8a7352.tar.gz external_llvm-b35d56c2fe39064a33d0e4e7faf5464b6d8a7352.tar.bz2 |
Generalize an assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-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 6740786..d0b3477 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -76,6 +76,12 @@ inline bool isUIntN(unsigned N, uint64_t x) { return x == (x & (~0ULL >> (64 - N))); } +/// isIIntN - Checks if an signed integer fits into the given (dynamic) +/// bit width. +inline bool isIntN(unsigned N, int64_t x) { + return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); +} + /// 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. |