[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

Reid Spencer reid at x10sys.com
Thu Mar 1 09:15:49 PST 2007



Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.61 -> 1.62
---
Log message:

Add methods for bit width modification: sextOrTrunc, zextOrTrunc.


---
Diffs of the changes:  (+16 -0)

 APInt.cpp |   16 ++++++++++++++++
 1 files changed, 16 insertions(+)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.61 llvm/lib/Support/APInt.cpp:1.62
--- llvm/lib/Support/APInt.cpp:1.61	Thu Mar  1 00:23:32 2007
+++ llvm/lib/Support/APInt.cpp	Thu Mar  1 11:15:32 2007
@@ -985,6 +985,22 @@
   return *this;
 }
 
+APInt &APInt::zextOrTrunc(uint32_t width) {
+  if (BitWidth < width)
+    return zext(width);
+  if (BitWidth > width)
+    return trunc(width);
+  return *this;
+}
+
+APInt &APInt::sextOrTrunc(uint32_t width) {
+  if (BitWidth < width)
+    return sext(width);
+  if (BitWidth > width)
+    return trunc(width);
+  return *this;
+}
+
 /// Arithmetic right-shift this APInt by shiftAmt.
 /// @brief Arithmetic right-shift function.
 APInt APInt::ashr(uint32_t shiftAmt) const {






More information about the llvm-commits mailing list