Commit Graph

583 Commits

Author SHA1 Message Date
Dan Gohman
93c276e1c9 Add a method to APFloat to convert directly from APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47738 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-29 01:26:11 +00:00
Anton Korobeynikov
95e78348f0 Update per review. Patch by Mikhail Glushenkov!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47628 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 21:44:24 +00:00
Bill Wendling
e85fe660e4 Detabify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 10:49:39 +00:00
Eli Friedman
faa999565f Add missing include (for ptrdiff_t).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47576 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-25 23:35:32 +00:00
Anton Korobeynikov
567a273370 Add smart refcounting pointer class to ADT back (known before as IntrusiveSPtr.h).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47482 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-22 17:26:05 +00:00
Anton Korobeynikov
602d1c51e0 Unbreak build for VC2008. Patch by Argiris Kirtzidis!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47480 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-22 10:11:21 +00:00
Dan Gohman
c9525263f6 Remove inline keywords from in-class function definitions, for
consistency.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 19:29:58 +00:00
Dan Gohman
bd99917892 Add an intersects method to APInt, to capture a common idiom.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47379 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 16:08:11 +00:00
Anton Korobeynikov
ae9f3a3b7c Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47367 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 11:08:44 +00:00
Scott Michel
0123b7dcfa 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 23:05:48 +00:00
Dan Gohman
cd2ad1df5d Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47097 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 22:32:12 +00:00
Dan Gohman
7649127ec1 Rename APInt's isPositive to isNonNegative, to reflect what it
actually does.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47090 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 22:09:18 +00:00
Dan Gohman
42dd77f207 Add countTrailingOnes member functions to APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47086 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 21:11:05 +00:00
Dan Gohman
b5cfaaedbe Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47085 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 20:56:53 +00:00
Dan Gohman
ffe3e2514a Change APInt::getBitsSet to accept a "half-open" range, where the
hiBit parameter marks the index one past the last desired set bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47032 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-12 21:47:33 +00:00
Dan Gohman
d3993d13be 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46978 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 23:45:14 +00:00
Ted Kremenek
a618f82c9f 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).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46975 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 23:11:12 +00:00
Ted Kremenek
1f801fa5ad 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46957 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-11 17:24:50 +00:00
Dan Gohman
ec646cfd07 Add an isSignedIntN, like isIntN but for signed integer values instead of
unsigned.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46894 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 21:58:15 +00:00
Ted Kremenek
86383e1f7c Constified operator<< in APSInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46882 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-08 07:14:19 +00:00
Dan Gohman
167b8bc24d Add support to FoldingSet for hashing APInt objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46833 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-06 23:09:15 +00:00
Anton Korobeynikov
5c4fb22809 Don't dereference an invalid pointer if string is empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46781 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 23:34:40 +00:00
Ted Kremenek
9dc7ab538e Added FoldingSet profiling support to ImmutableSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46757 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 18:50:25 +00:00
Ted Kremenek
95da16e288 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46753 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-05 17:30:43 +00:00
Ted Kremenek
c695ea9e8d Modified 'Profile' method of ImmutableMap to use the 'Profile' method
of the contained ImutAVLTree root.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46719 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 21:17:02 +00:00
Ted Kremenek
f357afb404 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46717 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 21:15:24 +00:00
Ted Kremenek
26e3c445fc Added "bucket_iterators" to FoldingSet. Bucket iterators allow iteration
over all the nodes in a particular bucket.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46716 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 21:11:17 +00:00
Ted Kremenek
d9719495c3 constified operator~().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46707 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 16:57:26 +00:00
Anton Korobeynikov
ec3e5c8a39 Add convenient std::string helpers to StringMap. Patch by Mikhail Glushenkov!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46625 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 23:02:33 +00:00
Anton Korobeynikov
713a13906a Reapply the patch with fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46615 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 17:43:25 +00:00
Chris Lattner
a91cfa9cd0 revert anton's recent stringmap patch, which breaks clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46614 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 17:24:51 +00:00
Anton Korobeynikov
f429a519c8 Make StringMap to be more STL'ish. Patch by Mikhail Glushenkov!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46612 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 12:30:40 +00:00
Anton Korobeynikov
75fb496fc6 Whitespace cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 12:10:41 +00:00
Ted Kremenek
d25c9cd3ff Altered ctor for APSInt to accept an optional "isUnsigned" flag. Default
behavior is unchanged.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-29 18:55:14 +00:00
Ted Kremenek
7afe973add Added destructor for template class FoldingSetNodeWrapper.
Added getValue() to FoldingSetNodeWrapper.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46465 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-28 22:05:23 +00:00
Ted Kremenek
cadf873c83 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46316 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 18:59:52 +00:00
Ted Kremenek
1eed950d7c Added "getRoot()" to ImmutableSet.
Made ImmutableSet::ImmutableSet(ImutAVLTree* Root) public. (this allows handy
casting between trees and sets).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46277 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-23 19:57:33 +00:00
Ted Kremenek
3387060470 Fixed buggy caching of the hash value of an ImutAVLTree node.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46229 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:54:46 +00:00
Ted Kremenek
8893b0d3ac Moved method call within a conditional branch because its effects will
be ignored on the false branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46228 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:51:35 +00:00
Ted Kremenek
c4125a3c44 Adjusted ImutAVLTree::ComputeHash to compute a hash value that is based on a
clearer sequence of hashing compositions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46227 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:50:37 +00:00
Ted Kremenek
c899b33b83 Added "clear" method to FoldingSetNodeID to allow a FoldingSetNodeID object
to be reused to compute multiple object profiles.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:49:22 +00:00
Ted Kremenek
6518f5fcbf 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:33:30 +00:00
Ted Kremenek
187784996c Changed argument name for 'Profile' method to potentially fix a name conflict
reported in pr1929 (http://llvm.org/PR1929).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46193 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 17:21:43 +00:00
Ted Kremenek
3cf8bec783 Modified ImmutableSet/ImmutableMap to use FoldingSet profiling using
FoldingSetTrait instead of directly calling a 'Profile' method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46190 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:51:55 +00:00
Ted Kremenek
4048a08284 Added FoldingSet style 'profiling' support for APSInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46189 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:31:12 +00:00
Ted Kremenek
e420debd26 Added FoldingSet style 'profiling' support for APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:23:33 +00:00
Ted Kremenek
0a3fecad0a 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46187 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 04:22:50 +00:00
Ted Kremenek
a753f703d1 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46186 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-19 03:58:00 +00:00
Chris Lattner
4569553432 don't form an std::string with a null pointer, it aborts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46166 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-18 18:54:31 +00:00
Ted Kremenek
e8277538e7 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46150 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-18 00:38:04 +00:00