aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r--llvm/lib/Support/APFloat.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 0a4f5ac..52bf3b9 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -3670,6 +3670,15 @@ double IEEEFloat::convertToDouble() const {
return api.bitsToDouble();
}
+#ifdef HAS_IEE754_FLOAT128
+float128 IEEEFloat::convertToQuad() const {
+ assert(semantics == (const llvm::fltSemantics *)&semIEEEquad &&
+ "Float semantics are not IEEEquads");
+ APInt api = bitcastToAPInt();
+ return api.bitsToQuad();
+}
+#endif
+
/// Integer bit is explicit in this format. Intel hardware (387 and later)
/// does not support these bit patterns:
/// exponent = all 1's, integer bit 0, significand 0 ("pseudoinfinity")
@@ -5265,6 +5274,21 @@ double APFloat::convertToDouble() const {
return Temp.getIEEE().convertToDouble();
}
+#ifdef HAS_IEE754_FLOAT128
+float128 APFloat::convertToQuad() const {
+ if (&getSemantics() == (const llvm::fltSemantics *)&semIEEEquad)
+ return getIEEE().convertToQuad();
+ assert(getSemantics().isRepresentableBy(semIEEEquad) &&
+ "Float semantics is not representable by IEEEquad");
+ APFloat Temp = *this;
+ bool LosesInfo;
+ opStatus St = Temp.convert(semIEEEquad, rmNearestTiesToEven, &LosesInfo);
+ assert(!(St & opInexact) && !LosesInfo && "Unexpected imprecision");
+ (void)St;
+ return Temp.getIEEE().convertToQuad();
+}
+#endif
+
float APFloat::convertToFloat() const {
if (&getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle)
return getIEEE().convertToFloat();