summaryrefslogtreecommitdiffstats
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-24 22:57:28 +0000
committerChris Lattner <sabre@nondot.org>2005-09-24 22:57:28 +0000
commita58ef7b6526ee30f4793fe91686899c602b4f9b9 (patch)
treecec2bd048e9ce45550cc6748fa3167320c7ec4a8 /include/llvm/Constants.h
parent5d735bf29bb85c3d691d4e0c61f15b1675b90355 (diff)
downloadexternal_llvm-a58ef7b6526ee30f4793fe91686899c602b4f9b9.zip
external_llvm-a58ef7b6526ee30f4793fe91686899c602b4f9b9.tar.gz
external_llvm-a58ef7b6526ee30f4793fe91686899c602b4f9b9.tar.bz2
Add long-overdue helpers for getting constants with known upper bits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 4a5d018..4b5d883 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -54,7 +54,21 @@ public:
/// unsigned integer value.
///
inline uint64_t getRawValue() const { return Val.Unsigned; }
+
+ /// getZExtValue - Return the constant zero extended as appropriate for this
+ /// type.
+ inline uint64_t getZExtValue() const {
+ unsigned Size = getType()->getPrimitiveSizeInBits();
+ return Val.Unsigned & (~0ULL >> (64-Size));
+ }
+ /// getSExtValue - Return the constant sign extended as appropriate for this
+ /// type.
+ inline int64_t getSExtValue() const {
+ unsigned Size = getType()->getPrimitiveSizeInBits();
+ return (Val.Signed << (64-Size)) >> (64-Size);
+ }
+
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue.
///