aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/APInt.cpp
AgeCommit message (Collapse)Author
2007-02-20Make long addition and subtraction work. Speed things up by using internalReid Spencer
functions more. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34458 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20Clean up variable names in operator*.Reid Spencer
Attempt #3 for getting a portable INFINITY value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34454 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20Use INFINITY macro from math.h instead of constructing hex floating pointReid Spencer
constants (avoids warnings). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34452 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-20First version that can process arith.cpp test case up to 1024 bits:Reid Spencer
1. Ensure pVal is set to 0 in each constructor. 2. Fix roundToDouble to make correct calculations and not read beyond the end of allocated memory. 3. Implement Knuth's "classical algorithm" for division from scratch and eliminate buffer overflows and uninitialized mememory reads. Document it properly too. 4. Implement a wrapper function for KnuthDiv which handles the 64-bit to 32-bit conversion and back. It also implement short division for the n == 1 case that Knuth's algorithm can't handle. 5. Simplify the logic of udiv and urem a little, make them exit early, and have them use the "divide" wrapper function to perform the division or remainder operation. 6. Move the toString function to the end of the file, closer to where the division functions are located. Note: division is still broken for some > 64 bit values, but at least it doesn't crash any more. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34449 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-181. Fix some indentation and variable names in the get{Min,Max}Value methods.Reid Spencer
2. Implement toString for power-of-2 radix without using divide and always printing full words. This allows hex/binary to look at the bit respresentation of the APInt as well as avoid bugs in divide. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34396 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-181. Use APINT_WORD_SIZE instead of sizeof(uint64_t)Reid Spencer
2. Teach slt about signedness. 3. Teach roundToDouble to properly sign extend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34391 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-181. Remove dead code (lshift function).Reid Spencer
2. Consolidate memory allocation into just two inline functions. 3. Convert "unsigned" to uint32_t to gaurantee its size. 4. Eliminate magic constants and replace with symbolic equivalent. 5. Improve code documentation slightly. 6. Simplify the logical operator code because bitwidths must be the same. 7. Fix indentation per coding standards. 8. Use exit-early style to reduce indentation in several functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34389 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18Make add_1 exit early if carry is 0.Reid Spencer
Fix line breaks and 80 cols violation. Simplify operator^= since bitwidths must be the same. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34388 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-18Implement signed output for toString.Reid Spencer
Fix bugs in countLeadingZeros and countTrailingZeros. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34386 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17Fix some bugs in division logic.Reid Spencer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34384 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17Move static functions closer to their usage.Reid Spencer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34363 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17Clean up the divide and remainder logic a bit (exit early). Use moreReid Spencer
meaningful variable names. Add comments to document the flow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34362 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17Fix bugs introduced by constructor parameter order change.Reid Spencer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34357 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-16Review changes:Reid Spencer
1. Function style changes. 2. 80-col violations. 3. Better names for things. 4. Arrange constructors so they all take bit width first. 5. Add named signed and unsigned comparison functions and remove the corresponding operators. 6. Remove operator&& and operator|| but provide a getBoolValue function which converts to bool as comparison against 0. This allows the normal && and || operators to be used as if (X.getBoolValue() && Y.getBoolValue()) Note: this still doesn't function 100% yet. I'm working on the bugs now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34353 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15Fix some buges:Zhou Sheng
1. Make getMinValue() returns the right value. 2. Fix the ByteSwap() crash problem. 3. Make Postfix increment work correctly. 4. Fix some bugs in LogBase2, Hi/LoBits and UDiv. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34304 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-14Use brute-force algorithm for to_string. It doesn't have to be efficientReid Spencer
at this point, it just needs to work so we can test things reliably. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34262 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-13Make some minor improvements to APInt:Reid Spencer
1. Make all the operators use uppercase 2. Rename APIntRoundToDouble method just RoundToDouble, the APInt is redundant. 3. Turn the class on for compilation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34253 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-121. Make APInt::shl work correctly and more efficiently.Zhou Sheng
2. Add functions to support the numberical conversion between APInt and double/float. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34201 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-09Eliminates friend function declaration inside APInt, instead, adds publicZhou Sheng
methods as those global function's internal implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34083 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08Switched this file on accidently.Zhou Sheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34054 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08As Chris and Reid suggested, remove "isSigned" field from APInt, instead,Zhou Sheng
add some signed/unsigned arithmetic operation functions into APInt.h to handle the signed/unsigned issue. These functions will be defined inside a namespace "APIntOps" which is inside llvm namespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34053 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07As Chris suggested, fixed some problems. (This is the first part)Zhou Sheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33989 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06As Reid suggested, fixed some problems.Zhou Sheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33955 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06Disable this for now.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33953 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06Add a class APInt to represent arbitrary precision constant integral values.Zhou Sheng
It is a functional replacement for common case integer type like "unsigned", "uint64_t", but also allows non-byte-width integer type and large integer value types such as 3-bits, 15-bits, or more than 64-bits of precision. For more details, see pr1043. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33951 91177308-0d34-0410-b5e6-96231b3b80d8