Author: andersca Date: Thu Aug 2 01:00:13 2007 New Revision: 40724 URL: http://llvm.org/viewvc/llvm-project?rev=40724&view=rev Log: Add extend and extOrTrunc methods that do sign or zero extension depending on whether the integer is signed or not
Modified: llvm/trunk/include/llvm/ADT/APSInt.h Modified: llvm/trunk/include/llvm/ADT/APSInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=40724&r1=40723&r2=40724&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APSInt.h (original) +++ llvm/trunk/include/llvm/ADT/APSInt.h Thu Aug 2 01:00:13 2007 @@ -83,6 +83,22 @@ 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); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits