aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/MathExtras.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2009-08-12 06:22:07 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2009-08-12 06:22:07 +0000
commit314f7f71410cf75f5900c9f8fd9da626147cb864 (patch)
tree6596d9985a6e4370edbf4bb7343eb94c53ab4aff /include/llvm/Support/MathExtras.h
parent970e1b7ac8c812e2a74d42eaa1d582988f546d78 (diff)
downloadexternal_llvm-314f7f71410cf75f5900c9f8fd9da626147cb864.zip
external_llvm-314f7f71410cf75f5900c9f8fd9da626147cb864.tar.gz
external_llvm-314f7f71410cf75f5900c9f8fd9da626147cb864.tar.bz2
Move immediate constant predicate templates from the Blackfin target to MathExtras.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r--include/llvm/Support/MathExtras.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index a143d19..15a67e4 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -52,6 +52,16 @@ inline bool isUInt32(int64_t Value) {
return static_cast<uint32_t>(Value) == Value;
}
+template<unsigned N>
+inline bool isInt(int64_t x) {
+ return -(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1));
+}
+
+template<unsigned N>
+inline bool isUint(uint64_t x) {
+ return x < (UINT64_C(1)<<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.