diff options
author | Jay Foad <jay.foad@gmail.com> | 2010-11-28 21:04:48 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2010-11-28 21:04:48 +0000 |
commit | e4d19c9eb22899c9a555395d446a9ceef3bea7eb (patch) | |
tree | 0e8700eca311224bf9289faf4b222029b521c48c /include | |
parent | d8f717911dcdccb1a60b3049ea22c7767970dcb7 (diff) | |
download | llvm-e4d19c9eb22899c9a555395d446a9ceef3bea7eb.tar.gz llvm-e4d19c9eb22899c9a555395d446a9ceef3bea7eb.tar.bz2 llvm-e4d19c9eb22899c9a555395d446a9ceef3bea7eb.tar.xz |
PR5207: change APInt::doubleToBits() and APInt::floatToBits() to be
static methods that return a new APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/APInt.h | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index d398f8e3f6..22d9738333 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -1293,37 +1293,27 @@ public: } /// The conversion does not do a translation from double to integer, it just - /// re-interprets the bits of the double. Note that it is valid to do this on - /// any bit width but bits from V may get truncated. + /// re-interprets the bits of the double. /// @brief Converts a double to APInt bits. - APInt& doubleToBits(double V) { + static APInt doubleToBits(double V) { union { uint64_t I; double D; } T; T.D = V; - if (isSingleWord()) - VAL = T.I; - else - pVal[0] = T.I; - return clearUnusedBits(); + return APInt(sizeof T * CHAR_BIT, T.I); } /// The conversion does not do a translation from float to integer, it just - /// re-interprets the bits of the float. Note that it is valid to do this on - /// any bit width but bits from V may get truncated. + /// re-interprets the bits of the float. /// @brief Converts a float to APInt bits. - APInt& floatToBits(float V) { + static APInt floatToBits(float V) { union { unsigned I; float F; } T; T.F = V; - if (isSingleWord()) - VAL = T.I; - else - pVal[0] = T.I; - return clearUnusedBits(); + return APInt(sizeof T * CHAR_BIT, T.I); } /// @} |