aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ADT/APFloat.h2
-rw-r--r--lib/Support/APFloat.cpp17
2 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h
index 65cb1e5..411d8ad 100644
--- a/include/llvm/ADT/APFloat.h
+++ b/include/llvm/ADT/APFloat.h
@@ -208,6 +208,8 @@ namespace llvm {
opStatus convert(const fltSemantics &, roundingMode);
opStatus convertToInteger(integerPart *, unsigned int, bool,
roundingMode) const;
+ opStatus convertFromAPInt(const APInt &,
+ bool, roundingMode);
opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int,
bool, roundingMode);
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int,
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index cc86e79..3b448208 100644
--- a/lib/Support/APFloat.cpp
+++ b/lib/Support/APFloat.cpp
@@ -1913,6 +1913,23 @@ APFloat::convertFromUnsignedParts(const integerPart *src,
return normalize(rounding_mode, lost_fraction);
}
+APFloat::opStatus
+APFloat::convertFromAPInt(const APInt &Val,
+ bool isSigned,
+ roundingMode rounding_mode)
+{
+ unsigned int partCount = Val.getNumWords();
+ APInt api = Val;
+
+ sign = false;
+ if (isSigned && api.isNegative()) {
+ sign = true;
+ api = -api;
+ }
+
+ return convertFromUnsignedParts(api.getRawData(), partCount, rounding_mode);
+}
+
/* Convert a two's complement integer SRC to a floating point number,
rounding according to ROUNDING_MODE. ISSIGNED is true if the
integer is signed, in which case it must be sign-extended. */