aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/APInt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove uses of uint32_t in favor of 'unsigned' for better Chris Lattner2009-01-211-193/+193
| | | | | | | compatibility with cygwin. Patch by Jay Foad! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62695 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo, sentence fragment.Nick Lewycky2009-01-191-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62512 91177308-0d34-0410-b5e6-96231b3b80d8
* rearrange some code.Chris Lattner2008-10-111-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57384 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the asmprinter (.ll) and all the stuff it requires over toChris Lattner2008-08-231-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | use raw_ostream instead of std::ostream. Among other goodness, this speeds up llvm-dis of kc++ with a release build from 0.85s to 0.49s (88% faster). Other interesting changes: 1) This makes Value::print be non-virtual. 2) AP[S]Int and ConstantRange can no longer print to ostream directly, use raw_ostream instead. 3) This fixes a bug in raw_os_ostream where it didn't flush itself when destroyed. 4) This adds a new SDNode::print method, instead of only allowing "dump". A lot of APIs have both std::ostream and raw_ostream versions, it would be useful to go through and systematically anihilate the std::ostream versions. This passes dejagnu, but there may be minor fallout, plz let me know if so and I'll fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55263 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the fast-path (<=i64) cases of various APInt methods inlineChris Lattner2008-08-201-150/+40
| | | | | | | | and the slow-path cases out of line. This speeds up instcombine a bit in real world cases. Patch contributed by m-s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55063 91177308-0d34-0410-b5e6-96231b3b80d8
* It's not necessary to check if a value is null before delete[].Dan Gohman2008-08-201-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55053 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework the routines that convert AP[S]Int into a string. Now, instead ofChris Lattner2008-08-171-95/+98
| | | | | | | | | | | | | | | | | | | returning an std::string by value, it fills in a SmallString/SmallVector passed in. This significantly reduces string thrashing in some cases. More specifically, this: - Adds an operator<< and a print method for APInt that allows you to directly send them to an ostream. - Reimplements APInt::toString to be much simpler and more efficient algorithmically in addition to not thrashing strings quite as much. This speeds up llvm-dis on kc++ by 7%, and may also slightly speed up the asmprinter. This also fixes a bug I introduced into the asmwriter in a previous patch w.r.t. alias printing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54873 91177308-0d34-0410-b5e6-96231b3b80d8
* remove a dead APInt ctor.Chris Lattner2008-08-171-8/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54869 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR2088. Use modulo linear equation solver to compute loop iterationWojciech Matyjewicz2008-07-201-1/+1
| | | | | | | count. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53810 91177308-0d34-0410-b5e6-96231b3b80d8
* First step to fix PR2088. Implement routine to compute the Wojciech Matyjewicz2008-06-231-7/+48
| | | | | | | | | multiplicative inverse of a given number. Modify udivrem to allow input and output pairs of arguments to overlap. Patch is based on the work by Chandler Carruth. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52638 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid creating a redundant zero APInt.Dan Gohman2008-06-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52602 91177308-0d34-0410-b5e6-96231b3b80d8
* As comments said, for negative value, the arithmetic Zhou Sheng2008-06-051-1/+1
| | | | | | | | | | over-shift-right should return -1. So here it should be signed-extended, when bitwidth larger than 64. test case: llvm/test/ExecutionEngine/2008-06-05-APInt-OverAShr.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51999 91177308-0d34-0410-b5e6-96231b3b80d8
* Suppress -Wshorten-64-to-32 warnings for 64-bit hosts.Evan Cheng2008-05-021-20/+21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50590 91177308-0d34-0410-b5e6-96231b3b80d8
* Make several symbols static.Dan Gohman2008-04-101-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49496 91177308-0d34-0410-b5e6-96231b3b80d8
* A quick nm audit turned up several fixed tables and objects that wereDan Gohman2008-03-251-1/+1
| | | | | | | | marked read-write. Use const so that they can be allocated in a read-only segment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48800 91177308-0d34-0410-b5e6-96231b3b80d8
* Add assert for non-hexadecimal radixes.Bill Wendling2008-03-161-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48421 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo. It's causing consumer-typeset to miscompile. Perhaps more.Evan Cheng2008-03-071-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48035 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support to APInt for shift and rotate operations with APIntDan Gohman2008-02-291-0/+27
| | | | | | | instead of uint32_t for the shift/rotate count operand type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47741 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed bug in APInt::Profile() where the BitWidth field was not included in theTed Kremenek2008-02-191-0/+2
| | | | | | | | profile of the APSInt object. This caused unexpected Profile collisions where none should have occurred. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47338 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a warning about comparison between signed and unsigned,Dan Gohman2008-02-141-1/+1
| | | | | | | being consistent with the rest of the APInt implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47138 91177308-0d34-0410-b5e6-96231b3b80d8
* Add countTrailingOnes member functions to APInt.Dan Gohman2008-02-131-0/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47086 91177308-0d34-0410-b5e6-96231b3b80d8
* Added FoldingSet style 'profiling' support for APInt.Ted Kremenek2008-01-191-1/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46188 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
* Cygwin defines uint32_t as unsigned long. Unbreak call to std::min in this caseAnton Korobeynikov2007-12-241-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45342 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't have APInt.cpp depend upon DerivedTypes.h. This helps with splitting theReid Spencer2007-12-111-14/+23
| | | | | | | Support libraries separately into their own module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44852 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.Chris Lattner2007-11-231-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44296 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix APInt::countTrailingZeros to return BitWidth if the input is zero ↵Chris Lattner2007-11-231-2/+2
| | | | | | instead of returning some random large number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44294 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't attempt to mask no bitsNeil Booth2007-10-121-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42909 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new function tcExtract for extracting a bignum from anNeil Booth2007-10-081-34/+76
| | | | | | | | | | | | | | | arbitrary range of bits embedded in the middle of another bignum. This kind of operation is desirable in many cases of software floating point, e.g. converting bignum integers to floating point numbers of fixed precision (you want to extract the precision most significant bits). Elsewhere, add an assertion, and exit the shift functions early if the shift count is zero. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42745 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix and clarify some comments.Neil Booth2007-10-061-12/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42670 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize tcFullMultiply so that the operands can be of differingNeil Booth2007-10-061-13/+20
| | | | | | | | | part widths. Also, return the number of parts actually required to hold the result's value. Remove an over-cautious condition from rounding of float->hex conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42669 91177308-0d34-0410-b5e6-96231b3b80d8
* Change APFloat::convertFromInteger to take the incomingDale Johannesen2007-09-211-1/+1
| | | | | | | | | | | | bit width instead of number of words allocated, which makes it actually work for int->APF conversions. Adjust callers. Add const to one of the APInt constructors to prevent surprising match when called with const argument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42210 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not hide APInt::dump() inside #ifndef NDEBUG.Devang Patel2007-09-171-4/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42068 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the assumption that FP's are either float orDale Johannesen2007-09-141-1/+1
| | | | | | | | | | | | | | | double from some of the many places in the optimizers it appears, and do something reasonable with x86 long double. Make APInt::dump() public, remove newline, use it to dump ConstantSDNode's. Allow APFloats in FoldingSet. Expand X86 backend handling of long doubles (conversions to/from int, mostly). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41967 91177308-0d34-0410-b5e6-96231b3b80d8
* rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()Chris Lattner2007-08-231-2/+2
| | | | | | | | Add an APSInt::toString() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41309 91177308-0d34-0410-b5e6-96231b3b80d8
* initial checkin of Neil's APFloat work.Chris Lattner2007-08-201-10/+30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41203 91177308-0d34-0410-b5e6-96231b3b80d8
* This adds a bunch of static functions that implement unsignedChris Lattner2007-08-161-0/+566
| | | | | | | | | | | | | two's complement bignum arithmetic. They could be used to implement much of APInt, but the idea is they are enough to implement APFloat as well, which the current APInt interface is not suited for. Patch by Neil Booth! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41124 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an assertion introduced by my last change to the toString method. WeReid Spencer2007-05-191-2/+2
| | | | | | | | can't use getZExtValue() to extract the low order bits for each digit. Instead, we need to access the low order word directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37242 91177308-0d34-0410-b5e6-96231b3b80d8
* Get rid of leading zeros in the output of toString.Reid Spencer2007-05-171-8/+27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37175 91177308-0d34-0410-b5e6-96231b3b80d8
* For lshr by 0 bits, just return *this as a short cut. This also preventsReid Spencer2007-05-171-0/+6
| | | | | | | undefined behavior when the width > 64 bits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37153 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in the "fromString" method where radix 2,8 and 16 values wereReid Spencer2007-05-161-8/+13
| | | | | | | | | not being generated correctly because the shl operator does not mutate its object but returns a new value. Also, make the distinction between radix 16 and the others more clear. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37111 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the results for the rotate functions correct when rotateAmt == 0.Reid Spencer2007-05-141-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37026 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some things needed by the llvm-gcc version supporting bit accurate integerReid Spencer2007-05-131-1/+67
| | | | | | | | | | | | types: 1. Functions to compute div/rem at the same time. 2. Further assurance that an APInt with 0 bitwidth cannot be constructed. 3. Left and right rotate operations. 4. An exactLogBase2 function which requires an exact power of two or it returns -1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37025 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix shl to produce the correct result when the bitwidth is > 64 and theReid Spencer2007-05-121-0/+6
| | | | | | | | shift amount is 0. Previously this code would do a lshr by the bit width which can lead to incorrect results. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37010 91177308-0d34-0410-b5e6-96231b3b80d8
* silence some annoying gcc 4.3 warningsChris Lattner2007-05-031-7/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36680 91177308-0d34-0410-b5e6-96231b3b80d8
* We want the number of bits needed, not the power of 2.Reid Spencer2007-04-141-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35977 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement a getBitsNeeded method to determine how many bits are needed toReid Spencer2007-04-131-0/+37
| | | | | | | represent a string in binary form by an APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35968 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an approximate calculation in an assertion not to give false negatives.Reid Spencer2007-04-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35901 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in getAllOnesValue() which brokeZhou Sheng2007-03-211-1/+1
| | | | | | | some test cases for bitwidth > 64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35232 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix (and simplify) 48-bit byte swap.Jeff Cohen2007-03-201-9/+8
| | | | | | | Get pos/neg infinity the correct way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35223 91177308-0d34-0410-b5e6-96231b3b80d8