[llvm-commits] CVS: llvm/lib/Support/APInt.cpp
Reid Spencer
reid at x10sys.com
Wed Feb 28 09:34:49 PST 2007
Changes in directory llvm/lib/Support:
APInt.cpp updated: 1.58 -> 1.59
---
Log message:
Make the trunc/sext/zext methods return APInt& so that these operations
can be chained together with other operations.
---
Diffs of the changes: (+8 -7)
APInt.cpp | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.58 llvm/lib/Support/APInt.cpp:1.59
--- llvm/lib/Support/APInt.cpp:1.58 Tue Feb 27 19:30:08 2007
+++ llvm/lib/Support/APInt.cpp Wed Feb 28 11:34:32 2007
@@ -896,7 +896,7 @@
}
// Truncate to new width.
-void APInt::trunc(uint32_t width) {
+APInt &APInt::trunc(uint32_t width) {
assert(width < BitWidth && "Invalid APInt Truncate request");
assert(width >= IntegerType::MIN_INT_BITS && "Can't truncate to 0 bits");
uint32_t wordsBefore = getNumWords();
@@ -915,17 +915,17 @@
pVal = newVal;
}
}
- clearUnusedBits();
+ return clearUnusedBits();
}
// Sign extend to a new width.
-void APInt::sext(uint32_t width) {
+APInt &APInt::sext(uint32_t width) {
assert(width > BitWidth && "Invalid APInt SignExtend request");
assert(width <= IntegerType::MAX_INT_BITS && "Too many bits");
// If the sign bit isn't set, this is the same as zext.
if (!isNegative()) {
zext(width);
- return;
+ return *this;
}
// The sign bit is set. First, get some facts
@@ -944,7 +944,7 @@
else
pVal[wordsBefore-1] |= mask;
clearUnusedBits();
- return;
+ return *this;
}
uint64_t mask = wordBits == 0 ? 0 : ~0ULL << wordBits;
@@ -961,11 +961,11 @@
if (wordsBefore != 1)
delete [] pVal;
pVal = newVal;
- clearUnusedBits();
+ return clearUnusedBits();
}
// Zero extend to a new width.
-void APInt::zext(uint32_t width) {
+APInt &APInt::zext(uint32_t width) {
assert(width > BitWidth && "Invalid APInt ZeroExtend request");
assert(width <= IntegerType::MAX_INT_BITS && "Too many bits");
uint32_t wordsBefore = getNumWords();
@@ -982,6 +982,7 @@
delete [] pVal;
pVal = newVal;
}
+ return *this;
}
/// Arithmetic right-shift this APInt by shiftAmt.
More information about the llvm-commits
mailing list