1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 13:02:52 +02:00
Commit Graph

663 Commits

Author SHA1 Message Date
Dan Gohman
abc71f026a Add an empty() member to FoldingSet.
llvm-svn: 55182
2008-08-22 16:14:23 +00:00
Dan Gohman
3b4af81381 Fix SmallVector's size calculation so that a size of 0 is
handled correctly, and change a few SmallVector uses to use
size 0 to more clearly reflect their intent.

llvm-svn: 55181
2008-08-22 16:07:55 +00:00
Chris Lattner
fd64cbf22d consolidate DenseMapInfo implementations, and add one for std::pair.
Patch contributed by m-s.

llvm-svn: 55167
2008-08-22 05:08:25 +00:00
Chris Lattner
bb8a53802b remove redundant include
llvm-svn: 55116
2008-08-21 06:41:07 +00:00
Chris Lattner
16121a7f73 Fix the build with gcc 4.3 as the host, patch by Zhongxing Xu!
llvm-svn: 55115
2008-08-21 06:25:28 +00:00
Nick Lewycky
d9012655db Fix build on GCC 4.3.
llvm-svn: 55110
2008-08-21 05:36:03 +00:00
Chris Lattner
c9fdd97035 Move the fast-path (<=i64) cases of various APInt methods inline
and the slow-path cases out of line.  This speeds up instcombine
a bit in real world cases.  Patch contributed by m-s.

llvm-svn: 55063
2008-08-20 17:02:31 +00:00
Chris Lattner
c0610874cc Rework the routines that convert AP[S]Int into a string. Now, instead of
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.

llvm-svn: 54873
2008-08-17 07:19:36 +00:00
Chris Lattner
4e4a482a41 remove a dead APInt ctor.
llvm-svn: 54869
2008-08-17 04:58:58 +00:00
Owen Anderson
b307df554d Add a value_type typedef to SmallVector, to make it more compatible with STL adapters.
llvm-svn: 54819
2008-08-15 18:45:51 +00:00
Ted Kremenek
7bc723b79f Removed redundant ctor.
llvm-svn: 54789
2008-08-14 21:17:07 +00:00
Daniel Dunbar
e249d30421 Add default constructor to APSInt
- Creates uninitialized APInt. 
 - Prevents need for embedding arbitrary constants when used as an out
   parameter, for example.

llvm-svn: 54757
2008-08-13 20:53:17 +00:00
Bill Wendling
5aaf075b29 Removed unused parameters.
llvm-svn: 54262
2008-08-01 05:50:13 +00:00
Dan Gohman
9653b21dc2 Fold the useful features of alist and alist_node into ilist, and
a new ilist_node class, and remove them. Unlike alist_node,
ilist_node doesn't attempt to manage storage itself, so it avoids
the associated problems, including being opaque in gdb.

Adjust the Recycler class so that it doesn't depend on alist_node.
Also, change it to use explicit Size and Align parameters, allowing
it to work when the largest-sized node doesn't have the greatest
alignment requirement.

Change MachineInstr's MachineMemOperand list from a pool-backed
alist to a std::list for now.

llvm-svn: 54146
2008-07-28 21:51:04 +00:00
Anton Korobeynikov
583ed0eb6e Remove bogus assertion. This unbreaks mingw, where ConstantSDNode
has alignment 8 and LoadSDNode (used as LargestT template) - 4.

llvm-svn: 53782
2008-07-19 05:52:44 +00:00
Ted Kremenek
6efe7adf98 Inline typedef for alist_iterator::pointer to work with MSVC++.
llvm-svn: 53517
2008-07-12 18:28:46 +00:00
Nick Lewycky
0dae6f90bb operator[] is not defined for list::iterator. Overload it in ilist::iterator
to prevent silly things from happening accidentally. PR2171

llvm-svn: 53507
2008-07-12 07:00:52 +00:00
Ted Kremenek
d6dcdf8802 Minor tweaks to the ImmutableList iterator interface.
Added partial specialization of DenseMapInfo<T> for ImmutableList.

llvm-svn: 53485
2008-07-11 22:43:07 +00:00
Ted Kremenek
4e5efc791c Make typedef public to make MSVC++ happy.
llvm-svn: 53433
2008-07-10 23:24:20 +00:00
Ted Kremenek
d2eef72ae9 Make some typedefs public to make MSVC++ happy.
llvm-svn: 53432
2008-07-10 23:09:45 +00:00
Ted Kremenek
9bd15119cd Make typedefs in ilist public (Visual C++ errors out when they are private).
llvm-svn: 53431
2008-07-10 22:58:10 +00:00
Bill Wendling
7e2acf0dc9 Pull r53428 from Gaz into mainline:
Remove warnings about unused/shadowed variables.

llvm-svn: 53430
2008-07-10 22:57:49 +00:00
Ted Kremenek
91171c5406 Added ImmutableMap constructor that accepts a const TreeTy*.
llvm-svn: 53429
2008-07-10 22:57:10 +00:00
Dan Gohman
c3f346dc55 Tidy up #includes.
llvm-svn: 53426
2008-07-10 22:26:19 +00:00
Duncan Sands
e667a05fcb Correct a comment.
llvm-svn: 53401
2008-07-10 11:21:59 +00:00
Dan Gohman
60e964b34c Add some basic Pool-allocation infrastructure. This adds a Recycler class,
for handling bookkeeping for deleted objects, as well as the alist class
template, for keeping lists of objects allocated from Recyclers, and some
related utilities.

llvm-svn: 53210
2008-07-07 22:58:06 +00:00
Dan Gohman
1834981eb0 Make ilist noncopyable too.
llvm-svn: 53190
2008-07-07 18:43:32 +00:00
Dan Gohman
fca9922b1b Don't use std::advance just to increment or decrement by one.
llvm-svn: 53189
2008-07-07 18:39:33 +00:00
Dan Gohman
3755664b6d Remove unnecessary static_casts.
llvm-svn: 53181
2008-07-07 18:08:20 +00:00
Dan Gohman
9112a5463e Remove an unnecessary reinterpret_cast.
llvm-svn: 53180
2008-07-07 18:07:36 +00:00
Dan Gohman
955fdc7a4c Add explicit keywords.
llvm-svn: 53179
2008-07-07 18:00:37 +00:00
Dan Gohman
c97817aac3 Make DenseMap's insert return a pair, to more closely resemble std::map.
llvm-svn: 53177
2008-07-07 17:46:23 +00:00
Ted Kremenek
1d321b8875 Removed ImmutableMap::SlimFind and replaced it with ImmutableMap::lookup. The new method does the same thing, except that it returns a pointer to the mapped data type, and not to an internal tree node.
llvm-svn: 53171
2008-07-07 16:20:55 +00:00
Dan Gohman
9c78662057 Use operator new instead of new char[].
llvm-svn: 53067
2008-07-03 00:59:36 +00:00
Owen Anderson
dd29406f31 Have DenseSet::insert return a bool indicating whether the insertion succeeded or not.
llvm-svn: 53033
2008-07-02 17:29:59 +00:00
Chris Lattner
441571cc05 optimize StringMap::clear
llvm-svn: 53009
2008-07-02 05:30:45 +00:00
Chris Lattner
06545d1c4a Add a new (simple) StringMap::clear method, patch by Pratik
Solanki!

llvm-svn: 53008
2008-07-02 05:26:32 +00:00
Ted Kremenek
41502657f7 Implemented operator!= for the ImmutableList iterator.
llvm-svn: 52998
2008-07-02 00:06:55 +00:00
Owen Anderson
1530481dd3 Add a version of AddString that takes a const char* so we can avoid extraneous
conversions to std::string.

llvm-svn: 52995
2008-07-01 23:49:59 +00:00
Ted Kremenek
0b662363f9 Added partial specialization of FoldingSetTrait for pointers.
llvm-svn: 52989
2008-07-01 22:30:13 +00:00
Seo Sanghyeon
0b4c1205fb Compilation fix
llvm-svn: 52950
2008-07-01 05:27:28 +00:00
Dan Gohman
081848d881 Make SmallVector's grow use memcpy in common cases
instead of std::uninitialized_copy, which uses memmove.

llvm-svn: 52928
2008-06-30 21:45:13 +00:00
Dan Gohman
06ca992a01 Use plain operator new instead of new char[].
llvm-svn: 52927
2008-06-30 21:33:02 +00:00
Ted Kremenek
834afcfdcd Added some comments and some cleanups.
llvm-svn: 52922
2008-06-30 20:41:22 +00:00
Ted Kremenek
70f042f0a1 Added ImmutableList, a companion ADT to ImmutableSet and ImmutableMap that is used to represent a purely functional list.
llvm-svn: 52911
2008-06-30 18:07:38 +00:00
Chris Lattner
9adb1b56de add convenience 'constructors'
llvm-svn: 52908
2008-06-30 18:02:44 +00:00
Bill Wendling
36ebc296c1 Remove warnings about shadowed and unused variables.
llvm-svn: 52791
2008-06-26 18:11:45 +00:00
Dan Gohman
d1ec941698 Pass std::string by reference. Thanks Chris!
llvm-svn: 52678
2008-06-24 16:40:22 +00:00
Dan Gohman
490250e7f2 Add a clear() method to PriorityQueue.
llvm-svn: 52656
2008-06-23 23:47:46 +00:00
Dan Gohman
512bf41c02 Simplify erase_one slightly. It's not necessary to preserve
the value of the element to be erased while the heap is
being updated.

llvm-svn: 52646
2008-06-23 21:46:21 +00:00
Dan Gohman
54b67be86a Add methods to StringMap to erase entries by key.
llvm-svn: 52640
2008-06-23 21:07:03 +00:00
Wojciech Matyjewicz
1de28ac425 First step to fix PR2088. Implement routine to compute the
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.

llvm-svn: 52638
2008-06-23 19:39:50 +00:00
Dan Gohman
4099d0bf27 Add a priority queue class, which is a wrapper around std::priority_queue
and provides fairly efficient removal of arbitrary elements. Switch
ScheduleDAGRRList from std::set to this new priority queue.

llvm-svn: 52582
2008-06-21 18:35:25 +00:00
Owen Anderson
609a53ac86 Fix use of placement new to actually use an address.
llvm-svn: 52423
2008-06-17 18:07:43 +00:00
Duncan Sands
a487df7710 Remove some DAG combiner assumptions about sizes
of integer types.  Fix the isMask APInt method to
actually work (hopefully) rather than crashing
because it adds apints of different bitwidths.
It looks like isShiftedMask is also broken, but
I'm leaving that one to the APInt people (it is
not used anywhere).

llvm-svn: 52142
2008-06-09 11:32:28 +00:00
Chris Lattner
ed8780055e Add a simple, but efficient, generic scoped hash table
llvm-svn: 52112
2008-06-09 00:42:10 +00:00
Chris Lattner
0e6bb31def add a predicate.
llvm-svn: 51842
2008-06-01 18:09:04 +00:00
Dan Gohman
b67e96f3aa Add an operator< for SmallVector.
llvm-svn: 51791
2008-05-30 22:37:47 +00:00
Dan Gohman
edc136d18f Fix an error in the comment for APInt::getMinSignedBits.
llvm-svn: 51720
2008-05-30 00:46:49 +00:00
Anton Korobeynikov
80d70cd681 Remove guard, so *each* inclusion will result in a warning
llvm-svn: 51708
2008-05-29 21:57:11 +00:00
Dan Gohman
3ea2dceca0 Prune and tidy #includes.
llvm-svn: 51697
2008-05-29 19:52:31 +00:00
Anton Korobeynikov
f46e96a222 Add file with warning for backward comptibility. Should be removed after 2.4
llvm-svn: 51693
2008-05-29 18:18:15 +00:00
Anton Korobeynikov
c128302249 Update guards
llvm-svn: 51692
2008-05-29 18:17:53 +00:00
Anton Korobeynikov
f77142326f For PR1338: rename include/llvm/ADT/ilist and friends to end with ".h"
llvm-svn: 51687
2008-05-29 17:41:17 +00:00
Matthijs Kooijman
2a23a4e495 Use an explicit llvm:: prefix in the STATISTIC macro, so STATISTIC can still be
used when "using namespace llvm" is not in effect.

llvm-svn: 51592
2008-05-27 12:41:24 +00:00
Bill Wendling
1866fa680f Remove warnings about unused parameters and shadowed variables.
llvm-svn: 51266
2008-05-19 20:15:12 +00:00
Anton Korobeynikov
5961d53986 Add thin layer over StringMap to form StringSet. By Mikhail Glushenkov.
llvm-svn: 51048
2008-05-13 15:03:16 +00:00
Ted Kremenek
1534cce257 Make the interface of CStrInCStrNoCase be the same as strcasestr.
llvm-svn: 50828
2008-05-07 20:04:18 +00:00
Ted Kremenek
b82fe559d6 Fix some serious logical errors in CStrInCStrNoCase pointed out by Bill.
llvm-svn: 50826
2008-05-07 19:22:36 +00:00
Ted Kremenek
cbaf12a084 Guard for empty strings in CStrInCStrNoCase.
llvm-svn: 50823
2008-05-07 18:49:31 +00:00
Ted Kremenek
535ed35152 Added CStrInCStrNoCase, a portable implementation of strcasestr.
llvm-svn: 50821
2008-05-07 18:35:46 +00:00
Nick Lewycky
adfc627b77 Typo.
llvm-svn: 50805
2008-05-07 06:39:04 +00:00
Evan Cheng
d9353009b7 Fix more -Wshorten-64-to-32 warnings.
llvm-svn: 50659
2008-05-05 18:30:58 +00:00
Ted Kremenek
aff3b5126a Implement operator-> for ImmutableMap iterators.
llvm-svn: 50603
2008-05-03 01:05:46 +00:00
Evan Cheng
c2d34f03bf Suppress -Wshorten-64-to-32 warnings for 64-bit hosts.
llvm-svn: 50590
2008-05-02 21:15:08 +00:00
Chris Lattner
27fa922841 Remove the SmallVector ctor that converts from a SmallVectorImpl. This
conversion open the door for many nasty implicit conversion issues, and
can be easily solved by initializing with (V.begin(), V.end()) when 
needed.

This patch includes many small cleanups for sdisel also.

llvm-svn: 50340
2008-04-28 06:44:42 +00:00
Chris Lattner
89339f3a90 restore the copy ctor in SmallVector. This fixes serious
errors I introduced in my last patch.

llvm-svn: 50338
2008-04-28 06:32:08 +00:00
Chris Lattner
a03159bc35 generalize SmallVector copy ctor, there is no requirement for
the initialization vector to have the same fixed size, just the
same element type.

llvm-svn: 50334
2008-04-28 06:01:06 +00:00
Ted Kremenek
247bdc8ec7 Implement != for DenseSet iterators.
llvm-svn: 50236
2008-04-24 23:49:45 +00:00
Ted Kremenek
100956926c Added iterator support for DenseSet.
llvm-svn: 50235
2008-04-24 23:48:12 +00:00
Argyrios Kyrtzidis
2f4e52ee48 Bring in uint32_t, uint64_t, and int64_t types for MSVC.
llvm-svn: 49854
2008-04-17 13:56:31 +00:00
Chris Lattner
3d52eb61ca fix off by one error.
llvm-svn: 49766
2008-04-16 04:10:37 +00:00
Chris Lattner
f24665de72 give smallstring some methods to do 'itoa'.
llvm-svn: 49765
2008-04-16 04:05:02 +00:00
Chris Lattner
01e31663c8 improvements for IntrusiveRefCntPtr, patch by Mikhail Glushenkov
llvm-svn: 49538
2008-04-11 16:42:06 +00:00
Owen Anderson
4ad5a5201c Add operator= implementations to SparseBitVector, allowing it to be used in GVN. This results
in both time and memory savings for GVN.  For example, one testcase went from 10.5s to 6s with
this patch.

llvm-svn: 49345
2008-04-07 17:38:23 +00:00
David Greene
0ca05878fe Iterators folloring a SmallVector erased element are invalidated so
don't access cached iterators from after the erased element.

Re-apply 49056 with SmallVector support.

llvm-svn: 49106
2008-04-02 18:24:46 +00:00
Chris Lattner
49e9edd6f6 Fix "Control reaches the end of non-void function" warnings,
patch by David Chisnall.

llvm-svn: 48963
2008-03-30 18:22:13 +00:00
Chris Lattner
7f9e824685 when a node is removed from an ilist, set its next/prev pointers to
null.  This means that uses of invalidated iterators will explode violently
with:
ilist:143: failed assertion `NodePtr && "++'d off the end of an ilist!"'

instead of happening to work "most of the time".

llvm-svn: 48859
2008-03-27 02:43:03 +00:00
Dan Gohman
2b96ce84aa Add explicit keywords.
llvm-svn: 48801
2008-03-25 22:06:05 +00:00
Anton Korobeynikov
261bddcbeb Add first proof-of-concept universal compiler driver framework based
on ideas mentioned in PR686.
Written by Mikhail Glushenkov and contributed by Codedgers, Inc.

Old llvmc will be removed soon after new one will have all its properties.

llvm-svn: 48699
2008-03-23 08:57:20 +00:00
Duncan Sands
486fdbb67f Fix comment.
llvm-svn: 48543
2008-03-19 10:59:59 +00:00
Scott Michel
889ee011f7 Dial down gcc's warnings: don't use 0UL when 0U suffices (and when the
variables and methods themselves only use unsigned.)

llvm-svn: 48492
2008-03-18 16:55:06 +00:00
Dan Gohman
339b887ff6 No need for typedefs with enums in C++.
llvm-svn: 48312
2008-03-13 01:07:53 +00:00
Dan Gohman
2b8022a8c6 Add support to APInt for shift and rotate operations with APInt
instead of uint32_t for the shift/rotate count operand type.

llvm-svn: 47741
2008-02-29 01:40:47 +00:00
Dan Gohman
45a26a462f Add a method to APFloat to convert directly from APInt.
llvm-svn: 47738
2008-02-29 01:26:11 +00:00
Anton Korobeynikov
ba0d97969e Update per review. Patch by Mikhail Glushenkov!
llvm-svn: 47628
2008-02-26 21:44:24 +00:00
Bill Wendling
ebb707d162 Detabify
llvm-svn: 47597
2008-02-26 10:49:39 +00:00
Eli Friedman
c1fb49b19f Add missing include (for ptrdiff_t).
llvm-svn: 47576
2008-02-25 23:35:32 +00:00
Anton Korobeynikov
fd4b209731 Add smart refcounting pointer class to ADT back (known before as IntrusiveSPtr.h).
llvm-svn: 47482
2008-02-22 17:26:05 +00:00
Anton Korobeynikov
5eaa8e774e Unbreak build for VC2008. Patch by Argiris Kirtzidis!
llvm-svn: 47480
2008-02-22 10:11:21 +00:00
Dan Gohman
62071ec646 Remove inline keywords from in-class function definitions, for
consistency.

llvm-svn: 47393
2008-02-20 19:29:58 +00:00
Dan Gohman
00fed8a97e Add an intersects method to APInt, to capture a common idiom.
llvm-svn: 47379
2008-02-20 16:08:11 +00:00
Anton Korobeynikov
0c5e186924 Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Scott Michel
3ad0263173 Make tblgen a little smarter about constants smaller than i32. Currently,
tblgen will complain if a sign-extended constant does not fit into a
data type smaller than i32, e.g., i16. This causes a problem when certain
hex constants are used, such as 0xff for byte masks or immediate xor
values.

tblgen will try the sign-extended value first and, if the sign extended
value would overflow, it tries to see if the unsigned value will fit.
Consequently, a software developer can now safely incant:

	(XORHIr16 R16C:$rA, 0xffff)

which is somewhat clearer and more informative than incanting:

	(XORHIr16 R16C:$rA, (i16 -1))

even if the two are bitwise equivalent.

Tblgen also outputs the 64-bit unsigned constant in the generated ISel code
when getTargetConstant() is invoked.

llvm-svn: 47188
2008-02-15 23:05:48 +00:00
Dan Gohman
5562e340b7 Fix a typo in a comment.
llvm-svn: 47097
2008-02-13 22:32:12 +00:00
Dan Gohman
588498082a Rename APInt's isPositive to isNonNegative, to reflect what it
actually does.

llvm-svn: 47090
2008-02-13 22:09:18 +00:00
Dan Gohman
d22101a970 Add countTrailingOnes member functions to APInt.
llvm-svn: 47086
2008-02-13 21:11:05 +00:00
Dan Gohman
547ea0a60d Fix a typo in a comment.
llvm-svn: 47085
2008-02-13 20:56:53 +00:00
Dan Gohman
f65b0b112c Change APInt::getBitsSet to accept a "half-open" range, where the
hiBit parameter marks the index one past the last desired set bit.

llvm-svn: 47032
2008-02-12 21:47:33 +00:00
Dan Gohman
b7bbe43ad3 Correct the order of the arguments in the examples in the comments
for APInt::getBitsSet. And fix an off-by-one bug in "wrapping" mode.

llvm-svn: 46978
2008-02-11 23:45:14 +00:00
Ted Kremenek
dbef529071 The factories for ImutAVLTree/ImmutableSet/ImmutableMap now take an (optional)
BumpPtrAllocator argument to their constructors.  This BumpPtrAllocator
will be used to allocate trees.  If no BumpPtrAllocator is provided, one
is created (as before).

llvm-svn: 46975
2008-02-11 23:11:12 +00:00
Ted Kremenek
f06b7ac532 Added "Profile" method to APFloat for use with FoldingSet.
Added member template "Add" to FoldingSetNodeID that allows "adding" arbitrary
objects to a profile via dispatch to FoldingSetTrait<T>::Profile().

Removed FoldingSetNodeID::AddAPFloat and FoldingSetNodeID::APInt, as their
functionality is now replaced using the above mentioned member template.

llvm-svn: 46957
2008-02-11 17:24:50 +00:00
Dan Gohman
3d296e049c Add an isSignedIntN, like isIntN but for signed integer values instead of
unsigned.

llvm-svn: 46894
2008-02-08 21:58:15 +00:00
Ted Kremenek
557bbab669 Constified operator<< in APSInt.
llvm-svn: 46882
2008-02-08 07:14:19 +00:00
Dan Gohman
011075cfdb Add support to FoldingSet for hashing APInt objects.
llvm-svn: 46833
2008-02-06 23:09:15 +00:00
Anton Korobeynikov
b1576212e7 Don't dereference an invalid pointer if string is empty.
llvm-svn: 46781
2008-02-05 23:34:40 +00:00
Ted Kremenek
3277f38b25 Added FoldingSet profiling support to ImmutableSet.
llvm-svn: 46757
2008-02-05 18:50:25 +00:00
Ted Kremenek
571ad3913c Changed profiling method for ImmutableMap to once again just use its
unique ImutAVLTree* for profiling.

Modified ImutAVLTree:
 (1) changed ComputeHash() to ComputeDigest() and
 (2) changed Profile() to use the computed digest and
 (3) modified insertion of IMutAVLTree into the FoldingSet owned by
     the ImutAVLTreeFactory object to use profiling instead of computing
     a direct hash.  This fixes a bug where our abuse of the FoldingSet would
     not work when the FoldingSet was resized.

llvm-svn: 46753
2008-02-05 17:30:43 +00:00
Ted Kremenek
f2e96e37f4 Modified 'Profile' method of ImmutableMap to use the 'Profile' method
of the contained ImutAVLTree root.

llvm-svn: 46719
2008-02-04 21:17:02 +00:00
Ted Kremenek
9679f99479 Modified node creation of ImutAVLTree to do a hash lookup for an existing
node in the FoldingSet of nodes held by the Factory object.  If we
we find a node with a matching hash, we do a full structural comparison.
Nodes are also now inserted into the FoldingSet only when we mark them
Immutable, as their children can change during intermediate-rebalancing.

The 'Profile' method for ImutAVLTree is no longer used when looking up
existing ImutAVLTrees with a given set of contents; instead the Profile method
is used by other clients that wish to insert such a tree into a folding set.
This means that we are not using FoldingSet in ImutAVLTreeFactory in the way
it was intended, but instead are using it as an opaque hashtable.

llvm-svn: 46717
2008-02-04 21:15:24 +00:00
Ted Kremenek
6dab41ed32 Added "bucket_iterators" to FoldingSet. Bucket iterators allow iteration
over all the nodes in a particular bucket.

llvm-svn: 46716
2008-02-04 21:11:17 +00:00
Ted Kremenek
62853a3478 constified operator~().
llvm-svn: 46707
2008-02-04 16:57:26 +00:00
Anton Korobeynikov
1cc154d068 Add convenient std::string helpers to StringMap. Patch by Mikhail Glushenkov!
llvm-svn: 46625
2008-01-31 23:02:33 +00:00
Anton Korobeynikov
91b7d99e8a Reapply the patch with fix.
llvm-svn: 46615
2008-01-31 17:43:25 +00:00
Chris Lattner
87c2925656 revert anton's recent stringmap patch, which breaks clang.
llvm-svn: 46614
2008-01-31 17:24:51 +00:00
Anton Korobeynikov
55998b56a0 Make StringMap to be more STL'ish. Patch by Mikhail Glushenkov!
llvm-svn: 46612
2008-01-31 12:30:40 +00:00
Anton Korobeynikov
45e5afd820 Whitespace cleanup
llvm-svn: 46611
2008-01-31 12:10:41 +00:00
Ted Kremenek
acc17d1b24 Altered ctor for APSInt to accept an optional "isUnsigned" flag. Default
behavior is unchanged.

llvm-svn: 46521
2008-01-29 18:55:14 +00:00
Ted Kremenek
752475ffa1 Added destructor for template class FoldingSetNodeWrapper.
Added getValue() to FoldingSetNodeWrapper.

llvm-svn: 46465
2008-01-28 22:05:23 +00:00
Ted Kremenek
274df5b7db Added additional overloaded operators for APSInt to match the operators of
APInt.

While some operators were already specifically overloaded for APSInt, others
resulted in using the overloaded operator methods in APInt, which would result
in the signedness bit being lost.

Modified the APSInt(APInt&) constructor to be "explicit" and to take an
extra (optional) flag to indicate the signedness.  Making the ctor explicit
will catch any implicit conversations between APSInt -> APInt -> APSInt that
results in the signedness flag being lost.

llvm-svn: 46316
2008-01-24 18:59:52 +00:00
Ted Kremenek
d6669b6b8a Added "getRoot()" to ImmutableSet.
Made ImmutableSet::ImmutableSet(ImutAVLTree* Root) public. (this allows handy
casting between trees and sets).

llvm-svn: 46277
2008-01-23 19:57:33 +00:00
Ted Kremenek
8425e78e77 Fixed buggy caching of the hash value of an ImutAVLTree node.
llvm-svn: 46229
2008-01-21 22:54:46 +00:00
Ted Kremenek
bee8cd7cd8 Moved method call within a conditional branch because its effects will
be ignored on the false branch.

llvm-svn: 46228
2008-01-21 22:51:35 +00:00
Ted Kremenek
1c8968610e Adjusted ImutAVLTree::ComputeHash to compute a hash value that is based on a
clearer sequence of hashing compositions.

llvm-svn: 46227
2008-01-21 22:50:37 +00:00
Ted Kremenek
fed0381d40 Added "clear" method to FoldingSetNodeID to allow a FoldingSetNodeID object
to be reused to compute multiple object profiles.

llvm-svn: 46226
2008-01-21 22:49:22 +00:00
Ted Kremenek
91db428477 Replaced (FoldingSet) profiling of ImutAVLTree with a hashing based scheme. The
problem was that we previously hashed based on the pointers of the left and
right children, but this is bogus: we can easily have different trees that
represent the same set. Now we use a hashing based scheme that compares the
*contents* of the trees, but not without having to do a full scan of a tree. The
only caveat is that with hashing is that we may have collisions, which result in
two different trees being falsely labeled as equivalent. If this becomes a
problem, we can add extra data to the profile to hopefully resolve most
collisions.

llvm-svn: 46224
2008-01-21 22:33:30 +00:00
Ted Kremenek
99c2b963e8 Changed argument name for 'Profile' method to potentially fix a name conflict
reported in pr1929 (http://llvm.org/PR1929).

llvm-svn: 46193
2008-01-19 17:21:43 +00:00
Ted Kremenek
7de447b8a6 Modified ImmutableSet/ImmutableMap to use FoldingSet profiling using
FoldingSetTrait instead of directly calling a 'Profile' method.

llvm-svn: 46190
2008-01-19 04:51:55 +00:00
Ted Kremenek
dce31b9785 Added FoldingSet style 'profiling' support for APSInt.
llvm-svn: 46189
2008-01-19 04:31:12 +00:00
Ted Kremenek
702d3b8f37 Added FoldingSet style 'profiling' support for APInt.
llvm-svn: 46188
2008-01-19 04:23:33 +00:00
Ted Kremenek
a0105180ad Made 'FoldingSetNodeID' a proper class instead of a nested class in
'FoldingSetNodeImpl' (previously 'FoldingSetNodeID' was a typedef of
'FoldingSetNodeImpl::NodeID').

Why?  Clients can now easily forward declare 'FoldingSetNodeID' without having
to include FoldingSet.h.

llvm-svn: 46187
2008-01-19 04:22:50 +00:00
Ted Kremenek
f28b73631c Made 'profiling' of objects in a FoldingSet trait-based using FoldingSetTrait
instead of always assuming that the stored objects had a method called
'Profile'. The default behavior is to dispatch to a 'Profile' method (as
before), but via template specialization this behavior can now be overridden by
clients.

Added templated class 'FoldingSetNodeWrapper', a generic wrapper class that
allows one to insert objects into a FoldingSet that do not directly inherit from
FoldingSetNode. This is useful for inserting objects that do not always need to
pay the overhead of inheriting from FoldingSetNode, or were designed with that
behavior in mind.

llvm-svn: 46186
2008-01-19 03:58:00 +00:00
Chris Lattner
55c50079c3 don't form an std::string with a null pointer, it aborts.
llvm-svn: 46166
2008-01-18 18:54:31 +00:00
Ted Kremenek
e08671bc63 Reverted implementation of ImmutableMap::find() to return a TreeTy* instead of
an iterator, since the implementation returned an iterator that pointed to a
different node! Renamed this implementation to SlimFind() so that users do not
expect it to return an iterator (it is a more efficient implementation than
returning an iterator if the user just wants to find the value of a key).

Added a FIXME to implement ImmutableMap::find() that returns an iterator.

llvm-svn: 46150
2008-01-18 00:38:04 +00:00
Ted Kremenek
7c8ee3790f Implemented "FIXME" in ImutAVLTree: isEqual() now also compares the *data* value
and not just the key value when comparing trees. To do this we added data_type
and data_type_ref to the ImutContainerInfo trait classes. For values stored in
the tree that do not have separate key and data components, data_type is simply
a typedef of bool, and isDataEqual() always evaluates to true. This allows us to
support both ImmutableSet and ImmutableMap using the same underlying logic.

llvm-svn: 46130
2008-01-17 17:36:49 +00:00
Ted Kremenek
9b2d0769ed Changed ImmutableMap::find to return an iterator instead of a pointer
to the tree node.

llvm-svn: 46034
2008-01-15 23:53:53 +00:00
Chris Lattner
89d996afce add operator==/!= to smallvector.
llvm-svn: 45872
2008-01-11 18:42:02 +00:00
Ted Kremenek
8461cdc206 Added "getRoot()" to ImmutableMap.
Made the ctor for ImmutableMap to construct a map from an AVL tree public.

llvm-svn: 45756
2008-01-08 21:05:59 +00:00
Ted Kremenek
9d742fd3c4 Fixed 80 col. violation.
llvm-svn: 45752
2008-01-08 19:38:55 +00:00
Ted Kremenek
08801d9556 Inverted argument order for ImmutableMap::Profile.
llvm-svn: 45507
2008-01-02 22:18:33 +00:00