summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-02-28 17:34:32 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-02-28 17:34:32 +0000
commit91d3b3fce99545d2fa09da78d0331d8595f28c96 (patch)
tree541ed51f7461be732b2e740424b7e7d14564e86f /llvm/lib/Support
parent074b8a080e363385f8102e8d83f8ec6678a394ba (diff)
downloadbcm5719-llvm-91d3b3fce99545d2fa09da78d0331d8595f28c96.tar.gz
bcm5719-llvm-91d3b3fce99545d2fa09da78d0331d8595f28c96.zip
Make the trunc/sext/zext methods return APInt& so that these operations
can be chained together with other operations. llvm-svn: 34743
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/APInt.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index f9656254503..b56c561ef5d 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -896,7 +896,7 @@ double APInt::roundToDouble(bool isSigned) const {
}
// 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 @@ void APInt::trunc(uint32_t width) {
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 @@ void APInt::sext(uint32_t width) {
else
pVal[wordsBefore-1] |= mask;
clearUnusedBits();
- return;
+ return *this;
}
uint64_t mask = wordBits == 0 ? 0 : ~0ULL << wordBits;
@@ -961,11 +961,11 @@ void APInt::sext(uint32_t width) {
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 @@ void APInt::zext(uint32_t width) {
delete [] pVal;
pVal = newVal;
}
+ return *this;
}
/// Arithmetic right-shift this APInt by shiftAmt.
OpenPOWER on IntegriCloud