aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/APFloat.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ↵Jeffrey Yasskin2011-07-181-7/+7
| | | | | | | | | ambiguity errors like the one corrected by r135261. Migrate all LLVM callers of the old constructor to the new one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135431 91177308-0d34-0410-b5e6-96231b3b80d8
* Explicitly cast the second argument to unsigned in order to select theChandler Carruth2011-07-151-1/+1
| | | | | | | | | desired overload. This is a bit of a hackish workaround to fix the compile after r135259. Let me know if there is a better approach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135261 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an APFloat::convertToInt(APSInt) function that automatically manages theJeffrey Yasskin2011-07-151-0/+18
| | | | | | memory for the result. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135259 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | | | Luis Felipe Strano Moraes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid turning a floating point division with a constant power of two into a ↵Benjamin Kramer2011-03-301-0/+8
| | | | | | | | | denormal multiplication. Some platforms may treat denormals as zero, on other platforms multiplication with a subnormal is slower than dividing by a normal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128555 91177308-0d34-0410-b5e6-96231b3b80d8
* Add APFloat::getExactInverse.Benjamin Kramer2011-03-301-0/+26
| | | | | | | | | | | | | | The idea is, that if an ieee 754 float is divided by a power of two, we can turn the division into a cheaper multiplication. This function sees if we can get an exact multiplicative inverse for a divisor and returns it if possible. This is the hard part of PR9587. I tested many inputs against llvm-gcc's frotend implementation of this optimization and didn't find any difference. However, floating point is the land of weird edge cases, so any review would be appreciated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128545 91177308-0d34-0410-b5e6-96231b3b80d8
* Initialize the only-used-with-PPC-double-double parts of the APFloat class. ThisBill Wendling2011-03-181-13/+10
| | | | | | | | makes valgrind stop complaining about uninitialized variables being read when it accesses a bitfield (category) that shares its bits with these variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127871 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance constant folding of bitcast operations on vectors of floats.Nadav Rotem2011-02-171-0/+6
| | | | | | | | | Add getAllOnesValue of FP numbers to Constants and APFloat. Add more tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125776 91177308-0d34-0410-b5e6-96231b3b80d8
* Null initialize a few variables flagged byTed Kremenek2011-01-231-1/+1
| | | | | | | | | | clang's -Wuninitialized-experimental warning. While these don't look like real bugs, clang's -Wuninitialized-experimental analysis is stricter than GCC's, and these fixes have the benefit of being general nice cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124073 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed parsing of hex floats.Abramo Bagnara2011-01-061-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122963 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-3/+3
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: change APInt::doubleToBits() and APInt::floatToBits() to beJay Foad2010-11-281-4/+2
| | | | | | static methods that return a new APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120261 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not assert when reading an exponent out of range.Dale Johannesen2010-08-191-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111534 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't pass StringRef by reference.Benjamin Kramer2010-07-141-5/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108366 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix minor style issues.Dan Gohman2010-03-241-143/+141
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99414 91177308-0d34-0410-b5e6-96231b3b80d8
* make APFloat::toString be const.Chris Lattner2010-03-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97883 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't potentially read past the end of the fill data when making a NaN fromJohn McCall2010-03-011-1/+2
| | | | | | | | an APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97467 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly clear all the extra bits in a significand when making a NaN from anJohn McCall2010-02-281-8/+28
| | | | | | | | | APInt. Be certain to set the integer bit in an x87 extended-precision significand so that we don't accidentally make a pseudo-NaN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97382 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-widthJohn McCall2010-02-281-11/+36
| | | | | | | | | | payloads. APFloat's internal folding routines always make QNaNs now, instead of sometimes making QNaNs and sometimes SNaNs depending on the type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97364 91177308-0d34-0410-b5e6-96231b3b80d8
* Make APFloat's string-parsing routines a bit safer against very large exponents.John McCall2010-02-261-2/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97278 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement support for converting to string at "natural precision", and fix someJohn McCall2009-12-241-16/+26
| | | | | | | | major bugs in long-precision conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92150 91177308-0d34-0410-b5e6-96231b3b80d8
* Substantially optimize APFloat::toString() by doing a single large divide toJohn McCall2009-12-241-0/+37
| | | | | | | | | | | | | | cut the significand down to the desired precision *before* entering the core divmod loop. Makes the overall algorithm logarithmic in the exponent. There's still a lot of room for improvement here, but this gets the performance back down to acceptable-for-diagnostics levels, even for long doubles. negligible, even on long doubles. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92130 91177308-0d34-0410-b5e6-96231b3b80d8
* Add accessors for the largest-magnitude, smallest-magnitude, andJohn McCall2009-12-241-0/+301
| | | | | | | | | | smallest-normalized-magnitude values in a given FP semantics. Provide an APFloat-to-string conversion which I am quite ready to admit could be much more efficient. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92126 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove getIEEEFloatParts and getIEEEDoubleParts. They are not needed.Evan Cheng2009-10-281-50/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85358 91177308-0d34-0410-b5e6-96231b3b80d8
* Add new APFloat methods that return sign, exp, and mantissa of ieee float ↵Evan Cheng2009-10-271-12/+62
| | | | | | and double values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85318 91177308-0d34-0410-b5e6-96231b3b80d8
* Commit fixes for half precision I noted in review, soDale Johannesen2009-10-231-3/+3
| | | | | | | | | they don't get lost; I don't think the originator has write access. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84928 91177308-0d34-0410-b5e6-96231b3b80d8
* Add half precision floating point support (float16) to APFloat,Chris Lattner2009-10-161-1/+69
| | | | | | | patch by Peter Johnson! (PR5195) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84239 91177308-0d34-0410-b5e6-96231b3b80d8
* wrap long lines.Chris Lattner2009-09-241-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82715 91177308-0d34-0410-b5e6-96231b3b80d8
* add a version of the APFloat constructor that initializes to 0.0Chris Lattner2009-09-171-0/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82110 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo.Anton Korobeynikov2009-08-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79688 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement APInt <-> APFloat conversion for IEEE 128-bit floats.Anton Korobeynikov2009-08-211-3/+83
| | | | | | This fixes PR2555 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79677 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for including '+' in APFloat strings, more asserts,Erick Tryzelaar2009-08-201-28/+34
| | | | | | and many new unit tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79574 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix two APFloat bugs in converting hexadecimal constants.Daniel Dunbar2009-08-201-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79540 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an uninitialized value warning in APFloat.Erick Tryzelaar2009-08-181-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79353 91177308-0d34-0410-b5e6-96231b3b80d8
* Modify APFloat to take a StringRef instead of a c string.Erick Tryzelaar2009-08-161-63/+106
| | | | | | | This also adds unit tests to APFloat that mainly tests the string handling of APFloat, but not much else of it's api. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79210 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-7/+7
| | | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-7/+8
| | | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for letting the client choose different flavors of NaNs. ↵Mike Stump2009-05-301-6/+12
| | | | | | | | | Testcase to be added in clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72606 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix whitespacing (space after switch).Mike Stump2009-05-131-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71738 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix internal representation of fp80 to be theDale Johannesen2009-03-231-8/+6
| | | | | | | | | | | | same as a normal i80 {low64, high16} rather than its own {high64, low16}. A depressing number of places know about this; I think I got them all. Bitcode readers and writers convert back to the old form to avoid breaking compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67562 91177308-0d34-0410-b5e6-96231b3b80d8
* just initialize the first element, we don't need to set the rest to zeros.Chris Lattner2009-03-131-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66850 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate a 9640 byte static mutable initialized data item by moving itChris Lattner2009-03-131-2/+2
| | | | | | | to the stack. This shrinks all llvm tools by 9k, and improves reentrancy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66847 91177308-0d34-0410-b5e6-96231b3b80d8
* static functions don't need an anonymous namespace.Chris Lattner2009-03-121-373/+371
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66845 91177308-0d34-0410-b5e6-96231b3b80d8
* Unbreak the build on win32.Cedric Venet2009-02-141-1/+1
| | | | | | | | | | | Cleanup some warning. Remark: when struct/class are declared differently than they are defined, this make problem for VC++ since it seems to mangle class differently that struct. These error are very hard to understand and find. So please, try to keep your definition/declaration in sync. Only tested with VS2008. hope it does not break anything. feel free to revert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64554 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not use host floating point types when emittingDale Johannesen2009-01-211-1/+2
| | | | | | | | | | | ASCII IR; loading and storing these can change the bits of NaNs on some hosts. Remove or add warnings at a few other places using host floating point; this is a bad thing to do in general. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62712 91177308-0d34-0410-b5e6-96231b3b80d8
* Make special cases (0 inf nan) work for frem.Dale Johannesen2009-01-211-23/+63
| | | | | | | | | | Besides APFloat, this involved removing code from two places that thought they knew the result of frem(0., x) but were wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62645 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an IEEE remainder function, which is notDale Johannesen2009-01-201-1/+39
| | | | | | | | | | fully implemented yet and not used. This is mainly to clarify that APFloat::mod implements C fmod, not remainder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62593 91177308-0d34-0410-b5e6-96231b3b80d8
* compile-time fmod was done incorrectly. PR 3316.Dale Johannesen2009-01-191-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62528 91177308-0d34-0410-b5e6-96231b3b80d8
* Get rid of bogus "control may reach end of non-void function ‘...’ beingBill Wendling2008-11-271-2/+2
| | | | | | | inlined" message. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60165 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r60042. IndVarSimplify should check if APFloat is PPCDoubleDouble ↵Evan Cheng2008-11-261-7/+1
| | | | | | first before trying to convert it to an integer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60072 91177308-0d34-0410-b5e6-96231b3b80d8