Commit Graph

290 Commits

Author SHA1 Message Date
Reid Spencer
443b570149 Implement signed output for toString.
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-18 00:44:22 +00:00
Reid Spencer
cd6f2bfc26 Fix bugs introduced by constructor parameter order change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34357 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-17 00:18:01 +00:00
Reid Spencer
e81d2dad2c Review changes:
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-16 22:36:51 +00:00
Evan Cheng
b5aabee330 Proper fix for the off-by-one bug in clear_unused_bits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34328 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 21:38:15 +00:00
Reid Spencer
f1f007d2ff Fix an off-by-one bug in computing the index of the word to clear.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34326 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 20:49:10 +00:00
Reid Spencer
9d1597b086 Make sure Capacity gets initialized too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34325 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 20:14:06 +00:00
Evan Cheng
852b4baf47 Missing a ;
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34322 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:29:05 +00:00
Evan Cheng
e01ad2d129 BitVector::reference operator=(const reference& rhs) is unnecessary thanks to autoconvert to bool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34320 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:21:44 +00:00
Evan Cheng
1f46998b3f Remove unnecessary checks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34319 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:18:12 +00:00
Evan Cheng
638417f788 operator== returns false when two bitvectors have different sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34317 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:16:21 +00:00
Evan Cheng
c761df18ae Merges two resize() variants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34316 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:12:39 +00:00
Evan Cheng
ccae61c5da Clear no longer deleting the bits to avoid mallocs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34315 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:10:34 +00:00
Evan Cheng
7bf26c1d68 BitVector::count() bugs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34314 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:09:36 +00:00
Evan Cheng
334df9d83f Eliminate a redundent ctor; eliminate one more potential new [0].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34313 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:05:25 +00:00
Evan Cheng
057f8e0845 1 -> 1L since BitWord has type unsigned long.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34312 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 19:03:23 +00:00
Evan Cheng
5f92ce4696 Eliminate new[0], just set Bits to NULL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34311 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 18:59:15 +00:00
Evan Cheng
c48aafe6c6 Inverted the condition by accident.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34309 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 18:48:41 +00:00
Evan Cheng
506e899490 Bug fixes: assignment operator forgot to copy over size; copy ctor forgot to clear unused top bits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34305 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 08:15:58 +00:00
Zhou Sheng
b04973edfa Fix some buges:
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-15 06:36:31 +00:00
Evan Cheng
ad1d5c3bc5 Add a BitVector class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34301 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-15 05:56:11 +00:00
Reid Spencer
db3faa64ee Make some minor improvements to APInt:
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-13 22:41:58 +00:00
Chris Lattner
8c06509f95 fix a critical bug in smallvector, where it would destroy elements that are
not in its range (!).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34230 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-13 07:25:36 +00:00
Zhou Sheng
d93f00c35d 1. Make APInt::shl work correctly and more efficiently.
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-12 20:02:55 +00:00
Chris Lattner
a96b4ee7ff add new ShouldRehash method to factor out common code. Fix the dtor to not
delete tombstones.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34189 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 21:46:36 +00:00
Chris Lattner
65033ffc29 do not allow hash table to be filled with tombstones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34186 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 21:07:36 +00:00
Chris Lattner
44dcd01cb3 Add support for removing elements out of StringMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 20:58:00 +00:00
Chris Lattner
b5bb9f5b5c Replace the ugly FindValue method with STL-like find methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34183 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 19:49:41 +00:00
Chris Lattner
360cac8fef remove support for stringmap visitors now that iterators exist.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34180 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 08:22:15 +00:00
Chris Lattner
6ccadf6f7f add iterator support, plus support for size() and empty().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34178 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 08:12:13 +00:00
Chris Lattner
9cc2d3dce8 Split StringMapEntry construction out of StringMap, into StringMapEntry.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34170 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11 00:10:26 +00:00
Chris Lattner
569b935e6b Make find return the appropriate iterator/const_iterator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34137 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-10 06:58:17 +00:00
Chris Lattner
a76b1febd4 Allow DenseMAp to take an explicit DenseMapKeyInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34134 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-10 06:34:58 +00:00
Zhou Sheng
ff4304f824 Eliminates friend function declaration inside APInt, instead, adds public
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-09 07:48:24 +00:00
Chris Lattner
bb28a81ba3 Rename CStringMap -> StringMap, since it now supports nul characters in the
strings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34064 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 19:20:57 +00:00
Chris Lattner
ee182422ff Allow cstringmap to contain strings with nul characters in them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08 19:08:37 +00:00
Zhou Sheng
0b706b18bd As Chris and Reid suggested, remove "isSigned" field from APInt, instead,
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-08 14:35:19 +00:00
Lauro Ramos Venancio
58a0d64fae Fix build error.
include/llvm/ADT/APInt.h:326: error: ‘assert’ was not declared in this scope


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34002 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 16:59:17 +00:00
Zhou Sheng
f29a09d627 As Chris suggested, fixed some problems. (This is the first part.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33986 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 05:58:38 +00:00
Chris Lattner
e237cf934f do not let the table fill up with tombstones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33973 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 01:11:25 +00:00
Chris Lattner
04a3115e61 Fix a really subtle bug where the entire hash table could fill with
tombstones, causing subsequent insertions to infinitely loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33972 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-07 00:55:59 +00:00
Lauro Ramos Venancio
53a58106d4 Fix build error.
UniqueVector.h:66: error: ‘assert’ was not declared in this scope


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33961 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06 14:59:28 +00:00
Zhou Sheng
7406dcdc29 As Reid suggested, fixed some problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33954 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-06 05:59:47 +00:00
Chris Lattner
c04a1ce623 Simplify this a bit, add an assertion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33936 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 23:24:48 +00:00
Chris Lattner
7b13624b32 Const method must use const_iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33933 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 23:18:32 +00:00
Zhou Sheng
d0f285e212 Add a class APInt to represent arbitrary precision constant integral values.
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@33913 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 17:29:16 +00:00
Chris Lattner
28f72279f5 add a version of insert that takes the key and value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33856 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 00:42:41 +00:00
Chris Lattner
5fcaf3ed14 Make SmallSetVector useful
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33854 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 00:30:40 +00:00
Chris Lattner
7235928b45 Various bugfixes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33848 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 00:12:12 +00:00
Chris Lattner
337cde0d5a Convert SetVector to be a true adapter class and add SmallSetVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33846 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-03 23:56:03 +00:00
Chris Lattner
5a5f6b6e38 8 buckets is way too small to start out with. This was only for testing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33835 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-03 19:30:48 +00:00