Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.6 -> 1.7 --- Log message: 1. Make APInt::shl work correctly and more efficiently. 2. Add functions to support the numberical conversion between APInt and double/float. --- Diffs of the changes: (+24 -0) APInt.h | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.6 llvm/include/llvm/ADT/APInt.h:1.7 --- llvm/include/llvm/ADT/APInt.h:1.6 Fri Feb 9 01:47:22 2007 +++ llvm/include/llvm/ADT/APInt.h Mon Feb 12 14:02:55 2007 @@ -289,6 +289,9 @@ inline uint64_t getValue() { if (isSingleWord()) return VAL; + unsigned n = getNumWords() * 64 - CountLeadingZeros(); + if (n <= 64) + return pVal[0]; assert(0 && "This APInt's bitwidth > 64"); } @@ -385,6 +388,9 @@ CountLeadingZeros(); } + /// @brief Converts this APInt to a double value. + double APIntRoundToDouble(bool isSigned = false) const; + /// Arithmetic right-shift this APInt by shiftAmt. /// @brief Arithmetic right-shift function. APInt ashr(unsigned shiftAmt) const; @@ -456,6 +462,24 @@ /// using Euclid's algorithm. APInt GreatestCommonDivisor(const APInt& API1, const APInt& API2); +/// @brief Converts the given APInt to a double value. +inline double APIntRoundToDouble(const APInt& APIVal, bool isSigned = false) { + return APIVal.APIntRoundToDouble(isSigned); +} + +/// @brief Converts the given APInt to a float vlalue. +inline float APIntRoundToFloat(const APInt& APIVal) { + return float(APIntRoundToDouble(APIVal)); +} + +/// @brief Converts the given double value into a APInt. +APInt DoubleRoundToAPInt(double Double); + +/// @brief Converts the given float value into a APInt. +inline APInt FloatRoundToAPInt(float Float) { + return DoubleRoundToAPInt(double(Float)); +} + /// Arithmetic right-shift the APInt by shiftAmt. /// @brief Arithmetic right-shift function. inline APInt ashr(const APInt& LHS, unsigned shiftAmt) { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits