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

709 Commits

Author SHA1 Message Date
Ted Kremenek
106f694b2e Added OwningArrayPtr smart pointer class to provide an analogous class to
OwningPtr except that it works for pointers to arrays.

llvm-svn: 45266
2007-12-20 19:53:47 +00:00
Chris Lattner
4934fef7da add new smart pointer for clang.
llvm-svn: 45261
2007-12-20 19:14:02 +00:00
Anton Korobeynikov
ed6c70ec4b More eye-candy stuff :)
llvm-svn: 45247
2007-12-20 01:30:27 +00:00
Anton Korobeynikov
b31ccdedcd Add iterators for child traversal.
llvm-svn: 45246
2007-12-20 01:21:50 +00:00
Chris Lattner
ea78f7ae10 cleanup this code, making it more "llvm-like".
Add comments to reset indicating that it deletes its pointer.
Add a new take() method, which can be used to get the pointer
without it being deleted.

llvm-svn: 45112
2007-12-17 18:58:23 +00:00
Anton Korobeynikov
685e0a62bf Define addString() and lookup() out-of-line to dissuade the C++ compiler from inlining it.
llvm-svn: 45068
2007-12-16 01:36:16 +00:00
Anton Korobeynikov
b4378fc9b8 Provide GraphTraits and DOTGraphTraits interface for Trie.
Retoss private/public stuff.
Make copy ctor and operator= private.

llvm-svn: 45067
2007-12-16 01:27:04 +00:00
Anton Korobeynikov
7e9eec3dfc Use references in DF iterators. This eliminates copy-ctor calls on huge objects (graphs)
llvm-svn: 45063
2007-12-15 22:23:24 +00:00
Dan Gohman
80af3e255d Add explicit keywords, and fix a minor typo that they uncovered.
llvm-svn: 45034
2007-12-14 15:41:34 +00:00
Anton Korobeynikov
638a7cffbc Use vector for child storage instead of map. This will also make
our life during future GraphTraits'ing slightly easier.

llvm-svn: 44952
2007-12-12 19:08:44 +00:00
Anton Korobeynikov
f5c6b49537 Remove Trie::Edge class. Now edge labels are stored into nodes itself.
llvm-svn: 44880
2007-12-11 21:55:38 +00:00
Wojciech Matyjewicz
f9fb2b23fe Use correct member access operator.
(my test commit as well)

llvm-svn: 44868
2007-12-11 17:46:25 +00:00
Anton Korobeynikov
0fc72aee23 Add first and really dirty version of generic Trie structure
llvm-svn: 44851
2007-12-11 06:53:44 +00:00
Ted Kremenek
d0f4955b73 Added two bounds checks to the BitVector class to detect
out-of-bounds bit accesses.  The checks are only performed
in a Debug build.

llvm-svn: 44815
2007-12-10 22:28:35 +00:00
Chris Lattner
8b88401fbe remove dead #include.
llvm-svn: 44711
2007-12-08 19:06:21 +00:00
Chris Lattner
d62e99bd4a eliminate dependency on Bitcode headers.
llvm-svn: 44709
2007-12-08 19:01:44 +00:00
Chris Lattner
44b8c0e9e1 remove dead #include, APInt.h already has the needed forward decls.
llvm-svn: 44708
2007-12-08 19:00:38 +00:00
Chris Lattner
2190758012 Pass the whole StringMapEntry into StringMapEntryInitializer::Initialize.
llvm-svn: 44432
2007-11-29 06:14:41 +00:00
Chris Lattner
5d29c4130c provide an optional API to allow datatypes in a stringmap to be *gasp*
initialized with a value if they want, by specializing the 
StringMapEntryInitializer class.

llvm-svn: 44430
2007-11-29 06:04:41 +00:00
Chris Lattner
36854c740d Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
llvm-svn: 44296
2007-11-23 22:42:31 +00:00
Dan Gohman
760d574313 Add explicit keywords.
llvm-svn: 44234
2007-11-19 15:30:20 +00:00
Daniel Berlin
13a0e04717 Fix bugs in iterator invalidation
llvm-svn: 44174
2007-11-15 18:06:49 +00:00
Chris Lattner
9673aa6fd1 Import the boost scoped_ptr class to LLVM. This patch was prepared by
Cédric Venet.

llvm-svn: 44161
2007-11-15 05:57:06 +00:00
Hartmut Kaiser
1ba24a4989 Fixed a strange construct. Please review.
llvm-svn: 44082
2007-11-13 23:04:06 +00:00
Ted Kremenek
846a3448a1 Implemented generic serialization of APFloat.
llvm-svn: 43829
2007-11-07 18:39:22 +00:00
Ted Kremenek
7c8260f21b Fixed default ctor for APInt to properly initialize BitWidth to a
non-random value.

llvm-svn: 43795
2007-11-07 00:27:59 +00:00
Chris Lattner
edf6668dda make smallptrset more const and type correct, which caught a few
minor bugs.

llvm-svn: 43782
2007-11-06 22:12:43 +00:00
Neil Booth
d04447b7ae When converting to integer, do bit manipulations in the destination
memory rather than in a copy of the APFloat.  This avoids problems
when the destination is wider than our significand and is cleaner.

Also provide deterministic values in all cases where conversion
fails, namely zero for NaNs and the minimal or maximal value
respectively for underflow or overflow.

llvm-svn: 43626
2007-11-01 22:43:37 +00:00
Ted Kremenek
5517254faa Added typedef "value_type" to DenseMap (similar typedef appears in std::map).
Added method FindAndConstruct() to DenseMap, which does the same thing as
operator[], except that it refers value_type& (a reference to both the
key and mapped data pair).  This method is useful for clients that wish
to access the stored key value, as opposed to the key used to do the
actual lookup (these need not always be the same).

Redefined operator[] to use FindAndConstruct() (same logic).

llvm-svn: 43594
2007-11-01 00:54:57 +00:00
Ted Kremenek
4284b7c63c Changed access control within FoldingSet for some ivars from "private"
to "protected".  This allows iterators to work.

llvm-svn: 43559
2007-10-31 17:12:47 +00:00
Ted Kremenek
d3e5310f68 Added member function "size()" to FoldingSet to return the number of
nodes in the FoldingSet.

llvm-svn: 43531
2007-10-30 23:35:55 +00:00
Ted Kremenek
3f3b4818ef Added serialization support for APInt.
llvm-svn: 43405
2007-10-26 21:50:10 +00:00
Ted Kremenek
5b2ac3504a Fixed incorrect "path name" in preamble (comment) of header file.
llvm-svn: 43402
2007-10-26 20:44:02 +00:00
Ted Kremenek
0347caa918 Fixed incorrect "path name" in preamble (comment) of header file.
llvm-svn: 43401
2007-10-26 20:42:45 +00:00
Chris Lattner
ef90913394 add a nice predicate to check to see if nan
llvm-svn: 43304
2007-10-24 18:54:28 +00:00
Christopher Lamb
b9c6101dd5 Add an uppercase conversion utility function.
llvm-svn: 43146
2007-10-18 19:31:38 +00:00
Ted Kremenek
c00b2095fa Changed the return type of type-specific Allocate() methods to return
void*.  This is hint that we are returning uninitialized memory rather
than a constructed object.

Patched ImutAVLTree to conform to this new interface.

llvm-svn: 43106
2007-10-18 00:30:14 +00:00
Ted Kremenek
7d21c85cca ImutAVLTree now allocates tree nodes from the BumpPtrAllocator using
the new type-aligned Allocate() method.

llvm-svn: 43100
2007-10-17 22:17:01 +00:00
Ted Kremenek
24219dc48a Minor cosmetic cleanups in the calculation of alignments for
StringMapEntry objects.  No functionality change.

llvm-svn: 43097
2007-10-17 22:09:45 +00:00
Ted Kremenek
307fa3bed5 Updated StringMap to use llvm::AlignOf to compute the alignment of map
entries.

llvm-svn: 43089
2007-10-17 21:13:50 +00:00
Hartmut Kaiser
ed12f66488 Updated VC++ build system.
Silenced some VC warnings.

I'm getting linker errors, though: unresolved externals:

llvm::Split<class llvm::BasicBlock *,struct llvm::GraphTraits<class llvm::BasicBlock *> >(class llvm::DominatorTreeBase<class llvm::BasicBlock> &,class llvm::BasicBlock *)

and

llvm::Split<struct llvm::Inverse<class llvm::BasicBlock *>,struct llvm::GraphTraits<struct llvm::Inverse<class llvm::BasicBlock *> > >(class llvm::DominatorTreeBase<class llvm::BasicBlock> &,class llvm::BasicBlock *)

Where are these defined?

llvm-svn: 43073
2007-10-17 14:56:40 +00:00
Ted Kremenek
89ca477326 Fixed incorrect renaming of method name (forgot two characters).
llvm-svn: 42999
2007-10-15 19:15:48 +00:00
Ted Kremenek
432c112649 Added more doxygen comments.
Renamed internal method of ImutAVLTree::RemoveMutableFlag to MarkImmutable.
Added enum for bit manipulation (more self-documentating).

llvm-svn: 42998
2007-10-15 18:52:34 +00:00
Neil Booth
1463947f03 Consolidate logic for creating NaNs. Silence compiler warning.
llvm-svn: 42966
2007-10-14 10:39:51 +00:00
Chris Lattner
18867ab274 don't use intptr_t without including it.
llvm-svn: 42921
2007-10-12 18:16:23 +00:00
Chris Lattner
e80faf3036 Make this compute the correct offset, handling alignment of the element
pointer correctly.

llvm-svn: 42918
2007-10-12 17:49:52 +00:00
Neil Booth
078f455d15 Implement correctly-rounded decimal->binary conversion, i.e. conversion
from user input strings.

Such conversions are more intricate and subtle than they may appear;
it is unlikely I have got it completely right first time.  I would
appreciate being informed of any bugs and incorrect roundings you
might discover.

llvm-svn: 42912
2007-10-12 16:02:31 +00:00
Chris Lattner
e47ae5fe94 make operator== work with non-equal sized bitvectors, as long as
the extra bits are all zeros.  This allows  "010" and "010000" to be
treated as equal.

llvm-svn: 42889
2007-10-12 03:48:59 +00:00
Ted Kremenek
ee654dc6ef Provided accessors to internal allocator for ImutAVLTree and ImmutableSet.
Added postfix ++,-- support for ImmutableSet::iterator.

llvm-svn: 42877
2007-10-11 21:51:04 +00:00
Dale Johannesen
0ee2a2fb59 Next PPC long double bits. First cut at constants.
No compile-time support for constant operations yet,
just format transformations.  Make readers and
writers work.  Split constants into 2 doubles in
Legalize.

llvm-svn: 42865
2007-10-11 18:07:22 +00:00
Chris Lattner
0330d81fcf make bitvector &= do the right thing if vectors have mismatched length.
llvm-svn: 42860
2007-10-11 06:12:33 +00:00
Ted Kremenek
6781a1791a Added iterators to ImmutableSet.
llvm-svn: 42851
2007-10-11 00:14:49 +00:00
Ted Kremenek
7ebd4a09c9 Added some doxygen comments to ImmutableSet.
llvm-svn: 42850
2007-10-10 23:47:03 +00:00
Ted Kremenek
4c37e29cf4 Removed uninformative assertions that catch problems that will
fire anyway at runtime due to a NULL dereference.

llvm-svn: 42848
2007-10-10 23:35:04 +00:00
Ted Kremenek
89e6ab12de Removed "height" of an AVL tree node from its Profile. This is
implicitly captured by using the addresses of its children in the
profile.

llvm-svn: 42847
2007-10-10 23:32:01 +00:00
Ted Kremenek
d0843e54f5 Removed spurious forward declaration to a structure that will no longer be used.
llvm-svn: 42839
2007-10-10 20:45:34 +00:00
Ted Kremenek
e5e9880bfc Added some doxygen comments to a few methods of ImutAVLTree.
llvm-svn: 42837
2007-10-10 20:44:21 +00:00
Ted Kremenek
9b6872e3d5 Added preliminary support for iterators in ImutAVLTree.
Implemented ImutAVLTree::isEqual.

llvm-svn: 42833
2007-10-10 18:11:16 +00:00
Ted Kremenek
7a878948f9 Renamed internal method "Create" of ImutAVLTree to "CreateNode".
llvm-svn: 42825
2007-10-10 16:27:33 +00:00
Ted Kremenek
a8e090bd1c Added implementation of immutable (functional) maps and sets, as
implemented on top of a functional AVL tree.  The AVL balancing code
is inspired by the OCaml implementation of Map, which also uses a functional
AVL tree.

Documentation is currently limited and cleanups are planned, but this code
compiles and has been tested.

llvm-svn: 42813
2007-10-09 21:38:09 +00:00
Chris Lattner
8ee06ab2ab Fix problems where DenseMap used operator!= instead of correctly
calling the traits implementation of isEqual.

llvm-svn: 42782
2007-10-09 05:42:12 +00:00
Chris Lattner
19cb9fa4cc Change a #include into a forward declaration
llvm-svn: 42781
2007-10-09 03:40:30 +00:00
Neil Booth
f003f9bf1a Add a new function tcExtract for extracting a bignum from an
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.

llvm-svn: 42745
2007-10-08 13:47:12 +00:00
Chris Lattner
ddd980044f Finish off PR1723, by working around some strange compiler bug.
llvm-svn: 42737
2007-10-07 17:57:10 +00:00
Neil Booth
6f9602ac12 Add back convertFromSignExtendedInteger.
llvm-svn: 42735
2007-10-07 12:15:41 +00:00
Neil Booth
db4dbedfea Reimplement convertFromUnsignedInteger so it is passed a const bignum.
It used to modify its argument in-place.

This interface is saner and the implementation more efficient.  It will
be needed for decimal->binary conversion.

llvm-svn: 42733
2007-10-07 12:07:53 +00:00
Neil Booth
6e01c5df37 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Neil Booth
726126f4d6 combineLostFractions does not need to be a member function
llvm-svn: 42729
2007-10-07 08:51:21 +00:00
Daniel Berlin
afb1610cf3 Some more problems noticed by Curtis
llvm-svn: 42717
2007-10-07 04:47:57 +00:00
Neil Booth
2c4419d71b Generalize tcFullMultiply so that the operands can be of differing
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.

llvm-svn: 42669
2007-10-06 00:24:48 +00:00
Chris Lattner
c604dd270a Mark count method const.
llvm-svn: 42639
2007-10-05 17:40:38 +00:00
Daniel Berlin
7cb8b28613 Fix intersectWithComplement bug noticed by Curtis Dunham
Optimize |= case for empty RHS

llvm-svn: 42629
2007-10-05 05:10:53 +00:00
Daniel Berlin
cf42f07a47 Fix the previous bug a slightly different way (by modifying how find_next works)
llvm-svn: 42613
2007-10-04 21:27:17 +00:00
Daniel Berlin
bbe5e56458 Fix off by one error in iterator
llvm-svn: 42612
2007-10-04 21:18:20 +00:00
Daniel Berlin
cd14e3d42a It helps a lot when you check for the end of your list before randomly
dereferencing things.

llvm-svn: 42605
2007-10-04 05:29:36 +00:00
Daniel Berlin
a4df074d31 Make SparseBitVector::set actually work properly when sets are not in ascending or descending order.
llvm-svn: 42604
2007-10-04 05:25:51 +00:00
Neil Booth
2dc065755d Add APFloat -> hexadecimal string conversion, as per %a and %A in C99.
Useful for diagnostics and debugging.

llvm-svn: 42598
2007-10-03 22:26:02 +00:00
Owen Anderson
7d39d6d4cb Add a GraphTraits partial specialization to make the inverse of an inverse be the same as the underlying graph.
llvm-svn: 42592
2007-10-03 21:24:38 +00:00
Chris Lattner
de233151af Add initial iterator support for folding set.
llvm-svn: 42589
2007-10-03 21:12:09 +00:00
Neil Booth
1e709921bc Tweak RoundAwayFromZero the bit number below which is truncated, and make
it const.

Preparation for APFloat -> hexadecimal string conversion.

llvm-svn: 42576
2007-10-03 15:16:41 +00:00
Chris Lattner
c013b7f395 Add a helper useful when mapping from a map element to its hash node.
llvm-svn: 42480
2007-09-30 08:31:46 +00:00
Chris Lattner
1654385fd0 Add a new DenseSet abstraction.
llvm-svn: 42474
2007-09-30 00:47:20 +00:00
Neil Booth
3680e05d98 Whitespace cleanup.
llvm-svn: 42374
2007-09-26 21:35:05 +00:00
Daniel Berlin
4ba5c86ebb Fix small bug in operator== for iterators
llvm-svn: 42331
2007-09-26 00:11:59 +00:00
Daniel Berlin
f6cb4c3d65 Comment fixups
llvm-svn: 42279
2007-09-24 22:20:45 +00:00
Daniel Berlin
f900d1295f Implement offline variable substitution in order to reduce memory
and time usage.
Fixup operator == to make this work, and add a resize method to DenseMap
so we can resize our hashtable once we know how big it should be.

llvm-svn: 42269
2007-09-24 19:45:49 +00:00
Owen Anderson
02c6c6bba7 Fix typo.
llvm-svn: 42256
2007-09-24 02:33:22 +00:00
Dale Johannesen
c7279629cc Change APFloat::convertFromInteger to take the incoming
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.

llvm-svn: 42210
2007-09-21 22:09:37 +00:00
Owen Anderson
40196b7929 Fix CopyFrom for non-POD data types.
llvm-svn: 42208
2007-09-21 20:55:54 +00:00
Devang Patel
547d418b8e Do not hide APInt::dump() inside #ifndef NDEBUG.
llvm-svn: 42068
2007-09-17 22:24:00 +00:00
Chris Lattner
cc315726f7 Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo
Add a new DenseMapInfo::isEqual method to allow clients to redefine
the equality predicate used when probing the hash table.

llvm-svn: 42042
2007-09-17 18:34:04 +00:00
Daniel Berlin
a19af373e3 That's what i get for using carbon emacs in a terminal
llvm-svn: 42040
2007-09-17 18:05:59 +00:00
Daniel Berlin
d26deb0a6d Fix iterator so it doesn't sometimes report bits that aren't in the bitmap
llvm-svn: 42039
2007-09-17 18:04:21 +00:00
Daniel Berlin
d44b2016ca Fix bug in andersen's related to test_and_set.
Add operator == and != to SparseBitVector.
Simplify code for test_and_set

llvm-svn: 42018
2007-09-16 23:59:53 +00:00
Daniel Berlin
688e8d9b60 Fix a few bugs related to zero'ing of elements
llvm-svn: 42017
2007-09-16 22:31:47 +00:00
Dale Johannesen
575bd6070a Remove the assumption that FP's are either float or
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).

llvm-svn: 41967
2007-09-14 22:26:36 +00:00
Dan Gohman
1c9bf0bfb9 And an FoldingSetImpl::NodeID::AddInteger overload for int64_t, to avoid
ambiguity.

llvm-svn: 41960
2007-09-14 20:48:42 +00:00
Chris Lattner
7b29e6a714 Make single-argument ctors explicit to avoid tricky bugs :)
llvm-svn: 41924
2007-09-13 06:15:57 +00:00
Daniel Berlin
f778d9ea43 Move dump out of class, use "\n" instead of endl
llvm-svn: 41872
2007-09-11 22:58:27 +00:00
Dale Johannesen
7bc3969cea Add APInt interfaces to APFloat (allows directly
access to bits).  Use them in place of float and
double interfaces where appropriate.
First bits of x86 long double constants handling 
(untested, probably does not work).

llvm-svn: 41858
2007-09-11 18:32:33 +00:00
Daniel Berlin
b4c820ecfd Convert to use ilist and non-pointer lists for extra goodness
llvm-svn: 41855
2007-09-11 17:42:22 +00:00
Owen Anderson
0c2fdab32a Add a ValueInfoT template parameter to DenseMap so that it can properly make decisions
based on whether the key AND the value require ctors/dtors.

llvm-svn: 41837
2007-09-11 05:08:05 +00:00
Owen Anderson
a96cf4c60a Don't bother to initialize values corresponding to empty or tombstone
keys.

llvm-svn: 41834
2007-09-11 04:43:51 +00:00
Daniel Berlin
c0ef77b9f6 Fix bugs with &=, intersect with complement. Add three argument version of intersect with complement.
llvm-svn: 41832
2007-09-11 04:11:28 +00:00
Owen Anderson
8014c7f1f3 Fix non-deterministic behavior in the DenseMap copy constructor.
llvm-svn: 41831
2007-09-11 03:48:08 +00:00
Daniel Berlin
be8b616451 Add remaining functions necessary for andersen's
llvm-svn: 41830
2007-09-11 01:38:07 +00:00
Daniel Berlin
f0f3834ee6 Add SparseBitVector implementation
llvm-svn: 41790
2007-09-09 01:10:40 +00:00
Chuck Rose III
788df70ec3 Fix for VisualStudio. It is treating a 2 bit enum as a signed int for comparison purposes, causing failures. Using an extra bit fixes it.
llvm-svn: 41784
2007-09-08 04:17:08 +00:00
Owen Anderson
4b71e55287 Add lengthof and endof templates that hide a lot of sizeof computations.
Patch by Sterling Stein!

llvm-svn: 41758
2007-09-07 04:06:50 +00:00
Dale Johannesen
1f864b259a fix reversal bug in preceding checkin
llvm-svn: 41705
2007-09-04 17:32:27 +00:00
Dale Johannesen
b34e6b4898 Add mod, copysign, abs operations to APFloat.
Implement some constant folding in SelectionDAG and
DAGCombiner using APFloat.  Remove double versions
of constructor and getValue from ConstantFPSDNode.

llvm-svn: 41664
2007-08-31 23:34:27 +00:00
Dale Johannesen
a79f7d4068 Revise per review of previous patch.
llvm-svn: 41645
2007-08-31 17:03:33 +00:00
Dale Johannesen
81d6ecb886 Enhance APFloat to retain bits of NaNs (fixes oggenc).
Use APFloat interfaces for more references, mostly
of ConstantFPSDNode.

llvm-svn: 41632
2007-08-31 04:03:46 +00:00
Chris Lattner
d49a347b87 getMinSignedBits needs to take into consider the sign bit when the value is positive.
llvm-svn: 41566
2007-08-29 16:21:18 +00:00
Dan Gohman
e2c92effea Add explicit keywords and remove spurious trailing semicolons.
llvm-svn: 41482
2007-08-27 14:50:10 +00:00
Dale Johannesen
ab02edb700 Comment out declaration of operator== (undefined).
llvm-svn: 41383
2007-08-25 00:40:41 +00:00
Dale Johannesen
9ec1e28e79 Poison APFloat::operator==. Replace existing uses with bitwiseIsEqual.
This means backing out the preceding change to Constants.cpp, alas.

llvm-svn: 41378
2007-08-24 22:09:56 +00:00
Dale Johannesen
0aaabb858b Revised per review feedback from previous patch.
llvm-svn: 41353
2007-08-24 05:08:11 +00:00
Dale Johannesen
a3ab055b9d Change internal representation of ConstantFP to use APFloat.
Interface to rest of the compiler unchanged, as yet.

llvm-svn: 41348
2007-08-24 00:56:33 +00:00
Chris Lattner
346bc59e4f default this to radix 10 like the toString(Un)Signed methods.
llvm-svn: 41311
2007-08-23 05:21:48 +00:00
Chris Lattner
66d4ebe00f Avoid hiding issues.
llvm-svn: 41310
2007-08-23 05:20:48 +00:00
Chris Lattner
742b745b0c rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()
Add an APSInt::toString() method.

llvm-svn: 41309
2007-08-23 05:15:32 +00:00
Chris Lattner
401698e8b5 initial checkin of Neil's APFloat work.
llvm-svn: 41203
2007-08-20 22:49:32 +00:00
Chris Lattner
24d536e26b add reverse iterators to smallvector
llvm-svn: 41198
2007-08-20 21:22:48 +00:00
Chris Lattner
790dceee30 improve iplist comments. Switch iplist from allocating its sentinal object (for
end()) eagerly to allocating it lazily.  This saves a lot of memory for JIT applications
that read a module but don't materialize most of the functions (e.g. 62K for 252.eon).

llvm-svn: 41142
2007-08-17 16:49:19 +00:00
Chris Lattner
4c6c787315 This adds a bunch of static functions that implement unsigned
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!

llvm-svn: 41124
2007-08-16 15:56:55 +00:00
Owen Anderson
06cbd29787 Forgot a line.
llvm-svn: 41115
2007-08-16 00:25:42 +00:00
Owen Anderson
868a1a5ed6 Add a copy constructor and an assignment operator to DenseMap.
llvm-svn: 41114
2007-08-16 00:18:32 +00:00
Anton Korobeynikov
958dcad32d Properly use const qualifiers
llvm-svn: 41111
2007-08-15 21:12:30 +00:00
Reid Spencer
8c5c7c8453 Change casts from old style to new style. This helps document the details
better, gives the compiler a chance to validate the cast and reduces warnings
if the user turns on -Wold-style-cast option.

llvm-svn: 41033
2007-08-12 08:12:35 +00:00
Chris Lattner
f570f023cf memcpy with zero length is hugely expensive, so avoid it. This speeds up coallescing from 1.17s to 0.88s on siod.
llvm-svn: 40984
2007-08-10 07:02:50 +00:00
Chris Lattner
8995eae095 small speedup in the case where a smallvector is default ctor'd from
an empty vector.  This speeds up llc slightly.

llvm-svn: 40983
2007-08-10 06:54:38 +00:00
Chandler Carruth
e717210757 This fixes resizing issues with BitVectors. It ensures that the BitWord type and type size is always used, and ensures completely correct clearing of unused high bits, and setting of bits when resizing. It should resolve PR1563.
llvm-svn: 40871
2007-08-06 20:52:17 +00:00
Reid Spencer
2a23af68c8 Document a missing parameter.
llvm-svn: 40852
2007-08-05 19:36:39 +00:00
Chris Lattner
ab61b6f01e Fix a bug in DenseMap::clear, where we never reset a tombstone
to EmptyKey.

llvm-svn: 40839
2007-08-05 08:43:36 +00:00
Chris Lattner
10db9656ba When clearing a SmallPtrSet, if the set had a huge capacity, but the
contents of the set were small, deallocate and shrink the set.  This
avoids having us to memset as much data, significantly speeding up
some pathological cases.  For example, this speeds up the verifier
from 0.3899s to 0.0763 (5.1x) on the testcase from PR1432 in a 
release build.

llvm-svn: 40837
2007-08-05 07:32:14 +00:00
Anders Carlsson
122059b2e9 Fix bug spotted by Chris.
llvm-svn: 40725
2007-08-02 06:05:19 +00:00
Anders Carlsson
89ea07e724 Add extend and extOrTrunc methods that do sign or zero extension depending on whether the integer is signed or not
llvm-svn: 40724
2007-08-02 06:00:13 +00:00
Owen Anderson
997b15d967 Allow SmallPtrSet to hold pointers to const data.
llvm-svn: 40556
2007-07-27 18:07:02 +00:00
Chris Lattner
06bdb78751 Disable the string map copy ctor and assignment operators,
they don't do the right thing.  

Implement StringMap::erase.

Fix a nasty bug in the default ctor.

llvm-svn: 40395
2007-07-22 20:08:01 +00:00
Owen Anderson
2ceefaf94d Make the heuristic for shrinking DenseMap smarter.
llvm-svn: 40114
2007-07-20 18:56:46 +00:00
Owen Anderson
07f3b97796 Have DenseMap auto-shrink itself on clear(). This improves the time to optimize
403.gcc from 15.2s to 14.3s.

llvm-svn: 40100
2007-07-20 16:15:24 +00:00
Reid Spencer
3dd7b1699b Unbreak the build by putting calls to free into the implementation file and
having that implementation file #include <cstdlib>.

llvm-svn: 39952
2007-07-17 02:16:12 +00:00
Owen Anderson
f01c29815d Use realloc() to (potentially) resize the contents of SmallPtrSet in place.
llvm-svn: 39926
2007-07-16 21:27:44 +00:00
Chris Lattner
03bc1d9018 add a helper method.
llvm-svn: 39885
2007-07-15 23:32:03 +00:00
Owen Anderson
31eaa152b8 Evidently my earlier fix did not go far enough. When resizing a zero-sized
BitVector, make sure to set or clear ALL of the bits.

llvm-svn: 38481
2007-07-10 02:01:16 +00:00
Owen Anderson
1ab53d5ee7 When resizing a BitVector with size 0, be sure to clear the low word before using it.
llvm-svn: 38476
2007-07-09 23:39:39 +00:00
Owen Anderson
e48ed4f7a8 Make the assignment operator for SmallPtrSet return a reference, and fix a long-standing bug in the copy
ctor while I'm at it.

Thanks to Chris Lattner for help with this patch.

llvm-svn: 38470
2007-07-09 20:59:01 +00:00
Chris Lattner
39e93bf0e0 work around an aparent gcc name resolution bug by
detemplatizing this.

llvm-svn: 38461
2007-07-09 17:11:53 +00:00
Chris Lattner
97ba0c99ed implement operator= for smallptrset
llvm-svn: 38460
2007-07-09 16:54:03 +00:00
Dan Gohman
2d36dfca67 Add an explicit keyword. Thanks Chris!
llvm-svn: 37819
2007-06-29 22:16:25 +00:00
John Criswell
57e5ed4b5a Convert .cvsignore files
llvm-svn: 37801
2007-06-29 16:35:07 +00:00
Dan Gohman
d2a3725004 Add a default parameter to a SmallVector constructor to allow it to
be called with just an initial length value, just like in std::vector.

llvm-svn: 37779
2007-06-28 20:27:24 +00:00
Owen Anderson
907b0a4e10 Have internal df_iterator's use SmallPtrSet instead of std::set. This provides compile time speedups to any pass using df_iterator.
llvm-svn: 37694
2007-06-21 21:25:36 +00:00
Chris Lattner
c68a1721c2 silence some "comparison between signed and unsigned integer expressions"
warnings

llvm-svn: 37177
2007-05-17 20:01:40 +00:00
Dan Gohman
2340529c17 Fix some sporadic segfaults that are triggered when SmallVector's heap
storage lands near the end of the available address space. In the expression
Begin+N > Capacity, the Begin+N was overflowing. Fix this by replacing it
by with an expression that doesn't involve computation of an address
beyond the end of allocated memory.

llvm-svn: 37171
2007-05-17 18:29:01 +00:00
Reid Spencer
a17d02ad08 Add some things needed by the llvm-gcc version supporting bit accurate integer
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.

llvm-svn: 37025
2007-05-13 23:44:59 +00:00
Chris Lattner
49b1ec44eb This is a patch to fix a compile error in STLExtras.h, and
a bug in GraphWriter.cpp.

Patch by Florian Brandner

llvm-svn: 36684
2007-05-03 18:32:10 +00:00
Chris Lattner
d710ec51bf remove useless type qualifiers
llvm-svn: 36676
2007-05-03 17:09:36 +00:00
Jeff Cohen
34d6dc5574 Rename identifier that GCC uses as a macro, breaking llvm-gcc build.
llvm-svn: 36474
2007-04-26 15:07:47 +00:00
Chris Lattner
b6ae31a101 add a missing operator
llvm-svn: 36375
2007-04-23 20:58:14 +00:00
Jeff Cohen
ac369daaa3 Fix some VC++ warnings.
llvm-svn: 36259
2007-04-19 02:04:09 +00:00
Chris Lattner
4a83860eea Commit an patch from Gabor Greif in Mar 2005. This eliminates the tail
pointer from ilist, storing it in the prev pointer of the first node in the
list instead.

This shrinks ilist from 8 to 4 bytes, BasicBlock from 40->36 bytes, Function
from 76->68 bytes, Module from 52->44 bytes.

llvm-svn: 36210
2007-04-17 18:41:42 +00:00
Anton Korobeynikov
f3e62a428a Removed tabs everywhere except autogenerated & external files. Add make
target for tabs checking.

llvm-svn: 36146
2007-04-16 18:10:23 +00:00
Jeff Cohen
5a502fb622 Fix PR1329.
llvm-svn: 36016
2007-04-14 21:50:21 +00:00
Reid Spencer
6e7854339e Implement a getBitsNeeded method to determine how many bits are needed to
represent a string in binary form by an APInt.

llvm-svn: 35968
2007-04-13 19:19:07 +00:00
Chris Lattner
5af0826c0b fix a comment bug Reid noticed
llvm-svn: 35864
2007-04-10 16:33:06 +00:00
Chris Lattner
f661523670 add missing methods, mark stuff const
llvm-svn: 35862
2007-04-10 07:06:21 +00:00
Chris Lattner
9359e7f928 add a method
llvm-svn: 35860
2007-04-10 06:43:18 +00:00
Chris Lattner
d39ae2fa6d Add a helper class (APSInt) which can represent an APInt along with sign
information.  This is useful when a value does have a sign associated with
it.  This shouldn't be used generally in LLVM for mid-level optimizer stuff.

llvm-svn: 35681
2007-04-05 05:20:11 +00:00
Lauro Ramos Venancio
2dfc0515a6 Fix release build.
llvm-svn: 35676
2007-04-04 22:13:39 +00:00
Anton Korobeynikov
e16f421e0e Properly emit range comparisons for switch cases, where neighbour cases
go to the same destination. Now we're producing really good code for
switch-lower-feature.ll testcase

llvm-svn: 35672
2007-04-04 21:14:49 +00:00
Chris Lattner
5d12d66728 trivial optimization
llvm-svn: 35648
2007-04-04 06:18:21 +00:00
Chris Lattner
8a4ca643dd use calloc instead of new/memset, it is more efficient
llvm-svn: 35644
2007-04-04 00:44:31 +00:00
Chris Lattner
dbf6a79a71 Extend StringMap to support being initialized as completely empty. When
initialized this way, they do not do a malloc to allocate their buckets.

llvm-svn: 35642
2007-04-04 00:29:37 +00:00
Chris Lattner
b5e5784b28 add missing operator
llvm-svn: 35613
2007-04-03 04:25:46 +00:00
Chris Lattner
3ff8b2cf06 add a helper function.
llvm-svn: 35585
2007-04-02 05:41:00 +00:00
Chris Lattner
b59fc9767b add range version of insert()
llvm-svn: 35572
2007-04-02 01:21:19 +00:00
Zhou Sheng
551fa60212 Remove unused methods.
llvm-svn: 35553
2007-04-01 12:45:33 +00:00
Duncan Sands
def480579a Correct typo.
llvm-svn: 35504
2007-03-30 06:39:42 +00:00
Reid Spencer
4984ab6c01 Compute getLowBitsSet correctly. Using the complement of a 64-bit value
and shifting down without regard for the bitwidth of the APInt can lead
to incorrect initialization values. Instead, check for the word size case
(to avoid undef results from shift) and then do (1 << loBitsSet) - 1

llvm-svn: 35344
2007-03-25 21:58:42 +00:00
Reid Spencer
b5b291924a Fix a typo in a comment.
llvm-svn: 35316
2007-03-25 01:13:46 +00:00
Reid Spencer
16d08887ef Actually, for getHighBitsSet and getLowBitsSet, don't make a 0 bit size
illegal. Instead do the 0 valued construction for the user. This is because
the caller may not know (or care to check) that the number of bits set is
zero.

llvm-svn: 35315
2007-03-25 00:01:47 +00:00
Reid Spencer
d24dc1f9a6 Make it illegal to set 0 bits in getHighBitsSet and getLowBitsSet. For that
they should have used the uint64_t constructor. This avoids causing
undefined results via shifts by the word size when the bit width is an
exact multiple of the word size.

llvm-svn: 35313
2007-03-24 23:47:58 +00:00
Reid Spencer
fb188ea881 In the getBitsSet function, don't optimize for a common case that is
already covered by getLowBitsSet (i.e. when loBits==0). Consequently, remove
the default value for loBits and reorder the arguments to the more natural
loBits, hiBits order. This makes it more clear that this function is for bit
groups in the middle of the bit width and not towards one end or the other.

llvm-svn: 35312
2007-03-24 23:42:47 +00:00
Reid Spencer
091d6cf3b7 Don't invoke undefined behavior in shifts in the functions getHighBitsSet
and getLowBitsSet.

llvm-svn: 35311
2007-03-24 23:35:54 +00:00
Reid Spencer
0e466b183f Implement the getBitsSet function.
llvm-svn: 35310
2007-03-24 23:27:48 +00:00
Reid Spencer
1aa3f64ef4 Implement the getHighBitsSet and getLowBitsSet functions.
llvm-svn: 35308
2007-03-24 23:05:35 +00:00
Reid Spencer
30351837ca Get the signs in the right place!
llvm-svn: 35307
2007-03-24 22:50:43 +00:00
Reid Spencer
0ceb493ee2 Undo the last change and make this really implement remainder and not
modulus. The previous change was a result of incorrect documentation in
the LangRef.html.

llvm-svn: 35305
2007-03-24 22:37:23 +00:00
Reid Spencer
c1dfceab8b Correct the implementation of srem to be remainder, not modulus. The sign of
the result must follow the sign of the divisor.

llvm-svn: 35302
2007-03-24 21:56:22 +00:00
Reid Spencer
52ea41bb97 Clean up this interface:
1. Group similar methods into doxygen groups
2. Reorganize the groups into a consist flow.
3. Significantly improve the quality of the documentation on several methods
4. Rewrite srem and sdiv to eliminate a copy and improve readability.
5. Eliminate unneeded forward references.

llvm-svn: 35300
2007-03-24 18:09:18 +00:00
Reid Spencer
76c1fef30a Fix a comment.
llvm-svn: 35246
2007-03-21 22:22:19 +00:00
Zhou Sheng
a9c0018850 Correct the name: isStrictPositive --> isStrictlyPositive.
llvm-svn: 35201
2007-03-20 02:18:16 +00:00
Chris Lattner
305c3525af Add a dtor to fix leaks from all clients of BitVector.
llvm-svn: 35200
2007-03-20 02:10:56 +00:00
Reid Spencer
c3422e56d6 Add an indication of signedness to the uint64_t constructor so sign bits
can be extended. This helps fix test/Assembler/2007-03-19-NegValue.ll

llvm-svn: 35179
2007-03-19 20:36:48 +00:00
Zhou Sheng
6ecf1045a6 Add isStrictPositive() to APInt to determine if this APInt Value > 0.
llvm-svn: 35156
2007-03-19 05:22:18 +00:00
Zhou Sheng
dfcf9376bc Add zextOrCopy() into APInt for convenience.
llvm-svn: 35079
2007-03-13 06:16:26 +00:00
Zhou Sheng
9643d0a422 Add getSignBit() and operator<<= into APInt for convenience.
llvm-svn: 35059
2007-03-11 07:16:10 +00:00
Jeff Cohen
84d84f7381 The hack won't work on VS 2005, and it might not be needed anyway.
llvm-svn: 34930
2007-03-05 17:22:33 +00:00
Zhou Sheng
b6d1ac8682 Correct the calculation in APInt::logBase2().
llvm-svn: 34929
2007-03-05 16:42:58 +00:00
Jeff Cohen
b58af23ff3 Elminate tabs and improve comments.
llvm-svn: 34921
2007-03-05 00:46:22 +00:00
Jeff Cohen
98c99a3a02 Unbreak VC++ build.
llvm-svn: 34917
2007-03-05 00:00:42 +00:00
Chris Lattner
2510829eba add iterator range version of ctor.
llvm-svn: 34899
2007-03-04 04:04:43 +00:00
Reid Spencer
e2bf55dfe8 Regularize the interface for conversion functions to/from float/double.
llvm-svn: 34881
2007-03-03 08:34:02 +00:00
Reid Spencer
503dda5840 Make getNumWords public so that those using getRawData stand a chance of
not reading beyond the end of the buffer returned.

llvm-svn: 34873
2007-03-03 06:17:23 +00:00
Reid Spencer
47b01d6acb Add names for some of the operators. This is needed for the macros in
the Interpreter.

llvm-svn: 34872
2007-03-03 05:37:23 +00:00
Reid Spencer
e5244b132b Add isPositive for symmetry with isNegative.
llvm-svn: 34862
2007-03-03 00:24:39 +00:00
Chris Lattner
68244ce570 Fix PR1234 by working around a compiler bug.
llvm-svn: 34845
2007-03-02 18:16:29 +00:00
Evan Cheng
44257955c8 Make it 64-bit safe.
llvm-svn: 34829
2007-03-02 02:31:37 +00:00
Reid Spencer
d86182b19b Add an abs() function to get the absolute value.
llvm-svn: 34819
2007-03-01 23:37:09 +00:00
Reid Spencer
003170430b Add doubleToBits and floatToBits methods.
llvm-svn: 34807
2007-03-01 20:39:01 +00:00
Reid Spencer
90b6227b81 Add bitsToDouble and bitsToFloat methods for re-interpretation of bits as FP.
llvm-svn: 34800
2007-03-01 20:06:51 +00:00
Reid Spencer
6a95676875 Add methods for bit width modification: sextOrTrunc, zextOrTrunc.
llvm-svn: 34789
2007-03-01 17:15:32 +00:00
Reid Spencer
b6dd32889e Add a square root function.
llvm-svn: 34775
2007-03-01 05:39:56 +00:00
Reid Spencer
0f2d45e42c Make APInt a little more friendly to its users:
* Add support for + and - of a uint64_t.
  * Make trunc/sext/zext return *this so it can be chained with other ops
  * Add smin, smax, umin, umax functions for getting min/max values.

llvm-svn: 34742
2007-02-28 17:33:36 +00:00
Reid Spencer
949b3612a8 getActiveWords should return the number of words, not the index of the
highest active words. Increment its result by one.

llvm-svn: 34713
2007-02-28 02:20:49 +00:00
Reid Spencer
355cec42d1 Add some syntactic sugar.
llvm-svn: 34704
2007-02-27 23:47:33 +00:00
Reid Spencer
edbe747bab Implement countLeadingOnes() and getMinSignedBits(). This helps to minimize
the bit width of negative numbers by computing the minimum bit width for a
negative value. E.g. 0x1800000000000000 could be just 0x8000000000000000

llvm-svn: 34695
2007-02-27 21:59:26 +00:00
Reid Spencer
9e66d0921a Improve APInt interface:
1. Add unsigned and signed versions of methods so a "bool" argument doesn't
   need to be passed in.
2. Make the various getMin/getMax functions all be inline since they are
   so simple.
3. Simplify sdiv and srem code.

llvm-svn: 34680
2007-02-27 20:24:31 +00:00
Reid Spencer
612dfe195b Allow the RoundDoubleToAPInt function to specify a width to use.
llvm-svn: 34672
2007-02-27 18:22:31 +00:00
Reid Spencer
9bc19eab08 Fix indentation.
llvm-svn: 34643
2007-02-26 21:06:05 +00:00
Reid Spencer
18629544d3 1. Split getValue() into getSExtValue() and getZExtValue() to match
ConstantInt better.
2. Add a getHashValue() method.

llvm-svn: 34641
2007-02-26 20:57:12 +00:00
Reid Spencer
11f19f730c Implement inline methods that make transition of ConstantInt to use APInt
easier to comprehend and might be useful elsewhere.

llvm-svn: 34635
2007-02-26 17:50:32 +00:00
Reid Spencer
1252a271a1 Make isNegative() a const function since it doesn't modify the APInt.
llvm-svn: 34630
2007-02-26 07:45:40 +00:00
Reid Spencer
e8e8ea4fba Add an isNegative method to determine if the APInt's value is negative.
This is much less expensive than a test against zero.

llvm-svn: 34619
2007-02-26 01:20:59 +00:00
Reid Spencer
a4ab1c36d2 Fix clearUnusedBits to not depend on "undefined behavior" of >> operator
when the bit size is equal to the word size. This happens to work out okay
on x86, but might not on other platforms. The change just detects when
there are no bits to clear (because BitWidth is a multiple of the word size)
and returns early.

Also, move some comments from .cpp file into header.

llvm-svn: 34602
2007-02-25 19:26:01 +00:00
Reid Spencer
e7d8a0e3b7 Add a private constructor for efficiency.
llvm-svn: 34580
2007-02-25 07:29:03 +00:00
Reid Spencer
a2a4a55915 Improve documentation.
Make divide function internal (it was briefly external for testing).

llvm-svn: 34557
2007-02-24 09:50:13 +00:00
Reid Spencer
807eadb51a Add a dump() method for debugging.
llvm-svn: 34464
2007-02-21 03:56:12 +00:00
Reid Spencer
2e50b9ed5b Add an internal convenience method for division that urem and udiv use.
llvm-svn: 34448
2007-02-20 08:43:42 +00:00
Reid Spencer
6eb099875c Add some new constants.
llvm-svn: 34398
2007-02-19 03:18:22 +00:00
Reid Spencer
79d2fad9f5 1. "unsigned" -> "uint32_t" to gaurantee its bit width on all platforms.
Size matters in this case.
2. Remove the unused whichByte private function, which was also broken.
3. Remove the non-const overload of the getWord function, getWord() is
   never used as an lvalue.
4. Rename some local variables for clarity (e.g. API -> Result).

llvm-svn: 34390
2007-02-18 18:42:35 +00:00
Reid Spencer
62b55a934b Implement signed output for toString.
Fix bugs in countLeadingZeros and countTrailingZeros.

llvm-svn: 34386
2007-02-18 00:44:22 +00:00
Reid Spencer
9c5efbcef2 Fix bugs introduced by constructor parameter order change.
llvm-svn: 34357
2007-02-17 00:18:01 +00:00
Reid Spencer
d22266f456 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.
llvm-svn: 34353
2007-02-16 22:36:51 +00:00
Evan Cheng
c17b6ab5f7 Proper fix for the off-by-one bug in clear_unused_bits().
llvm-svn: 34328
2007-02-15 21:38:15 +00:00
Reid Spencer
3b68dab779 Fix an off-by-one bug in computing the index of the word to clear.
llvm-svn: 34326
2007-02-15 20:49:10 +00:00
Reid Spencer
6fd2d9d381 Make sure Capacity gets initialized too.
llvm-svn: 34325
2007-02-15 20:14:06 +00:00
Evan Cheng
ca4cab1cd2 Missing a ;
llvm-svn: 34322
2007-02-15 19:29:05 +00:00
Evan Cheng
f73b1abdea BitVector::reference operator=(const reference& rhs) is unnecessary thanks to autoconvert to bool.
llvm-svn: 34320
2007-02-15 19:21:44 +00:00
Evan Cheng
471e882080 Remove unnecessary checks.
llvm-svn: 34319
2007-02-15 19:18:12 +00:00
Evan Cheng
25a8dc8e25 operator== returns false when two bitvectors have different sizes.
llvm-svn: 34317
2007-02-15 19:16:21 +00:00
Evan Cheng
84142d6607 Merges two resize() variants.
llvm-svn: 34316
2007-02-15 19:12:39 +00:00
Evan Cheng
fe4d7486d2 Clear no longer deleting the bits to avoid mallocs.
llvm-svn: 34315
2007-02-15 19:10:34 +00:00
Evan Cheng
21177a5395 BitVector::count() bugs.
llvm-svn: 34314
2007-02-15 19:09:36 +00:00
Evan Cheng
a916761a3a Eliminate a redundent ctor; eliminate one more potential new [0].
llvm-svn: 34313
2007-02-15 19:05:25 +00:00
Evan Cheng
622cd4bd4d 1 -> 1L since BitWord has type unsigned long.
llvm-svn: 34312
2007-02-15 19:03:23 +00:00
Evan Cheng
a8fcf075f1 Eliminate new[0], just set Bits to NULL.
llvm-svn: 34311
2007-02-15 18:59:15 +00:00
Evan Cheng
2216148289 Inverted the condition by accident.
llvm-svn: 34309
2007-02-15 18:48:41 +00:00
Evan Cheng
7ff021d148 Bug fixes: assignment operator forgot to copy over size; copy ctor forgot to clear unused top bits.
llvm-svn: 34305
2007-02-15 08:15:58 +00:00
Zhou Sheng
9868d8d7db 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.

llvm-svn: 34304
2007-02-15 06:36:31 +00:00
Evan Cheng
0cd0f0f232 Add a BitVector class.
llvm-svn: 34301
2007-02-15 05:56:11 +00:00
Reid Spencer
80ac48cfdf 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.

llvm-svn: 34253
2007-02-13 22:41:58 +00:00
Chris Lattner
3490afcd50 fix a critical bug in smallvector, where it would destroy elements that are
not in its range (!).

llvm-svn: 34230
2007-02-13 07:25:36 +00:00
Zhou Sheng
7b47556f5c 1. Make APInt::shl work correctly and more efficiently.
2. Add functions to support the numberical conversion between APInt and
   double/float.

llvm-svn: 34201
2007-02-12 20:02:55 +00:00
Chris Lattner
d61a01003b add new ShouldRehash method to factor out common code. Fix the dtor to not
delete tombstones.

llvm-svn: 34189
2007-02-11 21:46:36 +00:00
Chris Lattner
15eaaa2bbd do not allow hash table to be filled with tombstones.
llvm-svn: 34186
2007-02-11 21:07:36 +00:00
Chris Lattner
ce3f5f906a Add support for removing elements out of StringMap.
llvm-svn: 34185
2007-02-11 20:58:00 +00:00
Chris Lattner
3a9d38035f Replace the ugly FindValue method with STL-like find methods.
llvm-svn: 34183
2007-02-11 19:49:41 +00:00
Chris Lattner
f1e2e9e259 remove support for stringmap visitors now that iterators exist.
llvm-svn: 34180
2007-02-11 08:22:15 +00:00
Chris Lattner
c3396d5ff8 add iterator support, plus support for size() and empty().
llvm-svn: 34178
2007-02-11 08:12:13 +00:00
Chris Lattner
8a8d0a44a6 Split StringMapEntry construction out of StringMap, into StringMapEntry.
llvm-svn: 34170
2007-02-11 00:10:26 +00:00
Chris Lattner
f686454486 Make find return the appropriate iterator/const_iterator
llvm-svn: 34137
2007-02-10 06:58:17 +00:00
Chris Lattner
025607b8b0 Allow DenseMAp to take an explicit DenseMapKeyInfo
llvm-svn: 34134
2007-02-10 06:34:58 +00:00
Zhou Sheng
20d0f4e319 Eliminates friend function declaration inside APInt, instead, adds public
methods as those global function's internal implementation.

llvm-svn: 34083
2007-02-09 07:48:24 +00:00
Chris Lattner
d16cc5ebcb Rename CStringMap -> StringMap, since it now supports nul characters in the
strings.

llvm-svn: 34064
2007-02-08 19:20:57 +00:00
Chris Lattner
3705cf294c Allow cstringmap to contain strings with nul characters in them.
llvm-svn: 34062
2007-02-08 19:08:37 +00:00
Zhou Sheng
6efcdc8049 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.

llvm-svn: 34053
2007-02-08 14:35:19 +00:00
Lauro Ramos Venancio
30734ef2e7 Fix build error.
include/llvm/ADT/APInt.h:326: error: ‘assert’ was not declared in this scope

llvm-svn: 34002
2007-02-07 16:59:17 +00:00
Zhou Sheng
7881ec420f As Chris suggested, fixed some problems. (This is the first part.)
llvm-svn: 33986
2007-02-07 05:58:38 +00:00
Chris Lattner
2c3df2a958 do not let the table fill up with tombstones.
llvm-svn: 33973
2007-02-07 01:11:25 +00:00
Chris Lattner
672550f0b1 Fix a really subtle bug where the entire hash table could fill with
tombstones, causing subsequent insertions to infinitely loop.

llvm-svn: 33972
2007-02-07 00:55:59 +00:00
Lauro Ramos Venancio
a38cfcb65c Fix build error.
UniqueVector.h:66: error: ‘assert’ was not declared in this scope

llvm-svn: 33961
2007-02-06 14:59:28 +00:00
Zhou Sheng
8eba14bd31 As Reid suggested, fixed some problems.
llvm-svn: 33954
2007-02-06 05:59:47 +00:00
Chris Lattner
7a51f3a520 Simplify this a bit, add an assertion
llvm-svn: 33936
2007-02-05 23:24:48 +00:00
Chris Lattner
4ec6868104 Const method must use const_iterator.
llvm-svn: 33933
2007-02-05 23:18:32 +00:00
Zhou Sheng
4967eb71b1 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.

llvm-svn: 33913
2007-02-05 17:29:16 +00:00
Chris Lattner
41ec7b272f add a version of insert that takes the key and value.
llvm-svn: 33856
2007-02-04 00:42:41 +00:00
Chris Lattner
1113f4c8ee Make SmallSetVector useful
llvm-svn: 33854
2007-02-04 00:30:40 +00:00
Chris Lattner
9758cc5fd2 Various bugfixes
llvm-svn: 33848
2007-02-04 00:12:12 +00:00
Chris Lattner
cfdda5e521 Convert SetVector to be a true adapter class and add SmallSetVector.
llvm-svn: 33846
2007-02-03 23:56:03 +00:00
Chris Lattner
71f7b41b05 8 buckets is way too small to start out with. This was only for testing.
llvm-svn: 33835
2007-02-03 19:30:48 +00:00
Chris Lattner
d4bf1bd958 remove a dead header
llvm-svn: 33820
2007-02-03 03:02:10 +00:00
Chris Lattner
c5f2684ba7 silence annoying warning in release-asserts build
llvm-svn: 33797
2007-02-02 21:19:18 +00:00
Chris Lattner
10292e5997 add find/erase, add const iterators, fix bugs in iterators.
llvm-svn: 33791
2007-02-02 20:34:32 +00:00
Chris Lattner
d0c5814b38 add iterators
llvm-svn: 33790
2007-02-02 19:27:13 +00:00
Chris Lattner
fe31060a23 Add a new dense hash table implementation
llvm-svn: 33751
2007-02-01 07:49:59 +00:00
Chris Lattner
a24a3aaa94 rename DenseMap to IndexedMap.
llvm-svn: 33749
2007-02-01 05:32:05 +00:00
Chris Lattner
e61728144b rename DenseMap -> IndexedMap.
llvm-svn: 33748
2007-02-01 05:28:10 +00:00
Chris Lattner
d9c5442b61 add missing ctor
llvm-svn: 33714
2007-01-31 20:08:34 +00:00
Chris Lattner
302032e482 provide a definition for uintptr_t
llvm-svn: 33592
2007-01-27 23:52:33 +00:00
Chris Lattner
38f873d682 Make SmallSet<whatever*, N> faster by transparently implementing it with
SmallPtrSet.  Some clients will need to use SmallPtrSet directly though if
they need to iterate over the set.

llvm-svn: 33584
2007-01-27 08:20:15 +00:00
Chris Lattner
4307892029 add some missing API
llvm-svn: 33583
2007-01-27 08:19:03 +00:00
Chris Lattner
8360d61860 Give SmallSet a reasonable fallback if it gets large: use an std::set.
llvm-svn: 33582
2007-01-27 08:14:53 +00:00
Chris Lattner
2ca5edd29e implement SmallPtrSet::erase
llvm-svn: 33581
2007-01-27 07:59:10 +00:00
Chris Lattner
cc42c6a00d Fix a limitation of SmallPtrSet. Before it would assert if the smallsize
was not a power of two.  Now it rounds up to the next power of two internally.

llvm-svn: 33580
2007-01-27 07:52:27 +00:00
Chris Lattner
6e11e4fb50 add some comments on the algorithm
llvm-svn: 33579
2007-01-27 07:24:51 +00:00
Chris Lattner
22513a4828 Add a new SmallSet ADT specialized for pointers.
llvm-svn: 33577
2007-01-27 07:10:46 +00:00
Chris Lattner
a0210a8d2b simplify insert interface
llvm-svn: 33567
2007-01-27 02:13:58 +00:00
Chris Lattner
8e8ec41bea clean up comment
llvm-svn: 33566
2007-01-27 01:14:20 +00:00
Chris Lattner
c7e278045f fit in 80 cols
llvm-svn: 33553
2007-01-26 21:48:40 +00:00
Chris Lattner
14958b0a08 fix typo
llvm-svn: 33459
2007-01-23 04:59:58 +00:00
Chris Lattner
213c43eaed make the SmallSet interface more std::set-like
llvm-svn: 33458
2007-01-23 01:16:19 +00:00
Chris Lattner
e24cf7736b add a trivial SmallSet class, which operates on a similar principle to
SmallVector.

llvm-svn: 33456
2007-01-23 00:59:15 +00:00
Reid Spencer
f1f0b585a8 For PR1094:
Make the SetVector::iterator be the vector's const_iterator.

llvm-svn: 33279
2007-01-17 02:22:18 +00:00
Chris Lattner
87e0f0787e eliminate constructor from Statistic class. It is now impossible to get a
static constructor for them :).   Transition complete.

llvm-svn: 32710
2006-12-19 23:17:40 +00:00
John Criswell
3b18f0e184 Added operator methods to the Statistic class; some LLVM projects depend
on these.

llvm-svn: 32701
2006-12-19 22:55:57 +00:00
Chris Lattner
c18ec8716e Refactor statistic a big and introduce a horrible-but-necessary macro
(STATISTIC), which allows us to define statistics that don't introduce
static ctors into the .o files.  I'm migrating code over to use this
incrementally.

llvm-svn: 32687
2006-12-19 21:27:47 +00:00
Bill Wendling
899c552208 Removed llvm_ostream and used std::ostream instead.
llvm-svn: 32658
2006-12-18 21:59:00 +00:00
Bill Wendling
7f6a73eb5c Added an automatic cast to "std::ostream*" etc. from OStream. We then can
rework the hacks that had us passing OStream in. We pass in std::ostream*
instead, check for null, and then dispatch to the correct print() method.

llvm-svn: 32636
2006-12-17 05:15:13 +00:00
Chris Lattner
9c52dc6c34 Change the implementation of statistic to not need destructors at all.
Instead, the stat info is printed when llvm_shutdown() is called.
These also don't need static ctors, but getting rid of them is uglier:
still investigating.  This reduces the number of static dtors in llvm from
~1400 to ~750.

llvm-svn: 32372
2006-12-08 20:00:42 +00:00
Bill Wendling
a3246c4272 Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.

llvm-svn: 32298
2006-12-07 01:30:32 +00:00
Chris Lattner
e626f6de68 merge the Statistic and StatisticBase classes, eliminating virtual methods
and eliminating #includes from the Statistic.h file.

llvm-svn: 32282
2006-12-06 18:20:44 +00:00
Chris Lattner
a531ce882e Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.

llvm-svn: 32279
2006-12-06 17:46:33 +00:00
Bill Wendling
5def3648f4 Support for llvm_ostreams.
llvm-svn: 31988
2006-11-28 23:31:42 +00:00
Chris Lattner
339c732e0b Add a helper function
llvm-svn: 31981
2006-11-28 22:32:35 +00:00
Bill Wendling
4157840bd6 Added a temporary hack to get the llvm-streams to work for future checkins.
llvm-svn: 31978
2006-11-28 22:21:29 +00:00
Jeff Cohen
e1003da1a2 Unbreak VC++ build.
llvm-svn: 31464
2006-11-05 19:31:28 +00:00
Jim Laskey
c770e68c11 Allow FoldingSet clients to pump up the initial hash size.
llvm-svn: 31377
2006-11-02 14:21:26 +00:00
Chris Lattner
5c33fa2a37 add a new form of insert.
llvm-svn: 31290
2006-10-30 05:07:51 +00:00
Chris Lattner
9a99a284dc Add SmallString a (currently) minimal class that adapts SmallVector to be
more string-like.

llvm-svn: 31289
2006-10-30 03:39:20 +00:00
Chris Lattner
593e2361b4 add a method
llvm-svn: 31288
2006-10-30 03:14:15 +00:00
Chris Lattner
08b405916c add newline at end of file
llvm-svn: 31287
2006-10-29 23:47:01 +00:00
Chris Lattner
1db6efc297 add a highly efficient hash table that is specialized for mapping C strings
to some other type.

llvm-svn: 31286
2006-10-29 23:42:03 +00:00
Jim Laskey
e65b6c3c60 Clean up
llvm-svn: 31238
2006-10-27 22:52:02 +00:00
Jim Laskey
3d1116e32c Apply editorials.
llvm-svn: 31218
2006-10-27 18:05:12 +00:00
Jim Laskey
69b57830c2 Breakout folding hash set from SelectionDAGCSEMap.
llvm-svn: 31215
2006-10-27 16:16:16 +00:00
Andrew Lenharth
6223a6ce63 Fix build error in gcc 3.4 and make more this general
llvm-svn: 30839
2006-10-09 19:05:44 +00:00
Chris Lattner
e3f0524253 Fix PR897
llvm-svn: 30820
2006-10-08 22:28:34 +00:00
Chris Lattner
7453a7d197 add a simple reserve method.
llvm-svn: 30011
2006-09-01 06:08:16 +00:00
Chris Lattner
e84b1b8352 Instantiate Statistic<> in one place, not in every .o file that uses it.
llvm-svn: 29971
2006-08-30 04:17:00 +00:00
Chris Lattner
4fa85705f6 Add 2nd form of resize
llvm-svn: 29945
2006-08-28 21:52:08 +00:00
Chris Lattner
a6735ae8d1 add resize, move swap out of line
llvm-svn: 29823
2006-08-22 17:28:57 +00:00
Chris Lattner
19d59ce917 add a bunch more operations, including swap, insert, erase, front(), and
bugfixes for operator=.

llvm-svn: 29811
2006-08-22 06:27:16 +00:00
Chris Lattner
402986c13f silence a warning.
llvm-svn: 29734
2006-08-16 22:09:24 +00:00
Chris Lattner
2cd25d1642 Bugfixes for smallvector when the element size is small and N is small.
llvm-svn: 29720
2006-08-16 01:23:31 +00:00
Chris Lattner
67305e3cf6 avoid a warning
llvm-svn: 29674
2006-08-14 21:47:50 +00:00
Chris Lattner
870808beda move code out of line so that GCC doesn't inline it at -O3
llvm-svn: 29636
2006-08-11 23:40:23 +00:00
Chris Lattner
6c9bcb32a3 Split SmallVector into SmallVector and SmallVectorImpl, which allows us to
eliminate code duplication due to the 'N' parameter.

llvm-svn: 29634
2006-08-11 23:19:51 +00:00
Chris Lattner
5f8473bc02 capacity is a pointer, not a value
llvm-svn: 29564
2006-08-08 01:54:17 +00:00
Chris Lattner
03c7b425a2 add a new assign method
llvm-svn: 29562
2006-08-08 01:44:16 +00:00
Chris Lattner
3bb43d2173 Add ctor that initializes from a range.
llvm-svn: 29560
2006-08-08 00:37:50 +00:00
Chris Lattner
3e1a9b0188 Remove assertions from the SmallVector class. They slow down clients of
smallvector too much in a release build.  Removing them speeds up isel 4%.

llvm-svn: 29556
2006-08-07 23:41:59 +00:00
Chris Lattner
a4af471488 Add a clear method to SmallVector
llvm-svn: 29542
2006-08-07 05:45:34 +00:00
Chris Lattner
3bf9d47cf1 Silence a warning on x86-64, reported by chandlerc.
llvm-svn: 29535
2006-08-06 18:12:50 +00:00
Evan Cheng
627a71290f This causes some random crashes.
llvm-svn: 29534
2006-08-05 17:31:00 +00:00
Chris Lattner
b0bf058d33 The smallvector dtor should destroy the elements.
Implement pop_back.
Chage some code to use 'iterator' instead of T*.  This unbreaks operators=.

llvm-svn: 29380
2006-07-28 05:03:42 +00:00
Chris Lattner
f2d0e0296a Use std::copy instead of custom loops to take advantage of STL optimizations.
Add a new append method for appending a range.

llvm-svn: 29323
2006-07-27 03:38:08 +00:00
Chris Lattner
d4d69f64dd Add a new llvm::SmallVector template, which is similar to the vector class, but
contains optimizations to avoid heap allocation if the vector size is smaller
than some threshold.  This can significantly improve the performance of code
that allocates many small vectors by eliminating tons of small malloc/free's.

llvm-svn: 29281
2006-07-26 06:22:30 +00:00