1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
Commit Graph

1306 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
40f23cd5ca Provide LiveIntervalUnion::Query::checkLoopInterference.
This is a three-way interval list intersection between a virtual register, a
live interval union, and a loop. It will be used to identify interference-free
loops for live range splitting.

llvm-svn: 122034
2010-12-17 04:09:47 +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
ae68a4eb6d Add IntervalMapOverlaps - An iterator for overlapping intervals in two
IntervalMaps.

The IntervalMaps can have different template parameters, but the KeyT and Traits
types must be the same.

Tests are forthcoming.

llvm-svn: 121935
2010-12-16 01:18:29 +00:00
Jakob Stoklund Olesen
3fbb216a33 Remove debugging code.
llvm-svn: 121738
2010-12-14 00:37:52 +00:00
Michael J. Spencer
c4c4e1133d Support: Move c_str from SmallVector back to SmallString and add a free standing
templated c_str in Windows.h to replace it.

llvm-svn: 121381
2010-12-09 17:37:18 +00:00
Jakob Stoklund Olesen
87009679c3 Fix begin() and end() on const IntervalMap.
llvm-svn: 121200
2010-12-07 23:18:43 +00:00
Jay Foad
79e18ed269 PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Michael J. Spencer
e5298b0f07 Support/ADT: Move c_str() from SmallString to SmallVectorImpl. The Windows PathV2
implementation needs it for wchar_t and SmallVectorImpl in general.

llvm-svn: 120984
2010-12-06 04:27:42 +00:00
Benjamin Kramer
e2e8053264 APInt: microoptimize a few methods.
llvm-svn: 120912
2010-12-04 18:05:36 +00:00
Benjamin Kramer
ec7938f7af Simplify APInt::getAllOnesValue.
llvm-svn: 120911
2010-12-04 16:37:47 +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
090cf77d32 Support/ADT/StringRef: Add find_last_of.
llvm-svn: 120495
2010-11-30 23:27:35 +00:00
Ted Kremenek
bacaf8fbf1 Performance optimization on ImmutableMap/ImmutableSet:
- Use a DenseSet instead of a FoldingSet to cache
canonicalized nodes.  This reduces the overhead
of double-hashing.

- Use reference counts in ImutAVLTree to much
more aggressively recover tree nodes that are
no longer usable.  We can generate many
transient nodes while using add() and remove()
on ImmutableSet/ImmutableMaps to generate a final
set/map.

For the clang static analyzer (the main client
of these data structures), this results in
a slight speedup (0.5%) when analyzing sqlite3,
but much more importantly results in a 30-60%
reduction in peak memory usage when the analyzer
is analyzing a given function in a file.  On
average that's about a ** 44% reduction ** in the
memory footprint of the static analyzer.

llvm-svn: 120459
2010-11-30 20:26:45 +00:00
Jay Foad
c663d7e4f6 PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.
llvm-svn: 120413
2010-11-30 09:02:01 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Jakob Stoklund Olesen
a5f9163586 Don't use std::copy and std::copy_backward, run 10% faster.
Sometimes std::copy can become a memmove call, and that is not a good idea when
copying relatively few bytes as we are doing. We also get a small win by
changing two loops into one.

llvm-svn: 120265
2010-11-28 22:17:14 +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
Jay Foad
eb28ac4a7a PR5207: remove unused methods APInt::Emit() and APInt::Read().
llvm-svn: 120262
2010-11-28 21:05:31 +00:00
Jay Foad
7378352505 PR5207: change APInt::doubleToBits() and APInt::floatToBits() to be
static methods that return a new APInt.

llvm-svn: 120261
2010-11-28 21:04:48 +00:00
Jakob Stoklund Olesen
69dce6e4b9 Tweak comments to make it clear that we are working in a namespace.
llvm-svn: 120256
2010-11-28 18:58:30 +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
5c6e97ccae Speed up simple insertions into an unbranched tree by not creating an iterator.
llvm-svn: 120232
2010-11-28 06:14:33 +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
Benjamin Kramer
3355314332 Remove PIC16 remnants.
llvm-svn: 120223
2010-11-27 18:20:30 +00:00
Daniel Dunbar
05a18ee325 Add an optional LowerCase argument to hexdigit().
llvm-svn: 120213
2010-11-27 13:19:46 +00:00
Daniel Dunbar
3258210b90 ADT/InMemoryStruct: Add an experimental helper class intended for use in
situations where on the common path an API can return a pointer to some direct
memory, but which on an exceptional path may need to return a pointer to a
temporary struct.

llvm-svn: 120201
2010-11-27 08:11:02 +00:00
Benjamin Kramer
3b0f0fd785 BitVector tweaks.
- Double the vector's capacity when growing to avoid unneeccesary reallocation.
- Do the reallocation with realloc(3) which can expand the memory in place.

llvm-svn: 120183
2010-11-26 18:25:20 +00:00
Benjamin Kramer
75de69b73c StringRefs are POD-like.
llvm-svn: 120181
2010-11-26 14:36:54 +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
Jakob Stoklund Olesen
8c952bc1cd Extract template function adjustSiblingSizes(), allowing instances to be shared
between B+-trees using the same KeyT.

llvm-svn: 120170
2010-11-26 06:54:17 +00:00
Michael J. Spencer
0d9fb7f72e Fix spelling!
llvm-svn: 120167
2010-11-26 04:16:20 +00:00
Michael J. Spencer
b2cfb3b443 Fix Whitespace.
llvm-svn: 120166
2010-11-26 04:16:08 +00:00
Jakob Stoklund Olesen
ac19a35444 Move tree navigation to a new Path class that doesn't have to be a template.
The path also holds a reference to the root node, and that allows important
iterator accessors like start() and stop() to have no conditional code. (When
the compiler is clever enough to remove it.)

llvm-svn: 120165
2010-11-26 01:39:40 +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
1cf4810406 Generalize overflowLeaf to also handle overflows in branch nodes.
This doesn't quite work yet because the calls to treeDecrement and treeIncrement
operate at the leaf level, not on pathNode(Level) as required.

llvm-svn: 120068
2010-11-24 00:03:32 +00:00
Frits van Bommel
da0d866809 Test commit: Fix two -Asserts mode warnings in StringMap.h.
llvm-svn: 119907
2010-11-20 18:37:24 +00:00
Jakob Stoklund Olesen
08e5752828 Fix old GCC build error.
llvm-svn: 119884
2010-11-20 01:24:43 +00:00
Jakob Stoklund Olesen
de3ebc098a Detemplatize NodeRef.
It is now possible to navigate the B+-tree using NodeRef::subtree() and
NodeRef::size() without knowing the key and value template types used in the
tree.

llvm-svn: 119880
2010-11-20 00:49:00 +00:00
Jakob Stoklund Olesen
4a44e92fd1 Rename NodeBase::{key,val} as {first,second} and swap the BranchNode arrays such
that the noderefs are the first member in the object.

This is in preparation of detemplatization of tree navigation.

llvm-svn: 119879
2010-11-20 00:48:57 +00:00
Jakob Stoklund Olesen
029e95d6d7 Implement IntervalMap destructor.
Key and value objects may not be destructed instantly when they are erased from
the container, but they will be destructed eventually by the IntervalMap
destructor.

llvm-svn: 119873
2010-11-19 23:28:59 +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
Jakob Stoklund Olesen
c65d4d6d14 Rename methods for clarity instead of brevity. No functional changes.
llvm-svn: 119820
2010-11-19 19:10:39 +00:00
Jakob Stoklund Olesen
0073a81d8d Include raw_ostream.h unconditionally even if it is only used for debug code.
We don't want any clients acidentally depending on this and then failing in a
-Asserts build.

llvm-svn: 119818
2010-11-19 18:51:46 +00:00
Jakob Stoklund Olesen
c8ac0c3c97 Work around GCC 4.0 build error:
llvm/include/llvm/ADT/IntervalMap.h:334: error: '((llvm::IntervalMapImpl::DesiredNodeBytes / static_cast<unsigned int>(((2 * sizeof (KeyT)) + sizeof (ValT)))) >? 3u)' is not a valid template argument for type 'unsigned int' because it is a non-constant expression

llvm-svn: 119790
2010-11-19 05:36:51 +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
Dan Gohman
ea25285426 Fix warnings about missing parents between || and &&.
llvm-svn: 119454
2010-11-17 02:40:30 +00:00
Jim Grosbach
4635621b41 Trailing whitespace.
llvm-svn: 118978
2010-11-13 04:17:15 +00:00
Dan Gohman
67f95d770b Factor code out of APInt to form a isUIntN helper function.
llvm-svn: 118133
2010-11-03 00:38:40 +00:00
Chandler Carruth
4d8fbad207 Add a specialization for 'long', a hole in the set of fundamental
specializations provided here. This is a little annoying because its size
changes from platform to platform. If possible, I may follow up with a patch
that uses standard constants to simplify much of this, but assuming for now
that was avoided for a reason.

llvm-svn: 117880
2010-10-31 22:57:03 +00:00
Chris Lattner
ee8dea6453 Rename alignof -> alignOf to avoid irritating C++'0x compilers,
PR8423, patch by nobled.

llvm-svn: 117774
2010-10-30 05:14:01 +00:00
Douglas Gregor
a598c0fbce Extend StringRef's edit-distance algorithm to permit an upper bound on the allowed edit distance
llvm-svn: 116867
2010-10-19 22:13:48 +00:00
Chris Lattner
451a0accb5 add uadd_ov/usub_ov to apint, consolidate constant folding
logic to use the new APInt methods.  Among other things this
implements rdar://8501501 - llvm.smul.with.overflow.i32 should constant fold

which comes from "clang -ftrapv", originally brought to my attention from PR8221.

llvm-svn: 116457
2010-10-14 00:05:07 +00:00
Chris Lattner
365326538a missed a line :(
llvm-svn: 116456
2010-10-13 23:57:00 +00:00
Chris Lattner
093d5fe0a9 constify these methods.
llvm-svn: 116455
2010-10-13 23:54:10 +00:00
Chris Lattner
70a78ab2c5 add a few operations for signed operations that also
return an overflow flag.

llvm-svn: 116452
2010-10-13 23:46:33 +00:00
Duncan Sands
6284b3db58 GCC extensions are no longer used here - update the comment.
llvm-svn: 115463
2010-10-03 15:31:50 +00:00
Duncan Sands
39e0233734 Remove two uses of the gcc specific 'aligned' attribute. This
is partly because this attribute caused trouble in the past (the
SmallVector one had to be changed from aligned to aligned(8) due
to causing crashes on i386 for example; in theory the same might
be needed in the Allocator case...).  But it's mostly because
there seems to be no point in special casing gcc here.  Using the
same implementation for all compilers results in better testing.

llvm-svn: 115462
2010-10-03 15:15:19 +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
Dan Gohman
d299070514 Make SetVector's remove indicate whether it actually removed something.
llvm-svn: 114612
2010-09-22 23:20:04 +00:00
Mikhail Glushenkov
637b2871f8 Trailing whitespace.
llvm-svn: 114432
2010-09-21 14:59:34 +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
Nick Lewycky
cad1395824 Create PTX backend. Patch by Che-Liang Chiou!
llvm-svn: 113235
2010-09-07 18:14:24 +00:00
Chris Lattner
6c6f196725 fix this to work with allocators that have reference type with compilers
that diagnose invalid references to references.

llvm-svn: 113078
2010-09-04 18:45:02 +00:00
John McCall
b91df6e799 After some discussion with djg, teach SmallVector to grow from a zero
capacity and remove the workaround in SmallVector<T,0>.  There are some
theoretical benefits to a N->2N+1 growth policy anyway.

llvm-svn: 112870
2010-09-02 21:55:03 +00:00
Dan Gohman
ace824be4a Make the iterator form of erase return void, since it always succeeds,
and since this is what std::map and std::set do.

llvm-svn: 112701
2010-09-01 14:00:35 +00:00
Eric Christopher
5f8ae3dbd6 Kill a couple of unused variables.
llvm-svn: 112498
2010-08-30 18:31:44 +00:00
Dan Gohman
5110488830 Delete an unused declaration.
llvm-svn: 112424
2010-08-29 14:48:15 +00:00
John McCall
33faad67cc SmallVector's growth policies don't like starting from zero capacity.
I think there are good reasons to change this, but in the interests
of short-term stability, make SmallVector<...,0> reserve non-zero
capacity in its constructors.  This means that SmallVector<...,0>
uses more memory than SmallVector<...,1> and should really only be
used (unless/until this workaround is removed) by clients that
care about using SmallVector with an incomplete type.

llvm-svn: 112147
2010-08-26 02:11:48 +00:00
John McCall
0c3659857d Provide an explicit specialization of SmallVector at N=0 which does
not require its type argument to be complete if no members are
actually used.

llvm-svn: 112106
2010-08-25 23:11:24 +00:00
Benjamin Kramer
926ba6058b Avoid O(n*m) complexity in StringRef::find_first(_not)_of(StringRef).
- Cache used characters in a bitset to reduce memory overhead to just 32 bytes.
- On my core2 this code is faster except when the checked string was very short
  (smaller than the list of delimiters).

llvm-svn: 111817
2010-08-23 18:16:08 +00:00
Benjamin Kramer
e4c21a06f7 StringRef tweaks:
- Respect find_first_of(char's From parameter instead of silently dropping it.
- Prefer std::string() to std::string("")

llvm-svn: 111814
2010-08-23 17:44:13 +00:00
Alexis Hunt
068811ea03 Finish full attribute class emission for clang.
For more information, see the accompanying clang patch.

llvm-svn: 111454
2010-08-18 23:23:09 +00:00
Jakob Stoklund Olesen
a94deec1c0 Revert r111394. It was too aggressive.
We must complete the DFS, otherwise we might miss needed phi-defs, and
prematurely color live ranges with a non-dominating value.

This is not a big deal since we get to color more of the CFG and the next
mapValue call will be faster.

llvm-svn: 111397
2010-08-18 20:06:05 +00:00
Jakob Stoklund Olesen
221c0b3c75 Aggressively prune the DFS when inserting phi-defs.
llvm-svn: 111394
2010-08-18 19:00:11 +00:00
Jakob Stoklund Olesen
d16fd86de1 Add df_iterator::getPathLength and getPath as a way of getting a path from the
entry node to the current node.

llvm-svn: 111392
2010-08-18 19:00:05 +00:00
Chris Lattner
c27b10f80d Don't pass in a null pointer to std::string's ctor, an empty string
ref should produce an empty std::string.  This fixes PR7879.

llvm-svn: 111332
2010-08-18 00:11:25 +00:00
Dan Gohman
06963ff7c4 Add hooks to FoldingSetTrait to allow specializations to provide
implementations of equality comparison and hash computation. This
can be used to optimize node lookup by avoiding creating lots of
temporary ID values just for hashing and comparison purposes.

llvm-svn: 111130
2010-08-16 15:30:39 +00:00
Dan Gohman
d4e78e0121 Tidy up whitespace in comments.
llvm-svn: 111129
2010-08-16 15:04:39 +00:00
Dan Gohman
d7f6f04d71 Constify FoldingSetNodeIDRef's Data.
llvm-svn: 111128
2010-08-16 15:03:24 +00:00
Dan Gohman
4446294688 Reverse the order of GetNodeProfile's arguments, for consistency
with FoldingSetTrait::Profile.

llvm-svn: 111127
2010-08-16 14:53:42 +00:00
Dan Gohman
8ba122de76 Fix indentation in example code in a comment.
llvm-svn: 111125
2010-08-16 14:45:36 +00:00
Benjamin Kramer
1725ef6c89 Use getAllOnesValue, saves a copy and looks better.
llvm-svn: 110991
2010-08-13 00:29:44 +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
6eec2f9421 Remove the ValueMap operator=, which was wrong (it did't correct the
Map pointers of any contained ValueMapCallbackVH's) and unused.

llvm-svn: 110577
2010-08-09 16:44:56 +00:00
Zhongxing Xu
d955bbe69b Change the Interval type to signed in ImmutableIntervalMap.h.
llvm-svn: 110562
2010-08-09 03:43: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
Nick Lewycky
b37e4d1eb2 Fix typo.
llvm-svn: 110502
2010-08-07 05:25:29 +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
Owen Anderson
fd7fc038ac Fill out the interface of DenseSet a bit.
llvm-svn: 109562
2010-07-27 23:55:47 +00:00
Chris Lattner
1cc20eea6f make lookup failures not fatal.
llvm-svn: 109530
2010-07-27 18:59:50 +00:00
Duncan Sands
a5314238d6 In commit 91421, isPod was changed from false to true for these value handles.
Change it back again: destructors and constructors need to be run.

llvm-svn: 109498
2010-07-27 09:09:05 +00:00
Chris Lattner
ae021d8590 add a new NullablePtr class which makes it more obvious in API
that a pointer can be null, forcing clients to think about it.

llvm-svn: 109348
2010-07-24 18:47:46 +00:00
Chris Lattner
ab2419e712 give StringMap a new ctor which allows you to initialize it
with an existing allocator.  The interesting use case of this
is that it allows "StringMap<whatever, BumpPtrAllocator&>" for
when you want to allocate out of a preexisting bump pointer
allocator owned by someone else.

llvm-svn: 109213
2010-07-23 03:29:59 +00:00
Chris Lattner
8697533a43 modernize stringset interface
llvm-svn: 109212
2010-07-23 03:21:53 +00:00
Benjamin Kramer
da3e6cdb26 Don't pass StringRef by reference.
llvm-svn: 108366
2010-07-14 22:38:02 +00:00
Eric Christopher
bc774d339c 80-columns
llvm-svn: 108228
2010-07-13 05:50:08 +00:00
Argyrios Kyrtzidis
b835e6d948 Add convenience method FoldingSetImpl::InsertNode(Node *N) that asserts if the node is already inserted.
llvm-svn: 108192
2010-07-12 20:47:08 +00:00
Bill Wendling
8f8b8753db getOrInsertLeaderValue cannot be const because it calls insert.
Patch by Xi Wang!

llvm-svn: 108188
2010-07-12 20:27:02 +00:00
Duncan Sands
5338c9f877 Use std::vector rather than SmallVector here because SmallVector
causes some versions of gcc to crash when building LLVM.

llvm-svn: 107869
2010-07-08 13:06:08 +00:00
Duncan Sands
dcc1398f44 Do not use std::stack because it causes obscure failures when
compiled with MSVC 2010 (PR7367).  Instead use a SmallVector.

llvm-svn: 107867
2010-07-08 11:54:27 +00:00
Chris Lattner
96566c78ef add some triple for minix, patch by Kees van Reeuwijk from PR7582
llvm-svn: 107785
2010-07-07 15:52:27 +00:00
Duncan Sands
b79597c3e9 Rename NextPowerOfTwo to RoundUpToPowerOfTwo.
llvm-svn: 107297
2010-06-30 17:24:28 +00:00
Duncan Sands
8ffa4b43c8 Clarify that the NextPowerOfTwo template is idempotent.
llvm-svn: 107286
2010-06-30 15:29:46 +00:00
Duncan Sands
de6d3111d0 Rather than giving SmallPtrSetImpl a member field SmallArray which is magically
replaced by a bigger array in SmallPtrSet (by overridding it), instead just use a
pointer to the start of the storage, and have SmallPtrSet pass in the value to use.
This has the disadvantage that SmallPtrSet becomes bigger by one pointer.  It has
the advantage that it no longer uses tricky C++ rules, and is clearly correct while
I'm not sure the previous version was.  This was inspired by g++-4.6 pointing out
that SmallPtrSetImpl was writing off the end of SmallArray, which it was.  Since
SmallArray is replaced with a bigger array in SmallPtrSet, the write was still to
valid memory.  But it was writing off the end of the declared array type - sounds
kind of dubious to me, like it sounded dubious to g++-4.6.  Maybe g++-4.6 is wrong
and this construct is perfectly valid and correctly compiled by all compilers, but
I think it is better to avoid the whole can of worms by avoiding this construct.

llvm-svn: 107285
2010-06-30 15:02:37 +00:00
Duncan Sands
73b36f31d7 Fix a buffer overflow noticed by gcc-4.6: zero is written into
SmallArray[SmallSize] in the SmallPtrSetIteratorImpl, and this is
one off the end of the array.  For those who care, right now gcc
warns about writing off the end because it is confused about the
declaration of SmallArray as having length 1 in the parent class
SmallPtrSetIteratorImpl.  However if you tweak code to unconfuse
it, then it still warns about writing off the end of the array,
because of this buffer overflow.  In short, even with this fix
gcc-4.6 will warn about writing off the end of the array, but now
that is only because it is confused.

llvm-svn: 107200
2010-06-29 20:12:02 +00:00
Duncan Sands
4828790444 NextPowerOfTwo was already used to ensure that SmallSizePowTwo is a power
of two, no need to do it a second time (NextPowerOfTwo is idempotent).

llvm-svn: 107199
2010-06-29 20:05:34 +00:00
Eric Christopher
7405c7bdb8 Silence some unused variable warnings.
llvm-svn: 106778
2010-06-24 20:14:34 +00:00
Dan Gohman
4f088f99fe Add a comment about a thread safety issue in Statistic.h.
llvm-svn: 106756
2010-06-24 16:31:32 +00:00
Chris Lattner
7420a283cf disable SmallVectorImpl's copy constructor. This prevents a class
of base class slicing bugs reported on irc

llvm-svn: 106028
2010-06-15 18:59:43 +00:00
John McCall
fade2aeb9f Define ContextualFoldingSet, which stores a context parameter to pass down to
the Profile method.  Currently this only works with the default FoldingSetTraits
implementation.

The point of this is to allow nodes to not store context values which are only
used during profiling.  A better solution would thread this value through the
folding algorithms, but then those would need to be (1) templated and
(2) non-opaque.

llvm-svn: 105819
2010-06-11 11:06:44 +00:00
Duncan Sands
78593d094f Add includes to get ptrdiff_t. This is needed by gcc-4.6 which has
done some more header trimming, resulting in cstdef being included
by less header files.

llvm-svn: 105786
2010-06-10 10:13:58 +00:00
Rafael Espindola
06df61cf04 Fix a gcc warning:
'class llvm::DAGDeltaAlgorithm' has virtual functions and accessible non-virtual destructor

Not sure if this is the best solution, but this class has state and some of the
classes that inherit from it also do, so it looks appropriate.

llvm-svn: 105675
2010-06-09 03:00:05 +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
Benjamin Kramer
d62b29412b Use realloc instead of malloc+memcpy when growing a POD SmallVector. A smart
realloc implementation can try to expand the allocated memory block in-place,
avoiding the copy.

llvm-svn: 105605
2010-06-08 11:44:30 +00:00
Dan Gohman
e1853a7473 Implement operator== and operator!= for SetVector.
llvm-svn: 105508
2010-06-05 00:26:02 +00:00
Jim Grosbach
90ca622864 remove trailing whitespace
llvm-svn: 105333
2010-06-02 17:45:54 +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
John Mosby
cec9b7fc9c Trivial change to dump() function for SparseBitVector
llvm-svn: 104433
2010-05-22 05:13:17 +00:00
Jakob Stoklund Olesen
011cea42b9 Optimize empty DenseMap iteration.
llvm-svn: 103962
2010-05-17 20:01:24 +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
Douglas Gregor
2f2491405a Fixes for Microsoft Visual Studio 2010, from Steven Watanabe!
llvm-svn: 103457
2010-05-11 06:17:44 +00:00
Chris Lattner
b9f858943a Implement rdar://7415680 - Twine integer support lacks greatness
Microoptimize Twine's with unsigned and int to not pin their value to
the stack.  This saves stack space in common cases and allows mem2reg
in the caller.  A simple example is:

void foo(const Twine &);
void bar(int x) {
  foo("xyz: " + Twine(x));
}

Before:

__Z3bari:
	subq	$40, %rsp
	movl	%edi, 36(%rsp)
	leaq	L_.str3(%rip), %rax
	leaq	36(%rsp), %rcx
	leaq	8(%rsp), %rdi
	movq	%rax, 8(%rsp)
	movq	%rcx, 16(%rsp)
	movb	$3, 24(%rsp)
	movb	$7, 25(%rsp)
	callq	__Z3fooRKN4llvm5TwineE
	addq	$40, %rsp
	ret

After:

__Z3bari:
	subq	$24, %rsp
	leaq	L_.str3(%rip), %rax
	movq	%rax, (%rsp)
	movslq	%edi, %rax
	movq	%rax, 8(%rsp)
	movb	$3, 16(%rsp)
	movb	$7, 17(%rsp)
	leaq	(%rsp), %rdi
	callq	__Z3fooRKN4llvm5TwineE
	addq	$24, %rsp
	ret

It saves 16 bytes of stack and one instruction in this case.

llvm-svn: 103107
2010-05-05 18:40:33 +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
Benjamin Kramer
e59c44ea79 Make sure SmallBitVector actually uses the small case and fix latent bugs.
- We can't use PointerIntPair here since we require the discrimination bit to be in the LSB.

llvm-svn: 102707
2010-04-30 11:34:01 +00:00
Evan Cheng
f0f25bd8e6 Add DenseMapInfo for int.
llvm-svn: 102652
2010-04-29 18:50:35 +00:00
Torok Edwin
9ddbae859f Fix PR6910.
Limit alignment in SmallVector 8, otherwise GCC assumes 16 byte alignment.
opetaror new, and malloc only return 8-byte aligned memory on 32-bit Linux,
which cause a crash if code is compiled with -O3 (or -ftree-vectorize) and some
SmallVector code is vectorized.

llvm-svn: 102604
2010-04-29 06:43:12 +00:00
Dan Gohman
f4e99e3f84 These functions don't need to access this.
llvm-svn: 101776
2010-04-19 15:38:38 +00:00
Chris Lattner
bef627e798 reenable r101565, removing a problematic assertion.
CGSCC can delete nodes in regions of the callgraph that
have already been visited.  If new CG nodes are allocated
to the same pointer, we shouldn't abort, just handle it
correctly by assigning a new number.  This should restore
stability by removing invalidated pointers that *will* be
reused from the densemap in the iterator.

llvm-svn: 101628
2010-04-17 07:17:19 +00:00
Chris Lattner
d28dcb3ffe building on the new CallGraphSCC abstraction, teach CallGraphSCCPassManager
to keep the node entries in scc_iterator up to date instead of dangling as
the SCC mutates.

This is a really terrible problem which was causing -g to affect codegen 
because it would permute the memory image of the compiler process.

Thanks to Dale for expertly hunting it down.

llvm-svn: 101565
2010-04-16 23:04:30 +00:00
Chris Lattner
a9a7c28cd2 move ReplaceNode out of line, rename scc_iterator::fini -> isAtEnd().
No functionality change.

llvm-svn: 101562
2010-04-16 22:59:24 +00:00
Chris Lattner
7e6e8651b7 tidy up
llvm-svn: 101548
2010-04-16 21:57:10 +00:00
Daniel Dunbar
d3c1f99fa1 Fix -Asserts warnings.
llvm-svn: 101191
2010-04-13 23:34:11 +00:00
Benjamin Kramer
adc8df5270 utostr isn't going away too soon, try to make it slightly smaller.
llvm-svn: 100977
2010-04-11 19:00:03 +00:00
Ted Kremenek
90babe9f35 Move 'Optional' class from Clang to LLVM/ADT.
llvm-svn: 100889
2010-04-09 20:25:54 +00:00
Dan Gohman
127f5c53e1 Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.
llvm-svn: 100824
2010-04-08 23:03:40 +00:00
Douglas Gregor
41de3d792a Remove MaybeOwningPtr. We're going to use reference-counting instead.
llvm-svn: 100499
2010-04-05 23:53:46 +00:00
Douglas Gregor
394c3bc02e Introduce MaybeOwningPtr, a smart pointer that may (or may not) have
ownership over the pointer it contains. Useful when we want to
communicate ownership while still having several clients holding on to
the same pointer *without* introducing reference counting.

llvm-svn: 100463
2010-04-05 21:09:22 +00:00
Douglas Gregor
63f8158cff Introduce namespace-scope functions to enable LLVM statistics without
passing the command-line parameter "-stats" and to print the resulting
statistics without calling llvm_shutdown().

llvm-svn: 99893
2010-03-30 17:32:08 +00:00
Ted Kremenek
59cdbd3cfc Change PointerUnionX::getFromOpaqueValue() to be declared 'static inline' instead of 'static'.
llvm-svn: 99892
2010-03-30 16:20:03 +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
Chris Lattner
93b617fac4 Add a method to get a StringMapEntry from a pointer to the string
data it contains (similar to GetStringMapEntryFromValue).  
Patch by Greg Clayton!

llvm-svn: 99371
2010-03-24 00:53:27 +00:00
Benjamin Kramer
d6a976f1da Fix a name clash that was breaking MSVC builds.
llvm-svn: 98852
2010-03-18 19:34:06 +00:00
Dan Gohman
24dc8de2a9 Fix a bug found by inspection; in the __GNUC__ code, the alignment
doesn't apply to the type, only to the variable, so subsequent uses
of U which expect it to be aligned weren't actually aligned.

llvm-svn: 98843
2010-03-18 18:40:47 +00:00
Andrew Lenharth
613a29aebe Nick wants these alphabetized
llvm-svn: 98840
2010-03-18 18:18:00 +00:00
Dan Gohman
8f98d70a9b Add the ability to "intern" FoldingSetNodeID data into a
BumpPtrAllocator-allocated region to allow it to be stored in a more
compact form and to avoid the need for a non-trivial destructor call.

Use this new mechanism in ScalarEvolution instead of
FastFoldingSetNode to avoid leaking memory in the case where a
FoldingSetNodeID uses heap storage, and to reduce overall memory
usage.

llvm-svn: 98829
2010-03-18 16:16:38 +00:00
Andrew Lenharth
9e9617e5b4 missing include
llvm-svn: 98752
2010-03-17 18:33:00 +00:00
Chris Lattner
bc3c70b81f work around an MSVC2010 bug, PR6504
llvm-svn: 98653
2010-03-16 19:07:05 +00:00
Jeffrey Yasskin
824bd1b30d Free DbgScopes in DwarfDebug::endFunction(). Also increased the const-ness of
several fields to make it easier to figure out where bugs might be creeping in.

llvm-svn: 98358
2010-03-12 17:45:06 +00:00
Andrew Lenharth
4f4af9d95c Iterator traits and swap. closes PR6548 and PR6549
llvm-svn: 97974
2010-03-08 20:45:52 +00:00
Douglas Gregor
c52fc8f922 Revert r97917, which was causing Clang Debug self-host failures.
llvm-svn: 97932
2010-03-08 02:58:37 +00:00
Jeffrey Yasskin
2c23c1d1a1 Roll r97906 forward again, without double-deleting CompileUnit::IndexTyDie.
llvm-svn: 97917
2010-03-07 17:10:13 +00:00
Jeffrey Yasskin
c68dc05867 _2_ gcc crashes, ah, ah, ah...
(Rolling back r97906.)

llvm-svn: 97909
2010-03-07 07:16:49 +00:00
Jeffrey Yasskin
c0123f0033 Avoid leaking CompileUnits and DbgScopes from DwarfDebug. Leaks found by Valgrind!
llvm-svn: 97906
2010-03-07 06:55:35 +00:00
Chris Lattner
a446775fd5 make APFloat::toString be const.
llvm-svn: 97883
2010-03-06 19:20:13 +00:00
Evan Cheng
a139c6cb44 TopLevelMap[] reference is a pointer.
llvm-svn: 97661
2010-03-03 20:46:48 +00:00
Evan Cheng
90979fa639 Allow specialization of ScopedHashTable of non-default DenseMapInfo.
llvm-svn: 97594
2010-03-02 22:10:24 +00:00
Evan Cheng
ab92cd0412 Add count() and lookup() to ScopedHashTable. It might be useful to get information out of the hash table.
llvm-svn: 97542
2010-03-02 02:37:33 +00:00
John McCall
b6e6dd63ad Add an override to StringRef::getAsInteger which parses into an APInt.
It gets its own implementation totally divorced from the (presumably
performance-sensitive) routines which parse into a uint64_t.

Add APInt::operator|=(uint64_t), which is situationally much better than
using a full APInt.

llvm-svn: 97381
2010-02-28 09:55:58 +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
Wesley Peck
94cdac52e5 Adding the MicroBlaze backend.
The MicroBlaze is a highly configurable 32-bit soft-microprocessor for
use on Xilinx FPGAs. For more information see:
http://www.xilinx.com/tools/microblaze.htm
http://en.wikipedia.org/wiki/MicroBlaze

The current LLVM MicroBlaze backend generates assembly which can be
compiled using the an appropriate binutils assembler.

llvm-svn: 96969
2010-02-23 19:15:24 +00:00
Dan Gohman
835086ef52 Fix various doxygen warnings.
llvm-svn: 96779
2010-02-22 04:10:52 +00:00
Daniel Dunbar
27247dd1e8 Fix comment.
llvm-svn: 96498
2010-02-17 19:26:45 +00:00
Bob Wilson
881d06c0b9 Fix a comment typo.
llvm-svn: 96027
2010-02-12 22:34:54 +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
Daniel Dunbar
e56fb57d08 ImmutableIntervalMap: Fix for unqualified lookup into dependent base class, done
by clang's -fixit! :)

llvm-svn: 95551
2010-02-08 18:08:46 +00:00
Chris Lattner
e43007d443 add support for the sparcv9-*-* target triple to turn on
64-bit sparc codegen.  Patch by Nathan Keynes!

llvm-svn: 95293
2010-02-04 06:34:01 +00:00
Zhongxing Xu
bbb98cd401 Remove redundant declaration.
llvm-svn: 95213
2010-02-03 09:05:21 +00:00
Zhongxing Xu
07020ea237 Add constructors.
llvm-svn: 95212
2010-02-03 09:04:11 +00:00
Dan Gohman
612cbcdc1a Make DenseSet's erase pass on the return value rather than swallowing it.
llvm-svn: 95127
2010-02-02 21:11:22 +00:00
Zhongxing Xu
2f90f25c13 Return value on every path.
llvm-svn: 95075
2010-02-02 07:05:31 +00:00
Zhongxing Xu
c41eb88823 simplify code.
llvm-svn: 95074
2010-02-02 06:33:32 +00:00
Zhongxing Xu
107fc8962f More logic correction: RemoveOverlap should always create new tree. Add a
parameter to record whether changes actually happened.

llvm-svn: 95073
2010-02-02 06:22:08 +00:00
Zhongxing Xu
7c9608096b Add a lookup method to the IntervalMap. The difference from the original
lookup is that if the lookup key is contained in the key, we return the data.

llvm-svn: 95070
2010-02-02 05:23:23 +00:00
Zhongxing Xu
007e05dce7 Fix a bunch of errors in the old logic.
llvm-svn: 95056
2010-02-02 02:40:56 +00:00
Zhongxing Xu
fa062ef731 11.8p1: A nested class is a member and as such has the same access rights as
any other member.

llvm-svn: 95047
2010-02-02 01:57:01 +00:00
Zhongxing Xu
e075bd78c6 Add an immutable interval map, prepared to be used by flat memory model
in the analyzer. WIP.

llvm-svn: 94976
2010-02-01 10:43:31 +00:00
Zhongxing Xu
f9abfaa0c2 Simplify code. We can compare TNew with T in one batch.
llvm-svn: 94973
2010-02-01 07:32:52 +00:00
Junjie Gu
4d7286efef Make sure the size is doubled (not 4x).
llvm-svn: 94845
2010-01-29 21:34:26 +00:00
Evan Cheng
4045e89a8f Add DenseMapInfo for signed long long.
llvm-svn: 94146
2010-01-22 03:33:01 +00:00
Ted Kremenek
20b78f8eef Store flags in bitfields instead of masking them into the pointer for the left child. This leads to some nice conceptually cleanups.
llvm-svn: 94121
2010-01-22 00:28:27 +00:00
Ted Kremenek
30dee16eed Tidy up assertion syntax. No functionality change.
llvm-svn: 94117
2010-01-21 23:42:57 +00:00
Benjamin Kramer
5db856d384 Introduce Twine::toStringRef, a variant of toVector which avoids the copy if the
twine can be represented as a single StringRef. Use the new methode to simplify
some twine users.

llvm-svn: 93317
2010-01-13 12:45:23 +00:00
Chris Lattner
9c1ca33ac3 add new isSingleStringRef()/getSingleStringRef() methods to twine,
and use them to avoid a copy of a string in getNameWithPrefix in
the common case.  It seems like Value::setName and other places 
should use this as well?

llvm-svn: 93301
2010-01-13 07:12:06 +00:00
Chris Lattner
a8deef7d39 give StringRef a const_iterator member.
llvm-svn: 93294
2010-01-13 04:50:20 +00:00
Benjamin Kramer
400ab557d3 Remove unused string functions.
llvm-svn: 93183
2010-01-11 20:33:12 +00:00
Benjamin Kramer
45e333ea95 Add StrInStrNoCase, a StringRef version of CStrInCStrNoCase.
llvm-svn: 93174
2010-01-11 19:45:18 +00:00
Benjamin Kramer
7ec2a31f14 Turns out llvm-gcc still uses SplitString with a vector. Add it back until I
have a fix.

llvm-svn: 93163
2010-01-11 18:44:35 +00:00
Benjamin Kramer
cdbc36f961 Reimplement getToken and SplitString as "StringRef helper functions"
- getToken is modeled after StringRef::split but it can split on multiple
  separator chars and skips leading seperators.
- SplitString is a StringRef::split variant for more than 2 elements with the
  same behaviour as getToken.

llvm-svn: 93161
2010-01-11 18:03:24 +00:00
Kovarththanan Rajaratnam
3a038bba47 Fix occurrence typo
llvm-svn: 92926
2010-01-07 18:46:52 +00:00
Dan Gohman
66ee3816ef Some versions of GCC don't like non-static data members in sizeof
in this context.

llvm-svn: 92731
2010-01-05 15:28:21 +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
Douglas Gregor
301af636d3 Implement edit distance for StringRef
llvm-svn: 92309
2009-12-30 17:23:44 +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
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
David Greene
32ec2e9057 Convert debug messages to use dbgs(). Generally this means
s/errs/dbgs/g except for certain special cases.

llvm-svn: 92005
2009-12-23 17:18:22 +00:00
Chris Lattner
609eded2e8 add a helper ctor.
llvm-svn: 91819
2009-12-21 07:15:15 +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
Chris Lattner
2e0b4ea606 tabs -> spaces.
llvm-svn: 91622
2009-12-17 21:23:46 +00:00
Steve Naroff
cbffdd23ee Fix Windows build breakage...
llvm-svn: 91617
2009-12-17 20:39:34 +00:00
Eric Christopher
9219efa49e Fix unused variable warning.
llvm-svn: 91609
2009-12-17 19:07:19 +00:00
Daniel Dunbar
9d1eac0cdd Fix one more missing this-> to placate that picky clang++.
llvm-svn: 91536
2009-12-16 11:38:03 +00:00
Chris Lattner
4b21831c59 fix more missing this->'s to placate clang++
llvm-svn: 91531
2009-12-16 09:17:12 +00:00
Chris Lattner
ccad2e6bd4 Fix a missing this-> that clang++ notices.
llvm-svn: 91530
2009-12-16 09:09:54 +00:00
Chris Lattner
eee37b7ba5 now that libsystem no longer uses SmallVector, we can move
SmallVectorBase::grow_pod out of line, finally satisfying PR3758.

llvm-svn: 91529
2009-12-16 08:44:24 +00:00
Chris Lattner
7ea3176b0c factor out the grow() method for all pod implementations into one
common function.  It is still an inline method, which will be fixed next.

llvm-svn: 91526
2009-12-16 08:34:40 +00:00
Chris Lattner
bc295111a1 pull destroy_range and uninitialized_copy up to the
SmallVectorTemplateBase class, which allows us to statically
dispatch on isPodLike instead of dynamically.

llvm-svn: 91523
2009-12-16 08:09:23 +00:00
Chris Lattner
c9b5e915c2 sink most of the meat in smallvector back from SmallVectorTemplateCommon
down into SmallVectorImpl.  This requires sprinking a ton of this->'s in,
but gives us a place to factor.

llvm-svn: 91522
2009-12-16 08:05:48 +00:00
Chris Lattner
19ee3f5216 substantial refactoring of SmallVector, now most code is in SmallVectorTemplateCommon,
and there is a new SmallVectorTemplateBase class in between it and SmallVectorImpl.
SmallVectorTemplateBase can be specialized based on isPodLike.

llvm-svn: 91518
2009-12-16 06:55:45 +00:00
Chris Lattner
b3db396df3 a few improvements:
1. Use std::equal instead of reinventing it.
2. don't run dtors in destroy_range if element is pod-like.
3. Use isPodLike to decide between memcpy/uninitialized_copy 
   instead of is_class.  isPodLike is more generous in some cases.

llvm-svn: 91427
2009-12-15 08:34:01 +00:00
Chris Lattner
f4e5966cf1 hoist the begin/end/capacity members and a few trivial methods
up into the non-templated SmallVectorBase class.

llvm-svn: 91426
2009-12-15 08:29:22 +00:00
Chris Lattner
f1a0d32b5f improve isPodLike to know that all non-class types are pod.
llvm-svn: 91425
2009-12-15 07:40:44 +00:00
Chris Lattner
587962c667 Remove isPod() from DenseMapInfo, splitting it out to its own
isPodLike type trait.  This is a generally useful type trait for
more than just DenseMap, and we really care about whether something
acts like a pod, not whether it really is a pod.

llvm-svn: 91421
2009-12-15 07:26:43 +00:00
John McCall
9ebba8d98e Names from dependent base classes are not found by unqualified lookup.
llvm-svn: 91407
2009-12-15 03:10:26 +00:00
Gabor Greif
8508c1f18e Simplify this class by removing the result cache.
This change removes the DefaultConstructible
and CopyAssignable constraints on the template
parameter T (the first one).

The second template parameter (R) is defaulted to be
identical to the first and controls the result type.
By specifying it to be (const T&) additionally the
CopyConstructible constraint on T can be removed.

This allows to use StringSwitch e.g. for llvm::Constant
instances.

Regarding the other review feedback regarding performance
because of taking pointers, this class should be completely
optimizable like before, since all methods are inline and
the pointer dereferencing and result value caching should be
possible behind the scenes by the "as-if" rule.

llvm-svn: 91123
2009-12-11 15:30:07 +00:00
Daniel Dunbar
a8dc0ca084 DeltaAlgorithm: Add a virtual destructor and home.
llvm-svn: 90957
2009-12-09 07:19:48 +00:00
Daniel Dunbar
b7c5aa749a Remove unneeded ';' and a class/struct mismatch (noticed by clang).
llvm-svn: 90934
2009-12-09 02:58:09 +00:00
Chris Lattner
c9a91632e1 remove extraneous comma clang warns about
llvm-svn: 90707
2009-12-06 16:58:41 +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
Gabor Greif
234d7dbe09 typo
llvm-svn: 90236
2009-12-01 15:53:33 +00:00
Gabor Greif
e65e0b8591 demonstrate usage of Cases() mapping several strings to the same value; remove trailing spaces
llvm-svn: 90230
2009-12-01 12:53:56 +00:00
Tobias Grosser
246c05c351 Remove forgotten ShortNames in Trie and CompilationGraph
llvm-svn: 90135
2009-11-30 13:14:13 +00:00
Daniel Dunbar
bd57261f1f Allow SmallString to implicitly convert to StringRef.
llvm-svn: 89529
2009-11-21 02:01:24 +00:00
Benjamin Kramer
3213126b9a cstdlib is not automatically included with StringRef anymore.
llvm-svn: 89359
2009-11-19 16:08:04 +00:00
Benjamin Kramer
3e24786569 Remove the now obsolete algorithm include from StringRef.h.
llvm-svn: 89354
2009-11-19 15:48:14 +00:00
Torok Edwin
2d2fb3f6ec Workaround PR5482, because all the gcc versions that I had were miscompiling StringRef:
4.2.4, 4.3.4, 4.4.2.
The workaround is to use a local min/max implementation that takes an integer
param, and not a reference to integer param (like std::min does).

llvm-svn: 89352
2009-11-19 15:39:50 +00:00
Edward O'Callaghan
fb2393159b Add PS3 Triple class, Credit to John Thompson.
llvm-svn: 89339
2009-11-19 11:59:00 +00:00
Daniel Dunbar
034c929118 Twine: Stores kinds as uchar instead of bitfield to be friendlier to the
optimizer.

llvm-svn: 89278
2009-11-19 00:04:43 +00:00
Viktor Kutuzov
1452b67541 Added getArchNameForAssembler method to the Triple class for which returns OS and Vendor independent target assembler arch.
llvm-svn: 89122
2009-11-17 18:48:27 +00:00
Nuno Lopes
44429689aa add Case() with 5 args
llvm-svn: 89099
2009-11-17 15:35:39 +00:00
Duncan Sands
3ced5472c3 1. Allow SCCIterator to work with GraphT types that are constant.
2.  Allow SCCIterator to work with inverse graphs.
3.  Fix an incorrect comment in GraphTraits.h (the type in the comment 
was given as GraphType* when it is actually const GraphType &).
Patch by Patrick Alexander Simmons.

llvm-svn: 89091
2009-11-17 10:54:25 +00:00
Eric Christopher
3877235021 Fix unused variables warnings.
llvm-svn: 88977
2009-11-16 22:34:32 +00:00
Chris Lattner
89c83b159c add a version of array_pod_sort that takes a custom comparator function.
llvm-svn: 88861
2009-11-15 19:52:43 +00:00
Edward O'Callaghan
c672c34d7a Add PSP OS Target to Triple, Credit to Bruno Cardoso Lopes.
llvm-svn: 88849
2009-11-15 10:18:17 +00:00
Dan Gohman
30f404fb4a Use .data() instead of .c_str() when nul-termination is not needed.
llvm-svn: 88703
2009-11-13 21:55:31 +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
880dfd38d8 StringRef(const char*) should not be used to turn null pointers into empty
strings.

llvm-svn: 87031
2009-11-12 21:26:11 +00:00
Benjamin Kramer
da70783da7 Add compare_lower and equals_lower methods to StringRef. Switch all users of
StringsEqualNoCase (from StringExtras.h) to it.

llvm-svn: 87020
2009-11-12 20:36:59 +00:00
Daniel Dunbar
da387a1c25 Add StringRef::split(StringRef), to complement StringRef::split(char).
llvm-svn: 86803
2009-11-11 05:19:11 +00:00
Daniel Dunbar
aa5d256b19 Add Triple::str() which returns the contents of the Triple as a string, as a more readable alternative to getTriple().
llvm-svn: 86773
2009-11-11 00:43:14 +00:00