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
Chris Lattner
fde62dcdb7 introduce a new TinyPtrVector class.
llvm-svn: 135365
2011-07-18 01:40:02 +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
Jay Foad
eaccc60d30 Add some bits that I found useful when converting InsertValueInst and
ExtractValueInst APIs to use ArrayRef: a new constructor taking a
(begin, end) range, and operators == and != for element-wise comparison.

llvm-svn: 135039
2011-07-13 09:15:05 +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
Nick Lewycky
233eabb210 Add ImmutableList::contains(). Patch by Rui Paulo!
llvm-svn: 134545
2011-07-06 21:59:48 +00:00
Eric Christopher
491e8d6593 Remove the confusing getDarwinNumber() api and friends.
Part of rdar://9714064

llvm-svn: 134291
2011-07-02 00:19:55 +00:00
Douglas Gregor
6ebfe1623c Add initial *-*-rtems* target, from Joel Sherrill
llvm-svn: 134282
2011-07-01 22:41:06 +00:00
Jay Foad
f921ffd79e Extend ConstantUniqueMap with a new template parameter ValRefType,
representing a constant reference to ValType. Normally this is just
"const ValType &", but when ValType is a std::vector we want to use
ArrayRef as the reference type.

llvm-svn: 133611
2011-06-22 08:50:06 +00:00
Jay Foad
6015684974 Remove deprecated forms of StringMap::GetOrCreateValue().
llvm-svn: 133517
2011-06-21 15:37:05 +00:00
Chris Lattner
a9ee8489df use the MapEntryTy typedef instead of writing it out long form,
add some fixme's about methods that should be removed.

Merged from type-system-rewrite.

llvm-svn: 133504
2011-06-21 06:22:33 +00:00
Argyrios Kyrtzidis
81d5aec961 Constify PackedVector::reference::operator T().
llvm-svn: 133074
2011-06-15 19:18:13 +00:00
Ted Kremenek
947d9a7e53 add option for literal formatting to APInt::toString()
toString() now takes an optional bool argument that,
depending on the radix, adds the appropriate prefix
to the integer's string representation that makes it into a
meaningful C literal, e.g.:

hexademical: '-f' becomes '-0xf'
octal: '77' becomes '077'
binary: '110' becomes '0b110'

Patch by nobled@dreamwidth.org!

llvm-svn: 133032
2011-06-15 00:51:55 +00:00
Argyrios Kyrtzidis
e9562b6cbc Introduce PackedVector, useful for storing a vector of values using a specific number of bits for each
value. Both signed and unsigned types can be used, e.g

   PackedVector<signed, 2> vec;

will create a vector accepting values -2, -1, 0, 1. Any other value will hit an assertion.

llvm-svn: 132325
2011-05-31 03:53:41 +00:00
John McCall
645e5b19b7 ...this is not a good commit day for me.
llvm-svn: 132294
2011-05-29 19:44:55 +00:00
John McCall
46c7b963b2 On Darwin ARM, set the UNWIND_RESUME libcall to _Unwind_SjLj_Resume.
This is important for the correct lowering of unwind instructions
(which doesn't matter at all) and llvm.eh.resume calls (which does).

llvm-svn: 132291
2011-05-29 19:39:04 +00:00
Argyrios Kyrtzidis
d58ffb7e7d Add asserts in StringRef to make sure we avoid undefined behavior:
-strlen should not be called with NULL. Also guarantee that StringRef's Length is 0 if Data is NULL.
-memcmp should not be called with NULL (even if size is 0)

Patch by Matthieu Monrocq!

llvm-svn: 131747
2011-05-20 19:24:12 +00:00
Zhongxing Xu
c520c46129 Remove redundant template partial specilization.
llvm-svn: 131402
2011-05-16 12:42:22 +00:00
John McCall
d24d94c11c Add an operator+= for appending StringRefs onto std::strings.
Previously this pattern would be compiled using an implicit conversion
to std::string.

llvm-svn: 131325
2011-05-13 23:58:45 +00:00
Bob Wilson
b718da182d Fix a comment.
llvm-svn: 130761
2011-05-03 17:22:56 +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
Chandler Carruth
c01a726544 Fix more -Wnon-pod-memset warnings.
llvm-svn: 130392
2011-04-28 08:17:08 +00:00
Ted Kremenek
2cd5c3603f Add utility method to DenseMap to return the amount of memory used for its buckets.
llvm-svn: 130382
2011-04-28 04:52:57 +00:00
Chris Lattner
70762e6755 silence some -Wnon-pod-memset warnings, since std::pair is not POD.
llvm-svn: 130364
2011-04-28 00:55:53 +00:00
Chris Lattner
e2e476dbdd Improve adherence to general style, use "foo_t &x" instead of "foo_t& x"
llvm-svn: 130153
2011-04-25 21:02:12 +00:00
Chris Lattner
75652009a0 allow adding a FoldingSetNodeID to a FastFoldingSetNode, resolving PR9499,
patch by Johannes Schaub!

llvm-svn: 130151
2011-04-25 20:58:50 +00:00
Sebastian Redl
69f3b52528 Give ImmutableIntervalMap.h an include guard.
llvm-svn: 130094
2011-04-24 15:46:46 +00:00
Jay Foad
c146569beb Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Justin Holewinski
dc1965a16c PTX: Add intrinsics to list of built-in intrinsics, which allows them to be
used by Clang.  To help Clang integration, the PTX target has been split
     into two targets: ptx32 and ptx64, depending on the desired pointer size.

- Add GCCBuiltin class to all intrinsics
- Split PTX target into ptx32 and ptx64

llvm-svn: 129851
2011-04-20 15:37:17 +00:00
Daniel Dunbar
82a4062a4e ADT/Triple: Renambe isOSX... methods to isMacOSX for consistency with the OS
triple component.

llvm-svn: 129838
2011-04-20 00:14:25 +00:00
Daniel Dunbar
3f19424547 ADT/Triple: Drop support for -osx style triples, we are going with -macosx
instead.

llvm-svn: 129836
2011-04-19 23:55:20 +00:00
Daniel Dunbar
6af8a09825 ADT/Triple: Add support for Triple::MacOSX per feedback from Chris, will remove
Triple::OSX once Clang has moved.

llvm-svn: 129833
2011-04-19 23:34:12 +00:00
Daniel Dunbar
9934e8436d ADT/Triple: Add isOSDarwin() and isOSWindows() helper functions.
llvm-svn: 129815
2011-04-19 21:12:05 +00:00
Daniel Dunbar
1e1f05faeb ADT/Triple: Add helper function for OS X version checks.
llvm-svn: 129801
2011-04-19 20:30:10 +00:00
Daniel Dunbar
6f283d346f ADT/Triple: Add isOSVersionLT helper function.
llvm-svn: 129800
2011-04-19 20:30:07 +00:00
Daniel Dunbar
e24d3d1bc5 ADT/Triple: Generalize and simplify getDarwinNumber to just be getOSVersion.
llvm-svn: 129799
2011-04-19 20:24:34 +00:00
Daniel Dunbar
ce4e39d010 ADT/Triple: Add support for more explicit "osx" and "ios" OS names.
llvm-svn: 129798
2011-04-19 20:19:27 +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
Chris Lattner
0304b82f80 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Jay Foad
35b9144371 Fix typo in comment.
llvm-svn: 129436
2011-04-13 12:50:47 +00:00
Chris Lattner
7605c67ada drive by bug fix: DenseMapInfo::isEqual should be determined according to
isEqual of its members, not operator==.

llvm-svn: 129233
2011-04-09 21:20:23 +00:00
Peter Collingbourne
44b69879c2 IntrusiveRefCntPtr: in RefCountedBase and RefCountedBaseVPTR, make
ref_cnt mutable and Retain/Release const to enable reference counted
pointers to const objects

llvm-svn: 128804
2011-04-04 00:57:03 +00:00
Jakob Stoklund Olesen
f881310607 Add an InterferenceCache class for caching per-block interference ranges.
When the greedy register allocator is splitting multiple global live ranges, it
tends to look at the same interference data many times. The InterferenceCache
class caches queries for unaltered LiveIntervalUnions.

llvm-svn: 128764
2011-04-02 06:03:35 +00:00
Jakob Stoklund Olesen
37134e568d Reset StringMap's NumTombstones on clears and rehashes.
StringMap was not properly updating NumTombstones after a clear or rehash.

This was not fatal until now because the table was growing faster than
NumTombstones could, but with the previous change of preventing infinite
growth of the table the invariant (NumItems + NumTombstones <= NumBuckets)
stopped being observed, causing infinite loops in certain situations.

Patch by José Fonseca!

llvm-svn: 128567
2011-03-30 18:32:51 +00:00
Jakob Stoklund Olesen
b4df99dc06 Prevent infinite growth of SmallPtrSet instances.
Rehash but don't grow when full of tombstones.

Patch by José Fonseca!

llvm-svn: 128566
2011-03-30 18:32:48 +00:00
Jakob Stoklund Olesen
0daa5f56cb Prevent infinite growth of SmallMap instances.
Rehash but don't grow when full of tombstones.

Patch by José Fonseca!

llvm-svn: 128565
2011-03-30 18:32:44 +00:00
Jakob Stoklund Olesen
492f97910d Prevent infinite growth of the DenseMap.
When the hash function uses object pointers all free entries eventually
become tombstones as they are used at least once, regardless of the size.

DenseMap cannot function with zero empty keys, so it double size to get
get ridof the tombstones.

However DenseMap never shrinks automatically unless it is cleared, so
the net result is that certain tables grow infinitely.

The solution is to make a fresh copy of the table without tombstones
instead of doubling size, by simply calling grow with the current size.

Patch by José Fonseca!

llvm-svn: 128564
2011-03-30 18:32:41 +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
Jay Foad
770a07e1a3 Fix more zero length memset warnings.
llvm-svn: 128543
2011-03-30 15:31:02 +00:00
Frits van Bommel
c234349939 Constant folding support for calls to umul.with.overflow(), basically identical to the smul.with.overflow() code.
llvm-svn: 128379
2011-03-27 14:26:13 +00:00
Ted Kremenek
a686187713 Relax access control on 'Release' method of RefCountedBase.
llvm-svn: 128054
2011-03-22 01:15:07 +00:00
Ted Kremenek
58a4560569 Allow a client to clear an IntrustiveRefCntPtr (deliberately leaking the referenced object).
llvm-svn: 128007
2011-03-21 18:37:59 +00:00
Argyrios Kyrtzidis
f906dcc618 If a class inherits from RefCountedBaseVPTR allow all its subclasses to be used with IntrusiveRefCntPtr.
llvm-svn: 127966
2011-03-20 06:14:56 +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
John Thompson
da294e31da Add scei vendor
llvm-svn: 127705
2011-03-15 21:51:56 +00:00
Duncan Sands
323db6bb99 Often GCC can see that NumBuckets is zero here, resulting in a warning
about possibly swapped memset parameters.  Avoid the warning.

llvm-svn: 127170
2011-03-07 19:38:38 +00:00
Argyrios Kyrtzidis
5a57c82f11 Try fixing mingw build.
llvm-svn: 127153
2011-03-07 05:35:01 +00:00
Argyrios Kyrtzidis
9cd53db2f9 Do a compiler check that we use one of the types from PointerUnion[N], instead of a runtime check.
llvm-svn: 127145
2011-03-07 01:30:20 +00:00
Benjamin Kramer
fbb4be942c Avoid zero-sized allocations when copying a fresh DenseMap.
llvm-svn: 127110
2011-03-05 22:00:28 +00:00
Benjamin Kramer
4861bbca65 Lazily allocate DenseMaps.
This makes lookup slightly more expensive but it's worth it, unused
DenseMaps are common in LLVM code apparently.

1% speedup on clang -O3 bzip2.c
4% speedup on clang -O3 oggenc.c (Release build of clang on i386/linux)

llvm-svn: 127088
2011-03-05 16:43:41 +00:00
Chris Lattner
e82c10f5df add some slice helper methods.
llvm-svn: 126878
2011-03-02 20:55:51 +00:00
Dan Gohman
304de5bc17 Simplify this code.
llvm-svn: 126785
2011-03-01 22:07:32 +00:00
Chris Lattner
7513f07004 add the ability to walk the scope tree and insert at not-the-current
scope.

llvm-svn: 126591
2011-02-27 22:51:57 +00:00
Chris Lattner
3fac41ace4 add a data() method.
llvm-svn: 126590
2011-02-27 22:51:37 +00:00
Daniel Dunbar
d4a7704765 Support: Add llvm::AreStatisticsEnabled().
llvm-svn: 126558
2011-02-26 23:17:12 +00:00
Cameron Zwarich
af4779907f Add a getNumSignBits() method to APInt.
llvm-svn: 126379
2011-02-24 10:00:20 +00:00
Frits van Bommel
68294aa16c Implement TODO for implicit C-array-to-ArrayRef conversion.
llvm-svn: 126311
2011-02-23 13:43:06 +00:00
Nick Lewycky
0c9c9c5beb Fix C++0x incompatibility. The signature of std::make_pair<> changes from:
template <class T1, class T2> pair<T1,T2> make_pair(const T1&, const T2&);
to
  template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
so explicitly specifying the template arguments to make_pair<> is going to break
when C++0x rolls through. Replace them with equivalent std::pair<>. Patch by
James Dennett!

llvm-svn: 126256
2011-02-22 22:48:47 +00:00
Argyrios Kyrtzidis
a3437f732e Allow getting the address of the value in a PointerUnion or PointerIntPair if one is
confident enough that he knows what he is doing.

llvm-svn: 126019
2011-02-19 03:55:58 +00:00
Ted Kremenek
cfdacb2104 Add ImmutableMap methods 'manualRetain()', 'manualRelease()', and 'getRootWithoutRetain()' to help more aggressively reclaim memory in the static analyzer.
llvm-svn: 126011
2011-02-19 01:59:21 +00:00
Nadav Rotem
ad2fd4eada Enhance constant folding of bitcast operations on vectors of floats.
Add getAllOnesValue of FP numbers to Constants and APFloat.
Add more tests.

llvm-svn: 125776
2011-02-17 21:22:27 +00:00
NAKAMURA Takumi
00228d0c2c Triple::MinGW64 is deprecated and removed. We can use Triple::MinGW32 generally.
No one uses *-mingw64. mingw-w64 is represented as {i686|x86_64}-w64-mingw32. In llvm side, i686 and x64 can be treated as similar way.

llvm-svn: 125747
2011-02-17 12:24:17 +00:00
Duncan Sands
061150ac1b Spelling fix: consequtive -> consecutive.
llvm-svn: 125563
2011-02-15 09:23:02 +00:00
Chris Lattner
f800339278 fix comments
llvm-svn: 125543
2011-02-15 00:23:53 +00:00
Chris Lattner
0848675c80 fix some typos.
llvm-svn: 125536
2011-02-15 00:06:37 +00:00
Chris Lattner
ee7f7c2494 revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125504
2011-02-14 18:15:46 +00:00
Chris Lattner
34f32cb4c2 Switch ConstantVector::get to use ArrayRef instead of a pointer+size
idiom.  Change various clients to simplify their code.

llvm-svn: 125487
2011-02-14 07:55:32 +00:00
Chris Lattner
cf712db15a add a new ArrayRef class. This is intended to replace the idiom we
use in many places where we pass a pointer and size to abstract APIs
that can take C arrays, std::vector, SmallVector, etc.  It is to arrays
what StringRef is to strings.

llvm-svn: 125486
2011-02-14 07:35:09 +00:00
Nick Lewycky
e980f95634 Fix typo in comment.
llvm-svn: 125480
2011-02-14 06:14:20 +00:00
Chris Lattner
307c1d4847 add a helper method.
llvm-svn: 125453
2011-02-13 08:04:16 +00:00
Douglas Gregor
cd73e97a29 Poison the relational operators ==, !=, <, <=, >=, > on llvm::Optional
objects, since they'll end up using the implicit conversion to "bool"
and causing some very "fun" surprises.

llvm-svn: 125380
2011-02-11 18:13:20 +00:00
Dan Gohman
a5cb7ac412 Optimize po_iterator: don't do redundant lookups.
llvm-svn: 125211
2011-02-09 19:25:31 +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
Evan Cheng
0e8c521bbd Patches to build EFI with Clang/LLVM. By Carl Norum.
llvm-svn: 124639
2011-02-01 01:14:13 +00:00
Nick Lewycky
8258d2da8c Add DenseSet::resize for API parity with DenseMap::resize.
llvm-svn: 124370
2011-01-27 09:10:42 +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
785d31a2d2 Remove MachineRegisterInfo::getLastVirtReg(), it was giving wrong results
when no virtual registers have been allocated.

It was only used to resize IndexedMaps, so provide an IndexedMap::resize()
method such that

 Map.grow(MRI.getLastVirtReg());

can be replaced with the simpler

 Map.resize(MRI.getNumVirtRegs());

This works correctly when no virtuals are allocated, and it bypasses the to/from
index conversions.

llvm-svn: 123130
2011-01-09 21:58:20 +00:00
Jakob Stoklund Olesen
9a7e67d141 Use IndexedMap for MachineRegisterInfo as well. No functional change.
llvm-svn: 123106
2011-01-09 03:05:46 +00:00
Jakob Stoklund Olesen
b3820cdc22 Use an IndexedMap for LiveOutRegInfo to hide its dependence on TargetRegisterInfo::FirstVirtualRegister.
llvm-svn: 123096
2011-01-08 23:10:50 +00:00
Chris Lattner
c6ccec7faf add a handy typedef.
llvm-svn: 122726
2011-01-03 03:16:20 +00:00
Chris Lattner
c375dcd5f5 really get this working with a custom allocator.
llvm-svn: 122722
2011-01-03 01:38:29 +00:00
Chris Lattner
85f8315219 Enhance ScopedHashTable to allow it to take an allocator argument.
llvm-svn: 122721
2011-01-03 01:29:37 +00:00
Jakob Stoklund Olesen
86786c46c2 Use IntEqClasses to compute connected components of live intervals.
llvm-svn: 122296
2010-12-21 00:48:17 +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
Nick Lewycky
de10f6132c Use the new way of silencing this warning.
llvm-svn: 122195
2010-12-19 20:57:14 +00:00
Nick Lewycky
c85935836b Add missing standard headers. Patch by Joerg Sonnenberger!
llvm-svn: 122193
2010-12-19 20:43:38 +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
Michael J. Spencer
f2bf8518fb Support/Path: Deprecate PathV1::isAbsolute.
llvm-svn: 122086
2010-12-17 21:21:31 +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
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