diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-09-24 22:57:28 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-09-24 22:57:28 +0000 |
| commit | 699c80eebefabae4635bace11e5e37e19842b0b5 (patch) | |
| tree | 8cb9c02cb68556767b34be70652f8acf9e9a08c6 | |
| parent | 175463a165419b5c553384674139faf600fe5ea5 (diff) | |
| download | bcm5719-llvm-699c80eebefabae4635bace11e5e37e19842b0b5.tar.gz bcm5719-llvm-699c80eebefabae4635bace11e5e37e19842b0b5.zip | |
Add long-overdue helpers for getting constants with known upper bits
llvm-svn: 23426
| -rw-r--r-- | llvm/include/llvm/Constants.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h index 4a5d0181a52..4b5d883bbfa 100644 --- a/llvm/include/llvm/Constants.h +++ b/llvm/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. /// |

