diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-29 01:26:11 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-29 01:26:11 +0000 |
commit | 35723eb4f6ebbf6d82a8027bd0eb8afc406da654 (patch) | |
tree | 050dbdfd76735c23f8e28b1bccb31da18a256b3c /llvm/lib | |
parent | 95a7be473c5818291e3b05677a6009f46fade16d (diff) | |
download | bcm5719-llvm-35723eb4f6ebbf6d82a8027bd0eb8afc406da654.tar.gz bcm5719-llvm-35723eb4f6ebbf6d82a8027bd0eb8afc406da654.zip |
Add a method to APFloat to convert directly from APInt.
llvm-svn: 47738
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index cc86e795e79..3b448208842 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/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. */ |