aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-03-30 03:22:55 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-03-30 03:22:55 +0000
commitb422d2d9e5632585adb0c1855b217f3123cbdfef (patch)
treeeb931b879b97fab1002ebbfd991705d706f11084
parent0d60b5a5439c13c82069bd4de696d09ec3b8d95b (diff)
Add two utility methods into ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35501 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Constants.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 86fc2e7018..7e9f5d0747 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -174,6 +174,22 @@ public:
return Val.isMinValue();
}
+ /// This function will return true iff this constant represents a value with
+ /// active bits bigger than 64 bits or a value greater than the given uint64_t
+ /// value.
+ /// @returns true iff this constant is greater or equal to the given number.
+ /// @brief Determine if the value is greater or equal to the given number.
+ bool greaterOrEqual(uint64_t Num) {
+ return Val.getActiveBits() > 64 || Val.getZExtValue() > Num;
+ }
+
+ /// @returns the 64-bit value of this constant if its active bits number is
+ /// not greater than 64, otherwise, just return the given uint64_t number.
+ /// @brief Get the constant's value if possible.
+ uint64_t getLimitedValue(uint64_t Limit) {
+ return (Val.getActiveBits() > 64) ? Limit : Val.getZExtValue();
+ }
+
/// @returns the value for an integer constant of the given type that has all
/// its bits set to true.
/// @brief Get the all ones value