[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Mon Feb 26 09:50:51 PST 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.21 -> 1.22
---
Log message:
Implement inline methods that make transition of ConstantInt to use APInt
easier to comprehend and might be useful elsewhere.
---
Diffs of the changes: (+38 -2)
APInt.h | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.21 llvm/include/llvm/ADT/APInt.h:1.22
--- llvm/include/llvm/ADT/APInt.h:1.21 Mon Feb 26 01:45:40 2007
+++ llvm/include/llvm/ADT/APInt.h Mon Feb 26 11:50:32 2007
@@ -463,12 +463,12 @@
/// if isSign == true, it should be largest signed value, otherwise largest
/// unsigned value.
/// @brief Gets max value of the APInt with bitwidth <= 64.
- static APInt getMaxValue(uint32_t numBits, bool isSign);
+ static APInt getMaxValue(uint32_t numBits, bool isSigned);
/// @returns the smallest value for an APInt of the given bit-width and
/// if isSign == true, it should be smallest signed value, otherwise zero.
/// @brief Gets min value of the APInt with bitwidth <= 64.
- static APInt getMinValue(uint32_t numBits, bool isSign);
+ static APInt getMinValue(uint32_t numBits, bool isSigned);
/// @returns the all-ones value for an APInt of the specified bit-width.
/// @brief Get the all-ones value.
@@ -484,6 +484,42 @@
return countLeadingZeros() != BitWidth;
}
+ /// This checks to see if the value has all bits of the APInt are set or not.
+ /// @brief Determine if all bits are set
+ inline bool isAllOnesValue() const {
+ return countPopulation() == BitWidth;
+ }
+
+ /// This checks to see if the value of this APInt is the maximum unsigned
+ /// value for the APInt's bit width.
+ /// @brief Determine if this is the largest unsigned value.
+ bool isMaxValue() const {
+ return countPopulation() == BitWidth;
+ }
+
+ /// This checks to see if the value of this APInt is the maximum signed
+ /// value for the APInt's bit width.
+ /// @brief Determine if this is the largest signed value.
+ bool isMaxSignedValue() const {
+ return BitWidth == 1 ? VAL == 0 :
+ !isNegative() && countPopulation() == BitWidth - 1;
+ }
+
+ /// This checks to see if the value of this APInt is the minimum signed
+ /// value for the APInt's bit width.
+ /// @brief Determine if this is the smallest unsigned value.
+ bool isMinValue() const {
+ return countPopulation() == 0;
+ }
+
+ /// This checks to see if the value of this APInt is the minimum signed
+ /// value for the APInt's bit width.
+ /// @brief Determine if this is the smallest signed value.
+ bool isMinSignedValue() const {
+ return BitWidth == 1 ? VAL == 1 :
+ isNegative() && countPopulation() == 1;
+ }
+
/// @returns a character interpretation of the APInt.
std::string toString(uint8_t radix = 10, bool wantSigned = true) const;
More information about the llvm-commits
mailing list