[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Reid Spencer
reid at x10sys.com
Thu Mar 1 12:07:08 PST 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.32 -> 1.33
---
Log message:
Add bitsToDouble and bitsToFloat methods for re-interpretation of bits as FP.
---
Diffs of the changes: (+26 -0)
APInt.h | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.32 llvm/include/llvm/ADT/APInt.h:1.33
--- llvm/include/llvm/ADT/APInt.h:1.32 Thu Mar 1 11:15:32 2007
+++ llvm/include/llvm/ADT/APInt.h Thu Mar 1 14:06:51 2007
@@ -697,6 +697,32 @@
return roundToDouble(true);
}
+ /// The conversion does not do a translation from integer to double, it just
+ /// re-interprets the bits as a double. Note that it is valid to do this on
+ /// any bit width. Exactly 64 bits will be translated.
+ /// @brief Converts APInt bits to a double
+ double bitsToDouble() const {
+ union {
+ uint64_t I;
+ double D;
+ } T;
+ T.I = (isSingleWord() ? VAL : pVal[0]);
+ return T.D;
+ }
+
+ /// The conversion does not do a translation from integer to float, it just
+ /// re-interprets the bits as a float. Note that it is valid to do this on
+ /// any bit width. Exactly 32 bits will be translated.
+ /// @brief Converts APInt bits to a double
+ float bitsToFloat() const {
+ union {
+ uint32_t I;
+ float F;
+ } T;
+ T.I = uint32_t((isSingleWord() ? VAL : pVal[0]));
+ return T.F;
+ }
+
/// @brief Compute the square root
APInt sqrt() const;
};
More information about the llvm-commits
mailing list