Improve APInt interface:

1. Add unsigned and signed versions of methods so a "bool" argument doesn't
   need to be passed in.
2. Make the various getMin/getMax functions all be inline since they are
   so simple.
3. Simplify sdiv and srem code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34680 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2007-02-27 20:24:31 +00:00
parent 96d91372fd
commit 66ed1099ff
2 changed files with 67 additions and 55 deletions
+1 -34
View File
@@ -654,39 +654,6 @@ APInt& APInt::flip(uint32_t bitPosition) {
return *this;
}
/// getMaxValue - This function returns the largest value
/// for an APInt of the specified bit-width and if isSign == true,
/// it should be largest signed value, otherwise unsigned value.
APInt APInt::getMaxValue(uint32_t numBits, bool isSign) {
APInt Result(numBits, 0);
Result.set();
if (isSign)
Result.clear(numBits - 1);
return Result;
}
/// getMinValue - This function returns the smallest value for
/// an APInt of the given bit-width and if isSign == true,
/// it should be smallest signed value, otherwise zero.
APInt APInt::getMinValue(uint32_t numBits, bool isSign) {
APInt Result(numBits, 0);
if (isSign)
Result.set(numBits - 1);
return Result;
}
/// getAllOnesValue - This function returns an all-ones value for
/// an APInt of the specified bit-width.
APInt APInt::getAllOnesValue(uint32_t numBits) {
return getMaxValue(numBits, false);
}
/// getNullValue - This function creates an '0' value for an
/// APInt of the specified bit-width.
APInt APInt::getNullValue(uint32_t numBits) {
return getMinValue(numBits, false);
}
uint64_t APInt::getHashValue() const {
// Put the bit width into the low order bits.
uint64_t hash = BitWidth;
@@ -1734,6 +1701,6 @@ void APInt::dump() const
else for (unsigned i = getNumWords(); i > 0; i--) {
cerr << pVal[i-1] << " ";
}
cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10);
cerr << " (" << this->toString(10) << ")\n" << std::setbase(10);
}
#endif