diff options
| author | Neil Booth <neil@daikokuya.co.uk> | 2007-10-07 12:15:41 +0000 |
|---|---|---|
| committer | Neil Booth <neil@daikokuya.co.uk> | 2007-10-07 12:15:41 +0000 |
| commit | 03f58ab706a4ca87a098b4e2476f61609a8cf514 (patch) | |
| tree | 3ab58830a4fa47b2dbc8c4ef5e1bcda838c2e71f /llvm/lib/Support | |
| parent | ba205229e7141510bcf8767d75f42f0802228817 (diff) | |
| download | bcm5719-llvm-03f58ab706a4ca87a098b4e2476f61609a8cf514.tar.gz bcm5719-llvm-03f58ab706a4ca87a098b4e2476f61609a8cf514.zip | |
Add back convertFromSignExtendedInteger.
llvm-svn: 42735
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/APFloat.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 8343ffe39b7..388bbd7aa24 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -1587,6 +1587,36 @@ APFloat::convertFromUnsignedParts(const integerPart *src, 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, |

