1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

457 Commits

Author SHA1 Message Date
Owen Anderson
cb8d1f6815 Fix a bug in the set(I,E)/reset(I,E) methods that I recently added. The boundary condition for checking if I and E were in the same word were incorrect, and, beyond that, the mask computation was not using a wide enough constant.
llvm-svn: 166015
2012-10-16 06:04:27 +00:00
Owen Anderson
e678a60cc8 Add range-based set()/reset() to BitVector. These allow fast setting/resetting of ranges of bits, particularly useful when dealing with very large BitVector's.
llvm-svn: 165984
2012-10-15 22:05:27 +00:00
Benjamin Kramer
e80e7ac945 Update CMake build.
llvm-svn: 165908
2012-10-14 16:06:09 +00:00
Benjamin Kramer
25522ac16c Fix a typo that made ImmutableMap::getMaxElement() useless.
Add a basic unit test for ImmutableMap. Found by inspection.

llvm-svn: 165907
2012-10-14 15:56:39 +00:00
Duncan Sands
fe6c41af6b Add powerpc-ibm-aix to Triple. Patch by Kai.
llvm-svn: 165792
2012-10-12 11:08:57 +00:00
Nick Kledzik
df402d7821 Use unsigned long long instead of uin64_t for OS where that matters.
llvm-svn: 165147
2012-10-03 19:27:25 +00:00
Benjamin Kramer
c4738f8eac Don't call getAsUnsignedInteger directly, it fails to compile if uint64_t is not "unsigned long long".
while there add more test cases.

llvm-svn: 165140
2012-10-03 18:54:36 +00:00
Nick Kledzik
9057d55506 Add getAsUnsignedInteger test case that checks that known bad values are rejected
llvm-svn: 165136
2012-10-03 18:15:27 +00:00
Benjamin Kramer
6b5f441814 APFloat::roundToIntegral: Special values don't keep the exponent value up to date, don't rely on it.
Add a couple of unit tests for special floats. Fixes 13929, found by MemorySanitizer.

llvm-svn: 164698
2012-09-26 14:06:58 +00:00
Craig Topper
845fbb6919 Fix includes of llvm files that used angle brackets.
llvm-svn: 163979
2012-09-15 18:45:38 +00:00
NAKAMURA Takumi
6ed297bdc3 ADTTests: [CMake] Exclude DenseMapTest.cpp and SmallVectorTest.cpp on MSVC9 due to its bug.
llvm-svn: 162918
2012-08-30 16:22:32 +00:00
Owen Anderson
903f25db0a Fix another roundToIntegral bug where very large values could become infinity. Problem and solution identified by Steve Canon.
llvm-svn: 161969
2012-08-15 18:28:45 +00:00
Owen Anderson
3b09e94409 Fix a problem with APFloat::roundToIntegral where it would return incorrect results for negative inputs to trunc. Add unit tests to verify this behavior.
llvm-svn: 161929
2012-08-15 05:39:46 +00:00
Chandler Carruth
892c043c64 Add range erase, element insert, and range insert methods to
TinyPtrVector. With these, it is sufficiently functional for my more
normal / pedestrian uses.

I've not included some r-value reference stuff here because the value
type for a TinyPtrVector is, necessarily, just a pointer.

I've added tests that cover the basic behavior of these routines, but
they aren't as comprehensive as I'd like. In particular, they don't
really test the iterator semantics as thoroughly as they should. Maybe
some brave soul will feel enterprising and flesh them out. ;]

llvm-svn: 161104
2012-08-01 08:40:48 +00:00
Chandler Carruth
7a45c5707e Implement copy and move assignment for TinyPtrVector. These try to
re-use allocated vectors as much as possible.

llvm-svn: 161041
2012-07-31 09:42:24 +00:00
Chandler Carruth
58525185d2 Bring TinyPtrVector under test. Somehow we never picked up unit tests
for this class. These tests exercise most of the basic properties, but
the API for TinyPtrVector is very strange currently. My plan is to start
fleshing out the API to match that of SmallVector, but I wanted a test
for what is there first.

Sadly, it doesn't look reasonable to just re-use the SmallVector tests,
as this container can only ever store pointers, and much of the
SmallVector testing is to get construction and destruction right.

Just to get this basic test working, I had to add value_type to the
interface.

While here I found a subtle bug in the combination of 'erase', 'begin',
and 'end'. Both 'begin' and 'end' wanted to use a null pointer to
indicate the "end" iterator of an empty vector, regardless of whether
there is actually a vector allocated or the pointer union is null.
Everything else was fine with this except for erase. If you erase the
last element of a vector after it has held more than one element, we
return the end iterator of the underlying SmallVector which need not be
a null pointer. Instead, simply use the pointer, and poniter + size()
begin/end definitions in the tiny case, and delegate to the inner vector
whenever it is present.

llvm-svn: 161024
2012-07-31 02:48:31 +00:00
Chandler Carruth
a15888ba2d Move the SmallVector unit tests to be type-parameterized so that we can
test more than a single instantiation of SmallVector.

Add testing for 0, 1, 2, and 4 element sized "small" buffers. These
appear to be essentially untested in the unit tests until now.

Fix several tests to be robust in the face of a '0' small buffer. As
a consequence of this size buffer, the growth patterns are actually
observable in the test -- yes this means that many tests never caused
a grow to occur before. For some tests I've merely added a reserve call
to normalize behavior. For others, the growth is actually interesting,
and so I captured the fact that growth would occur and adjusted the
assertions to not assume how rapidly growth occured.

Also update the specialization for a '0' small buffer length to have all
the same interface points as the normal small vector.

llvm-svn: 161001
2012-07-30 22:17:52 +00:00
Chandler Carruth
f372f64b71 Completely refactor the structuring of unittest CMake files to match the
Makefiles, the CMake files in every other part of the LLVM tree, and
sanity.

This should also restore the output tree structure of all the unit
tests, sorry for breaking that, and thanks for letting me know.

The fundamental change is to put a CMakeLists.txt file in the unittest
directory, with a single test binary produced from it. This has several
advantages:

- No more weird directory stripping in the unittest macro, allowing it
  to be used more readily in other projects.
- No more directory prefixes on all the source files.
- Allows correct and precise use of LLVM's per-directory dependency
  system.
- Allows use of the checking logic for source files that have not been
  added to the CMake build. This uncovered a file being skipped with
  CMake in LLVM and one in Clang's unit tests.
- Makes Specifying conditional compilation or other custom logic for JIT
  tests easier.

It did require adding the concept of an explicit 'optional' source file
to the CMake build so that the missing-file check can skip cases where
the file is *supposed* to be missing. =]

This is another chunk of refactoring the CMake build in order to make it
usable for other clients like CompilerRT / ASan / TSan.

Note that this is interdependent with a Clang CMake change.

llvm-svn: 158909
2012-06-21 09:51:26 +00:00
Chandler Carruth
0cdc2e28c6 Fix PR13148, an inf-loop in StringMap.
StringMap suffered from the same bug as DenseMap: when you explicitly
construct it with a small number of buckets, you can arrange for the
tombstone-based growth path to be followed when the number of buckets
was less than '8'. In that case, even with a full map, it would compare
'0' as not less than '0', and refuse to grow the table, leading to
inf-loops trying to find an empty bucket on the next insertion. The fix
is very simple: use '<=' as the comparison. The same fix was applied to
DenseMap as well during its recent refactoring.

Thanks to Alex Bolz for the great report and test case. =]

llvm-svn: 158725
2012-06-19 17:40:35 +00:00
Chandler Carruth
7da26940bd Remove some superfluous SCOPED_TRACEs from this unit test.
GoogleTest already prints errors with all the information about which
test case contained the error.

llvm-svn: 158724
2012-06-19 17:40:29 +00:00
Benjamin Kramer
35708de228 Remove SmallMap unittests, unbreaking the build.
I don't know how useful these are for SmallDenseMap, I'll leave that decision to Chandler.

llvm-svn: 158646
2012-06-17 12:46:18 +00:00
Benjamin Kramer
d408a3b134 Bring the return value of SmallVector::insert in line with std::vector::insert.
It always returns the iterator for the first inserted element, or the passed in
iterator if the inserted range was empty. Flesh out the unit test more and fix
all the cases it uncovered so far.

llvm-svn: 158645
2012-06-17 12:46:13 +00:00
Benjamin Kramer
f78d0a14b0 SmallVector: return a valid iterator for the rare case of inserting an empty range into a SmallVector.
Patch by Johannes Schaub!

llvm-svn: 158643
2012-06-17 11:52:22 +00:00
Chandler Carruth
5b13784777 Add a unit test for 'swap', and fix a pile of bugs in
SmallDenseMap::swap.

First, make it parse cleanly. Yay for uninstantiated methods.

Second, make the inline-buckets case work correctly. This is way
trickier than it should be due to the uninitialized values in empty and
tombstone buckets.

Finally fix a few typos that caused construction/destruction mismatches
in the counting unittest.

llvm-svn: 158641
2012-06-17 11:28:13 +00:00
Chandler Carruth
ea5804adca Add tests for *DenesMap for both key and value types' construction and
destruction and fix a bug in SmallDenseMap they caught.

This is kind of a poor-man's version of the testing that just adds the
addresses to a set on construction and removes them on destruction. We
check that double construction and double destruction don't occur.
Amusingly enough, this is enough to catch a lot of SmallDenseMap issues
because we spend a lot of time with fixed stable addresses in the inline
buffer.

The SmallDenseMap bug fix included makes grow() not double-destroy in
some cases. It also fixes a FIXME there, the code was pretty crappy. We
now don't have any wasted initialization, but we do move the entries in
inline bucket array an extra time. It's probably a better tradeoff, and
is much easier to get correct.

llvm-svn: 158639
2012-06-17 10:33:51 +00:00
Chandler Carruth
1501b6be37 Introduce a SmallDenseMap container that re-uses the existing DenseMap
implementation.

This type includes an inline bucket array which is used initially. Once
it is exceeded, an array of 64 buckets is allocated on the heap. The
bucket count grows from there as needed. Some highlights of this
implementation:

- The inline buffer is very carefully aligned, and so supports types
  with alignment constraints.
- It works hard to avoid aliasing issues.
- Supports types with non-trivial constructors, destructors, copy
  constructions, etc. It works reasonably hard to minimize copies and
  unnecessary initialization. The most common initialization is to set
  keys to the empty key, and so that should be fast if at all possible.

This class has a performance / space trade-off. It tries to optimize for
relatively small maps, and so packs the inline bucket array densely into
the object. It will be marginally slower than a normal DenseMap in a few
use patterns, so it isn't appropriate everywhere.

The unit tests for DenseMap have been generalized a bit to support
running over different map implementations in addition to different
key/value types. They've then been automatically extended to cover the
new container through the magic of GoogleTest's typed tests.

All of this is still a bit rough though. I'm going to be cleaning up
some aspects of the implementation, documenting things better, and
adding tests which include non-trivial types. As soon as I'm comfortable
with the correctness, I plan to switch existing users of SmallMap over
to this class as it is already more correct w.r.t. construction and
destruction of objects iin the map.

Thanks to Benjamin Kramer for all the reviews of this and the lead-up
patches. That said, more review on this would really be appreciated. As
I've noted a few times, I'm quite surprised how hard it is to get the
semantics for a hashtable-based map container with a small buffer
optimization correct. =]

llvm-svn: 158638
2012-06-17 09:05:09 +00:00
Benjamin Kramer
ed052699c6 Merge the SmallBitVector and BitVector unit tests with gtest's typed test magic and bring SmallBitVector up to date.
llvm-svn: 158600
2012-06-16 10:51:07 +00:00
Chandler Carruth
6516b04810 Work around a bug with MSVC 10 where it fails to recognize a valid use
of typename. GCC and Clang were fine with this, but MSVC won't accept
it. Fortunately, it also doesn't need it. Yuck.

Thanks to Nakamura for pointing this out in IRC.

llvm-svn: 158593
2012-06-16 03:54:11 +00:00
Chandler Carruth
03bff6651c Type parameterize the DenseMap unit tests.
These were already trying to be type parameterized over different
key/value pairs. I've realized this goal using GoogleTest's typed test
functionality. This allows us to easily replicate the tests across
different key/value combinations and soon different mapping templates.

I've fixed a few bugs in the tests and extended them a bit in the
process as many tests were only applying to the int->int mapping.

llvm-svn: 158589
2012-06-16 01:31:33 +00:00
Benjamin Kramer
bb30e1face Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157885
2012-06-02 10:20:22 +00:00
Justin Holewinski
ee3de35dee Remove the PTX back-end and all of its artifacts (triple, etc.)
This back-end was deprecated in favor of the NVPTX back-end.

NV_CONTRIB

llvm-svn: 157417
2012-05-24 21:38:21 +00:00
Nuno Lopes
328f9efec2 fix the quotient returned by sdivrem() for the case when LHS is negative and RHS is positive
based on a patch by Preston Briggs, with some modifications

llvm-svn: 157231
2012-05-22 01:09:48 +00:00
Bill Wendling
18c55548e9 Remove warning about testing unsigned int with int.
llvm-svn: 156812
2012-05-15 09:59:13 +00:00
Stepan Dyatkovskiy
6d83dd3cf8 Fixed one small stupid, but critical bug.
llvm-svn: 156810
2012-05-15 09:21:39 +00:00
Jakob Stoklund Olesen
184e921187 Remove the expensive BitVector::operator~().
Returning a temporary BitVector is very expensive. If you must, create
the temporary explicitly: Use BitVector(A).flip() instead of ~A.

llvm-svn: 156768
2012-05-14 15:46:27 +00:00
Jakob Stoklund Olesen
8783cdf045 Add BitVector::anyCommon().
The existing operation (A & B).any() is very slow.

llvm-svn: 156760
2012-05-14 15:01:19 +00:00
Michael J. Spencer
6161587c9f [Support/StringRef] Add find_last_not_of and {r,l,}trim.
llvm-svn: 156652
2012-05-11 22:08:50 +00:00
Chad Rosier
ccf58fa5fd Add unittests for Triple::getMacOSXVersion and Triple::getiOSVersion.
llvm-svn: 156507
2012-05-09 19:31:41 +00:00
Benjamin Kramer
74da5acd41 SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types.
llvm-svn: 155791
2012-04-29 10:53:29 +00:00
Stepan Dyatkovskiy
4c3c675cca Fixed SmallMap test. The order of items is undefined in DenseMap. So being checking the increment for big mode, we can only check that all items are in map.
llvm-svn: 155651
2012-04-26 18:45:24 +00:00
Benjamin Kramer
36acdd4832 Reapply the SmallMap patch with a fix.
Comparing ~0UL with an unsigned will always return false when long is 64 bits long.

llvm-svn: 155568
2012-04-25 18:01:58 +00:00
Eric Christopher
d38d9bb28b Revert "First implementation of:"
This reverts commit 76271a3366731d4c372fdebcd8d3437e6e09a61b.

as it's breaking the bots.

llvm-svn: 155562
2012-04-25 17:51:00 +00:00
Stepan Dyatkovskiy
a580659b6c First implementation of:
- FlatArrayMap. Very simple map container that uses flat array inside.
- MultiImplMap. Map container interface, that has two modes, one for small amount of elements and one for big amount.
- SmallMap. SmallMap is DenseMap compatible MultiImplMap. It uses FlatArrayMap for small mode, and DenseMap for big mode. 

Also added unittests for new classes and update for ProgrammersManual.
For more details about new classes see ProgrammersManual and comments in sourcecode.

llvm-svn: 155557
2012-04-25 17:09:38 +00:00
Andrew Trick
56264ae675 SparseSet: Add support for key-derived indexes and arbitrary key types.
This nicely handles the most common case of virtual register sets, but
also handles anticipated cases where we will map pointers to IDs.

The goal is not to develop a completely generic SparseSet
template. Instead we want to handle the expected uses within llvm
without any template antics in the client code. I'm adding a bit of
template nastiness here, and some assumption about expected usage in
order to make the client code very clean.

The expected common uses cases I'm designing for:
- integer keys that need to be reindexed, and may map to additional
  data
- densely numbered objects where we want pointer keys because no
  number->object map exists.

llvm-svn: 155227
2012-04-20 20:05:28 +00:00
Hal Finkel
d6e526ae11 Add triple support for the IBM BG/P and BG/Q supercomputers.
llvm-svn: 153882
2012-04-02 18:31:33 +00:00
Michael J. Spencer
a979afa64b Fix warnings.
llvm-svn: 152522
2012-03-11 00:51:01 +00:00
Michael J. Spencer
69772efcb2 Make StringRef::getAsInteger work with all integer types. Before this change
it would fail with {,u}int64_t on x86-64 Linux.

This also removes code duplication.

llvm-svn: 152517
2012-03-10 23:02:54 +00:00
Chandler Carruth
25594f9e13 Add support to the hashing infrastructure for automatically hashing both
integral and enumeration types. This is accomplished with a bit of
template type trait magic. Thanks to Richard Smith for the core idea
here to detect viable types by detecting the set of types which can be
default constructed in a template parameter.

This is used (in conjunction with a system for detecting nullptr_t
should it exist) to provide an is_integral_or_enum type trait that
doesn't need a whitelist or direct compiler support.

With this, the hashing is extended to the more general facility. This
will be used in a subsequent commit to hashing more things, but I wanted
to make sure the type trait magic went through the build bots separately
in case other compilers don't like this formulation.

llvm-svn: 152217
2012-03-07 09:32:32 +00:00
Benjamin Kramer
0637e87d74 SmallPtrSet: Provide a more efficient implementation of swap than the default triple-copy std::swap.
This currently assumes that both sets have the same SmallSize to keep the implementation simple,
a limitation that can be lifted if someone cares.

llvm-svn: 152143
2012-03-06 20:40:02 +00:00
Chandler Carruth
b4a6f80d2e Add generic support for hashing StringRef objects using the new hashing library.
llvm-svn: 152003
2012-03-04 10:55:27 +00:00
Chandler Carruth
9b15a1b01a Teach the hashing facilities how to hash std::string objects.
llvm-svn: 152000
2012-03-04 10:23:15 +00:00
Chandler Carruth
c4402e5be6 Split this test up into two smaller, and more focused tests.
llvm-svn: 151999
2012-03-04 10:23:11 +00:00
Francois Pichet
62ed4767ac Move the NonPOD struct out of the anonymous namespace instead of adding llvm:: everywhere to fix the HashingTest on MSVC .
chandlerc proposed this better solution on IRC.

llvm-svn: 151974
2012-03-03 09:39:54 +00:00
Francois Pichet
1dd0f1f6bc Fixes the Hashing tests on MSVC by adding llvm:: prefix to hash_value function call.
llvm-svn: 151971
2012-03-03 07:56:49 +00:00
NAKAMURA Takumi
97b9ef724d unittests/ADT/HashingTest.cpp: Temporarily disable a new test introduced in r151891, to appease msvc.
llvm-svn: 151970
2012-03-03 07:00:58 +00:00
Chandler Carruth
37925e436c Simplify the pair optimization. Rather than using complex type traits,
just ensure that the number of bytes in the pair is the sum of the bytes
in each side of the pair. As long as thats true, there are no extra
bytes that might be padding.

Also add a few tests that previously would have slipped through the
checking. The more accurate checking mechanism catches these and ensures
they are handled conservatively correctly.

Thanks to Duncan for prodding me to do this right and more simply.

llvm-svn: 151891
2012-03-02 10:56:40 +00:00
Chandler Carruth
3d56aa3bb6 Add a golden data test that I missed somehow the first time around.
llvm-svn: 151886
2012-03-02 10:01:29 +00:00
Chandler Carruth
d4bc57656d Fix bad indenting that was left over from cut/paste of the golden values
for 32-bit builds in here.

llvm-svn: 151885
2012-03-02 10:01:27 +00:00
Chandler Carruth
8ef1184049 We really want to hash pairs of directly-hashable data as directly
hashable data. This matters when we have pair<T*, U*> as a key, which is
quite common in DenseMap, etc. To that end, we need to detect when this
is safe. The requirements on a generic std::pair<T, U> are:

1) Both T and U must satisfy the existing is_hashable_data trait. Note
   that this includes the requirement that T and U have no internal
   padding bits or other bits not contributing directly to equality.
2) The alignment constraints of std::pair<T, U> do not require padding
   between consecutive objects.
3) The alignment constraints of U and the size of T do not conspire to
   require padding between the first and second elements.

Grow two somewhat magical traits to detect this by forming a pod
structure and inspecting offset artifacts on it. Hopefully this won't
cause any compilers to panic.

Added and adjusted tests now that pairs, even nested pairs, are treated
as just sequences of data.

Thanks to Jeffrey Yasskin for helping me sort through this and reviewing
the somewhat subtle traits.

llvm-svn: 151883
2012-03-02 09:26:36 +00:00
Chandler Carruth
09d76cf26d Add support for hashing pairs by delegating to each sub-object. There is
an open question of whether we can do better than this by treating pairs
as boring data containers and directly hashing the two subobjects. This
at least makes the API reasonable.

In order to make this change, I reorganized the header a bit. I lifted
the declarations of the hash_value functions up to the top of the header
with their doxygen comments as these are intended for users to interact
with. They shouldn't have to wade through implementation details. I then
defined them at the very end so that they could be defined in terms of
hash_combine or any other hashing infrastructure.

Added various pair-hashing unittests.

llvm-svn: 151882
2012-03-02 08:32:29 +00:00
Chandler Carruth
e07f473768 Remove the misguided extension here that reserved two special values in
the hash_code. I'm not sure what I was thinking here, the use cases for
special values are in the *keys*, not in the hashes of those keys.

We can always resurrect this if needed, or clients can accomplish the
same goal themselves. This makes the general case somewhat faster (~5
cycles faster on my machine) and smaller with less branching.

llvm-svn: 151865
2012-03-02 00:48:38 +00:00
Chandler Carruth
0516597fc7 Re-disable the debug output. The comment is there explaining why we want
to keep this around -- updating golden tests is annoying otherwise.

Thanks to Benjamin for pointing this omission out on IRC.

llvm-svn: 151860
2012-03-01 23:20:45 +00:00
Chandler Carruth
3b6ab8a33e Provide the 32-bit variant of the golden tests. Not sure how I forgot to
do this initially, sorry.

llvm-svn: 151857
2012-03-01 23:06:19 +00:00
Chandler Carruth
cc9b4516cb Rewrite LLVM's generalized support library for hashing to follow the API
of the proposed standard hashing interfaces (N3333), and to use
a modified and tuned version of the CityHash algorithm.

Some of the highlights of this change:
 -- Significantly higher quality hashing algorithm with very well
    distributed results, and extremely few collisions. Should be close to
    a checksum for up to 64-bit keys. Very little clustering or clumping of
    hash codes, to better distribute load on probed hash tables.
 -- Built-in support for reserved values.
 -- Simplified API that composes cleanly with other C++ idioms and APIs.
 -- Better scaling performance as keys grow. This is the fastest
    algorithm I've found and measured for moderately sized keys (such as
    show up in some of the uniquing and folding use cases)
 -- Support for enabling per-execution seeds to prevent table ordering
    or other artifacts of hashing algorithms to impact the output of
    LLVM. The seeding would make each run different and highlight these
    problems during bootstrap.

This implementation was tested extensively using the SMHasher test
suite, and pased with flying colors, doing better than the original
CityHash algorithm even.

I've included a unittest, although it is somewhat minimal at the moment.
I've also added (or refactored into the proper location) type traits
necessary to implement this, and converted users of GeneralHash over.

My only immediate concerns with this implementation is the performance
of hashing small keys. I've already started working to improve this, and
will continue to do so. Currently, the only algorithms faster produce
lower quality results, but it is likely there is a better compromise
than the current one.

Many thanks to Jeffrey Yasskin who did most of the work on the N3333
paper, pair-programmed some of this code, and reviewed much of it. Many
thanks also go to Geoff Pike Pike and Jyrki Alakuijala, the original
authors of CityHash on which this is heavily based, and Austin Appleby
who created MurmurHash and the SMHasher test suite.

Also thanks to Nadav, Tobias, Howard, Jay, Nick, Ahmed, and Duncan for
all of the review comments! If there are further comments or concerns,
please let me know and I'll jump on 'em.

llvm-svn: 151822
2012-03-01 18:55:25 +00:00
Jakob Stoklund Olesen
0d60aa4b33 Fix typos.
llvm-svn: 151163
2012-02-22 16:01:54 +00:00
Chandler Carruth
c5b687b241 Support was removed from LLVM's MIPS backend for the PSP variant of that
chip in r139383, and the PSP components of the triple are really
annoying to parse. Let's leave this chapter behind. There is no reason
to expect LLVM to see a PSP-related triple these days, and so no
reasonable motivation to support them.

It might be reasonable to prune a few of the older MIPS triple forms in
general, but as those at least cause no burden on parsing (they aren't
both a chip and an OS!), I'm happy to leave them in for now.

llvm-svn: 151156
2012-02-22 11:32:54 +00:00
Jakob Stoklund Olesen
3b18c7d900 Add a Briggs and Torczon sparse set implementation.
For objects that can be identified by small unsigned keys, SparseSet
provides constant time clear() and fast deterministic iteration. Insert,
erase, and find operations are typically faster than hash tables.

SparseSet is useful for keeping information about physical registers,
virtual registers, or numbered basic blocks.

llvm-svn: 151110
2012-02-22 00:56:08 +00:00
Chandler Carruth
34c9c293e1 Switch the llvm::Triple class to immediately parse the triple string on
construction. Simplify its interface, implementation, and users
accordingly as there is no longer an 'uninitialized' state to check for.
Also, fixes a bug lurking in the interface as there was one method that
didn't correctly check for initialization.

llvm-svn: 151024
2012-02-21 03:39:36 +00:00
Talin
777c85d862 Hashing.h - utilities for hashing various data types.
llvm-svn: 150890
2012-02-18 21:00:49 +00:00
Benjamin Kramer
6d9863be3a Add a unittest for rotating a really big APInt.
Clang miscompiles it under certain circumstances, and it's a good exercise for APInt.

llvm-svn: 149986
2012-02-07 16:27:39 +00:00
Chandler Carruth
a05c6dc02c Introduce helpers to compute the 32-bit varaints and 64-bit variants of
some architectures. These are useful for interacting with multiarch or
bi-arch GCC (or GCC-based) toolchains.

llvm-svn: 149895
2012-02-06 20:46:33 +00:00
Manuel Klimek
bd5c3cbb68 RefCountedBaseVPTR needs the IntrusiveRefCntPtrInfo as friend,
now that this handles the release / retain calls.

Adds a regression test for that bug (which is a compile-time
regression) and for the last two changes to the IntrusiveRefCntPtr,
especially tests for the memory leak due to copy construction of the
ref-counted object and ensuring that the traits are used for release /
retain calls.

llvm-svn: 149411
2012-01-31 19:58:34 +00:00
Chandler Carruth
a71c1f9470 Add various coarse bit-width architecture predicates to llvm::Triple.
These are very useful for frontends and other utilities reasoning about
or selecting between triples.

llvm-svn: 149353
2012-01-31 04:52:32 +00:00
Talin
d6b8c10155 DenseMap::find_as() and unit tests.
llvm-svn: 149229
2012-01-30 06:55:43 +00:00
Talin
12820f024e Additional methods for SmallString.
llvm-svn: 148881
2012-01-24 23:43:59 +00:00
Jakob Stoklund Olesen
4004b18f94 Add portable bit mask operations to BitVector.
BitVector uses the native word size for its internal representation.
That doesn't work well for literal bit masks in source code.

This patch adds BitVector operations to efficiently apply literal bit
masks specified as arrays of uint32_t.  Since each array entry always
holds exactly 32 bits, these portable bit masks can be source code
literals, probably produced by TableGen.

llvm-svn: 148272
2012-01-17 01:24:32 +00:00
Eli Friedman
41be35819d Some unittests for APInt rotates; patch by Cameron McInally.
llvm-svn: 147186
2011-12-22 22:11:19 +00:00
Chandler Carruth
c8e6351626 As Doug pointed out (and I really should know), it is perfectly easy to
make VariadicFunction actually be trivial. Do so, and also make it look
more like your standard trivial functor by making it a struct with no
access specifiers. The unit test is updated to initialize its functors
properly.

llvm-svn: 146827
2011-12-17 10:20:15 +00:00
Dylan Noblesmith
91b9af8f44 APInt: update asserts for base-36
Hexatridecimal was added in r139695.

And fix the unittest that now triggers the assert.

llvm-svn: 146754
2011-12-16 20:36:31 +00:00
Chandler Carruth
9ad7094a8c Put the '*' in the right place in the unit test. Forgot to fix up this
bit of style, sorry.

llvm-svn: 146733
2011-12-16 09:37:55 +00:00
Chandler Carruth
1cf4d2d1ae Add a generic collection of class templates to ADT for building
variadic-like functions in C++98. See the comments in the header file
for a more detailed description of how these work. We plan to use these
extensively in the AST matching library. This code and idea were
originally authored by Zhanyong Wan. I've condensed it using macros
to reduce repeatition and adjusted it to fit better with LLVM's ADT.

Thanks to both David Blaikie and Doug Gregor for the review!

llvm-svn: 146729
2011-12-16 08:58:59 +00:00
Eli Friedman
448be745f6 Fix APFloat::convert so that it handles narrowing conversions correctly; it
was returning incorrect values in rare cases, and incorrectly marking
exact conversions as inexact in some more common cases. Fixes PR11406, and a
missed optimization in test/CodeGen/X86/fp-stack-O0.ll.

llvm-svn: 145141
2011-11-26 03:38:02 +00:00
Benjamin Kramer
0c20486517 Add a bad char heuristic to StringRef::find.
Based on Horspool's simplified version of Boyer-Moore. We use a constant-sized table of
uint8_ts to keep cache thrashing low, needles bigger than 255 bytes are uncommon anyways.

The worst case is still O(n*m) but we do a lot better on the average case now.

llvm-svn: 142061
2011-10-15 10:08:31 +00:00
Eli Friedman
b70efeb6fc Attempt to fix MSVC build.
llvm-svn: 141831
2011-10-12 23:14:41 +00:00
Eli Friedman
cda27f4c18 Fix APFloat::getLargest so that it actually returns the correct value. Found by accident while reviewing a patch to nearby code.
llvm-svn: 141816
2011-10-12 21:51:36 +00:00
Eli Friedman
433785c651 Fix APInt::operator*= so that it computes the correct result for large integers where there is unsigned overflow. Fix APFloat::toString so that it doesn't depend on the incorrect behavior in common cases (and computes the correct result in some rare cases). Fixes PR11086.
llvm-svn: 141441
2011-10-07 23:40:49 +00:00
Jakob Stoklund Olesen
783b18e818 Fix a bug in compare_numeric().
Thanks to Alexandru Dura and Jonas Paulsson for finding it.

llvm-svn: 140859
2011-09-30 17:03:55 +00:00
Douglas Gregor
8c0777c5f3 Add APInt support for converting to/from hexatridecimal strings
llvm-svn: 139695
2011-09-14 15:54:46 +00:00
Matt Beaumont-Gay
f26343ced2 Fix a test that wasn't testing the right thing.
The APFloat "Zero" test was actually calling the
APFloat(const fltSemantics &, integerPart) constructor, and EXPECT_EQ was
treating 0 and -0 as equal.

llvm-svn: 138745
2011-08-29 17:54:20 +00:00
Duncan Sands
652364a5ec Avoid undefined behaviour if somehow NUM_GRAPHS equals 2^32 (or
whatever the size of unsigned is), though this can't actually
occur for any integer value of NUM_NODES.

llvm-svn: 136460
2011-07-29 07:50:02 +00:00
Jakub Staszak
ba1160825b Remove extra semicolon.
llvm-svn: 136432
2011-07-29 00:05:35 +00:00
Duncan Sands
cfca795839 Use unsigned rather than uint16_t in case anyone feels like testing
more graphs, like all graphs with 5 nodes or less.  With a 32 bit
unsigned type, the maximum is graphs with 6 nodes or less, but that
would take a while to test - 5 nodes or less already requires a few
seconds.

llvm-svn: 136354
2011-07-28 14:37:53 +00:00
Duncan Sands
bda9b8bd4b Check an additional property specific to the way LLVM
iterates over SCC's.

llvm-svn: 136353
2011-07-28 14:33:01 +00:00
Duncan Sands
f9a0cc2e7b Add a unittest for the simply connected components (SCC) iterator class.
This computes every graph with 4 or fewer nodes, and checks that the SCC
class indeed returns exactly the simply connected components reachable
from the initial node.

llvm-svn: 136351
2011-07-28 14:17:11 +00:00
Jay Foad
0312e901da Remove some code that is no longer needed now that googletest knows how
to print STL containers.

llvm-svn: 136213
2011-07-27 09:26:13 +00:00
Chris Lattner
0e3472660b Add Twine support for characters, and switch twine to use a union internally
to eliminate some casting.

llvm-svn: 135888
2011-07-24 20:44:30 +00:00
Jeffrey Yasskin
2e0f2a0985 Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity
errors like the one corrected by r135261.  Migrate all LLVM callers of the old
constructor to the new one.

llvm-svn: 135431
2011-07-18 21:45:40 +00:00
Chris Lattner
e1fe7061ce land David Blaikie's patch to de-constify Type, with a few tweaks.
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jeffrey Yasskin
4d5d3fceaa Add an APFloat::convertToInt(APSInt) function that automatically manages the
memory for the result.

llvm-svn: 135259
2011-07-15 07:04:56 +00:00
Chris Lattner
5bf752bcf4 The key of a StringMap can contain nul's in it, so having first() return
const char* doesn't make sense.  Have it return StringRef instead.

llvm-svn: 135167
2011-07-14 18:31:43 +00:00
Owen Anderson
461ad5951b Fix a subtle issue in SmallVector. The following code did not work as expected:
vec.insert(vec.begin(), vec[3]);
The issue was that vec[3] returns a reference into the vector, which is invalidated when insert() memmove's the elements down to make space.  The method needs to specifically detect and handle this case to correctly match std::vector's semantics.

Thanks to Howard Hinnant for clarifying the correct behavior, and explaining how std::vector solves this problem.

llvm-svn: 134554
2011-07-06 22:36:59 +00:00
Dylan Noblesmith
b75ad906fa unittests: add test for APInt::toString()
Follow up to r133032.

llvm-svn: 133107
2011-06-15 23:36:34 +00:00
Argyrios Kyrtzidis
eeacf97cad Try fixing http://google1.osuosl.org:8011/builders/clang-i686-freebsd/builds/3548
llvm-svn: 133081
2011-06-15 20:39:05 +00:00
Argyrios Kyrtzidis
67dd868df2 Add unit tests for ADT/PackedVector
llvm-svn: 133075
2011-06-15 19:19:09 +00:00
Lenny Maiorani
1b1a9860d1 Remove bounded StringRef::compare() since nothing but Clang SA was using it and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing.
llvm-svn: 130430
2011-04-28 20:20:12 +00:00
Lenny Maiorani
dfae65d305 Implements StringRef::compare with bounds. It is behaves similarly to strncmp(). Unit tests also included.
llvm-svn: 129582
2011-04-15 17:56:50 +00:00
Benjamin Kramer
e6e5b11a65 Avoid turning a floating point division with a constant power of two into a denormal multiplication.
Some platforms may treat denormals as zero, on other platforms multiplication
with a subnormal is slower than dividing by a normal.

llvm-svn: 128555
2011-03-30 17:02:54 +00:00
Benjamin Kramer
7888d0935d Add APFloat::getExactInverse.
The idea is, that if an ieee 754 float is divided by a power of two, we can
turn the division into a cheaper multiplication. This function sees if we can
get an exact multiplicative inverse for a divisor and returns it if possible.

This is the hard part of PR9587.

I tested many inputs against llvm-gcc's frotend implementation of this
optimization and didn't find any difference. However, floating point is the
land of weird edge cases, so any review would be appreciated.

llvm-svn: 128545
2011-03-30 15:42:27 +00:00
Benjamin Kramer
a85996c235 Add an argument to APInt's magic udiv calculation to specify the number of bits that are known zero in the divided number.
This will come in handy soon.

llvm-svn: 127828
2011-03-17 20:39:06 +00:00
Cameron Zwarich
b7e676db6c The signed version of our "magic number" computation for the integer approximation
of a constant had a minor typo introduced when copying it from the book, which
caused it to favor negative approximations over positive approximations in many
cases. Positive approximations require fewer operations beyond the multiplication.

In the case of division by 3, we still generate code that is a single instruction
larger than GCC's code.

llvm-svn: 126097
2011-02-21 00:22:02 +00:00
Duncan Sands
ac9fa024f8 Part of this test is invariant inside the inner loop - move it outside
the loop.

llvm-svn: 124784
2011-02-03 08:14:04 +00:00
Duncan Sands
cfc61f7efb Remove NoVendor and NoOS, added in commit 123990, from Triple. While it
may be useful to understand "none", this is not the place for it.  Tweak
the fix to Normalize while there: the fix added in 123990 works correctly,
but I like this way better.  Finally, now that Triple understands some
non-trivial environment values, teach the unittests about them.

llvm-svn: 124720
2011-02-02 10:08:38 +00:00
Chris Lattner
7bdd5c3eb7 Don't infinitely recurse! Patch by Marius Wachtler!
llvm-svn: 124366
2011-01-27 07:35:27 +00:00
Renato Golin
cf89d692dc Clang was not parsing target triples involving EABI and was generating wrong IR (wrong PCS) and passing the wrong information down llc via the target-triple printed in IR. I've fixed this by adding the parsing of EABI into LLVM's Triple class and using it to choose the correct PCS in Clang's Tools. A Clang patch is on its way to use this infrastructure.
llvm-svn: 123990
2011-01-21 18:25:47 +00:00
Jakob Stoklund Olesen
26b4e8ec0a Add ADT/IntEqClasses.h as a light-weight implementation of EquivalenceClasses.h.
This implementation already exists as ConnectedVNInfoEqClasses in
LiveInterval.cpp, and it seems to be generally useful to have a light-weight way
of forming equivalence classes of small integers.

IntEqClasses doesn't allow enumeration of the elements in a class.

llvm-svn: 122293
2010-12-21 00:04:46 +00:00
Jakob Stoklund Olesen
64c013d79d Add more checks to IntervalMapOverlaps::advance() to ensure that advanceTo sees
monotonic keys.

llvm-svn: 122093
2010-12-17 22:07:54 +00:00
Jakob Stoklund Olesen
f17722908c It is allowed to call IntervalMap::const_iterator::advanceTo() with a key that
moves the iterator to end(), and it is valid to call it on end().

That means it is valid to call advanceTo() with any monotonic key sequence.

llvm-svn: 122092
2010-12-17 22:07:51 +00:00
Jakob Stoklund Olesen
aec6ae67a1 Fix crash when IntervalMapOverlaps::advanceTo moves past the last overlap.
llvm-svn: 122081
2010-12-17 19:18:38 +00:00
Jakob Stoklund Olesen
c63484e962 Complete tests for IntervalMapOverlaps.
llvm-svn: 122019
2010-12-17 01:31:49 +00:00
Jakob Stoklund Olesen
9681be67c5 Add basic test exposing many bugs.
llvm-svn: 121995
2010-12-16 19:46:09 +00:00
Jakob Stoklund Olesen
4cd667151d Add IntervalMap::iterator::set{Start,Stop,Value} methods that allow limited
editing of the current interval.

These methods may cause coalescing, there are corresponding set*Unchecked
methods for editing without coalescing. The non-coalescing methods are useful
for applying monotonic transforms to all keys or values in a map without
accidentally coalescing transformed and untransformed intervals.

llvm-svn: 120829
2010-12-03 19:02:00 +00:00
Michael J. Spencer
03bbd0f21d Support/ADT/Twine: Add toNullTerminatedStringRef.
llvm-svn: 120600
2010-12-01 20:37:30 +00:00
Jay Foad
789e8ac4f7 PR5207: Rename overloaded APInt methods set(), clear(), flip() to
setAllBits(), setBit(unsigned), etc.

llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Jakob Stoklund Olesen
36f332e23a Disallow overlapping inserts, even when inserting the same value.
We always disallowed overlapping inserts with different values, and this makes
the insertion code smaller and faster.

If an overwriting insert is needed, it can be added as a separate method that
trims any existing intervals before inserting. The immediate use cases for
IntervalMap don't need this - they only use disjoint insertions.

llvm-svn: 120264
2010-11-28 22:17:11 +00:00
Jakob Stoklund Olesen
40f22dea6e Add default constructors for iterators.
These iterators don't point anywhere, and they can't be compared to anything.
They are only good for assigning to.

llvm-svn: 120239
2010-11-28 07:21:48 +00:00
Jakob Stoklund Olesen
3ef9f7bc95 Implement const_iterator::advanceTo().
This is a version of find() that always searches forwards and is faster for
local searches.

llvm-svn: 120237
2010-11-28 07:00:46 +00:00
Jakob Stoklund Olesen
d23cc8a255 Add more tests for erase(). Fix a few exposed bugs.
llvm-svn: 120227
2010-11-27 22:56:53 +00:00
Jakob Stoklund Olesen
c6f16354b9 Add test case with randomly ordered insertions, massive coalescing.
Implement iterator::erase() in a simple version that erases nodes when they
become empty, but doesn't try to redistribute elements among siblings for better
packing.

Handle coalescing across leaf nodes which may require erasing entries.

llvm-svn: 120226
2010-11-27 21:12:36 +00:00
Jakob Stoklund Olesen
6e57d83076 Add B+-tree test case that creates a height 3 tree with a smaller root node.
Change temporary debugging code to write a dot file directly.

llvm-svn: 120171
2010-11-26 06:54:20 +00:00
Ted Kremenek
bb322e520d Tweak ImmutableMap/ImmutableSet/ImmutableList APIs
to use lowercase letters for the start of most
method names and to replace some method names
with more descriptive names (e.g., "getLeft()"
instead of "Left()").  No real functionality
change.

llvm-svn: 120070
2010-11-24 00:54:28 +00:00
Jakob Stoklund Olesen
9dd0f0a04d Implement IntervalMap::clear().
llvm-svn: 119872
2010-11-19 23:28:57 +00:00
Jakob Stoklund Olesen
328eb0d328 Support backwards iteration starting from end().
llvm-svn: 119871
2010-11-19 23:28:53 +00:00
Dale Johannesen
0840b75ab3 Add test for PR 8111. By Frits van Bommel.
llvm-svn: 119870
2010-11-19 23:23:22 +00:00
Jakob Stoklund Olesen
52d6dd3079 Add ADT/IntervalMap.
This is a sorted interval map data structure for small keys and values with
automatic coalescing and bidirectional iteration over coalesced intervals.

Except for coalescing intervals, it provides similar functionality to std::map.
It is however much more compact for small keys and values, and hopefully faster
too.

The container object itself can hold the first few intervals without any
allocations, then it switches to a cache conscious B+-tree representation. A
recycling allocator can be shared between many containers, even between
containers holding different types.

The IntervalMap is initially intended to be used with SlotIndex intervals for:

- Backing store for LiveIntervalUnion that is smaller and faster than std::set.

- Backing store for LiveInterval with less overhead than std::vector for typical
  intervals and O(N log N) merging of large intervals. 99% of virtual registers
  need 4 entries or less and would benefit from the small object optimization.

- Backing store for LiveDebugVariable which doesn't exist yet, but will track
  debug variables during register allocation.

This is a work in progress. Missing items are:

- Performance metrics.
- erase().
- insert() shrinkage.
- clear().
- More performance metrics.
- Simplification and detemplatization.

llvm-svn: 119787
2010-11-19 04:47:19 +00:00
Jakob Stoklund Olesen
254cd4bc4d Revert "Add ADT/IntervalMap.", GCC doesn't like it.
This reverts r119772.

llvm-svn: 119773
2010-11-19 01:21:03 +00:00
Jakob Stoklund Olesen
7d82c5c710 Add ADT/IntervalMap.
This is a sorted interval map data structure for small keys and values with
automatic coalescing and bidirectional iteration over coalesced intervals.

Except for coalescing intervals, it provides similar functionality to std::map.
It is however much more compact for small keys and values, and hopefully faster
too.

The container object itself can hold the first few intervals without any
allocations, then it switches to a cache conscious B+-tree representation. A
recycling allocator can be shared between many containers, even between
containers holding different types.

The IntervalMap is initially intended to be used with SlotIndex intervals for:

- Backing store for LiveIntervalUnion that is smaller and faster than std::set.

- Backing store for LiveInterval with less overhead than std::vector for typical
  intervals and O(N log N) merging of large intervals. 99% of virtual registers
  need 4 entries or less and would benefit from the small object optimization.

- Backing store for LiveDebugVariable which doesn't exist yet, but will track
  debug variables during register allocation.

This is a work in progress. Missing items are:

- Performance metrics.
- erase().
- insert() shrinkage.
- clear().
- More performance metrics.
- Simplification and detemplatization.

llvm-svn: 119772
2010-11-19 01:14:40 +00:00
Chandler Carruth
7799a873bb Switch attribute macros to use 'LLVM_' as a prefix. We retain the old names
until other LLVM projects using these are cleaned up.

llvm-svn: 117200
2010-10-23 08:10:43 +00:00
Dan Gohman
144a1ac84e Move ValueMapTest from ADT to VMCore so that ADT doesn't need
to link in "core".

llvm-svn: 114831
2010-09-27 15:50:08 +00:00
Dan Gohman
f9d7d6c9f9 Add an all() method to BitVector, for testing whether all bits are set.
llvm-svn: 114830
2010-09-27 15:48:37 +00:00
Duncan Sands
c128b42eb8 Add better support for environment portion of triple. Original patch by
Cameron Esfahani, tweaked to use array_lengthof.

llvm-svn: 114073
2010-09-16 08:25:48 +00:00
Jakob Stoklund Olesen
0a9b86f575 Attempt to unbreak the FreeBSD buildbot by XFAILing a unit test that seems to be
miscompiled by the system gcc-4.2.1

The test remains enabled for the second-stage test.

llvm-svn: 113824
2010-09-14 00:51:58 +00:00
Benjamin Kramer
7dcd303d9c StringRef::compare_numeric also differed from StringRef::compare for characters > 127.
llvm-svn: 112189
2010-08-26 15:25:35 +00:00
Benjamin Kramer
25003daf90 Do unsigned char comparisons in StringRef::compare_lower to be more consistent with compare in corner cases.
llvm-svn: 112185
2010-08-26 14:21:08 +00:00
Bill Wendling
51b5bcd605 Silence 'unused' warning.
llvm-svn: 111539
2010-08-19 18:52:02 +00:00
Duncan Sands
6f5776e1d2 Add a 'normalize' method to the Triple class, which takes a mucked up
target triple and straightens it out.  This does less than gcc's script
config.sub, for example it turns i386-mingw32 into i386--mingw32 not
i386-pc-mingw32, but it does a decent job of turning funky triples into
something that the rest of the Triple class can understand.  The plan
is to use this to canonicalize triple's when they are first provided
by users, and have the rest of LLVM only deal with canonical triples.
Once this is done the special case workarounds in the Triple constructor
can be removed, making the class more regular and easier to use.  The
comments and unittests for the Triple class are already adjusted in this
patch appropriately for this brave new world of increased uniformity.

llvm-svn: 110909
2010-08-12 11:31:39 +00:00
Duncan Sands
fa440174ee Remove the ValueMap copy constructor. It's not used anywhere,
and removing it catches the mistake of passing a ValueMap by
copy rather than by reference.

llvm-svn: 110549
2010-08-08 12:57:48 +00:00
Duncan Sands
57ab333302 Fix the ValueMap copy constructor. The issue is that the map keys are value
handles with a pointer to the containing map.  When a map is copied, these
pointers need to be corrected to point to the new map.  If not, then consider
the case of a map M1 which maps a value V to something.  Create a copy M2 of
M1.  At this point there are two value handles on V, one representing V as a
key in M1, the other representing V as a key in M2.  But both value handles
point to M1 as the containing map.  Now delete V.  The value handles remove
themselves from their containing map (which destroys them), but only the first
value handle is successful: the second one cannot remove itself from M1 as
(once the first one has removed itself) there is nothing there to remove; it
is therefore not destroyed.  This causes an assertion failure "All references
to V were not removed?".

llvm-svn: 109851
2010-07-30 05:49:32 +00:00
Chandler Carruth
e3d4a2cbbc Switch from EXPECT_EQ({true,false, ...) to the more canonical
EXPECT_{TRUE,FALSE}(...) macros. This also prevents suprious warnings about
bool-to-pointer conversion that occurs withit EXPECT_EQ.

llvm-svn: 108248
2010-07-13 17:28:05 +00:00
Bill Wendling
48c8ee1c11 Use non-bool values for .count.
llvm-svn: 108048
2010-07-10 18:56:35 +00:00
Daniel Dunbar
956f97134b ADT: Add DAGDeltaAlgorithm, which is a DAG minimization algorithm built on top of the standard 'delta debugging' algorithm.
- This can give substantial speedups in the delta process for inputs we can construct dependency information for.

llvm-svn: 105612
2010-06-08 16:21:22 +00:00
Jakob Stoklund Olesen
1c0aa5f14a Add StringRef::compare_numeric and use it to sort TableGen register records.
This means that our Registers are now ordered R7, R8, R9, R10, R12, ...
Not R1, R10, R11, R12, R2, R3, ...

llvm-svn: 104745
2010-05-26 21:47:28 +00:00
Daniel Dunbar
10ef3afee3 Fix const ilist_node::get{Prev,Next}Node() to actually compile. Picky, picky.
llvm-svn: 103723
2010-05-13 18:35:02 +00:00
Daniel Dunbar
78bb7f4dc9 ADT: Add ilist_node::get{Prev,Next}Node, which return the adjacent node or null.
- This provides a convenient alternative to using something llvm::prior or
   manual iterator access, for example::

    if (T *Prev = foo->getPrevNode())
      ...

   instead of::

     iterator it(foo);
     if (it != begin()) {
       --it;
       ... 
     }

 - Chris, please review.

llvm-svn: 103647
2010-05-12 21:35:19 +00:00
Dan Gohman
73722062f7 Update BitVectorTest.cpp to stay in sync with SmallBitVectorTest.cpp,
and fix a bug in BitVector's reference proxy class which this exposed.

llvm-svn: 102768
2010-04-30 20:50:28 +00:00
Benjamin Kramer
f3e9546fc1 SmallBitVector: Rework find_first/find_next and tweak test to test them (at least on 64 bit platforms).
llvm-svn: 102712
2010-04-30 13:40:27 +00:00
Benjamin Kramer
e4ebf09068 Implement a read/write operator[] for SmallBitVector with a proxy class.
llvm-svn: 102709
2010-04-30 12:29:39 +00:00
Chris Lattner
733984a968 silence some unused-value warnings.
llvm-svn: 101689
2010-04-18 03:28:20 +00:00
Dan Gohman
8d37faa2f7 Fix SmallVector's insert to handle non-random-access iterators.
llvm-svn: 99633
2010-03-26 18:53:37 +00:00
Dan Gohman
73fc4f80ba Make this test more lenient; with SmallVector now using actually
aligned storage, the capacity may be more than what is explicitly
requested.

llvm-svn: 98846
2010-03-18 18:47:50 +00:00
Jeffrey Yasskin
4443f00d2b Fix death tests in -Asserts builds.
llvm-svn: 98701
2010-03-17 01:18:45 +00:00
John McCall
69bc985550 Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-width
payloads.  APFloat's internal folding routines always make QNaNs now,
instead of sometimes making QNaNs and sometimes SNaNs depending on the
type.

llvm-svn: 97364
2010-02-28 02:51:25 +00:00
John McCall
bb9c3309b2 Make APFloat's string-parsing routines a bit safer against very large exponents.
llvm-svn: 97278
2010-02-26 22:20:41 +00:00
Jeffrey Yasskin
eb0dbdca22 Fix (harmless) memory leak found by memcheck.
llvm-svn: 95862
2010-02-11 07:16:13 +00:00
Benjamin Kramer
0a0f0f6465 Silence GCC warnings.
llvm-svn: 95779
2010-02-10 13:34:02 +00:00
Dan Gohman
2dd0d36f14 Implement operators |=, &=, and ^= for SmallBitVector, and remove the
restriction in BitVector for |= and ^= that the operand must be the
same length.

llvm-svn: 95768
2010-02-10 05:54:04 +00:00
Dale Johannesen
af10702e49 Disable unittests/ADT/BitVectorTest on PPC Darwin.
It fails with a release build only, for reasons
as yet unknown.  (If there's a better way to Xfail
things here let me know, doesn't seem to be any
prior art in unittests.)

llvm-svn: 95700
2010-02-09 22:15:27 +00:00
John McCall
8bcabdeffc Make APInt::countLeadingZerosSlowCase() treat the contents of padding bits
as undefined.  Fixes an assertion in APFloat::toString noticed by Dale.

llvm-svn: 95196
2010-02-03 03:42:44 +00:00
Dan Gohman
090f279ac5 Add a SmallBitVector class, which mimics BitVector but uses only
a single pointer (PointerIntPair) member. In "small" mode, the
pointer field is reinterpreted as a set of bits. In "large" mode,
the pointer points to a heap-allocated object.

Also, give BitVector empty and swap functions.

And, add some simple unittests for BitVector and SmallBitVector.

llvm-svn: 92730
2010-01-05 15:04:49 +00:00
Benjamin Kramer
9e60957f54 Silence compiler warning.
warning: comparison between signed and unsigned integer expressions
llvm-svn: 92359
2009-12-31 16:27:13 +00:00
Douglas Gregor
c4174c69ea Document the edit-distance algorithm used in StringRef, switch it over
to SmallVector, and add a unit test.

llvm-svn: 92340
2009-12-31 04:24:34 +00:00
John McCall
75f1b8beeb Implement support for converting to string at "natural precision", and fix some
major bugs in long-precision conversion.

llvm-svn: 92150
2009-12-24 23:18:09 +00:00
Douglas Gregor
1dafbbc020 Move the two definitions of operator<< into namespace llvm, so they
will be found by argument-dependent lookup. As with the previous
commit, GCC is allowing ill-formed code.

llvm-svn: 92146
2009-12-24 21:15:37 +00:00
Douglas Gregor
a31d6d49b0 Define the new operator<< for sets into namespace std, so that
argument-dependent lookup can find it. This is another case where an
LLVM bug (not making operator<< visible) was masked by a GCC bug
(looking in the global namespace when it shouldn't).

llvm-svn: 92144
2009-12-24 21:11:45 +00:00
John McCall
c71c44ec7f Add accessors for the largest-magnitude, smallest-magnitude, and
smallest-normalized-magnitude values in a given FP semantics.
Provide an APFloat-to-string conversion which I am quite ready to admit could
be much more efficient.

llvm-svn: 92126
2009-12-24 08:56:26 +00:00
Eli Friedman
fe6a796851 Change StringRef::startswith and StringRef::endswith to versions which are a
bit more verbose, but optimize to much shorter code.

llvm-svn: 91817
2009-12-21 06:49:24 +00:00
Daniel Dunbar
63e2201f3e Add an implementation of the delta debugging algorithm.
- This is a pretty slow / memory intensive implementation, and I will likely
   change it to an iterative model, but it works.

llvm-svn: 90447
2009-12-03 11:12:42 +00:00
Duncan Sands
78f8022d71 Only run this mutex test if threading is enabled. This
fixes PR5395.

llvm-svn: 89385
2009-11-19 20:48:14 +00:00
Benjamin Kramer
891fbcdb60 Reenable Split2 StringRef test with Apple gcc.
llvm-svn: 89357
2009-11-19 16:04:41 +00:00
Daniel Dunbar
e36c429c3b "XFAIL" the Split2 StringReft test with Apple gcc, which miscompiles it.
- I plan on fixing/workarounding this, but until then I'd like the bots to stay
   green.

llvm-svn: 89077
2009-11-17 09:29:59 +00:00
Rafael Espindola
bece8d9ae7 Distinguish "a," from "a". The first one splits into "a" + "" and the second one into
"a" + 0.

llvm-svn: 87084
2009-11-13 04:55:09 +00:00
Rafael Espindola
11ceba8119 Switch to smallvector. Also fix issue with using unsigend for MaxSplit.
llvm-svn: 87068
2009-11-13 02:18:25 +00:00
Rafael Espindola
22f040b797 Add a new split method to StringRef that puts the substrings in a vector.
llvm-svn: 87058
2009-11-13 01:24:40 +00:00
Daniel Dunbar
16a5387db2 Add From arguments to StringRef search functions, and tweak doxyments.
Also, add unittests for find_first_of and find_first_not_of.

llvm-svn: 86770
2009-11-11 00:28:53 +00:00
Jeffrey Yasskin
23ac706aab Fix DenseMap iterator constness.
This patch forbids implicit conversion of DenseMap::const_iterator to
DenseMap::iterator which was possible because DenseMapIterator inherited
(publicly) from DenseMapConstIterator. Conversion the other way around is now
allowed as one may expect.

The template DenseMapConstIterator is removed and the template parameter
IsConst which specifies whether the iterator is constant is added to
DenseMapIterator.

Actually IsConst parameter is not necessary since the constness can be
determined from KeyT but this is not relevant to the fix and can be addressed
later.

Patch by Victor Zverovich!

llvm-svn: 86636
2009-11-10 01:02:17 +00:00
Chris Lattner
fa5b1df64a Type.h doesn't need to #include LLVMContext.h
llvm-svn: 85254
2009-10-27 17:08:31 +00:00
Chandler Carruth
766362c707 Move DataTypes.h to include/llvm/System, update all users. This breaks the last
direct inclusion edge from System to Support.

llvm-svn: 85086
2009-10-26 01:35:46 +00:00
Jeffrey Yasskin
bc5f122491 Fix stylistic and documentation problems in ValueMap found by Nick Lewycky and
Evan Cheng.

llvm-svn: 84967
2009-10-23 20:54:00 +00:00
Jeffrey Yasskin
e90afea0ba Try r84890 again (adding ValueMap<>), now that I've tested the compile on
gcc-4.4.

llvm-svn: 84902
2009-10-22 22:11:22 +00:00
Jeffrey Yasskin
7555ed8cdc Revert r84890, which broke the linux build.
llvm-svn: 84892
2009-10-22 20:23:43 +00:00
Jeffrey Yasskin
ad8692124f Add a ValueMap<ValueOrSubclass*, T> type. ValueMap<Value*, T> is safe to use
even when keys get RAUWed and deleted during its lifetime. By default the keys
act like WeakVHs, but users can pass a third template parameter to configure
how updates work and whether to do anything beyond updating the map on each
action.

It's also possible to automatically acquire a lock around ValueMap updates
triggered by RAUWs and deletes, to support the ExecutionEngine.

llvm-svn: 84890
2009-10-22 20:10:20 +00:00
Duncan Sands
19c1644f1f Pacify the compiler (signed with unsigned comparison) by making
these constants unsigned.

llvm-svn: 83962
2009-10-13 09:23:11 +00:00
Dan Gohman
f9067da535 Add a ceilLogBase2 function to APInt.
llvm-svn: 83932
2009-10-13 01:49:02 +00:00
Daniel Dunbar
d4df08bb72 Fix a few more conversion warnings on 4.0
llvm-svn: 82232
2009-09-18 17:48:05 +00:00
Daniel Dunbar
b415837d62 Another try at fixing compile warnings on 4.0
llvm-svn: 82148
2009-09-17 17:46:53 +00:00
Daniel Dunbar
60e1dee7fa Add StringRef::{rfind, rsplit}
llvm-svn: 82087
2009-09-16 22:38:48 +00:00
Daniel Dunbar
23724b98d0 Attempt to fix some 4.0.0 build warnings.
llvm-svn: 81752
2009-09-14 02:38:53 +00:00
Daniel Dunbar
7ef30987f7 Simplify, now that gtest supports raw_ostream directly.
llvm-svn: 81102
2009-09-06 02:31:26 +00:00
Daniel Dunbar
29f5444a38 Add test for PR4873, which works for me.
llvm-svn: 80965
2009-09-03 22:57:02 +00:00
Chris Lattner
98f201632e split raw_os_ostream out to its own header and implementation file. This
means that raw_ostream no longer has to #include <iosfwd>.  Nothing in llvm
should use raw_os_ostream.h, but llvm-gcc and some unit tests do.

llvm-svn: 79886
2009-08-24 04:02:06 +00:00
Daniel Dunbar
56712ba250 Unbreak unit tests.
llvm-svn: 79879
2009-08-24 02:02:58 +00:00
Bill Wendling
e5dbd6b0f9 Correct for recent assert change.
llvm-svn: 79601
2009-08-21 06:35:41 +00:00
Erick Tryzelaar
ff8b504eb3 Fix bug with APInt::getBitsNeeded with for base 10 numbers 0-9.
llvm-svn: 79593
2009-08-21 03:15:28 +00:00
Erick Tryzelaar
11660bb729 Allow '+' to appear in APInt strings, and add more unit tests.
llvm-svn: 79592
2009-08-21 03:15:14 +00:00
Erick Tryzelaar
6bd69aaa86 Add support for including '+' in APFloat strings, more asserts,
and many new unit tests.

llvm-svn: 79574
2009-08-20 23:30:43 +00:00
Daniel Dunbar
9ad4b47cec Fix two APFloat bugs in converting hexadecimal constants.
llvm-svn: 79540
2009-08-20 17:12:33 +00:00
Benjamin Kramer
15b0649d13 Remove SmallString::append_*int* unit tests.
llvm-svn: 79451
2009-08-19 19:41:05 +00:00
Daniel Dunbar
6812c0db35 Add SmallVector::{capacity,set_size}.
- These allow clients to make use of the extra elements in the vector which
   have already been allocated, without requiring them to be value initialized.

llvm-svn: 79433
2009-08-19 17:48:28 +00:00
Daniel Dunbar
d334c67f60 Improve Triple to recognize the OS in i386-mingw32.
llvm-svn: 79359
2009-08-18 19:26:55 +00:00
Daniel Dunbar
09f40a7871 Fix pasto in StringRef::count(char)
llvm-svn: 79356
2009-08-18 18:34:22 +00:00
Daniel Dunbar
4a9a98a5de Add StringRef::count({char,StringRef})
llvm-svn: 79354
2009-08-18 18:26:35 +00:00
Erick Tryzelaar
3ca0a7b0e4 Wrap unit test death tests in GTEST_HAS_DEATH_TEST
llvm-svn: 79218
2009-08-17 00:55:33 +00:00
Erick Tryzelaar
9e37eae4d7 Change APFloatTest from using ASSERTs to EXPECTs
llvm-svn: 79216
2009-08-17 00:14:11 +00:00
Erick Tryzelaar
930c879b9e Modify APFloat to take a StringRef instead of a c string.
This also adds unit tests to APFloat that mainly tests the
string handling of APFloat, but not much else of it's api.

llvm-svn: 79210
2009-08-16 23:36:19 +00:00
Erick Tryzelaar
36d9dbb8a1 Add failure tests to APInt unit test.
llvm-svn: 79209
2009-08-16 23:36:01 +00:00
Daniel Dunbar
3a5a25d5d5 Convert APint::{fromString,APInt,getBitsNeeded} to use StringRef.
- Patch by Erick Tryzelaar, with some edits (and a bug fix) from me.

llvm-svn: 78885
2009-08-13 02:33:34 +00:00
Daniel Dunbar
f4e8af6ecc StringRef: Add find(char) and find(StringRef).
Also, regroup functions.

llvm-svn: 78712
2009-08-11 20:47:15 +00:00
Daniel Dunbar
edd0313a36 Twine: Use raw_ostream::write_hex, remove unused itohexstr method.
llvm-svn: 77617
2009-07-30 18:30:19 +00:00
Daniel Dunbar
4d8b1776b4 Twine: Provide [u]int{32,64} conversions via implicit constructors instead of
explicitly.

llvm-svn: 77576
2009-07-30 03:47:15 +00:00
Benjamin Kramer
276a105601 fix unittest on platforms with unsigned chars (e.g. linux-ppc)
llvm-svn: 77471
2009-07-29 16:48:32 +00:00
Daniel Dunbar
d13fcdaae5 Twines: Support numeric conversion directly (uitostr, etc).
- Provides static constructors for doing number to string conversions without
   using temporaries.

 - There are several ways to do this, I think given the Twine constraints this
   is the simplest one.

 - One FIXME for fast number -> hex conversion.

 - Added another comment on one last major bit of perf work Twines need, which
   is to make raw_svector_ostream more efficient.

llvm-svn: 77445
2009-07-29 07:08:44 +00:00
Daniel Dunbar
5a9d56ab90 Update Triple to use StringRef/Twine based APIs.
- This is now shorter, simpler, safer, and more efficient, what a deal.

llvm-svn: 77119
2009-07-26 03:31:47 +00:00
Daniel Dunbar
b97f9fc3f5 Add StringRef::{slice, split}, two convenient string operations which are simple
and efficient on a StringRef.

llvm-svn: 77117
2009-07-26 03:18:15 +00:00
Jeffrey Yasskin
da42799098 Add a missing ilist_node.h #include to SparseBitVector, and add a very short
test for it. The test is by no means complete, but it tests the problem I was
fixing.

llvm-svn: 77025
2009-07-25 00:33:57 +00:00
Daniel Dunbar
6f78d7ac27 Add Twine ADT.
- Not currently used.

llvm-svn: 76956
2009-07-24 07:04:27 +00:00
Daniel Dunbar
b5adc13728 Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications!

 - I kept StringMap::GetOrCreateValue for compatibility purposes, this can
   eventually go away. Likewise the StringMapEntry Create functions still follow
   the old style.

 - NIFC.

llvm-svn: 76888
2009-07-23 18:17:34 +00:00
Daniel Dunbar
6bbe0f1151 Support writing a StringRef to a raw_ostream directly.
llvm-svn: 76754
2009-07-22 17:13:20 +00:00
Daniel Dunbar
30c92a0aee Add StringRef::{substr, startswith}.
llvm-svn: 76559
2009-07-21 09:18:49 +00:00
Daniel Dunbar
8ab30670cc Add StringRef class, with fixes.
llvm-svn: 76543
2009-07-21 07:28:51 +00:00
Torok Edwin
4f4888bcf0 unbreak unit-tests on gcc-4.4.
llvm-svn: 76542
2009-07-21 07:09:05 +00:00
Daniel Dunbar
156565ace2 Add SmallString unit test.
- Patch by Ryan Flynn!

llvm-svn: 76081
2009-07-16 17:00:06 +00:00
Daniel Dunbar
29416147f7 Clarify a FIXME.
llvm-svn: 75422
2009-07-12 19:45:34 +00:00
Dan Gohman
148d3bb9b4 Reapply 74494, this time removing the conflicting definition of operator<<
in APIntTest.cpp.

llvm-svn: 74550
2009-06-30 20:10:56 +00:00
Daniel Dunbar
5d4e95558e Revert my intentional breakage.
llvm-svn: 74531
2009-06-30 16:26:57 +00:00
Daniel Dunbar
e2d86964db Intentionally break a unittest to test my buildbot gtest command.
- Apologies in advance for the noise.

llvm-svn: 74530
2009-06-30 16:11:58 +00:00
Misha Brukman
789c11dcc0 Reversed order of args in EXPECT_EQ() macros to be in the correct order:
EXPECT_EQ(expected, actual) .  This will make error messages understandable as
it uses terms such as "expected" and "actual" based on the order of arguments.

llvm-svn: 73150
2009-06-09 21:48:57 +00:00
Stuart Hastings
b3c08d427a Prevent looping when DenseSet is abused.
llvm-svn: 70572
2009-05-01 20:47:53 +00:00
Chris Lattner
d68b203337 Fix PR4040: APInt's string constructor is too strict
patch by Jeff Yasskin!

llvm-svn: 70058
2009-04-25 18:34:04 +00:00
Owen Anderson
d2cf86afcb Use the testcase from PR2791.
llvm-svn: 69846
2009-04-23 00:15:26 +00:00
Misha Brukman
56dff472d2 * Fixed calls to APInt ctor to work for negative values on Darwin/x86
* Converted C-style casts to C++-style casts

llvm-svn: 68613
2009-04-08 16:17:23 +00:00
Daniel Dunbar
588d3d1fd6 Add llvm::Triple class for abstracting access to target triples.
- The code is silly, I'm just amusing myself. Rewrite to be efficient
   if you like. :)

Also, if you wish to debate the proper names of the triple components
I'm all ears.

llvm-svn: 68252
2009-04-01 21:53:23 +00:00
Misha Brukman
6e86395ae7 Converted a1.ll to unittests.
llvm-svn: 67652
2009-03-24 21:36:09 +00:00
Misha Brukman
3c59ac1164 Renamed unittest files to have a consistent {Tt}est suffix.
llvm-svn: 67326
2009-03-19 19:09:48 +00:00
Bill Wendling
6ef1b025ba Fix comment.
llvm-svn: 64137
2009-02-09 12:31:40 +00:00
Torok Edwin
47c303034d APInt's countLeadingOnes() was broken for negative i128 values,
causing assertion failures in getSExtValue().
Fix it by making highWordBits actually contain what its name says,
and add some more unit-tests for APInt.
This fixes PR3419.

llvm-svn: 63107
2009-01-27 18:06:03 +00:00
Nick Lewycky
7c5381a70c Port this test from dejagnu to unit testing.
The way this worked before was to test APInt by running
"lli -force-interpreter=true" knowing the lli uses APInt under the hood to
store its values. Now, we test APInt directly.

llvm-svn: 62514
2009-01-19 18:08:33 +00:00
Bill Wendling
1c5828d337 Fix naming of file.
llvm-svn: 62035
2009-01-11 01:25:51 +00:00
Bill Wendling
d88988a11e Adding unittests for SmallVector. Test by Talin.
llvm-svn: 62025
2009-01-10 12:56:31 +00:00
Bill Wendling
282eca1712 Some generic clean-ups. Also make the StringMapEntryInitializer specialization apply only to the tests that are actually testing it.
llvm-svn: 61923
2009-01-08 09:31:36 +00:00
Bill Wendling
71f808dfa2 * Don't explicitly cast "0" to "void*". This doesn't work well with specialized
StringMapEntryInitializer classes. Leave it for the compiler to figure out what
 the type is and what "0" should be transformed into.

* Un-disable the unit tests which test the StringMapEntryInitializer class.

llvm-svn: 61922
2009-01-08 08:26:46 +00:00