mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-17 16:46:50 +00:00
Add a method to APFloat to convert directly from APInt.
llvm-svn: 47738
This commit is contained in:
parent
ea1f2d1110
commit
45a26a462f
@ -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,
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user