summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APFloat.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [APFloat] Added make{Zero,Inf} methods and implemented get{Zero,Inf} on top ↵Michael Gottesman2013-06-241-0/+16
| | | | | | of them. llvm-svn: 184712
* [APFloat] Removed a assert from significandParts() which says that one can ↵Michael Gottesman2013-06-241-2/+0
| | | | | | | | | | | | | | | | | only access the significand of FiniteNonZero/NaN floats. The method significandParts() is a helper method meant to ease access to APFloat's significand by allowing the user to not need to be aware of whether or not the APFloat is using memory allocated in the instance itself or in an external array. This assert says that one can only access the significand of FiniteNonZero/NaN floats. This makes it cumbersome and more importantly dangerous when one wishes to zero out the significand of a zero/infinity value since one will have to deal with the aforementioned quandary related to how the memory in APFloat is allocated. llvm-svn: 184711
* [APFloat] Rename macro convolve => PackCategoriesIntoKey so that it is clear ↵Michael Gottesman2013-06-241-86/+92
| | | | | | | | | | | | what APFloat is actually using said macro for. In the context of APFloat, seeing a macro called convolve suggests that APFloat is using said value in some sort of convolution somewhere in the source code. This is misleading. I also added a documentation comment to the macro. llvm-svn: 184710
* [APFloat] Rename llvm::exponent_t => llvm::APFloat::ExponentType.Michael Gottesman2013-06-241-5/+5
| | | | | | | | | exponent_t is only used internally in APFloat and no exponent_t values are exposed via the APFloat API. In light of such conditions it does not make any sense to gum up the llvm namespace with said type. Plus it makes it clearer that exponent_t is associated with APFloat. llvm-svn: 184686
* [APFloat] Converted all references to APFloat::isNormal => ↵Michael Gottesman2013-06-191-3/+3
| | | | | | | | APFloat::isFiniteNonZero. Turns out all the references were in llvm and not in clang. llvm-svn: 184356
* Fixed comment typo that causes the given comment to actually make sense.Michael Gottesman2013-06-191-1/+1
| | | | llvm-svn: 184286
* Introduce needsCleanup() for APFloat and APInt.Manuel Klimek2013-06-031-1/+1
| | | | | | | | | This is needed in clang so one can check if the object needs the destructor called after its memory was freed. This is useful when creating many APInt/APFloat objects with placement new, where the overhead of tracking the pointers for cleanup is significant. llvm-svn: 183100
* APFloat: Use isDenormal instead of hand-rolled code to check for denormals.Benjamin Kramer2013-06-011-1/+1
| | | | llvm-svn: 183072
* Implement IEEE-754R 2008 nextUp/nextDown functions in the guise of the ↵Michael Gottesman2013-05-301-20/+228
| | | | | | | | function APFloat::next(bool nextDown). rdar://13852078 llvm-svn: 182945
* Fix a bug that APFloat::fusedMultiplyAdd() mistakenly evaluate "14.5f * ↵Shuxin Yang2013-05-131-2/+27
| | | | | | -14.5f + 225.0f" to 225.0f. llvm-svn: 181715
* Fix AsmPrinter crashes with assertion. Bug 15318 in BugzillaHao Liu2013-03-201-4/+2
| | | | llvm-svn: 177472
* APFloat: Make sure that we get a well-formed x87 NaN when converting from a ↵Benjamin Kramer2013-01-251-0/+6
| | | | | | | | smaller type. Fixes PR15054. llvm-svn: 173459
* Make APFloat constructor require explicit semantics.Tim Northover2013-01-221-16/+32
| | | | | | | | | Previously we tried to infer it from the bit width size, with an added IsIEEE argument for the PPC/IEEE 128-bit case, which had a default value. This default value allowed bugs to creep in, where it was inappropriate. llvm-svn: 173138
* Add llvm::hexDigitValue to convert single characters to hex.Jordan Rose2013-01-181-20/+1
| | | | | | This is duplicated in a couple places in the codebase. Adopt this in APFloat. llvm-svn: 172851
* Remove redundant 'llvm::' qualificationsDmitri Gribenko2013-01-131-1/+1
| | | | llvm-svn: 172358
* Implement APFloat::isDenormal()Shuxin Yang2013-01-071-0/+7
| | | | llvm-svn: 171764
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-1/+1
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Fix a bug in APFloat.cpp: declare APFloat after fltSemantics itAlexey Samsonov2012-11-301-1/+3
| | | | | | | | | | | uses. APFloat::convert() takes the pointer to the fltSemantics variable, which is later accessed it in ~APFloat() desctructor. That is, semantics must still be alive at the moment we delete APFloat. Found by experimental AddressSanitizer use-after-scope checker. llvm-svn: 169047
* Drop the limitation to IEEE floating point types from the fdiv of pow2 -> ↵Benjamin Kramer2012-11-081-5/+0
| | | | | | | | fmul transform. This is safe for x87 long doubles and ppc double doubles too. llvm-svn: 167582
* APFloat cleanup: Remove now unused "arithmeticOK" logic.Ulrich Weigand2012-10-291-42/+8
| | | | llvm-svn: 166954
* APFloat cleanup: Remove now unused fields "sign2" and "exponent2".Ulrich Weigand2012-10-291-21/+9
| | | | llvm-svn: 166952
* Implement arithmetic on APFloat with PPCDoubleDouble semantics byUlrich Weigand2012-10-291-76/+65
| | | | | | | | | | | | treating it as if it were an IEEE floating-point type with 106-bit mantissa. This makes compile-time arithmetic on "long double" for PowerPC in clang (in particular parsing of floating point constants) work, and fixes all "long double" related failures in the test suite. llvm-svn: 166951
* APFloat::roundToIntegral: Special values don't keep the exponent value up to ↵Benjamin Kramer2012-09-261-1/+1
| | | | | | | | date, don't rely on it. Add a couple of unit tests for special floats. Fixes 13929, found by MemorySanitizer. llvm-svn: 164698
* Fix undefined behavior (signed integer overflow) when Clang parses a ↵Richard Smith2012-08-241-1/+3
| | | | | | hexfloat with an enormous exponent. Caught by an existing unit test + -ftrapv. llvm-svn: 162505
* Fix another roundToIntegral bug where very large values could become ↵Owen Anderson2012-08-151-0/+6
| | | | | | infinity. Problem and solution identified by Steve Canon. llvm-svn: 161969
* Fix typo in comment.Owen Anderson2012-08-151-1/+1
| | | | llvm-svn: 161956
* Fix a problem with APFloat::roundToIntegral where it would return incorrect ↵Owen Anderson2012-08-151-0/+12
| | | | | | results for negative inputs to trunc. Add unit tests to verify this behavior. llvm-svn: 161929
* Fix the construction of the magic constant for roundToIntegral to be 64-bit ↵Owen Anderson2012-08-141-2/+2
| | | | | | safe. Fixes c-torture/execute/990826-0.c llvm-svn: 161885
* Add a roundToIntegral method to APFloat, which can be parameterized over ↵Owen Anderson2012-08-131-0/+26
| | | | | | various rounding modes. Use this to implement SelectionDAG constant folding of FFLOOR, FCEIL, and FTRUNC. llvm-svn: 161807
* Don't add null characters to the end of the APFloat string buffer.David Blaikie2012-07-251-10/+2
| | | | | | Report/patch inspiration by Olaf Krzikalla. llvm-svn: 160744
* Replace the hashing functions on APInt and APFloat with overloads of theChandler Carruth2012-03-041-16/+15
| | | | | | | | | | | | | | new hash_value infrastructure, and replace their implementations using hash_combine. This removes a complete copy of Jenkin's lookup3 hash function (which is both significantly slower and lower quality than the one implemented in hash_combine) along with a somewhat scary xor-only hash function. Now that APInt and APFloat can be passed directly to hash_combine, simplify the rest of the LLVMContextImpl hashing to use the new infrastructure. llvm-svn: 152004
* APFloat::toString(): Fix overrun at scanning.NAKAMURA Takumi2012-02-191-1/+1
| | | | | | FYI, clang/test/SemaTemplate/template-id-printing.cpp had been failing due to it on cygwin-clang. llvm-svn: 150911
* Add 'llvm_unreachable' to passify GCC's understanding of the constraintsChandler Carruth2012-01-101-0/+1
| | | | | | | | of several newly un-defaulted switches. This also helps optimizers (including LLVM's) recognize that every case is covered, and we should assume as much. llvm-svn: 147861
* Remove unnecessary default cases in switches that cover all enum values.David Blaikie2012-01-101-3/+0
| | | | llvm-svn: 147855
* Add back a line I deleted by accident in r145141. Fixes uninitialized ↵Eli Friedman2011-11-281-0/+1
| | | | | | variable warnings and runtime failures. llvm-svn: 145256
* Fix APFloat::convert so that it handles narrowing conversions correctly; itEli Friedman2011-11-261-49/+36
| | | | | | | | was returning incorrect values in rare cases, and incorrectly marking exact conversions as inexact in some more common cases. Fixes PR11406, and a missed optimization in test/CodeGen/X86/fp-stack-O0.ll. llvm-svn: 145141
* Fix APFloat::getSmallestNormalized so the shift doesn't depend on undefined ↵Eli Friedman2011-10-121-1/+1
| | | | | | behavior. Patch from Ahmed Charles. llvm-svn: 141818
* Fix APFloat::getLargest so that it actually returns the correct value. ↵Eli Friedman2011-10-121-2/+3
| | | | | | Found by accident while reviewing a patch to nearby code. llvm-svn: 141816
* Fix APInt::operator*= so that it computes the correct result for large ↵Eli Friedman2011-10-071-1/+1
| | | | | | integers where there is unsigned overflow. Fix APFloat::toString so that it doesn't depend on the incorrect behavior in common cases (and computes the correct result in some rare cases). Fixes PR11086. llvm-svn: 141441
* Fix typo in comments.Nick Lewycky2011-10-031-2/+2
| | | | llvm-svn: 141032
* Silence a bunch (but not all) "variable written but not read" warningsDuncan Sands2011-08-121-0/+4
| | | | | | when building with assertions disabled. llvm-svn: 137460
* 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. llvm-svn: 135431
* 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. llvm-svn: 135261
* Add an APFloat::convertToInt(APSInt) function that automatically manages theJeffrey Yasskin2011-07-151-0/+18
| | | | | | memory for the result. llvm-svn: 135259
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129558
* 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. llvm-svn: 128555
* 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. llvm-svn: 128545
* 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. llvm-svn: 127871
* 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. llvm-svn: 125776
* 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. llvm-svn: 124073
OpenPOWER on IntegriCloud