[llvm-commits] [llvm] r42735 - in /llvm/trunk: include/llvm/ADT/APFloat.h lib/Support/APFloat.cpp
Neil Booth
neil at daikokuya.co.uk
Sun Oct 7 05:15:41 PDT 2007
Author: neil
Date: Sun Oct 7 07:15:41 2007
New Revision: 42735
URL: http://llvm.org/viewvc/llvm-project?rev=42735&view=rev
Log:
Add back convertFromSignExtendedInteger.
Modified:
llvm/trunk/include/llvm/ADT/APFloat.h
llvm/trunk/lib/Support/APFloat.cpp
Modified: llvm/trunk/include/llvm/ADT/APFloat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=42735&r1=42734&r2=42735&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h (original)
+++ llvm/trunk/include/llvm/ADT/APFloat.h Sun Oct 7 07:15:41 2007
@@ -194,6 +194,8 @@
opStatus convert(const fltSemantics &, roundingMode);
opStatus convertToInteger(integerPart *, unsigned int, bool,
roundingMode) const;
+ opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int,
+ bool, roundingMode);
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int,
bool, roundingMode);
opStatus convertFromString(const char *, roundingMode);
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=42735&r1=42734&r2=42735&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Sun Oct 7 07:15:41 2007
@@ -1587,6 +1587,36 @@
return normalize(rounding_mode, lost_fraction);
}
+/* 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. */
+APFloat::opStatus
+APFloat::convertFromSignExtendedInteger(const integerPart *src,
+ unsigned int srcCount,
+ bool isSigned,
+ roundingMode rounding_mode)
+{
+ opStatus status;
+
+ if (isSigned
+ && APInt::tcExtractBit(src, srcCount * integerPartWidth - 1)) {
+ integerPart *copy;
+
+ /* If we're signed and negative negate a copy. */
+ sign = true;
+ copy = new integerPart[srcCount];
+ APInt::tcAssign(copy, src, srcCount);
+ APInt::tcNegate(copy, srcCount);
+ status = convertFromUnsignedParts(copy, srcCount, rounding_mode);
+ delete [] copy;
+ } else {
+ sign = false;
+ status = convertFromUnsignedParts(src, srcCount, rounding_mode);
+ }
+
+ return status;
+}
+
/* FIXME: should this just take a const APInt reference? */
APFloat::opStatus
APFloat::convertFromZeroExtendedInteger(const integerPart *parts,
More information about the llvm-commits
mailing list