[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Chris Lattner
clattner at apple.com
Thu Mar 1 14:49:24 PST 2007
> Add doubleToBits and floatToBits methods.
These shouldn't be needed. bitstodouble only works with a 64-bit
source integer, and bitstofloat only works with a 32-bit source integer.
MathExtras.h should be sufficient here,
-Chris
>
> ---
> Diffs of the changes: (+34 -0)
>
> APInt.h | 34 ++++++++++++++++++++++++++++++++++
> 1 files changed, 34 insertions(+)
>
>
> Index: llvm/include/llvm/ADT/APInt.h
> diff -u llvm/include/llvm/ADT/APInt.h:1.33 llvm/include/llvm/ADT/
> APInt.h:1.34
> --- llvm/include/llvm/ADT/APInt.h:1.33 Thu Mar 1 14:06:51 2007
> +++ llvm/include/llvm/ADT/APInt.h Thu Mar 1 14:39:01 2007
> @@ -723,6 +723,40 @@
> return T.F;
> }
>
> + /// 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.
> + /// @brief Converts a double to APInt bits.
> + 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();
> + }
> +
> + /// 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.
> + /// @brief Converts a float to APInt bits.
> + APInt& floatToBits(float V) {
> + union {
> + uint32_t I;
> + float F;
> + } T;
> + T.F = V;
> + if (isSingleWord())
> + VAL = T.I;
> + else
> + pVal[0] = T.I;
> + return clearUnusedBits();
> + }
> +
> /// @brief Compute the square root
> APInt sqrt() const;
> };
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list