mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Add bitsToDouble and bitsToFloat methods for re-interpretation of bits as FP.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34800 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -697,6 +697,32 @@ public:
|
|||||||
return roundToDouble(true);
|
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
|
/// @brief Compute the square root
|
||||||
APInt sqrt() const;
|
APInt sqrt() const;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user