summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/APSInt.h
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2007-08-02 06:00:13 +0000
committerAnders Carlsson <andersca@mac.com>2007-08-02 06:00:13 +0000
commit7ccd9ec4f40d1cdf740c98dab8e212943a4b4863 (patch)
tree00795dc7f1686c3ac19457b6fc1cba548d60b3b7 /include/llvm/ADT/APSInt.h
parent7afa166c7663269824c3a164a3909ec5f97ed26a (diff)
downloadllvm-7ccd9ec4f40d1cdf740c98dab8e212943a4b4863.tar.gz
llvm-7ccd9ec4f40d1cdf740c98dab8e212943a4b4863.tar.bz2
llvm-7ccd9ec4f40d1cdf740c98dab8e212943a4b4863.tar.xz
Add extend and extOrTrunc methods that do sign or zero extension depending on whether the integer is signed or not
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40724 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APSInt.h')
-rw-r--r--include/llvm/ADT/APSInt.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/APSInt.h b/include/llvm/ADT/APSInt.h
index 4eb4be2317..a2f0321c8b 100644
--- a/include/llvm/ADT/APSInt.h
+++ b/include/llvm/ADT/APSInt.h
@@ -83,6 +83,22 @@ public:
return *this;
}
+ APSInt& extend(uint32_t width) {
+ if (IsUnsigned)
+ *this = zext(width);
+ else
+ *this = sext(width);
+ return *this;
+ }
+
+ APSInt& extOrTrunc(uint32_t width) {
+ if (IsUnsigned)
+ *this = zextOrTrunc(width);
+ else
+ *this = sextOrTrunc(width);
+ return *this;
+ }
+
APSInt operator>>(unsigned Amt) const {
return IsUnsigned ? lshr(Amt) : ashr(Amt);
}